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