| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/global_error_bubble_view.h" | 5 #include "chrome/browser/ui/views/global_error_bubble_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/global_error/global_error.h" | 12 #include "chrome/browser/ui/global_error/global_error.h" |
| 13 #include "chrome/browser/ui/global_error/global_error_service.h" | 13 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 14 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 14 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 15 #include "chrome/browser/ui/layout_constants.h" | 15 #include "chrome/browser/ui/layout_constants.h" |
| 16 #include "chrome/browser/ui/views/elevation_icon_setter.h" | 16 #include "chrome/browser/ui/views/elevation_icon_setter.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 18 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" | 17 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/base/ui_features.h" |
| 21 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 22 #include "ui/views/bubble/bubble_frame_view.h" | 22 #include "ui/views/bubble/bubble_frame_view.h" |
| 23 #include "ui/views/controls/button/blue_button.h" | 23 #include "ui/views/controls/button/blue_button.h" |
| 24 #include "ui/views/controls/button/label_button.h" | 24 #include "ui/views/controls/button/label_button.h" |
| 25 #include "ui/views/controls/image_view.h" | 25 #include "ui/views/controls/image_view.h" |
| 26 #include "ui/views/controls/label.h" | 26 #include "ui/views/controls/label.h" |
| 27 #include "ui/views/layout/grid_layout.h" | 27 #include "ui/views/layout/grid_layout.h" |
| 28 #include "ui/views/layout/layout_constants.h" | 28 #include "ui/views/layout/layout_constants.h" |
| 29 #include "ui/views/window/dialog_client_view.h" | 29 #include "ui/views/window/dialog_client_view.h" |
| 30 | 30 |
| 31 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| 32 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 33 #endif |
| 34 |
| 31 namespace { | 35 namespace { |
| 32 | 36 |
| 33 const int kMaxBubbleViewWidth = 362; | 37 const int kMaxBubbleViewWidth = 362; |
| 34 | 38 |
| 35 } // namespace | 39 } // namespace |
| 36 | 40 |
| 37 // GlobalErrorBubbleViewBase --------------------------------------------------- | 41 // GlobalErrorBubbleViewBase --------------------------------------------------- |
| 38 | 42 |
| 43 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| 39 // static | 44 // static |
| 40 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( | 45 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( |
| 41 Browser* browser, | 46 Browser* browser, |
| 42 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { | 47 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { |
| 43 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 48 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 44 views::View* app_menu_button = browser_view->toolbar()->app_menu_button(); | 49 views::View* app_menu_button = browser_view->toolbar()->app_menu_button(); |
| 45 GlobalErrorBubbleView* bubble_view = new GlobalErrorBubbleView( | 50 GlobalErrorBubbleView* bubble_view = |
| 46 app_menu_button, views::BubbleBorder::TOP_RIGHT, browser, error); | 51 new GlobalErrorBubbleView(app_menu_button, gfx::Point(), |
| 52 views::BubbleBorder::TOP_RIGHT, browser, error); |
| 47 views::BubbleDialogDelegateView::CreateBubble(bubble_view); | 53 views::BubbleDialogDelegateView::CreateBubble(bubble_view); |
| 48 bubble_view->GetWidget()->Show(); | 54 bubble_view->GetWidget()->Show(); |
| 49 return bubble_view; | 55 return bubble_view; |
| 50 } | 56 } |
| 57 #endif // !OS_MACOSX || MAC_VIEWS_BROWSER |
| 51 | 58 |
| 52 // GlobalErrorBubbleView ------------------------------------------------------- | 59 // GlobalErrorBubbleView ------------------------------------------------------- |
| 53 | 60 |
| 54 GlobalErrorBubbleView::GlobalErrorBubbleView( | 61 GlobalErrorBubbleView::GlobalErrorBubbleView( |
| 55 views::View* anchor_view, | 62 views::View* anchor_view, |
| 63 const gfx::Point& anchor_point, |
| 56 views::BubbleBorder::Arrow arrow, | 64 views::BubbleBorder::Arrow arrow, |
| 57 Browser* browser, | 65 Browser* browser, |
| 58 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) | 66 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) |
| 59 : BubbleDialogDelegateView(anchor_view, arrow), | 67 : BubbleDialogDelegateView(anchor_view, arrow), |
| 60 browser_(browser), | 68 browser_(browser), |
| 61 error_(error) {} | 69 error_(error) { |
| 70 if (!anchor_view) |
| 71 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
| 72 } |
| 62 | 73 |
| 63 GlobalErrorBubbleView::~GlobalErrorBubbleView() {} | 74 GlobalErrorBubbleView::~GlobalErrorBubbleView() {} |
| 64 | 75 |
| 65 base::string16 GlobalErrorBubbleView::GetWindowTitle() const { | 76 base::string16 GlobalErrorBubbleView::GetWindowTitle() const { |
| 66 return error_->GetBubbleViewTitle(); | 77 return error_->GetBubbleViewTitle(); |
| 67 } | 78 } |
| 68 | 79 |
| 69 gfx::ImageSkia GlobalErrorBubbleView::GetWindowIcon() { | 80 gfx::ImageSkia GlobalErrorBubbleView::GetWindowIcon() { |
| 70 gfx::Image image = error_->GetBubbleViewIcon(); | 81 gfx::Image image = error_->GetBubbleViewIcon(); |
| 71 DCHECK(!image.IsEmpty()); | 82 DCHECK(!image.IsEmpty()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 171 } |
| 161 | 172 |
| 162 bool GlobalErrorBubbleView::Close() { | 173 bool GlobalErrorBubbleView::Close() { |
| 163 // Don't fall through to either Cancel() or Accept(). | 174 // Don't fall through to either Cancel() or Accept(). |
| 164 return true; | 175 return true; |
| 165 } | 176 } |
| 166 | 177 |
| 167 void GlobalErrorBubbleView::CloseBubbleView() { | 178 void GlobalErrorBubbleView::CloseBubbleView() { |
| 168 GetWidget()->Close(); | 179 GetWidget()->Close(); |
| 169 } | 180 } |
| OLD | NEW |