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

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

Issue 2581493002: PageInfo bubble: Use the non-client view's window title and close button. (Closed)
Patch Set: selfnit: content->website Created 3 years, 11 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 (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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Spacing between rows in the site settings section 105 // Spacing between rows in the site settings section
106 const int kPermissionsVerticalSpacing = 12; 106 const int kPermissionsVerticalSpacing = 12;
107 107
108 // Button/styled label/link IDs ------------------------------------------------ 108 // Button/styled label/link IDs ------------------------------------------------
109 const int BUTTON_CLOSE = 1337; 109 const int BUTTON_CLOSE = 1337;
110 const int STYLED_LABEL_SECURITY_DETAILS = 1338; 110 const int STYLED_LABEL_SECURITY_DETAILS = 1338;
111 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; 111 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339;
112 const int LINK_COOKIE_DIALOG = 1340; 112 const int LINK_COOKIE_DIALOG = 1340;
113 const int LINK_SITE_SETTINGS = 1341; 113 const int LINK_SITE_SETTINGS = 1341;
114 114
115 // The default, ui::kTitleFontSizeDelta, is too large for the website settings
116 // bubble (e.g. +3). Use +1 to obtain a smaller font.
117 constexpr int kSummaryFontSizeDelta = 1;
118
115 } // namespace 119 } // namespace
116 120
117 // |PopupHeaderView| is the UI element (view) that represents the header of the 121 // |PopupHeaderView| is the UI element (view) that represents the header of the
118 // |WebsiteSettingsPopupView|. The header shows the status of the site's 122 // |WebsiteSettingsPopupView|. The header shows the status of the site's
119 // identity check and the name of the site's identity. 123 // identity check and the name of the site's identity.
120 class PopupHeaderView : public views::View { 124 class PopupHeaderView : public views::View {
121 public: 125 public:
122 explicit PopupHeaderView(views::ButtonListener* button_listener, 126 explicit PopupHeaderView(views::ButtonListener* button_listener,
123 views::StyledLabelListener* styled_label_listener); 127 views::StyledLabelListener* styled_label_listener);
124 ~PopupHeaderView() override; 128 ~PopupHeaderView() override;
125 129
126 // Sets the security summary for the current page. 130 // Sets the security summary for the current page.
127 void SetSummary(const base::string16& summary_text); 131 void SetSummary(const base::string16& summary_text);
128 132
129 // Sets the security details for the current page. 133 // Sets the security details for the current page.
130 void SetDetails(const base::string16& details_text); 134 void SetDetails(const base::string16& details_text);
131 135
132 void AddResetDecisionsLabel(); 136 void AddResetDecisionsLabel();
133 137
134 private: 138 private:
135 // The listener for the styled labels in this view. 139 // The listener for the styled labels in this view.
136 views::StyledLabelListener* styled_label_listener_; 140 views::StyledLabelListener* styled_label_listener_;
137 141
138 // The label that displays security summary for the current page.
139 views::Label* summary_label_;
140
141 // The label that displays the status of the identity check for this site. 142 // The label that displays the status of the identity check for this site.
142 // Includes a link to open the Chrome Help Center article about connection 143 // Includes a link to open the Chrome Help Center article about connection
143 // security. 144 // security.
144 views::StyledLabel* details_label_; 145 views::StyledLabel* details_label_;
145 146
146 // A container for the styled label with a link for resetting cert decisions. 147 // A container for the styled label with a link for resetting cert decisions.
147 // This is only shown sometimes, so we use a container to keep track of 148 // This is only shown sometimes, so we use a container to keep track of
148 // where to place it (if needed). 149 // where to place it (if needed).
149 views::View* reset_decisions_label_container_; 150 views::View* reset_decisions_label_container_;
150 views::StyledLabel* reset_decisions_label_; 151 views::StyledLabel* reset_decisions_label_;
(...skipping 26 matching lines...) Expand all
177 }; 178 };
178 179
179 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
180 // Popup Header 181 // Popup Header
181 //////////////////////////////////////////////////////////////////////////////// 182 ////////////////////////////////////////////////////////////////////////////////
182 183
183 PopupHeaderView::PopupHeaderView( 184 PopupHeaderView::PopupHeaderView(
184 views::ButtonListener* button_listener, 185 views::ButtonListener* button_listener,
185 views::StyledLabelListener* styled_label_listener) 186 views::StyledLabelListener* styled_label_listener)
186 : styled_label_listener_(styled_label_listener), 187 : styled_label_listener_(styled_label_listener),
187 summary_label_(nullptr),
188 details_label_(nullptr), 188 details_label_(nullptr),
189 reset_decisions_label_container_(nullptr), 189 reset_decisions_label_container_(nullptr),
190 reset_decisions_label_(nullptr) { 190 reset_decisions_label_(nullptr) {
191 views::GridLayout* layout = new views::GridLayout(this); 191 views::GridLayout* layout = new views::GridLayout(this);
192 SetLayoutManager(layout); 192 SetLayoutManager(layout);
193 193
194 const int label_column = 0;
195 views::ColumnSet* column_set = layout->AddColumnSet(label_column);
196 column_set->AddPaddingColumn(0, kSectionPaddingHorizontal);
197 column_set->AddColumn(views::GridLayout::FILL,
198 views::GridLayout::FILL,
199 1,
200 views::GridLayout::USE_PREF,
201 0,
202 0);
203 column_set->AddPaddingColumn(1, 0);
204 column_set->AddColumn(views::GridLayout::FILL,
205 views::GridLayout::FILL,
206 1,
207 views::GridLayout::USE_PREF,
208 0,
209 0);
210 column_set->AddPaddingColumn(0, kHeaderPaddingForCloseButton);
211
212 // First we add the padding needed for the close button.
213 // In order to move down the summary, we simulate additional padding by giving
214 // it an empty border on top later on.
215 layout->AddPaddingRow(0, kHeaderPaddingForCloseButton);
216
217 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
218
219 layout->StartRow(0, label_column);
220 const gfx::FontList& font_list = rb.GetFontListWithDelta(1);
221 summary_label_ = new views::Label(base::string16(), font_list);
222 summary_label_->SetMultiLine(true);
223 summary_label_->SetBorder(views::CreateEmptyBorder(
224 kHeaderPaddingTop - kHeaderPaddingForCloseButton, 0, 0, 0));
225 layout->AddView(summary_label_, 1, 1, views::GridLayout::LEADING,
226 views::GridLayout::TRAILING);
227 views::ImageButton* close_button = new views::ImageButton(button_listener);
228 close_button->set_id(BUTTON_CLOSE);
229 close_button->SetImage(views::CustomButton::STATE_NORMAL,
230 rb.GetImageNamed(IDR_CLOSE_2).ToImageSkia());
231 close_button->SetImage(views::CustomButton::STATE_HOVERED,
232 rb.GetImageNamed(IDR_CLOSE_2_H).ToImageSkia());
233 close_button->SetImage(views::CustomButton::STATE_PRESSED,
234 rb.GetImageNamed(IDR_CLOSE_2_P).ToImageSkia());
235 layout->AddView(close_button, 1, 1, views::GridLayout::TRAILING,
236 views::GridLayout::LEADING);
237
238 layout->AddPaddingRow(0, kHeaderLabelSpacing);
239
240 const int label_column_status = 1; 194 const int label_column_status = 1;
241 views::ColumnSet* column_set_status = 195 views::ColumnSet* column_set_status =
242 layout->AddColumnSet(label_column_status); 196 layout->AddColumnSet(label_column_status);
243 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal); 197 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal);
244 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 198 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
245 1, views::GridLayout::USE_PREF, 0, 0); 199 1, views::GridLayout::USE_PREF, 0, 0);
246 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal); 200 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal);
247 201
248 layout->AddPaddingRow(0, kHeaderLabelSpacing); 202 layout->AddPaddingRow(0, kHeaderLabelSpacing);
249 203
250 layout->StartRow(0, label_column_status); 204 layout->StartRow(0, label_column_status);
251 details_label_ = 205 details_label_ =
252 new views::StyledLabel(base::string16(), styled_label_listener); 206 new views::StyledLabel(base::string16(), styled_label_listener);
253 details_label_->set_id(STYLED_LABEL_SECURITY_DETAILS); 207 details_label_->set_id(STYLED_LABEL_SECURITY_DETAILS);
254 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL, 208 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL,
255 views::GridLayout::LEADING); 209 views::GridLayout::LEADING);
256 210
257 layout->StartRow(0, label_column_status); 211 layout->StartRow(0, label_column_status);
258 reset_decisions_label_container_ = new views::View(); 212 reset_decisions_label_container_ = new views::View();
259 reset_decisions_label_container_->SetLayoutManager( 213 reset_decisions_label_container_->SetLayoutManager(
260 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 214 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
261 layout->AddView(reset_decisions_label_container_, 1, 1, 215 layout->AddView(reset_decisions_label_container_, 1, 1,
262 views::GridLayout::FILL, views::GridLayout::LEADING); 216 views::GridLayout::FILL, views::GridLayout::LEADING);
263 217
264 layout->AddPaddingRow(1, kHeaderPaddingBottom); 218 layout->AddPaddingRow(1, kHeaderPaddingBottom);
265 } 219 }
266 220
267 PopupHeaderView::~PopupHeaderView() {} 221 PopupHeaderView::~PopupHeaderView() {}
268 222
269 void PopupHeaderView::SetSummary(const base::string16& summary_text) {
270 summary_label_->SetText(summary_text);
271 }
272
273 void PopupHeaderView::SetDetails(const base::string16& details_text) { 223 void PopupHeaderView::SetDetails(const base::string16& details_text) {
274 std::vector<base::string16> subst; 224 std::vector<base::string16> subst;
275 subst.push_back(details_text); 225 subst.push_back(details_text);
276 subst.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); 226 subst.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE));
277 227
278 std::vector<size_t> offsets; 228 std::vector<size_t> offsets;
279 229
280 base::string16 text = base::ReplaceStringPlaceholders( 230 base::string16 text = base::ReplaceStringPlaceholders(
281 base::ASCIIToUTF16("$1 $2"), subst, &offsets); 231 base::ASCIIToUTF16("$1 $2"), subst, &offsets);
282 details_label_->SetText(text); 232 details_label_->SetText(text);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 layout->AddView(separator_); 429 layout->AddView(separator_);
480 430
481 layout->AddPaddingRow(1, kHeaderMarginBottom); 431 layout->AddPaddingRow(1, kHeaderMarginBottom);
482 layout->StartRow(1, content_column); 432 layout->StartRow(1, content_column);
483 433
484 site_settings_view_ = CreateSiteSettingsView(); 434 site_settings_view_ = CreateSiteSettingsView();
485 layout->AddView(site_settings_view_); 435 layout->AddView(site_settings_view_);
486 436
487 // Each section handles its own padding. 437 // Each section handles its own padding.
488 set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0)); 438 set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0));
439 set_title_margins(gfx::Insets(kHeaderPaddingTop, kSectionPaddingHorizontal,
440 kHeaderLabelSpacing,
441 kHeaderPaddingForCloseButton));
489 442
490 views::BubbleDialogDelegateView::CreateBubble(this); 443 views::BubbleDialogDelegateView::CreateBubble(this);
491 444
492 presenter_.reset(new WebsiteSettings( 445 presenter_.reset(new WebsiteSettings(
493 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), 446 this, profile, TabSpecificContentSettings::FromWebContents(web_contents),
494 web_contents, url, security_info)); 447 web_contents, url, security_info));
495 } 448 }
496 449
497 void WebsiteSettingsPopupView::RenderFrameDeleted( 450 void WebsiteSettingsPopupView::RenderFrameDeleted(
498 content::RenderFrameHost* render_frame_host) { 451 content::RenderFrameHost* render_frame_host) {
(...skipping 11 matching lines...) Expand all
510 // The menu buttons for the permissions might have longer strings now, so we 463 // The menu buttons for the permissions might have longer strings now, so we
511 // need to size the whole bubble. 464 // need to size the whole bubble.
512 SizeToContents(); 465 SizeToContents();
513 } 466 }
514 467
515 void WebsiteSettingsPopupView::OnChosenObjectDeleted( 468 void WebsiteSettingsPopupView::OnChosenObjectDeleted(
516 const WebsiteSettingsUI::ChosenObjectInfo& info) { 469 const WebsiteSettingsUI::ChosenObjectInfo& info) {
517 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); 470 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object);
518 } 471 }
519 472
473 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const {
474 return summary_text_;
475 }
476
477 bool WebsiteSettingsPopupView::ShouldShowCloseButton() const {
478 return true;
479 }
480
520 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { 481 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) {
521 g_shown_popup_type = POPUP_NONE; 482 g_shown_popup_type = POPUP_NONE;
522 presenter_->OnUIClosing(); 483 presenter_->OnUIClosing();
523 } 484 }
524 485
525 int WebsiteSettingsPopupView::GetDialogButtons() const { 486 int WebsiteSettingsPopupView::GetDialogButtons() const {
526 return ui::DIALOG_BUTTON_NONE; 487 return ui::DIALOG_BUTTON_NONE;
527 } 488 }
528 489
490 const gfx::FontList& WebsiteSettingsPopupView::GetTitleFontList() const {
491 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
492 kSummaryFontSizeDelta);
493 }
494
529 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, 495 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button,
530 const ui::Event& event) { 496 const ui::Event& event) {
531 DCHECK_EQ(BUTTON_CLOSE, button->id()); 497 DCHECK_EQ(BUTTON_CLOSE, button->id());
532 GetWidget()->Close(); 498 GetWidget()->Close();
533 } 499 }
534 500
535 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, 501 void WebsiteSettingsPopupView::LinkClicked(views::Link* source,
536 int event_flags) { 502 int event_flags) {
537 // The popup closes automatically when the collected cookies dialog or the 503 // The popup closes automatically when the collected cookies dialog or the
538 // certificate viewer opens. So delay handling of the link clicked to avoid 504 // certificate viewer opens. So delay handling of the link clicked to avoid
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 site_settings_view_->AddChildView(link_section); 661 site_settings_view_->AddChildView(link_section);
696 662
697 SizeToContents(); 663 SizeToContents();
698 } 664 }
699 665
700 void WebsiteSettingsPopupView::SetIdentityInfo( 666 void WebsiteSettingsPopupView::SetIdentityInfo(
701 const IdentityInfo& identity_info) { 667 const IdentityInfo& identity_info) {
702 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = 668 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description =
703 identity_info.GetSecurityDescription(); 669 identity_info.GetSecurityDescription();
704 670
705 header_->SetSummary(security_description->summary); 671 summary_text_ = security_description->summary;
672 GetWidget()->UpdateWindowTitle();
706 673
707 if (identity_info.certificate) { 674 if (identity_info.certificate) {
708 certificate_ = identity_info.certificate; 675 certificate_ = identity_info.certificate;
709 676
710 if (identity_info.show_ssl_decision_revoke_button) 677 if (identity_info.show_ssl_decision_revoke_button)
711 header_->AddResetDecisionsLabel(); 678 header_->AddResetDecisionsLabel();
712 } 679 }
713 680
714 header_->SetDetails(security_description->details); 681 header_->SetDetails(security_description->details);
715 682
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); 746 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED);
780 break; 747 break;
781 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: 748 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS:
782 presenter_->OnRevokeSSLErrorBypassButtonPressed(); 749 presenter_->OnRevokeSSLErrorBypassButtonPressed();
783 GetWidget()->Close(); 750 GetWidget()->Close();
784 break; 751 break;
785 default: 752 default:
786 NOTREACHED(); 753 NOTREACHED();
787 } 754 }
788 } 755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698