Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / components / infobars / core / confirm_infobar_delegate.cc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/infobars/core/confirm_infobar_delegate.h"
6
7 #include "ui/base/l10n/l10n_util.h"
8 #include "ui/strings/grit/ui_strings.h"
9
10 using infobars::InfoBarDelegate;
11
12 ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
13 }
14
15 InfoBarDelegate::InfoBarAutomationType
16     ConfirmInfoBarDelegate::GetInfoBarAutomationType() const {
17   return CONFIRM_INFOBAR;
18 }
19
20 int ConfirmInfoBarDelegate::GetButtons() const {
21   return BUTTON_OK | BUTTON_CANCEL;
22 }
23
24 base::string16 ConfirmInfoBarDelegate::GetButtonLabel(
25     InfoBarButton button) const {
26   return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
27       IDS_APP_OK : IDS_APP_CANCEL);
28 }
29
30 bool ConfirmInfoBarDelegate::OKButtonTriggersUACPrompt() const {
31   return false;
32 }
33
34 bool ConfirmInfoBarDelegate::Accept() {
35   return true;
36 }
37
38 bool ConfirmInfoBarDelegate::Cancel() {
39   return true;
40 }
41
42 base::string16 ConfirmInfoBarDelegate::GetLinkText() const {
43   return base::string16();
44 }
45
46 bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
47   return true;
48 }
49
50 ConfirmInfoBarDelegate::ConfirmInfoBarDelegate()
51     : InfoBarDelegate() {
52 }
53
54 bool ConfirmInfoBarDelegate::ShouldExpireInternal(
55     const NavigationDetails& details) const {
56   return !details.did_replace_entry &&
57       InfoBarDelegate::ShouldExpireInternal(details);
58 }
59
60 // ConfirmInfoBarDelegate::CreateInfoBar() is implemented in platform-specific
61 // files.
62
63 bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
64   ConfirmInfoBarDelegate* confirm_delegate =
65       delegate->AsConfirmInfoBarDelegate();
66   return confirm_delegate &&
67       (confirm_delegate->GetMessageText() == GetMessageText());
68 }
69
70 ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
71   return this;
72 }