Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 128 |
| 129 // Sets the security details for the current page. | 129 // Sets the security details for the current page. |
| 130 void SetDetails(const base::string16& details_text); | 130 void SetDetails(const base::string16& details_text); |
| 131 | 131 |
| 132 void AddResetDecisionsLabel(); | 132 void AddResetDecisionsLabel(); |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 // The listener for the styled labels in this view. | 135 // The listener for the styled labels in this view. |
| 136 views::StyledLabelListener* styled_label_listener_; | 136 views::StyledLabelListener* styled_label_listener_; |
| 137 | 137 |
| 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. | 138 // 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 | 139 // Includes a link to open the Chrome Help Center article about connection |
| 143 // security. | 140 // security. |
| 144 views::StyledLabel* details_label_; | 141 views::StyledLabel* details_label_; |
| 145 | 142 |
| 146 // A container for the styled label with a link for resetting cert decisions. | 143 // 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 | 144 // This is only shown sometimes, so we use a container to keep track of |
| 148 // where to place it (if needed). | 145 // where to place it (if needed). |
| 149 views::View* reset_decisions_label_container_; | 146 views::View* reset_decisions_label_container_; |
| 150 views::StyledLabel* reset_decisions_label_; | 147 views::StyledLabel* reset_decisions_label_; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 177 }; | 174 }; |
| 178 | 175 |
| 179 //////////////////////////////////////////////////////////////////////////////// | 176 //////////////////////////////////////////////////////////////////////////////// |
| 180 // Popup Header | 177 // Popup Header |
| 181 //////////////////////////////////////////////////////////////////////////////// | 178 //////////////////////////////////////////////////////////////////////////////// |
| 182 | 179 |
| 183 PopupHeaderView::PopupHeaderView( | 180 PopupHeaderView::PopupHeaderView( |
| 184 views::ButtonListener* button_listener, | 181 views::ButtonListener* button_listener, |
| 185 views::StyledLabelListener* styled_label_listener) | 182 views::StyledLabelListener* styled_label_listener) |
| 186 : styled_label_listener_(styled_label_listener), | 183 : styled_label_listener_(styled_label_listener), |
| 187 summary_label_(nullptr), | |
| 188 details_label_(nullptr), | 184 details_label_(nullptr), |
| 189 reset_decisions_label_container_(nullptr), | 185 reset_decisions_label_container_(nullptr), |
| 190 reset_decisions_label_(nullptr) { | 186 reset_decisions_label_(nullptr) { |
| 191 views::GridLayout* layout = new views::GridLayout(this); | 187 views::GridLayout* layout = new views::GridLayout(this); |
| 192 SetLayoutManager(layout); | 188 SetLayoutManager(layout); |
| 193 | 189 |
| 194 const int label_column = 0; | |
|
lgarron
2016/12/14 23:46:23
yaaaaaaaaaaaay good riddance :-D
I've added 64085
| |
| 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; | 190 const int label_column_status = 1; |
| 241 views::ColumnSet* column_set_status = | 191 views::ColumnSet* column_set_status = |
| 242 layout->AddColumnSet(label_column_status); | 192 layout->AddColumnSet(label_column_status); |
| 243 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal); | 193 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal); |
| 244 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 194 column_set_status->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 245 1, views::GridLayout::USE_PREF, 0, 0); | 195 1, views::GridLayout::USE_PREF, 0, 0); |
| 246 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal); | 196 column_set_status->AddPaddingColumn(0, kSectionPaddingHorizontal); |
| 247 | 197 |
| 248 layout->AddPaddingRow(0, kHeaderLabelSpacing); | 198 layout->AddPaddingRow(0, kHeaderLabelSpacing); |
| 249 | 199 |
| 250 layout->StartRow(0, label_column_status); | 200 layout->StartRow(0, label_column_status); |
| 251 details_label_ = | 201 details_label_ = |
| 252 new views::StyledLabel(base::string16(), styled_label_listener); | 202 new views::StyledLabel(base::string16(), styled_label_listener); |
| 253 details_label_->set_id(STYLED_LABEL_SECURITY_DETAILS); | 203 details_label_->set_id(STYLED_LABEL_SECURITY_DETAILS); |
| 254 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL, | 204 layout->AddView(details_label_, 1, 1, views::GridLayout::FILL, |
| 255 views::GridLayout::LEADING); | 205 views::GridLayout::LEADING); |
| 256 | 206 |
| 257 layout->StartRow(0, label_column_status); | 207 layout->StartRow(0, label_column_status); |
| 258 reset_decisions_label_container_ = new views::View(); | 208 reset_decisions_label_container_ = new views::View(); |
| 259 reset_decisions_label_container_->SetLayoutManager( | 209 reset_decisions_label_container_->SetLayoutManager( |
| 260 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 210 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 261 layout->AddView(reset_decisions_label_container_, 1, 1, | 211 layout->AddView(reset_decisions_label_container_, 1, 1, |
| 262 views::GridLayout::FILL, views::GridLayout::LEADING); | 212 views::GridLayout::FILL, views::GridLayout::LEADING); |
| 263 | 213 |
| 264 layout->AddPaddingRow(1, kHeaderPaddingBottom); | 214 layout->AddPaddingRow(1, kHeaderPaddingBottom); |
| 265 } | 215 } |
| 266 | 216 |
| 267 PopupHeaderView::~PopupHeaderView() {} | 217 PopupHeaderView::~PopupHeaderView() {} |
| 268 | 218 |
| 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) { | 219 void PopupHeaderView::SetDetails(const base::string16& details_text) { |
| 274 std::vector<base::string16> subst; | 220 std::vector<base::string16> subst; |
| 275 subst.push_back(details_text); | 221 subst.push_back(details_text); |
| 276 subst.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 222 subst.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 277 | 223 |
| 278 std::vector<size_t> offsets; | 224 std::vector<size_t> offsets; |
| 279 | 225 |
| 280 base::string16 text = base::ReplaceStringPlaceholders( | 226 base::string16 text = base::ReplaceStringPlaceholders( |
| 281 base::ASCIIToUTF16("$1 $2"), subst, &offsets); | 227 base::ASCIIToUTF16("$1 $2"), subst, &offsets); |
| 282 details_label_->SetText(text); | 228 details_label_->SetText(text); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 layout->AddView(separator_); | 425 layout->AddView(separator_); |
| 480 | 426 |
| 481 layout->AddPaddingRow(1, kHeaderMarginBottom); | 427 layout->AddPaddingRow(1, kHeaderMarginBottom); |
| 482 layout->StartRow(1, content_column); | 428 layout->StartRow(1, content_column); |
| 483 | 429 |
| 484 site_settings_view_ = CreateSiteSettingsView(); | 430 site_settings_view_ = CreateSiteSettingsView(); |
| 485 layout->AddView(site_settings_view_); | 431 layout->AddView(site_settings_view_); |
| 486 | 432 |
| 487 // Each section handles its own padding. | 433 // Each section handles its own padding. |
| 488 set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0)); | 434 set_margins(gfx::Insets(0, 0, kPopupMarginBottom, 0)); |
| 435 set_title_margins(gfx::Insets(kHeaderPaddingTop, kSectionPaddingHorizontal, | |
| 436 kHeaderLabelSpacing, | |
| 437 kHeaderPaddingForCloseButton)); | |
| 489 | 438 |
| 490 views::BubbleDialogDelegateView::CreateBubble(this); | 439 views::BubbleDialogDelegateView::CreateBubble(this); |
| 491 | 440 |
| 492 presenter_.reset(new WebsiteSettings( | 441 presenter_.reset(new WebsiteSettings( |
| 493 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 442 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
| 494 web_contents, url, security_info)); | 443 web_contents, url, security_info)); |
| 495 } | 444 } |
| 496 | 445 |
| 497 void WebsiteSettingsPopupView::RenderFrameDeleted( | 446 void WebsiteSettingsPopupView::RenderFrameDeleted( |
| 498 content::RenderFrameHost* render_frame_host) { | 447 content::RenderFrameHost* render_frame_host) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 510 // The menu buttons for the permissions might have longer strings now, so we | 459 // The menu buttons for the permissions might have longer strings now, so we |
| 511 // need to size the whole bubble. | 460 // need to size the whole bubble. |
| 512 SizeToContents(); | 461 SizeToContents(); |
| 513 } | 462 } |
| 514 | 463 |
| 515 void WebsiteSettingsPopupView::OnChosenObjectDeleted( | 464 void WebsiteSettingsPopupView::OnChosenObjectDeleted( |
| 516 const WebsiteSettingsUI::ChosenObjectInfo& info) { | 465 const WebsiteSettingsUI::ChosenObjectInfo& info) { |
| 517 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 466 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
| 518 } | 467 } |
| 519 | 468 |
| 469 base::string16 WebsiteSettingsPopupView::GetWindowTitle() const { | |
| 470 return summary_text_; | |
| 471 } | |
| 472 | |
| 473 bool WebsiteSettingsPopupView::ShouldShowCloseButton() const { | |
| 474 return true; | |
| 475 } | |
| 476 | |
| 520 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { | 477 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 521 g_shown_popup_type = POPUP_NONE; | 478 g_shown_popup_type = POPUP_NONE; |
| 522 presenter_->OnUIClosing(); | 479 presenter_->OnUIClosing(); |
| 523 } | 480 } |
| 524 | 481 |
| 525 int WebsiteSettingsPopupView::GetDialogButtons() const { | 482 int WebsiteSettingsPopupView::GetDialogButtons() const { |
| 526 return ui::DIALOG_BUTTON_NONE; | 483 return ui::DIALOG_BUTTON_NONE; |
| 527 } | 484 } |
| 528 | 485 |
| 486 const gfx::FontList& WebsiteSettingsPopupView::GetTitleFontList() const { | |
|
lgarron
2016/12/14 23:46:23
It seems we're implementing this to make the font
tapted
2017/01/04 00:36:49
Done. Added a constant, with a comment. (we actual
| |
| 487 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(1); | |
| 488 } | |
| 489 | |
| 529 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, | 490 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, |
| 530 const ui::Event& event) { | 491 const ui::Event& event) { |
| 531 DCHECK_EQ(BUTTON_CLOSE, button->id()); | 492 DCHECK_EQ(BUTTON_CLOSE, button->id()); |
| 532 GetWidget()->Close(); | 493 GetWidget()->Close(); |
| 533 } | 494 } |
| 534 | 495 |
| 535 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 496 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
| 536 int event_flags) { | 497 int event_flags) { |
| 537 // The popup closes automatically when the collected cookies dialog or the | 498 // The popup closes automatically when the collected cookies dialog or the |
| 538 // certificate viewer opens. So delay handling of the link clicked to avoid | 499 // certificate viewer opens. So delay handling of the link clicked to avoid |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 site_settings_view_->AddChildView(link_section); | 656 site_settings_view_->AddChildView(link_section); |
| 696 | 657 |
| 697 SizeToContents(); | 658 SizeToContents(); |
| 698 } | 659 } |
| 699 | 660 |
| 700 void WebsiteSettingsPopupView::SetIdentityInfo( | 661 void WebsiteSettingsPopupView::SetIdentityInfo( |
| 701 const IdentityInfo& identity_info) { | 662 const IdentityInfo& identity_info) { |
| 702 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = | 663 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = |
| 703 identity_info.GetSecurityDescription(); | 664 identity_info.GetSecurityDescription(); |
| 704 | 665 |
| 705 header_->SetSummary(security_description->summary); | 666 summary_text_ = security_description->summary; |
| 667 GetWidget()->UpdateWindowTitle(); | |
| 706 | 668 |
| 707 if (identity_info.certificate) { | 669 if (identity_info.certificate) { |
| 708 certificate_ = identity_info.certificate; | 670 certificate_ = identity_info.certificate; |
| 709 | 671 |
| 710 if (identity_info.show_ssl_decision_revoke_button) | 672 if (identity_info.show_ssl_decision_revoke_button) |
| 711 header_->AddResetDecisionsLabel(); | 673 header_->AddResetDecisionsLabel(); |
| 712 } | 674 } |
| 713 | 675 |
| 714 header_->SetDetails(security_description->details); | 676 header_->SetDetails(security_description->details); |
| 715 | 677 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 779 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); | 741 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
| 780 break; | 742 break; |
| 781 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 743 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 782 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 744 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 783 GetWidget()->Close(); | 745 GetWidget()->Close(); |
| 784 break; | 746 break; |
| 785 default: | 747 default: |
| 786 NOTREACHED(); | 748 NOTREACHED(); |
| 787 } | 749 } |
| 788 } | 750 } |
| OLD | NEW |