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

Side by Side Diff: chrome/browser/ui/views/payments/payment_sheet_view_controller.cc

Issue 2899653002: Remove uses of FontList::Derive*(..) in views payments dialogs. (Closed)
Patch Set: self review Created 3 years, 7 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/payments/payment_sheet_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // correct size. To measure the required size, layout a label with each 132 // correct size. To measure the required size, layout a label with each
133 // section name, measure its width, then initialize |widest_column_width| 133 // section name, measure its width, then initialize |widest_column_width|
134 // with the largest value. 134 // with the largest value.
135 std::vector<int> section_names{ 135 std::vector<int> section_names{
136 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME, 136 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME,
137 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME, 137 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME,
138 IDS_PAYMENT_REQUEST_SHIPPING_SECTION_NAME}; 138 IDS_PAYMENT_REQUEST_SHIPPING_SECTION_NAME};
139 139
140 int widest_column_width = 0; 140 int widest_column_width = 0;
141 141
142 views::Label label(base::ASCIIToUTF16("")); 142 std::unique_ptr<views::Label> label = CreateMediumLabel(base::string16());
143 label.SetFontList(
144 label.font_list().DeriveWithWeight(gfx::Font::Weight::MEDIUM));
145 for (int name_id : section_names) { 143 for (int name_id : section_names) {
146 label.SetText(l10n_util::GetStringUTF16(name_id)); 144 label->SetText(l10n_util::GetStringUTF16(name_id));
147 widest_column_width = std::max( 145 widest_column_width =
148 label.GetPreferredSize().width(), 146 std::max(label->GetPreferredSize().width(), widest_column_width);
149 widest_column_width);
150 } 147 }
151 148
152 return widest_column_width; 149 return widest_column_width;
153 } 150 }
154 151
155 std::unique_ptr<views::Button> CreatePaymentSheetRow( 152 std::unique_ptr<views::Button> CreatePaymentSheetRow(
156 views::ButtonListener* listener, 153 views::ButtonListener* listener,
157 const base::string16& section_name, 154 const base::string16& section_name,
158 std::unique_ptr<views::View> content_view, 155 std::unique_ptr<views::View> content_view,
159 std::unique_ptr<views::View> extra_content_view, 156 std::unique_ptr<views::View> extra_content_view,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // A column for the extra content. 188 // A column for the extra content.
192 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 189 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
193 0, views::GridLayout::USE_PREF, 0, 0); 190 0, views::GridLayout::USE_PREF, 0, 0);
194 191
195 columns->AddPaddingColumn(0, kPaddingColumnsWidth); 192 columns->AddPaddingColumn(0, kPaddingColumnsWidth);
196 // A column for the trailing_button. 193 // A column for the trailing_button.
197 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 194 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
198 0, views::GridLayout::USE_PREF, 0, 0); 195 0, views::GridLayout::USE_PREF, 0, 0);
199 196
200 layout->StartRow(0, 0); 197 layout->StartRow(0, 0);
201 views::Label* name_label = new views::Label(section_name); 198 layout->AddView(CreateMediumLabel(section_name).release());
202 name_label->SetFontList(
203 name_label->font_list().DeriveWithWeight(gfx::Font::Weight::MEDIUM));
204 layout->AddView(name_label);
205 199
206 if (content_view) { 200 if (content_view) {
207 content_view->set_can_process_events_within_subtree(false); 201 content_view->set_can_process_events_within_subtree(false);
208 layout->AddView(content_view.release()); 202 layout->AddView(content_view.release());
209 } else { 203 } else {
210 layout->SkipColumns(1); 204 layout->SkipColumns(1);
211 } 205 }
212 206
213 if (extra_content_view) { 207 if (extra_content_view) {
214 extra_content_view->set_can_process_events_within_subtree(false); 208 extra_content_view->set_can_process_events_within_subtree(false);
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 data_source_label->SetDefaultStyle(default_style); 986 data_source_label->SetDefaultStyle(default_style);
993 data_source_label->AddStyleRange( 987 data_source_label->AddStyleRange(
994 gfx::Range(link_begin, link_begin + link_length), 988 gfx::Range(link_begin, link_begin + link_length),
995 views::StyledLabel::RangeStyleInfo::CreateForLink()); 989 views::StyledLabel::RangeStyleInfo::CreateForLink());
996 data_source_label->SizeToFit(0); 990 data_source_label->SizeToFit(0);
997 content_view->AddChildView(data_source_label.release()); 991 content_view->AddChildView(data_source_label.release());
998 return content_view; 992 return content_view;
999 } 993 }
1000 994
1001 } // namespace payments 995 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698