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

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

Issue 2692773002: [merge-m57] Ensure the line on the origin info bubble extends the full width of the bubble. (Closed)
Patch Set: Created 3 years, 10 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 | « chrome/browser/ui/views/website_settings/website_settings_popup_view.h ('k') | 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const int BUTTON_CLOSE = 1337; 102 const int BUTTON_CLOSE = 1337;
103 const int STYLED_LABEL_SECURITY_DETAILS = 1338; 103 const int STYLED_LABEL_SECURITY_DETAILS = 1338;
104 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; 104 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339;
105 const int LINK_COOKIE_DIALOG = 1340; 105 const int LINK_COOKIE_DIALOG = 1340;
106 const int LINK_SITE_SETTINGS = 1341; 106 const int LINK_SITE_SETTINGS = 1341;
107 107
108 // The default, ui::kTitleFontSizeDelta, is too large for the website settings 108 // The default, ui::kTitleFontSizeDelta, is too large for the website settings
109 // bubble (e.g. +3). Use +1 to obtain a smaller font. 109 // bubble (e.g. +3). Use +1 to obtain a smaller font.
110 constexpr int kSummaryFontSizeDelta = 1; 110 constexpr int kSummaryFontSizeDelta = 1;
111 111
112 // Adds a ColumnSet on |layout| with a single View column and padding columns
113 // on either side of it with |margin| width.
114 void AddColumnWithSideMargin(views::GridLayout* layout, int margin, int id) {
115 views::ColumnSet* column_set = layout->AddColumnSet(id);
116 column_set->AddPaddingColumn(0, margin);
117 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
118 views::GridLayout::USE_PREF, 0, 0);
119 column_set->AddPaddingColumn(0, margin);
120 }
121
112 } // namespace 122 } // namespace
113 123
114 // |PopupHeaderView| is the UI element (view) that represents the header of the 124 // |PopupHeaderView| is the UI element (view) that represents the header of the
115 // |WebsiteSettingsPopupView|. The header shows the status of the site's 125 // |WebsiteSettingsPopupView|. The header shows the status of the site's
116 // identity check and the name of the site's identity. 126 // identity check and the name of the site's identity.
117 class PopupHeaderView : public views::View { 127 class PopupHeaderView : public views::View {
118 public: 128 public:
119 explicit PopupHeaderView(views::ButtonListener* button_listener, 129 PopupHeaderView(views::ButtonListener* button_listener,
120 views::StyledLabelListener* styled_label_listener); 130 views::StyledLabelListener* styled_label_listener,
131 int side_margin);
121 ~PopupHeaderView() override; 132 ~PopupHeaderView() override;
122 133
123 // Sets the security summary for the current page. 134 // Sets the security summary for the current page.
124 void SetSummary(const base::string16& summary_text); 135 void SetSummary(const base::string16& summary_text);
125 136
126 // Sets the security details for the current page. 137 // Sets the security details for the current page.
127 void SetDetails(const base::string16& details_text); 138 void SetDetails(const base::string16& details_text);
128 139
129 void AddResetDecisionsLabel(); 140 void AddResetDecisionsLabel();
130 141
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 183
173 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); 184 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView);
174 }; 185 };
175 186
176 //////////////////////////////////////////////////////////////////////////////// 187 ////////////////////////////////////////////////////////////////////////////////
177 // Popup Header 188 // Popup Header
178 //////////////////////////////////////////////////////////////////////////////// 189 ////////////////////////////////////////////////////////////////////////////////
179 190
180 PopupHeaderView::PopupHeaderView( 191 PopupHeaderView::PopupHeaderView(
181 views::ButtonListener* button_listener, 192 views::ButtonListener* button_listener,
182 views::StyledLabelListener* styled_label_listener) 193 views::StyledLabelListener* styled_label_listener,
194 int side_margin)
183 : styled_label_listener_(styled_label_listener), 195 : styled_label_listener_(styled_label_listener),
184 details_label_(nullptr), 196 details_label_(nullptr),
185 reset_decisions_label_container_(nullptr), 197 reset_decisions_label_container_(nullptr),
186 reset_decisions_label_(nullptr) { 198 reset_decisions_label_(nullptr) {
187 views::GridLayout* layout = new views::GridLayout(this); 199 views::GridLayout* layout = new views::GridLayout(this);
188 SetLayoutManager(layout); 200 SetLayoutManager(layout);
189 201
190 const int label_column_status = 1; 202 const int label_column_status = 1;
191 views::ColumnSet* column_set_status = 203 AddColumnWithSideMargin(layout, side_margin, label_column_status);
192 layout->AddColumnSet(label_column_status);
193 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
194 1, views::GridLayout::USE_PREF, 0, 0);
195
196 layout->AddPaddingRow(0, kHeaderLabelSpacing); 204 layout->AddPaddingRow(0, kHeaderLabelSpacing);
197 205
198 layout->StartRow(0, label_column_status); 206 layout->StartRow(0, label_column_status);
199 details_label_ = 207 details_label_ =
200 new views::StyledLabel(base::string16(), styled_label_listener); 208 new views::StyledLabel(base::string16(), styled_label_listener);
201 details_label_->set_id(STYLED_LABEL_SECURITY_DETAILS); 209 details_label_->set_id(STYLED_LABEL_SECURITY_DETAILS);
202 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL, 210 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL,
203 views::GridLayout::LEADING); 211 views::GridLayout::LEADING);
204 212
205 layout->StartRow(0, label_column_status); 213 layout->StartRow(0, label_column_status);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 cookie_dialog_link_(nullptr), 403 cookie_dialog_link_(nullptr),
396 permissions_view_(nullptr), 404 permissions_view_(nullptr),
397 weak_factory_(this) { 405 weak_factory_(this) {
398 g_shown_popup_type = POPUP_WEBSITE_SETTINGS; 406 g_shown_popup_type = POPUP_WEBSITE_SETTINGS;
399 set_parent_window(parent_window); 407 set_parent_window(parent_window);
400 408
401 // Compensate for built-in vertical padding in the anchor view's image. 409 // Compensate for built-in vertical padding in the anchor view's image.
402 set_anchor_view_insets(gfx::Insets( 410 set_anchor_view_insets(gfx::Insets(
403 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 411 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
404 412
413 // Capture the default bubble margin, and move it to the Layout classes. This
414 // is necessary so that the views::Separator can extend the full width of the
415 // bubble.
416 const int side_margin = margins().left();
417 DCHECK_EQ(margins().left(), margins().right());
418
419 // Also remove the top margin from the client area so there is less space
420 // below the dialog title.
421 set_margins(gfx::Insets(0, 0, margins().bottom(), 0));
422
405 views::GridLayout* layout = new views::GridLayout(this); 423 views::GridLayout* layout = new views::GridLayout(this);
406 SetLayoutManager(layout); 424 SetLayoutManager(layout);
425
426 // Use a single ColumnSet here. Otherwise the preferred width doesn't properly
427 // propagate up to the dialog width.
407 const int content_column = 0; 428 const int content_column = 0;
408 views::ColumnSet* column_set = layout->AddColumnSet(content_column); 429 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
409 column_set->AddColumn(views::GridLayout::FILL, 430 column_set->AddColumn(views::GridLayout::FILL,
410 views::GridLayout::FILL, 431 views::GridLayout::FILL,
411 1, 432 1,
412 views::GridLayout::USE_PREF, 433 views::GridLayout::USE_PREF,
413 0, 434 0,
414 0); 435 0);
415 436
416 header_ = new PopupHeaderView(this, this); 437 header_ = new PopupHeaderView(this, this, side_margin);
417 layout->StartRow(1, content_column); 438 layout->StartRow(1, content_column);
418 layout->AddView(header_); 439 layout->AddView(header_);
419 440
420 layout->StartRow(0, content_column); 441 layout->StartRow(0, content_column);
421 separator_ = new views::Separator(views::Separator::HORIZONTAL); 442 separator_ = new views::Separator(views::Separator::HORIZONTAL);
422 layout->AddView(separator_); 443 layout->AddView(separator_);
423 444
424 layout->AddPaddingRow(1, kHeaderMarginBottom); 445 layout->AddPaddingRow(1, kHeaderMarginBottom);
425 layout->StartRow(1, content_column); 446 layout->StartRow(1, content_column);
426 447
427 site_settings_view_ = CreateSiteSettingsView(); 448 site_settings_view_ = CreateSiteSettingsView(side_margin);
428 layout->AddView(site_settings_view_); 449 layout->AddView(site_settings_view_);
429 450
430 // Remove the top margin from the client area so there is less space below the
431 // dialog title.
432 set_margins(
433 gfx::Insets(0, margins().left(), margins().bottom(), margins().right()));
434 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) { 451 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) {
435 // In non-material, titles are inset from the dialog margin. Ensure the 452 // In non-material, titles are inset from the dialog margin. Ensure the
436 // horizontal insets match. 453 // horizontal insets match.
437 set_title_margins(gfx::Insets(views::kPanelVertMargin, margins().left(), 0, 454 set_title_margins(
438 margins().right())); 455 gfx::Insets(views::kPanelVertMargin, side_margin, 0, side_margin));
439 } 456 }
440 views::BubbleDialogDelegateView::CreateBubble(this); 457 views::BubbleDialogDelegateView::CreateBubble(this);
441 458
442 presenter_.reset(new WebsiteSettings( 459 presenter_.reset(new WebsiteSettings(
443 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), 460 this, profile, TabSpecificContentSettings::FromWebContents(web_contents),
444 web_contents, url, security_info)); 461 web_contents, url, security_info));
445 } 462 }
446 463
447 void WebsiteSettingsPopupView::RenderFrameDeleted( 464 void WebsiteSettingsPopupView::RenderFrameDeleted(
448 content::RenderFrameHost* render_frame_host) { 465 content::RenderFrameHost* render_frame_host) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (identity_info.show_ssl_decision_revoke_button) 691 if (identity_info.show_ssl_decision_revoke_button)
675 header_->AddResetDecisionsLabel(); 692 header_->AddResetDecisionsLabel();
676 } 693 }
677 694
678 header_->SetDetails(security_description->details); 695 header_->SetDetails(security_description->details);
679 696
680 Layout(); 697 Layout();
681 SizeToContents(); 698 SizeToContents();
682 } 699 }
683 700
684 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { 701 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView(int side_margin) {
685 views::View* site_settings_view = new views::View(); 702 views::View* site_settings_view = new views::View();
686 views::BoxLayout* box_layout = 703 views::BoxLayout* box_layout =
687 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 704 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0);
688 site_settings_view->SetLayoutManager(box_layout); 705 site_settings_view->SetLayoutManager(box_layout);
689 box_layout->set_cross_axis_alignment( 706 box_layout->set_cross_axis_alignment(
690 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); 707 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
691 708
692 // Add cookies view. 709 // Add cookies view.
693 cookies_view_ = new views::View(); 710 cookies_view_ = new views::View();
694 site_settings_view->AddChildView(cookies_view_); 711 site_settings_view->AddChildView(cookies_view_);
695 712
696 return site_settings_view; 713 return site_settings_view;
697 } 714 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); 754 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED);
738 break; 755 break;
739 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: 756 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS:
740 presenter_->OnRevokeSSLErrorBypassButtonPressed(); 757 presenter_->OnRevokeSSLErrorBypassButtonPressed();
741 GetWidget()->Close(); 758 GetWidget()->Close();
742 break; 759 break;
743 default: 760 default:
744 NOTREACHED(); 761 NOTREACHED();
745 } 762 }
746 } 763 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/website_settings_popup_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698