• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "components/infobars/core/infobar_delegate.h"
6 
7 #include "base/logging.h"
8 #include "build/build_config.h"
9 #include "components/infobars/core/infobar.h"
10 #include "components/infobars/core/infobar_manager.h"
11 #include "ui/base/resource/resource_bundle.h"
12 
13 namespace infobars {
14 
15 const int InfoBarDelegate::kNoIconID = 0;
16 
~InfoBarDelegate()17 InfoBarDelegate::~InfoBarDelegate() {
18 }
19 
20 InfoBarDelegate::InfoBarAutomationType
GetInfoBarAutomationType() const21     InfoBarDelegate::GetInfoBarAutomationType() const {
22   return UNKNOWN_INFOBAR;
23 }
24 
EqualsDelegate(InfoBarDelegate * delegate) const25 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
26   return false;
27 }
28 
ShouldExpire(const NavigationDetails & details) const29 bool InfoBarDelegate::ShouldExpire(const NavigationDetails& details) const {
30   if (!details.is_navigation_to_different_page)
31     return false;
32 
33   return ShouldExpireInternal(details);
34 }
35 
InfoBarDismissed()36 void InfoBarDelegate::InfoBarDismissed() {
37 }
38 
GetIconID() const39 int InfoBarDelegate::GetIconID() const {
40   return kNoIconID;
41 }
42 
GetInfoBarType() const43 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
44   return WARNING_TYPE;
45 }
46 
AsAutoLoginInfoBarDelegate()47 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() {
48   return NULL;
49 }
50 
AsConfirmInfoBarDelegate()51 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() {
52   return NULL;
53 }
54 
AsExtensionInfoBarDelegate()55 ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
56   return NULL;
57 }
58 
59 InsecureContentInfoBarDelegate*
AsInsecureContentInfoBarDelegate()60     InfoBarDelegate::AsInsecureContentInfoBarDelegate() {
61   return NULL;
62 }
63 
AsMediaStreamInfoBarDelegate()64 MediaStreamInfoBarDelegate* InfoBarDelegate::AsMediaStreamInfoBarDelegate() {
65   return NULL;
66 }
67 
AsPopupBlockedInfoBarDelegate()68 PopupBlockedInfoBarDelegate* InfoBarDelegate::AsPopupBlockedInfoBarDelegate() {
69   return NULL;
70 }
71 
72 RegisterProtocolHandlerInfoBarDelegate*
AsRegisterProtocolHandlerInfoBarDelegate()73     InfoBarDelegate::AsRegisterProtocolHandlerInfoBarDelegate() {
74   return NULL;
75 }
76 
77 ScreenCaptureInfoBarDelegate*
AsScreenCaptureInfoBarDelegate()78     InfoBarDelegate::AsScreenCaptureInfoBarDelegate() {
79   return NULL;
80 }
81 
82 ThemeInstalledInfoBarDelegate*
AsThemePreviewInfobarDelegate()83     InfoBarDelegate::AsThemePreviewInfobarDelegate() {
84   return NULL;
85 }
86 
87 translate::TranslateInfoBarDelegate*
AsTranslateInfoBarDelegate()88 InfoBarDelegate::AsTranslateInfoBarDelegate() {
89   return NULL;
90 }
91 
StoreActiveEntryUniqueID()92 void InfoBarDelegate::StoreActiveEntryUniqueID() {
93   contents_unique_id_ = infobar()->owner()->GetActiveEntryID();
94 }
95 
GetIcon() const96 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 
InfoBarDelegate()102 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
103 }
104 
ShouldExpireInternal(const NavigationDetails & details) const105 bool InfoBarDelegate::ShouldExpireInternal(
106     const NavigationDetails& details) const {
107   // NOTE: If you change this, be sure to check and adjust the behavior of
108   // anyone who overrides this as necessary!
109   return (contents_unique_id_ != details.entry_id) || details.is_reload;
110 }
111 
112 }  // namespace infobars
113