global_error.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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.
4
5#include "chrome/browser/ui/global_error/global_error.h"
6
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"
12
13GlobalError::GlobalError()
14    : has_shown_bubble_view_(false),
15      bubble_view_(NULL) {
16}
17
18GlobalError::~GlobalError() {
19}
20
21GlobalError::Severity GlobalError::GetSeverity() {
22  return SEVERITY_MEDIUM;
23}
24
25int GlobalError::MenuItemIconResourceID() {
26  // If you change this make sure to also change the bubble icon and the wrench
27  // icon color.
28  return IDR_INPUT_ALERT_MENU;
29}
30
31bool GlobalError::HasShownBubbleView() {
32  return has_shown_bubble_view_;
33}
34
35void GlobalError::ShowBubbleView(Browser* browser) {
36  has_shown_bubble_view_ = true;
37#if defined(OS_ANDROID)
38  // http://crbug.com/136506
39  NOTIMPLEMENTED() << "Chrome for Android doesn't support global errors";
40#else
41  bubble_view_ =
42      GlobalErrorBubbleViewBase::ShowBubbleView(browser, AsWeakPtr());
43#endif
44}
45
46GlobalErrorBubbleViewBase* GlobalError::GetBubbleView() {
47  return bubble_view_;
48}
49
50gfx::Image GlobalError::GetBubbleViewIcon() {
51  // If you change this make sure to also change the menu icon and the wrench
52  // icon color.
53  return ResourceBundle::GetSharedInstance().GetNativeImageNamed(
54      IDR_INPUT_ALERT);
55}
56
57void GlobalError::BubbleViewDidClose(Browser* browser) {
58  DCHECK(browser);
59  bubble_view_ = NULL;
60  OnBubbleViewDidClose(browser);
61}
62