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

Side by Side Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 2400883002: Switch PopupHeaderView labels to use the GridLayout for automatic sizing. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/website_settings/website_settings_popup_view.h " 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft); 240 column_set_status->AddPaddingColumn(0, kHeaderPaddingLeft);
241 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 241 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
242 1, views::GridLayout::USE_PREF, 0, 0); 242 1, views::GridLayout::USE_PREF, 0, 0);
243 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText); 243 column_set_status->AddPaddingColumn(0, kHeaderPaddingRightForText);
244 244
245 layout->AddPaddingRow(0, kHeaderLabelSpacing); 245 layout->AddPaddingRow(0, kHeaderLabelSpacing);
246 246
247 layout->StartRow(0, label_column_status); 247 layout->StartRow(0, label_column_status);
248 details_label_ = 248 details_label_ =
249 new views::StyledLabel(base::string16(), styled_label_listener); 249 new views::StyledLabel(base::string16(), styled_label_listener);
250 layout->AddView(details_label_, 1, 1, views::GridLayout::LEADING, 250 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL,
251 views::GridLayout::LEADING); 251 views::GridLayout::LEADING);
252 252
253 layout->StartRow(0, label_column_status); 253 layout->StartRow(0, label_column_status);
254 reset_decisions_label_container_ = new views::View(); 254 reset_decisions_label_container_ = new views::View();
255 reset_decisions_label_container_->SetLayoutManager( 255 reset_decisions_label_container_->SetLayoutManager(
256 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 256 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
257 layout->AddView(reset_decisions_label_container_, 1, 1, 257 layout->AddView(reset_decisions_label_container_, 1, 1,
258 views::GridLayout::LEADING, views::GridLayout::LEADING); 258 views::GridLayout::FILL, views::GridLayout::LEADING);
259 259
260 layout->AddPaddingRow(1, kHeaderPaddingBottom); 260 layout->AddPaddingRow(1, kHeaderPaddingBottom);
261 } 261 }
262 262
263 PopupHeaderView::~PopupHeaderView() {} 263 PopupHeaderView::~PopupHeaderView() {}
264 264
265 int PopupHeaderView::GetPreferredNameWidth() const { 265 int PopupHeaderView::GetPreferredNameWidth() const {
266 return summary_label_->GetPreferredSize().width(); 266 return summary_label_->GetPreferredSize().width();
267 } 267 }
268 268
(...skipping 21 matching lines...) Expand all
290 views::StyledLabel::RangeStyleInfo link_style = 290 views::StyledLabel::RangeStyleInfo link_style =
291 views::StyledLabel::RangeStyleInfo::CreateForLink(); 291 views::StyledLabel::RangeStyleInfo::CreateForLink();
292 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) 292 if (!ui::MaterialDesignController::IsSecondaryUiMaterial())
293 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; 293 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE;
294 link_style.disable_line_wrapping = false; 294 link_style.disable_line_wrapping = false;
295 295
296 details_label_->AddStyleRange(details_range, link_style); 296 details_label_->AddStyleRange(details_range, link_style);
297 } else { 297 } else {
298 details_label_->SetText(details_text); 298 details_label_->SetText(details_text);
299 } 299 }
300
301 // Fit the styled label to occupy available width.
302 details_label_->SizeToFit(0);
303 } 300 }
304 301
305 void PopupHeaderView::AddResetDecisionsLabel() { 302 void PopupHeaderView::AddResetDecisionsLabel() {
306 std::vector<base::string16> subst; 303 std::vector<base::string16> subst;
307 subst.push_back( 304 subst.push_back(
308 l10n_util::GetStringUTF16(IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)); 305 l10n_util::GetStringUTF16(IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION));
309 subst.push_back(l10n_util::GetStringUTF16( 306 subst.push_back(l10n_util::GetStringUTF16(
310 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); 307 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON));
311 308
312 std::vector<size_t> offsets; 309 std::vector<size_t> offsets;
313 310
314 base::string16 text = base::ReplaceStringPlaceholders( 311 base::string16 text = base::ReplaceStringPlaceholders(
315 base::ASCIIToUTF16("$1 $2"), subst, &offsets); 312 base::ASCIIToUTF16("$1 $2"), subst, &offsets);
316 reset_decisions_label_ = new views::StyledLabel(text, styled_label_listener_); 313 reset_decisions_label_ = new views::StyledLabel(text, styled_label_listener_);
317 gfx::Range link_range(offsets[1], text.length()); 314 gfx::Range link_range(offsets[1], text.length());
318 315
319 views::StyledLabel::RangeStyleInfo link_style = 316 views::StyledLabel::RangeStyleInfo link_style =
320 views::StyledLabel::RangeStyleInfo::CreateForLink(); 317 views::StyledLabel::RangeStyleInfo::CreateForLink();
321 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) 318 if (!ui::MaterialDesignController::IsSecondaryUiMaterial())
322 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; 319 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE;
323 link_style.disable_line_wrapping = false; 320 link_style.disable_line_wrapping = false;
324 321
325 reset_decisions_label_->AddStyleRange(link_range, link_style); 322 reset_decisions_label_->AddStyleRange(link_range, link_style);
326 // Fit the styled label to occupy available width.
327 reset_decisions_label_->SizeToFit(0);
328 reset_decisions_label_container_->AddChildView(reset_decisions_label_); 323 reset_decisions_label_container_->AddChildView(reset_decisions_label_);
329 324
330 // Now that it contains a label, the container needs padding at the top. 325 // Now that it contains a label, the container needs padding at the top.
331 reset_decisions_label_container_->SetBorder( 326 reset_decisions_label_container_->SetBorder(
332 views::Border::CreateEmptyBorder(8, 0, 0, 0)); 327 views::Border::CreateEmptyBorder(8, 0, 0, 0));
333
334 InvalidateLayout();
335 } 328 }
336 329
337 //////////////////////////////////////////////////////////////////////////////// 330 ////////////////////////////////////////////////////////////////////////////////
338 // InternalPageInfoPopupView 331 // InternalPageInfoPopupView
339 //////////////////////////////////////////////////////////////////////////////// 332 ////////////////////////////////////////////////////////////////////////////////
340 333
341 InternalPageInfoPopupView::InternalPageInfoPopupView( 334 InternalPageInfoPopupView::InternalPageInfoPopupView(
342 views::View* anchor_view, 335 views::View* anchor_view,
343 gfx::NativeView parent_window, 336 gfx::NativeView parent_window,
344 const GURL& url) 337 const GURL& url)
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 gfx::NativeWindow parent = 839 gfx::NativeWindow parent =
847 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; 840 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr;
848 presenter_->RecordWebsiteSettingsAction( 841 presenter_->RecordWebsiteSettingsAction(
849 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); 842 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
850 ShowCertificateViewer(web_contents(), parent, certificate_.get()); 843 ShowCertificateViewer(web_contents(), parent, certificate_.get());
851 } else { 844 } else {
852 DevToolsWindow::OpenDevToolsWindow( 845 DevToolsWindow::OpenDevToolsWindow(
853 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); 846 web_contents(), DevToolsToggleAction::ShowSecurityPanel());
854 } 847 }
855 } 848 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698