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> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/certificate_viewer.h" | 18 #include "chrome/browser/certificate_viewer.h" |
| 19 #include "chrome/browser/devtools/devtools_toggle_action.h" | 19 #include "chrome/browser/devtools/devtools_toggle_action.h" |
|
msw
2016/11/15 01:56:07
nit: remove devtools includes
lgarron
2016/11/29 02:12:02
Done.
| |
| 20 #include "chrome/browser/devtools/devtools_window.h" | 20 #include "chrome/browser/devtools/devtools_window.h" |
| 21 #include "chrome/browser/infobars/infobar_service.h" | 21 #include "chrome/browser/infobars/infobar_service.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_dialogs.h" | 24 #include "chrome/browser/ui/browser_dialogs.h" |
| 25 #include "chrome/browser/ui/layout_constants.h" | 25 #include "chrome/browser/ui/layout_constants.h" |
| 26 #include "chrome/browser/ui/views/collected_cookies_views.h" | 26 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 27 #include "chrome/browser/ui/views/website_settings/chosen_object_row.h" | 27 #include "chrome/browser/ui/views/website_settings/chosen_object_row.h" |
| 28 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" | 28 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" |
| 29 #include "chrome/browser/ui/website_settings/website_settings.h" | 29 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 32 #include "chrome/grit/chromium_strings.h" | 32 #include "chrome/grit/chromium_strings.h" |
| 33 #include "chrome/grit/generated_resources.h" | 33 #include "chrome/grit/generated_resources.h" |
| 34 #include "chrome/grit/theme_resources.h" | 34 #include "chrome/grit/theme_resources.h" |
| 35 #include "components/content_settings/core/common/content_settings_types.h" | 35 #include "components/content_settings/core/common/content_settings_types.h" |
| 36 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
|
msw
2016/11/15 01:56:07
nit: remove prefs includes
lgarron
2016/11/29 02:12:02
Done.
| |
| 37 #include "components/strings/grit/components_chromium_strings.h" | 37 #include "components/strings/grit/components_chromium_strings.h" |
| 38 #include "components/strings/grit/components_strings.h" | 38 #include "components/strings/grit/components_strings.h" |
| 39 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 40 #include "content/public/browser/user_metrics.h" | 40 #include "content/public/browser/user_metrics.h" |
| 41 #include "extensions/common/constants.h" | 41 #include "extensions/common/constants.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/material_design/material_design_controller.h" | 43 #include "ui/base/material_design/material_design_controller.h" |
| 44 #include "ui/base/models/simple_menu_model.h" | 44 #include "ui/base/models/simple_menu_model.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
| 46 #include "ui/gfx/canvas.h" | 46 #include "ui/gfx/canvas.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 class PopupHeaderView : public views::View { | 123 class PopupHeaderView : public views::View { |
| 124 public: | 124 public: |
| 125 explicit PopupHeaderView(views::ButtonListener* button_listener, | 125 explicit PopupHeaderView(views::ButtonListener* button_listener, |
| 126 views::StyledLabelListener* styled_label_listener); | 126 views::StyledLabelListener* styled_label_listener); |
| 127 ~PopupHeaderView() override; | 127 ~PopupHeaderView() override; |
| 128 | 128 |
| 129 // Sets the security summary for the current page. | 129 // Sets the security summary for the current page. |
| 130 void SetSummary(const base::string16& summary_text); | 130 void SetSummary(const base::string16& summary_text); |
| 131 | 131 |
| 132 // Sets the security details for the current page. | 132 // Sets the security details for the current page. |
| 133 void SetDetails(const base::string16& details_text, | 133 void SetDetails(const base::string16& details_text); |
| 134 bool include_details_link); | |
| 135 | 134 |
| 136 void AddResetDecisionsLabel(); | 135 void AddResetDecisionsLabel(); |
| 137 | 136 |
| 138 private: | 137 private: |
| 139 // The listener for the styled labels in this view. | 138 // The listener for the styled labels in this view. |
| 140 views::StyledLabelListener* styled_label_listener_; | 139 views::StyledLabelListener* styled_label_listener_; |
| 141 | 140 |
| 142 // The label that displays security summary for the current page. | 141 // The label that displays security summary for the current page. |
| 143 views::Label* summary_label_; | 142 views::Label* summary_label_; |
| 144 | 143 |
| 145 // The label that displays the status of the identity check for this site. | 144 // The label that displays the status of the identity check for this site. |
| 146 // Includes a link to open the DevTools Security panel. | 145 // Includes a link to open the Chrome Help Center article about connection |
| 146 // security. | |
| 147 views::StyledLabel* details_label_; | 147 views::StyledLabel* details_label_; |
| 148 | 148 |
| 149 // A container for the styled label with a link for resetting cert decisions. | 149 // A container for the styled label with a link for resetting cert decisions. |
| 150 // This is only shown sometimes, so we use a container to keep track of | 150 // This is only shown sometimes, so we use a container to keep track of |
| 151 // where to place it (if needed). | 151 // where to place it (if needed). |
| 152 views::View* reset_decisions_label_container_; | 152 views::View* reset_decisions_label_container_; |
| 153 views::StyledLabel* reset_decisions_label_; | 153 views::StyledLabel* reset_decisions_label_; |
| 154 | 154 |
| 155 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 155 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
| 156 }; | 156 }; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 | 266 |
| 267 layout->AddPaddingRow(1, kHeaderPaddingBottom); | 267 layout->AddPaddingRow(1, kHeaderPaddingBottom); |
| 268 } | 268 } |
| 269 | 269 |
| 270 PopupHeaderView::~PopupHeaderView() {} | 270 PopupHeaderView::~PopupHeaderView() {} |
| 271 | 271 |
| 272 void PopupHeaderView::SetSummary(const base::string16& summary_text) { | 272 void PopupHeaderView::SetSummary(const base::string16& summary_text) { |
| 273 summary_label_->SetText(summary_text); | 273 summary_label_->SetText(summary_text); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void PopupHeaderView::SetDetails(const base::string16& details_text, | 276 void PopupHeaderView::SetDetails(const base::string16& details_text) { |
| 277 bool include_details_label_link) { | 277 base::string16 learn_more_text = |
| 278 if (include_details_label_link) { | 278 l10n_util::GetStringUTF16(IDS_PAGE_INFO_LEARN_MORE); |
|
msw
2016/11/15 01:56:07
nit: inline below, nix |learn_more_text|
lgarron
2016/11/29 02:12:02
Done.
| |
| 279 base::string16 details_link_text = | |
| 280 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_DETAILS_LINK); | |
| 281 | 279 |
| 282 std::vector<base::string16> subst; | 280 std::vector<base::string16> subst; |
| 283 subst.push_back(details_text); | 281 subst.push_back(details_text); |
| 284 subst.push_back(details_link_text); | 282 subst.push_back(learn_more_text); |
| 285 | 283 |
| 286 std::vector<size_t> offsets; | 284 std::vector<size_t> offsets; |
| 287 | 285 |
| 288 base::string16 text = base::ReplaceStringPlaceholders( | 286 base::string16 text = base::ReplaceStringPlaceholders( |
| 289 base::ASCIIToUTF16("$1 $2"), subst, &offsets); | 287 base::ASCIIToUTF16("$1 $2"), subst, &offsets); |
| 290 details_label_->SetText(text); | 288 details_label_->SetText(text); |
| 291 gfx::Range details_range(offsets[1], text.length()); | 289 gfx::Range details_range(offsets[1], text.length()); |
| 292 | 290 |
| 293 views::StyledLabel::RangeStyleInfo link_style = | 291 views::StyledLabel::RangeStyleInfo link_style = |
| 294 views::StyledLabel::RangeStyleInfo::CreateForLink(); | 292 views::StyledLabel::RangeStyleInfo::CreateForLink(); |
| 295 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) | 293 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 296 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; | 294 link_style.font_style |= gfx::Font::FontStyle::UNDERLINE; |
| 297 link_style.disable_line_wrapping = false; | 295 link_style.disable_line_wrapping = false; |
| 298 | 296 |
| 299 details_label_->AddStyleRange(details_range, link_style); | 297 details_label_->AddStyleRange(details_range, link_style); |
| 300 } else { | |
| 301 details_label_->SetText(details_text); | |
| 302 } | |
| 303 } | 298 } |
| 304 | 299 |
| 305 void PopupHeaderView::AddResetDecisionsLabel() { | 300 void PopupHeaderView::AddResetDecisionsLabel() { |
| 306 std::vector<base::string16> subst; | 301 std::vector<base::string16> subst; |
| 307 subst.push_back( | 302 subst.push_back( |
| 308 l10n_util::GetStringUTF16(IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)); | 303 l10n_util::GetStringUTF16(IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)); |
| 309 subst.push_back(l10n_util::GetStringUTF16( | 304 subst.push_back(l10n_util::GetStringUTF16( |
| 310 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); | 305 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); |
| 311 | 306 |
| 312 std::vector<size_t> offsets; | 307 std::vector<size_t> offsets; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 profile_(profile), | 453 profile_(profile), |
| 459 header_(nullptr), | 454 header_(nullptr), |
| 460 separator_(nullptr), | 455 separator_(nullptr), |
| 461 site_settings_view_(nullptr), | 456 site_settings_view_(nullptr), |
| 462 cookies_view_(nullptr), | 457 cookies_view_(nullptr), |
| 463 cookie_dialog_link_(nullptr), | 458 cookie_dialog_link_(nullptr), |
| 464 permissions_view_(nullptr), | 459 permissions_view_(nullptr), |
| 465 weak_factory_(this) { | 460 weak_factory_(this) { |
| 466 g_shown_popup_type = POPUP_WEBSITE_SETTINGS; | 461 g_shown_popup_type = POPUP_WEBSITE_SETTINGS; |
| 467 set_parent_window(parent_window); | 462 set_parent_window(parent_window); |
| 468 is_devtools_disabled_ = | 463 is_devtools_disabled_ = |
|
msw
2016/11/15 01:56:07
nit: remove this.
lgarron
2016/11/29 02:12:02
Done.
| |
| 469 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 464 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
| 470 | 465 |
| 471 // Compensate for built-in vertical padding in the anchor view's image. | 466 // Compensate for built-in vertical padding in the anchor view's image. |
| 472 set_anchor_view_insets(gfx::Insets( | 467 set_anchor_view_insets(gfx::Insets( |
| 473 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 468 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 474 | 469 |
| 475 views::GridLayout* layout = new views::GridLayout(this); | 470 views::GridLayout* layout = new views::GridLayout(this); |
| 476 SetLayoutManager(layout); | 471 SetLayoutManager(layout); |
| 477 const int content_column = 0; | 472 const int content_column = 0; |
| 478 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 473 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 | 712 |
| 718 header_->SetSummary(security_description->summary); | 713 header_->SetSummary(security_description->summary); |
| 719 | 714 |
| 720 if (identity_info.certificate) { | 715 if (identity_info.certificate) { |
| 721 certificate_ = identity_info.certificate; | 716 certificate_ = identity_info.certificate; |
| 722 | 717 |
| 723 if (identity_info.show_ssl_decision_revoke_button) | 718 if (identity_info.show_ssl_decision_revoke_button) |
| 724 header_->AddResetDecisionsLabel(); | 719 header_->AddResetDecisionsLabel(); |
| 725 } | 720 } |
| 726 | 721 |
| 727 bool include_details_link = !is_devtools_disabled_ || certificate_; | 722 header_->SetDetails(security_description->details); |
| 728 | |
| 729 header_->SetDetails(security_description->details, include_details_link); | |
| 730 | 723 |
| 731 Layout(); | 724 Layout(); |
| 732 SizeToContents(); | 725 SizeToContents(); |
| 733 } | 726 } |
| 734 | 727 |
| 735 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | 728 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { |
| 736 // TODO(lgarron): Remove this method. (https://crbug.com/571533) | 729 // TODO(lgarron): Remove this method. (https://crbug.com/571533) |
| 737 } | 730 } |
| 738 | 731 |
| 739 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { | 732 views::View* WebsiteSettingsPopupView::CreateSiteSettingsView() { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 779 default: | 772 default: |
| 780 NOTREACHED(); | 773 NOTREACHED(); |
| 781 } | 774 } |
| 782 } | 775 } |
| 783 | 776 |
| 784 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label, | 777 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label, |
| 785 const gfx::Range& range, | 778 const gfx::Range& range, |
| 786 int event_flags) { | 779 int event_flags) { |
| 787 switch (label->id()) { | 780 switch (label->id()) { |
| 788 case STYLED_LABEL_SECURITY_DETAILS: | 781 case STYLED_LABEL_SECURITY_DETAILS: |
| 782 web_contents()->OpenURL(content::OpenURLParams( | |
| 783 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), | |
| 784 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | |
| 785 false)); | |
| 789 presenter_->RecordWebsiteSettingsAction( | 786 presenter_->RecordWebsiteSettingsAction( |
| 790 WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED); | 787 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED); |
|
msw
2016/11/15 01:56:07
Deprecate this and WEBSITE_SETTINGS_CERTIFICATE_DI
lgarron
2016/11/29 02:12:02
I've made a separate CL for this: https://coderevi
| |
| 791 | |
| 792 if (is_devtools_disabled_) { | |
| 793 DCHECK(certificate_); | |
| 794 gfx::NativeWindow parent = | |
| 795 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; | |
| 796 presenter_->RecordWebsiteSettingsAction( | |
| 797 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); | |
| 798 ShowCertificateViewer(web_contents(), parent, certificate_.get()); | |
| 799 } else { | |
| 800 DevToolsWindow::OpenDevToolsWindow( | |
| 801 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); | |
| 802 } | |
| 803 break; | 788 break; |
| 804 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 789 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
| 805 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 790 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 806 GetWidget()->Close(); | 791 GetWidget()->Close(); |
| 807 break; | 792 break; |
| 808 default: | 793 default: |
| 809 NOTREACHED(); | 794 NOTREACHED(); |
| 810 } | 795 } |
| 811 } | 796 } |
| OLD | NEW |