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 InfoBarDelegate::Type
InfoBarDelegate::GetInfoBarType() const {
29 int InfoBarDelegate::GetIconID() const {
33 gfx::Image
InfoBarDelegate::GetIcon() const {
34 int icon_id
= GetIconID();
35 return (icon_id
== kNoIconID
) ? gfx::Image() :
36 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id
);
39 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate
* delegate
) const {
43 bool InfoBarDelegate::ShouldExpire(const NavigationDetails
& details
) const {
44 if (!details
.is_navigation_to_different_page
)
47 return ShouldExpireInternal(details
);
50 void InfoBarDelegate::InfoBarDismissed() {
53 AutoLoginInfoBarDelegate
* InfoBarDelegate::AsAutoLoginInfoBarDelegate() {
57 ConfirmInfoBarDelegate
* InfoBarDelegate::AsConfirmInfoBarDelegate() {
61 InsecureContentInfoBarDelegate
*
62 InfoBarDelegate::AsInsecureContentInfoBarDelegate() {
66 MediaStreamInfoBarDelegate
* InfoBarDelegate::AsMediaStreamInfoBarDelegate() {
70 NativeAppInfoBarDelegate
* InfoBarDelegate::AsNativeAppInfoBarDelegate() {
74 PopupBlockedInfoBarDelegate
* InfoBarDelegate::AsPopupBlockedInfoBarDelegate() {
78 RegisterProtocolHandlerInfoBarDelegate
*
79 InfoBarDelegate::AsRegisterProtocolHandlerInfoBarDelegate() {
83 ScreenCaptureInfoBarDelegate
*
84 InfoBarDelegate::AsScreenCaptureInfoBarDelegate() {
88 ThemeInstalledInfoBarDelegate
*
89 InfoBarDelegate::AsThemePreviewInfobarDelegate() {
93 ThreeDAPIInfoBarDelegate
* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() {
97 translate::TranslateInfoBarDelegate
*
98 InfoBarDelegate::AsTranslateInfoBarDelegate() {
102 void InfoBarDelegate::StoreActiveEntryUniqueID() {
103 contents_unique_id_
= infobar()->owner()->GetActiveEntryID();
106 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
109 bool InfoBarDelegate::ShouldExpireInternal(
110 const NavigationDetails
& details
) const {
111 // NOTE: If you change this, be sure to check and adjust the behavior of
112 // anyone who overrides this as necessary!
113 return (contents_unique_id_
!= details
.entry_id
) || details
.is_reload
;
116 } // namespace infobars