Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / infobars / core / infobar_delegate.cc
blob9651dd3eed3004907c33c27d80bb0dc245a7609b
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/material_design/material_design_controller.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/vector_icons_public.h"
15 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID)
16 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/native_theme/common_theme.h"
18 #include "ui/native_theme/native_theme.h"
19 #endif
21 namespace infobars {
23 const int InfoBarDelegate::kNoIconID = 0;
25 InfoBarDelegate::~InfoBarDelegate() {
28 InfoBarDelegate::InfoBarAutomationType
29 InfoBarDelegate::GetInfoBarAutomationType() const {
30 return UNKNOWN_INFOBAR;
33 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
34 return WARNING_TYPE;
37 int InfoBarDelegate::GetIconId() const {
38 return kNoIconID;
41 gfx::VectorIconId InfoBarDelegate::GetVectorIconId() const {
42 return gfx::VectorIconId::VECTOR_ICON_NONE;
45 gfx::Image InfoBarDelegate::GetIcon() const {
46 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID)
47 if (ui::MaterialDesignController::IsModeMaterial()) {
48 gfx::VectorIconId vector_id = GetVectorIconId();
49 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) {
50 SkColor icon_color;
51 if (GetInfoBarType() == WARNING_TYPE) {
52 icon_color = SkColorSetRGB(0xFF, 0x6F, 0x00);
53 } else {
54 ui::CommonThemeGetSystemColor(ui::NativeTheme::kColorId_GoogleBlue,
55 &icon_color);
57 return gfx::Image(gfx::CreateVectorIcon(vector_id, 16, icon_color));
60 #endif
62 int icon_id = GetIconId();
63 return icon_id == kNoIconID ? gfx::Image() :
64 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id);
67 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
68 return false;
71 bool InfoBarDelegate::ShouldExpire(const NavigationDetails& details) const {
72 return details.is_navigation_to_different_page &&
73 !details.did_replace_entry &&
74 // This next condition ensures a navigation that passes the above
75 // conditions doesn't dismiss infobars added while that navigation was
76 // already in process. We carve out an exception for reloads since we
77 // want reloads to dismiss infobars, but they will have unchanged entry
78 // IDs.
79 ((nav_entry_id_ != details.entry_id) || details.is_reload);
82 void InfoBarDelegate::InfoBarDismissed() {
85 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() {
86 return nullptr;
89 HungRendererInfoBarDelegate* InfoBarDelegate::AsHungRendererInfoBarDelegate() {
90 return nullptr;
93 InsecureContentInfoBarDelegate*
94 InfoBarDelegate::AsInsecureContentInfoBarDelegate() {
95 return nullptr;
98 MediaStreamInfoBarDelegate* InfoBarDelegate::AsMediaStreamInfoBarDelegate() {
99 return nullptr;
102 NativeAppInfoBarDelegate* InfoBarDelegate::AsNativeAppInfoBarDelegate() {
103 return nullptr;
106 PermissionInfobarDelegate* InfoBarDelegate::AsPermissionInfobarDelegate() {
107 return nullptr;
110 PopupBlockedInfoBarDelegate* InfoBarDelegate::AsPopupBlockedInfoBarDelegate() {
111 return nullptr;
114 RegisterProtocolHandlerInfoBarDelegate*
115 InfoBarDelegate::AsRegisterProtocolHandlerInfoBarDelegate() {
116 return nullptr;
119 ScreenCaptureInfoBarDelegate*
120 InfoBarDelegate::AsScreenCaptureInfoBarDelegate() {
121 return nullptr;
124 ThemeInstalledInfoBarDelegate*
125 InfoBarDelegate::AsThemePreviewInfobarDelegate() {
126 return nullptr;
129 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() {
130 return nullptr;
133 translate::TranslateInfoBarDelegate*
134 InfoBarDelegate::AsTranslateInfoBarDelegate() {
135 return nullptr;
138 InfoBarDelegate::InfoBarDelegate() : nav_entry_id_(0) {
141 } // namespace infobars