Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/ui/views/global_error_bubble_view.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: LayoutDelegate -> LayoutProvider Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/harmony/layout_delegate.h" 17 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
18 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 18 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/ui_features.h" 21 #include "ui/base/ui_features.h"
22 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
23 #include "ui/views/bubble/bubble_frame_view.h" 23 #include "ui/views/bubble/bubble_frame_view.h"
24 #include "ui/views/controls/button/blue_button.h" 24 #include "ui/views/controls/button/blue_button.h"
25 #include "ui/views/controls/button/label_button.h" 25 #include "ui/views/controls/button/label_button.h"
26 #include "ui/views/controls/image_view.h" 26 #include "ui/views/controls/image_view.h"
27 #include "ui/views/controls/label.h" 27 #include "ui/views/controls/label.h"
28 #include "ui/views/layout/grid_layout.h" 28 #include "ui/views/layout/grid_layout.h"
29 #include "ui/views/views_delegate.h"
30 #include "ui/views/window/dialog_client_view.h" 29 #include "ui/views/window/dialog_client_view.h"
31 30
32 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) 31 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
33 #include "chrome/browser/ui/views/frame/browser_view.h" 32 #include "chrome/browser/ui/views/frame/browser_view.h"
34 #endif 33 #endif
35 34
36 namespace { 35 namespace {
37 36
38 const int kMaxBubbleViewWidth = 362; 37 const int kMaxBubbleViewWidth = 362;
39 38
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 gfx::ImageSkia GlobalErrorBubbleView::GetWindowIcon() { 82 gfx::ImageSkia GlobalErrorBubbleView::GetWindowIcon() {
84 gfx::Image image; 83 gfx::Image image;
85 if (error_) { 84 if (error_) {
86 image = error_->GetBubbleViewIcon(); 85 image = error_->GetBubbleViewIcon();
87 DCHECK(!image.IsEmpty()); 86 DCHECK(!image.IsEmpty());
88 } 87 }
89 return *image.ToImageSkia(); 88 return *image.ToImageSkia();
90 } 89 }
91 90
92 bool GlobalErrorBubbleView::ShouldShowWindowIcon() const { 91 bool GlobalErrorBubbleView::ShouldShowWindowIcon() const {
93 return LayoutDelegate::Get()->ShouldShowWindowIcon(); 92 return ChromeLayoutProvider::Get()->ShouldShowWindowIcon();
94 } 93 }
95 94
96 void GlobalErrorBubbleView::WindowClosing() { 95 void GlobalErrorBubbleView::WindowClosing() {
97 if (error_) 96 if (error_)
98 error_->BubbleViewDidClose(browser_); 97 error_->BubbleViewDidClose(browser_);
99 } 98 }
100 99
101 void GlobalErrorBubbleView::Init() { 100 void GlobalErrorBubbleView::Init() {
102 // |error_| is assumed to be valid, and stay valid, at least until Init() 101 // |error_| is assumed to be valid, and stay valid, at least until Init()
103 // returns. 102 // returns.
(...skipping 16 matching lines...) Expand all
120 119
121 // First row, message labels. 120 // First row, message labels.
122 views::ColumnSet* cs = layout->AddColumnSet(0); 121 views::ColumnSet* cs = layout->AddColumnSet(0);
123 cs->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 122 cs->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
124 views::GridLayout::FIXED, kMaxBubbleViewWidth, 0); 123 views::GridLayout::FIXED, kMaxBubbleViewWidth, 0);
125 124
126 for (size_t i = 0; i < message_labels.size(); ++i) { 125 for (size_t i = 0; i < message_labels.size(); ++i) {
127 layout->StartRow(1, 0); 126 layout->StartRow(1, 0);
128 layout->AddView(message_labels[i]); 127 layout->AddView(message_labels[i]);
129 if (i < message_labels.size() - 1) 128 if (i < message_labels.size() - 1)
130 layout->AddPaddingRow( 129 layout->AddPaddingRow(0, ChromeLayoutProvider::Get()->GetDistanceMetric(
Peter Kasting 2017/04/12 21:37:43 Nit: I guess this could be LayoutProvider::Get()?
kylix_rd 2017/04/13 16:45:42 Technically, yes. ChromeLayoutProvider already had
131 0, views::ViewsDelegate::GetInstance()->GetDistanceMetric( 130 views::DISTANCE_RELATED_CONTROL_VERTICAL));
132 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
133 } 131 }
134 132
135 // These bubbles show at times where activation is sporadic (like at startup, 133 // These bubbles show at times where activation is sporadic (like at startup,
136 // or a new window opening). Make sure the bubble doesn't disappear before the 134 // or a new window opening). Make sure the bubble doesn't disappear before the
137 // user sees it, if the bubble needs to be acknowledged. 135 // user sees it, if the bubble needs to be acknowledged.
138 set_close_on_deactivate(error_->ShouldCloseOnDeactivate()); 136 set_close_on_deactivate(error_->ShouldCloseOnDeactivate());
139 } 137 }
140 138
141 void GlobalErrorBubbleView::UpdateButton(views::LabelButton* button, 139 void GlobalErrorBubbleView::UpdateButton(views::LabelButton* button,
142 ui::DialogButton type) { 140 ui::DialogButton type) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 190 }
193 191
194 bool GlobalErrorBubbleView::Close() { 192 bool GlobalErrorBubbleView::Close() {
195 // Don't fall through to either Cancel() or Accept(). 193 // Don't fall through to either Cancel() or Accept().
196 return true; 194 return true;
197 } 195 }
198 196
199 void GlobalErrorBubbleView::CloseBubbleView() { 197 void GlobalErrorBubbleView::CloseBubbleView() {
200 GetWidget()->Close(); 198 GetWidget()->Close();
201 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698