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 return details
.is_navigation_to_different_page
&&
45 !details
.did_replace_entry
&&
46 // This next condition ensures a navigation that passes the above
47 // conditions doesn't dismiss infobars added while that navigation was
48 // already in process. We carve out an exception for reloads since we
49 // want reloads to dismiss infobars, but they will have unchanged entry
51 ((nav_entry_id_
!= details
.entry_id
) || details
.is_reload
);
54 void InfoBarDelegate::InfoBarDismissed() {
57 AutoLoginInfoBarDelegate
* InfoBarDelegate::AsAutoLoginInfoBarDelegate() {
61 ConfirmInfoBarDelegate
* InfoBarDelegate::AsConfirmInfoBarDelegate() {
65 InsecureContentInfoBarDelegate
*
66 InfoBarDelegate::AsInsecureContentInfoBarDelegate() {
70 MediaStreamInfoBarDelegate
* InfoBarDelegate::AsMediaStreamInfoBarDelegate() {
74 NativeAppInfoBarDelegate
* InfoBarDelegate::AsNativeAppInfoBarDelegate() {
78 PermissionInfobarDelegate
* InfoBarDelegate::AsPermissionInfobarDelegate() {
82 PopupBlockedInfoBarDelegate
* InfoBarDelegate::AsPopupBlockedInfoBarDelegate() {
86 RegisterProtocolHandlerInfoBarDelegate
*
87 InfoBarDelegate::AsRegisterProtocolHandlerInfoBarDelegate() {
91 ScreenCaptureInfoBarDelegate
*
92 InfoBarDelegate::AsScreenCaptureInfoBarDelegate() {
96 ThemeInstalledInfoBarDelegate
*
97 InfoBarDelegate::AsThemePreviewInfobarDelegate() {
101 ThreeDAPIInfoBarDelegate
* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() {
105 translate::TranslateInfoBarDelegate
*
106 InfoBarDelegate::AsTranslateInfoBarDelegate() {
110 InfoBarDelegate::InfoBarDelegate() : nav_entry_id_(0) {
113 } // namespace infobars