Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / global_error / global_error.cc
blob7f464027dd8ad53f2b543108dc9be85d083407e7
1 // Copyright (c) 2012 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 "chrome/browser/ui/global_error/global_error.h"
7 #include "base/logging.h"
8 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h"
9 #include "grit/theme_resources.h"
10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/image/image.h"
13 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
14 #include "ui/gfx/paint_vector_icon.h"
15 #include "ui/gfx/vector_icons_public.h"
16 #include "ui/native_theme/common_theme.h"
17 #include "ui/native_theme/native_theme.h"
18 #endif
20 // GlobalError ---------------------------------------------------------------
22 GlobalError::GlobalError() {}
24 GlobalError::~GlobalError() {}
26 GlobalError::Severity GlobalError::GetSeverity() { return SEVERITY_MEDIUM; }
28 gfx::Image GlobalError::MenuItemIcon() {
29 #if defined(OS_MACOSX) || defined(OS_ANDROID)
30 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(
31 IDR_INPUT_ALERT_MENU);
32 #else
33 SkColor icon_color;
34 ui::CommonThemeGetSystemColor(ui::NativeTheme::kColorId_Amber, &icon_color);
35 return gfx::Image(
36 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, icon_color));
37 #endif
40 // GlobalErrorWithStandardBubble ---------------------------------------------
42 GlobalErrorWithStandardBubble::GlobalErrorWithStandardBubble()
43 : has_shown_bubble_view_(false), bubble_view_(NULL) {}
45 GlobalErrorWithStandardBubble::~GlobalErrorWithStandardBubble() {}
47 bool GlobalErrorWithStandardBubble::HasBubbleView() { return true; }
49 bool GlobalErrorWithStandardBubble::HasShownBubbleView() {
50 return has_shown_bubble_view_;
53 void GlobalErrorWithStandardBubble::ShowBubbleView(Browser* browser) {
54 has_shown_bubble_view_ = true;
55 #if defined(OS_ANDROID)
56 // http://crbug.com/136506
57 NOTIMPLEMENTED() << "Chrome for Android doesn't support global errors";
58 #else
59 bubble_view_ =
60 GlobalErrorBubbleViewBase::ShowStandardBubbleView(browser, AsWeakPtr());
61 #endif
64 GlobalErrorBubbleViewBase* GlobalErrorWithStandardBubble::GetBubbleView() {
65 return bubble_view_;
68 bool GlobalErrorWithStandardBubble::ShouldCloseOnDeactivate() const {
69 return true;
72 gfx::Image GlobalErrorWithStandardBubble::GetBubbleViewIcon() {
73 // If you change this make sure to also change the menu icon and the wrench
74 // icon color.
75 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(
76 IDR_INPUT_ALERT);
79 bool GlobalErrorWithStandardBubble::ShouldShowCloseButton() const {
80 return false;
83 bool GlobalErrorWithStandardBubble::ShouldAddElevationIconToAcceptButton() {
84 return false;
87 void GlobalErrorWithStandardBubble::BubbleViewDidClose(Browser* browser) {
88 DCHECK(browser);
89 bubble_view_ = NULL;
90 OnBubbleViewDidClose(browser);