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.
5 #include "components/infobars/core/infobar_delegate.h"
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"
15 const int InfoBarDelegate::kNoIconID
= 0;
17 InfoBarDelegate::~InfoBarDelegate() {
20 InfoBarDelegate::InfoBarAutomationType
21 InfoBarDelegate::GetInfoBarAutomationType() const {
22 return UNKNOWN_INFOBAR
;
25 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate
* delegate
) const {
29 bool InfoBarDelegate::ShouldExpire(const NavigationDetails
& details
) const {
30 if (!details
.is_navigation_to_different_page
)
33 return ShouldExpireInternal(details
);
36 void InfoBarDelegate::InfoBarDismissed() {
39 int InfoBarDelegate::GetIconID() const {
43 InfoBarDelegate::Type
InfoBarDelegate::GetInfoBarType() const {
47 AutoLoginInfoBarDelegate
* InfoBarDelegate::AsAutoLoginInfoBarDelegate() {
51 ConfirmInfoBarDelegate
* InfoBarDelegate::AsConfirmInfoBarDelegate() {
55 ExtensionInfoBarDelegate
* InfoBarDelegate::AsExtensionInfoBarDelegate() {
59 InsecureContentInfoBarDelegate
*
60 InfoBarDelegate::AsInsecureContentInfoBarDelegate() {
64 MediaStreamInfoBarDelegate
* InfoBarDelegate::AsMediaStreamInfoBarDelegate() {
68 PopupBlockedInfoBarDelegate
* InfoBarDelegate::AsPopupBlockedInfoBarDelegate() {
72 RegisterProtocolHandlerInfoBarDelegate
*
73 InfoBarDelegate::AsRegisterProtocolHandlerInfoBarDelegate() {
77 ScreenCaptureInfoBarDelegate
*
78 InfoBarDelegate::AsScreenCaptureInfoBarDelegate() {
82 ThemeInstalledInfoBarDelegate
*
83 InfoBarDelegate::AsThemePreviewInfobarDelegate() {
87 TranslateInfoBarDelegate
* InfoBarDelegate::AsTranslateInfoBarDelegate() {
91 void InfoBarDelegate::StoreActiveEntryUniqueID() {
92 contents_unique_id_
= infobar()->owner()->GetActiveEntryID();
95 gfx::Image
InfoBarDelegate::GetIcon() const {
96 int icon_id
= GetIconID();
97 return (icon_id
== kNoIconID
) ? gfx::Image() :
98 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id
);
101 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
104 bool InfoBarDelegate::ShouldExpireInternal(
105 const NavigationDetails
& details
) const {
106 // NOTE: If you change this, be sure to check and adjust the behavior of
107 // anyone who overrides this as necessary!
108 return (contents_unique_id_
!= details
.entry_id
) || details
.is_reload
;
111 } // namespace infobars