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

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: Deleted LayoutDelegate and HarmonyLayoutDelegate. 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_views_layout_delegate.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(new views::BoxLayout(
76 views::BoxLayout::kHorizontal, 0, 0, 76 views::BoxLayout::kHorizontal, 0, 0,
77 LayoutDelegate::Get()->GetMetric( 77 ChromeViewsLayoutDelegate::Get()->GetDistanceMetric(
78 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING))); 78 ChromeDistanceMetric::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 ChromeViewsLayoutDelegate* delegate = ChromeViewsLayoutDelegate::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 delegate->GetDistanceMetric(
113 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING))); 113 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL)));
114 114
115 // Add the content string. 115 // Add the content string.
116 views::Label* content_label = 116 views::Label* content_label =
117 new views::Label(delegate_->GetBodyText(anchored_to_action_)); 117 new views::Label(delegate_->GetBodyText(anchored_to_action_));
118 content_label->SetMultiLine(true); 118 content_label->SetMultiLine(true);
119 int width = views::Widget::GetLocalizedContentsWidth( 119 int width = views::Widget::GetLocalizedContentsWidth(
120 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); 120 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS);
121 content_label->SizeToFit(width); 121 content_label->SizeToFit(width);
122 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 122 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
123 AddChildView(content_label); 123 AddChildView(content_label);
124 124
125 base::string16 item_list = delegate_->GetItemListText(); 125 base::string16 item_list = delegate_->GetItemListText();
126 126
127 if (!item_list.empty()) { 127 if (!item_list.empty()) {
128 item_list_ = new views::Label(item_list); 128 item_list_ = new views::Label(item_list);
129 item_list_->SetBorder(views::CreateEmptyBorder( 129 item_list_->SetBorder(views::CreateEmptyBorder(
130 0, 130 0,
131 delegate->GetMetric( 131 delegate->GetDistanceMetric(
132 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING), 132 ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL),
133 0, 0)); 133 0, 0));
134 item_list_->SetMultiLine(true); 134 item_list_->SetMultiLine(true);
135 item_list_->SizeToFit(width); 135 item_list_->SizeToFit(width);
136 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 136 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
137 AddChildView(item_list_); 137 AddChildView(item_list_);
138 } 138 }
139 } 139 }
140 140
141 int ToolbarActionsBarBubbleViews::GetDialogButtons() const { 141 int ToolbarActionsBarBubbleViews::GetDialogButtons() const {
142 int buttons = ui::DIALOG_BUTTON_NONE; 142 int buttons = ui::DIALOG_BUTTON_NONE;
(...skipping 14 matching lines...) Expand all
157 ui::DialogButton button) const { 157 ui::DialogButton button) const {
158 return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText() 158 return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText()
159 : delegate_->GetDismissButtonText(); 159 : delegate_->GetDismissButtonText();
160 } 160 }
161 161
162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, 162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link,
163 int event_flags) { 163 int event_flags) {
164 close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE; 164 close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE;
165 GetWidget()->Close(); 165 GetWidget()->Close();
166 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698