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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/toolbar/toolbar_actions_bar_bubble_views.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h"
6 6
7 #include "chrome/browser/ui/views/harmony/layout_delegate.h" 7 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
8 #include "chrome/grit/locale_settings.h" 8 #include "chrome/grit/locale_settings.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/color_palette.h" 10 #include "ui/gfx/color_palette.h"
11 #include "ui/gfx/paint_vector_icon.h" 11 #include "ui/gfx/paint_vector_icon.h"
12 #include "ui/views/controls/button/label_button.h" 12 #include "ui/views/controls/button/label_button.h"
13 #include "ui/views/controls/image_view.h" 13 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
15 #include "ui/views/controls/link.h" 15 #include "ui/views/controls/link.h"
16 #include "ui/views/layout/box_layout.h" 16 #include "ui/views/layout/box_layout.h"
17 17
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 link_ = new views::Link(text); 65 link_ = new views::Link(text);
66 link_->set_listener(this); 66 link_->set_listener(this);
67 label.reset(link_); 67 label.reset(link_);
68 } else { 68 } else {
69 label.reset(new views::Label(text)); 69 label.reset(new views::Label(text));
70 } 70 }
71 } 71 }
72 72
73 if (icon && label) { 73 if (icon && label) {
74 views::View* parent = new views::View(); 74 views::View* parent = new views::View();
75 parent->SetLayoutManager(new views::BoxLayout( 75 parent->SetLayoutManager(
76 views::BoxLayout::kHorizontal, 0, 0, 76 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
77 LayoutDelegate::Get()->GetMetric( 77 ChromeLayoutProvider::Get()->GetDistanceMetric(
78 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING))); 78 views::DISTANCE_RELATED_CONTROL_VERTICAL)));
79 parent->AddChildView(icon.release()); 79 parent->AddChildView(icon.release());
80 parent->AddChildView(label.release()); 80 parent->AddChildView(label.release());
81 return parent; 81 return parent;
82 } 82 }
83 83
84 return icon ? static_cast<views::View*>(icon.release()) 84 return icon ? static_cast<views::View*>(icon.release())
85 : static_cast<views::View*>(label.release()); 85 : static_cast<views::View*>(label.release());
86 } 86 }
87 87
88 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { 88 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const {
(...skipping 10 matching lines...) Expand all
99 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); 99 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE);
100 return true; 100 return true;
101 } 101 }
102 102
103 bool ToolbarActionsBarBubbleViews::Close() { 103 bool ToolbarActionsBarBubbleViews::Close() {
104 delegate_->OnBubbleClosed(close_reason_); 104 delegate_->OnBubbleClosed(close_reason_);
105 return true; 105 return true;
106 } 106 }
107 107
108 void ToolbarActionsBarBubbleViews::Init() { 108 void ToolbarActionsBarBubbleViews::Init() {
109 LayoutDelegate* delegate = LayoutDelegate::Get(); 109 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
110 SetLayoutManager(new views::BoxLayout( 110 SetLayoutManager(new views::BoxLayout(
111 views::BoxLayout::kVertical, 0, 0, 111 views::BoxLayout::kVertical, 0, 0,
112 delegate->GetMetric( 112 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
113 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)));
114 113
115 // Add the content string. 114 // Add the content string.
116 views::Label* content_label = 115 views::Label* content_label =
117 new views::Label(delegate_->GetBodyText(anchored_to_action_)); 116 new views::Label(delegate_->GetBodyText(anchored_to_action_));
118 content_label->SetMultiLine(true); 117 content_label->SetMultiLine(true);
119 int width = views::Widget::GetLocalizedContentsWidth( 118 int width = views::Widget::GetLocalizedContentsWidth(
120 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); 119 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS);
121 content_label->SizeToFit(width); 120 content_label->SizeToFit(width);
122 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 121 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
123 AddChildView(content_label); 122 AddChildView(content_label);
124 123
125 base::string16 item_list = delegate_->GetItemListText(); 124 base::string16 item_list = delegate_->GetItemListText();
126 125
127 if (!item_list.empty()) { 126 if (!item_list.empty()) {
128 item_list_ = new views::Label(item_list); 127 item_list_ = new views::Label(item_list);
129 item_list_->SetBorder(views::CreateEmptyBorder( 128 item_list_->SetBorder(views::CreateEmptyBorder(
130 0, 129 0,
131 delegate->GetMetric( 130 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL),
132 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING),
133 0, 0)); 131 0, 0));
134 item_list_->SetMultiLine(true); 132 item_list_->SetMultiLine(true);
135 item_list_->SizeToFit(width); 133 item_list_->SizeToFit(width);
136 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 134 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
137 AddChildView(item_list_); 135 AddChildView(item_list_);
138 } 136 }
139 } 137 }
140 138
141 int ToolbarActionsBarBubbleViews::GetDialogButtons() const { 139 int ToolbarActionsBarBubbleViews::GetDialogButtons() const {
142 int buttons = ui::DIALOG_BUTTON_NONE; 140 int buttons = ui::DIALOG_BUTTON_NONE;
(...skipping 14 matching lines...) Expand all
157 ui::DialogButton button) const { 155 ui::DialogButton button) const {
158 return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText() 156 return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText()
159 : delegate_->GetDismissButtonText(); 157 : delegate_->GetDismissButtonText();
160 } 158 }
161 159
162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, 160 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link,
163 int event_flags) { 161 int event_flags) {
164 close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE; 162 close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE;
165 GetWidget()->Close(); 163 GetWidget()->Close();
166 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698