OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/infobars/core/infobar_delegate.h" | 5 #include "components/infobars/core/infobar_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "components/infobars/core/infobar.h" | 9 #include "components/infobars/core/infobar.h" |
10 #include "components/infobars/core/infobar_manager.h" | 10 #include "components/infobars/core/infobar_manager.h" |
11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
12 | 12 |
13 namespace infobars { | 13 namespace infobars { |
14 | 14 |
15 const int InfoBarDelegate::kNoIconID = 0; | 15 const int InfoBarDelegate::kNoIconID = 0; |
16 | 16 |
17 InfoBarDelegate::~InfoBarDelegate() { | 17 InfoBarDelegate::~InfoBarDelegate() { |
18 } | 18 } |
19 | 19 |
20 InfoBarDelegate::InfoBarAutomationType | 20 InfoBarDelegate::InfoBarAutomationType |
21 InfoBarDelegate::GetInfoBarAutomationType() const { | 21 InfoBarDelegate::GetInfoBarAutomationType() const { |
22 return UNKNOWN_INFOBAR; | 22 return UNKNOWN_INFOBAR; |
23 } | 23 } |
24 | 24 |
| 25 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { |
| 26 return WARNING_TYPE; |
| 27 } |
| 28 |
| 29 int InfoBarDelegate::GetIconID() const { |
| 30 return kNoIconID; |
| 31 } |
| 32 |
| 33 gfx::Image InfoBarDelegate::GetIcon() const { |
| 34 int icon_id = GetIconID(); |
| 35 return (icon_id == kNoIconID) ? gfx::Image() : |
| 36 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); |
| 37 } |
| 38 |
25 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | 39 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { |
26 return false; | 40 return false; |
27 } | 41 } |
28 | 42 |
29 bool InfoBarDelegate::ShouldExpire(const NavigationDetails& details) const { | 43 bool InfoBarDelegate::ShouldExpire(const NavigationDetails& details) const { |
30 if (!details.is_navigation_to_different_page) | 44 if (!details.is_navigation_to_different_page) |
31 return false; | 45 return false; |
32 | 46 |
33 return ShouldExpireInternal(details); | 47 return ShouldExpireInternal(details); |
34 } | 48 } |
35 | 49 |
36 void InfoBarDelegate::InfoBarDismissed() { | 50 void InfoBarDelegate::InfoBarDismissed() { |
37 } | 51 } |
38 | 52 |
39 int InfoBarDelegate::GetIconID() const { | |
40 return kNoIconID; | |
41 } | |
42 | |
43 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { | |
44 return WARNING_TYPE; | |
45 } | |
46 | |
47 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() { | 53 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() { |
48 return nullptr; | 54 return nullptr; |
49 } | 55 } |
50 | 56 |
51 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { | 57 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { |
52 return nullptr; | 58 return nullptr; |
53 } | 59 } |
54 | 60 |
55 InsecureContentInfoBarDelegate* | 61 InsecureContentInfoBarDelegate* |
56 InfoBarDelegate::AsInsecureContentInfoBarDelegate() { | 62 InfoBarDelegate::AsInsecureContentInfoBarDelegate() { |
(...skipping 20 matching lines...) Expand all Loading... |
77 ScreenCaptureInfoBarDelegate* | 83 ScreenCaptureInfoBarDelegate* |
78 InfoBarDelegate::AsScreenCaptureInfoBarDelegate() { | 84 InfoBarDelegate::AsScreenCaptureInfoBarDelegate() { |
79 return nullptr; | 85 return nullptr; |
80 } | 86 } |
81 | 87 |
82 ThemeInstalledInfoBarDelegate* | 88 ThemeInstalledInfoBarDelegate* |
83 InfoBarDelegate::AsThemePreviewInfobarDelegate() { | 89 InfoBarDelegate::AsThemePreviewInfobarDelegate() { |
84 return nullptr; | 90 return nullptr; |
85 } | 91 } |
86 | 92 |
| 93 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() { |
| 94 return nullptr; |
| 95 } |
| 96 |
87 translate::TranslateInfoBarDelegate* | 97 translate::TranslateInfoBarDelegate* |
88 InfoBarDelegate::AsTranslateInfoBarDelegate() { | 98 InfoBarDelegate::AsTranslateInfoBarDelegate() { |
89 return nullptr; | 99 return nullptr; |
90 } | 100 } |
91 | 101 |
92 void InfoBarDelegate::StoreActiveEntryUniqueID() { | 102 void InfoBarDelegate::StoreActiveEntryUniqueID() { |
93 contents_unique_id_ = infobar()->owner()->GetActiveEntryID(); | 103 contents_unique_id_ = infobar()->owner()->GetActiveEntryID(); |
94 } | 104 } |
95 | 105 |
96 gfx::Image InfoBarDelegate::GetIcon() const { | |
97 int icon_id = GetIconID(); | |
98 return (icon_id == kNoIconID) ? gfx::Image() : | |
99 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); | |
100 } | |
101 | |
102 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) { | 106 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) { |
103 } | 107 } |
104 | 108 |
105 bool InfoBarDelegate::ShouldExpireInternal( | 109 bool InfoBarDelegate::ShouldExpireInternal( |
106 const NavigationDetails& details) const { | 110 const NavigationDetails& details) const { |
107 // NOTE: If you change this, be sure to check and adjust the behavior of | 111 // NOTE: If you change this, be sure to check and adjust the behavior of |
108 // anyone who overrides this as necessary! | 112 // anyone who overrides this as necessary! |
109 return (contents_unique_id_ != details.entry_id) || details.is_reload; | 113 return (contents_unique_id_ != details.entry_id) || details.is_reload; |
110 } | 114 } |
111 | 115 |
112 } // namespace infobars | 116 } // namespace infobars |
OLD | NEW |