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 18 matching lines...) Expand all Loading... |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
31 #include "chrome/grit/chromium_strings.h" | 31 #include "chrome/grit/chromium_strings.h" |
32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
33 #include "chrome/grit/theme_resources.h" | 33 #include "chrome/grit/theme_resources.h" |
34 #include "components/content_settings/core/common/content_settings_types.h" | 34 #include "components/content_settings/core/common/content_settings_types.h" |
35 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
36 #include "components/strings/grit/components_chromium_strings.h" | 36 #include "components/strings/grit/components_chromium_strings.h" |
37 #include "components/strings/grit/components_strings.h" | 37 #include "components/strings/grit/components_strings.h" |
38 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
39 #include "content/public/browser/cert_store.h" | |
40 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
41 #include "extensions/common/constants.h" | 40 #include "extensions/common/constants.h" |
42 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
43 #include "ui/base/material_design/material_design_controller.h" | 42 #include "ui/base/material_design/material_design_controller.h" |
44 #include "ui/base/models/simple_menu_model.h" | 43 #include "ui/base/models/simple_menu_model.h" |
45 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
46 #include "ui/gfx/canvas.h" | 45 #include "ui/gfx/canvas.h" |
47 #include "ui/gfx/font_list.h" | 46 #include "ui/gfx/font_list.h" |
48 #include "ui/gfx/geometry/insets.h" | 47 #include "ui/gfx/geometry/insets.h" |
49 #include "ui/gfx/image/image.h" | 48 #include "ui/gfx/image/image.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 const GURL& url, | 432 const GURL& url, |
434 const security_state::SecurityStateModel::SecurityInfo& security_info) | 433 const security_state::SecurityStateModel::SecurityInfo& security_info) |
435 : content::WebContentsObserver(web_contents), | 434 : content::WebContentsObserver(web_contents), |
436 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 435 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
437 header_(nullptr), | 436 header_(nullptr), |
438 separator_(nullptr), | 437 separator_(nullptr), |
439 site_settings_view_(nullptr), | 438 site_settings_view_(nullptr), |
440 site_data_content_(nullptr), | 439 site_data_content_(nullptr), |
441 cookie_dialog_link_(nullptr), | 440 cookie_dialog_link_(nullptr), |
442 permissions_content_(nullptr), | 441 permissions_content_(nullptr), |
443 cert_id_(0), | |
444 site_settings_link_(nullptr), | 442 site_settings_link_(nullptr), |
445 weak_factory_(this) { | 443 weak_factory_(this) { |
446 set_parent_window(parent_window); | 444 set_parent_window(parent_window); |
447 | 445 |
448 is_devtools_disabled_ = | 446 is_devtools_disabled_ = |
449 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 447 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
450 | 448 |
451 // Compensate for built-in vertical padding in the anchor view's image. | 449 // Compensate for built-in vertical padding in the anchor view's image. |
452 set_anchor_view_insets(gfx::Insets( | 450 set_anchor_view_insets(gfx::Insets( |
453 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 451 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
(...skipping 23 matching lines...) Expand all Loading... |
477 site_settings_view_ = CreateSiteSettingsView(); | 475 site_settings_view_ = CreateSiteSettingsView(); |
478 layout->AddView(site_settings_view_); | 476 layout->AddView(site_settings_view_); |
479 | 477 |
480 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 478 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, |
481 kPopupMarginBottom, kPopupMarginRight)); | 479 kPopupMarginBottom, kPopupMarginRight)); |
482 | 480 |
483 views::BubbleDialogDelegateView::CreateBubble(this); | 481 views::BubbleDialogDelegateView::CreateBubble(this); |
484 | 482 |
485 presenter_.reset(new WebsiteSettings( | 483 presenter_.reset(new WebsiteSettings( |
486 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), | 484 this, profile, TabSpecificContentSettings::FromWebContents(web_contents), |
487 web_contents, url, security_info, content::CertStore::GetInstance())); | 485 web_contents, url, security_info)); |
488 } | 486 } |
489 | 487 |
490 void WebsiteSettingsPopupView::RenderFrameDeleted( | 488 void WebsiteSettingsPopupView::RenderFrameDeleted( |
491 content::RenderFrameHost* render_frame_host) { | 489 content::RenderFrameHost* render_frame_host) { |
492 if (render_frame_host == web_contents()->GetMainFrame()) | 490 if (render_frame_host == web_contents()->GetMainFrame()) |
493 GetWidget()->Close(); | 491 GetWidget()->Close(); |
494 } | 492 } |
495 | 493 |
496 void WebsiteSettingsPopupView::WebContentsDestroyed() { | 494 void WebsiteSettingsPopupView::WebContentsDestroyed() { |
497 weak_factory_.InvalidateWeakPtrs(); | 495 weak_factory_.InvalidateWeakPtrs(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 site_settings_view_->AddChildView(link_section); | 705 site_settings_view_->AddChildView(link_section); |
708 | 706 |
709 SizeToContents(); | 707 SizeToContents(); |
710 } | 708 } |
711 | 709 |
712 void WebsiteSettingsPopupView::SetIdentityInfo( | 710 void WebsiteSettingsPopupView::SetIdentityInfo( |
713 const IdentityInfo& identity_info) { | 711 const IdentityInfo& identity_info) { |
714 base::string16 security_summary_text = identity_info.GetSecuritySummary(); | 712 base::string16 security_summary_text = identity_info.GetSecuritySummary(); |
715 header_->SetIdentityName(base::UTF8ToUTF16(identity_info.site_identity)); | 713 header_->SetIdentityName(base::UTF8ToUTF16(identity_info.site_identity)); |
716 | 714 |
717 if (identity_info.cert_id) { | 715 if (identity_info.certificate) { |
718 cert_id_ = identity_info.cert_id; | 716 certificate_ = identity_info.certificate; |
719 | 717 |
720 if (identity_info.show_ssl_decision_revoke_button) | 718 if (identity_info.show_ssl_decision_revoke_button) |
721 header_->AddResetDecisionsButton(); | 719 header_->AddResetDecisionsButton(); |
722 } | 720 } |
723 | 721 |
724 bool include_details_link = | 722 bool include_details_link = !is_devtools_disabled_ || certificate_; |
725 !is_devtools_disabled_ || identity_info.cert_id != 0; | |
726 | 723 |
727 header_->SetSecuritySummary(security_summary_text, include_details_link); | 724 header_->SetSecuritySummary(security_summary_text, include_details_link); |
728 | 725 |
729 Layout(); | 726 Layout(); |
730 SizeToContents(); | 727 SizeToContents(); |
731 } | 728 } |
732 | 729 |
733 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | 730 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { |
734 // TODO(lgarron): Remove this method. (https://crbug.com/571533) | 731 // TODO(lgarron): Remove this method. (https://crbug.com/571533) |
735 } | 732 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 } | 815 } |
819 } | 816 } |
820 | 817 |
821 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label, | 818 void WebsiteSettingsPopupView::StyledLabelLinkClicked(views::StyledLabel* label, |
822 const gfx::Range& range, | 819 const gfx::Range& range, |
823 int event_flags) { | 820 int event_flags) { |
824 presenter_->RecordWebsiteSettingsAction( | 821 presenter_->RecordWebsiteSettingsAction( |
825 WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED); | 822 WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED); |
826 | 823 |
827 if (is_devtools_disabled_) { | 824 if (is_devtools_disabled_) { |
828 DCHECK_NE(cert_id_, 0); | 825 DCHECK(certificate_); |
829 gfx::NativeWindow parent = | 826 gfx::NativeWindow parent = |
830 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; | 827 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; |
831 presenter_->RecordWebsiteSettingsAction( | 828 presenter_->RecordWebsiteSettingsAction( |
832 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); | 829 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); |
833 ShowCertificateViewerByID(web_contents(), parent, cert_id_); | 830 ShowCertificateViewer(web_contents(), parent, certificate_.get()); |
834 } else { | 831 } else { |
835 DevToolsWindow::OpenDevToolsWindow( | 832 DevToolsWindow::OpenDevToolsWindow( |
836 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); | 833 web_contents(), DevToolsToggleAction::ShowSecurityPanel()); |
837 } | 834 } |
838 } | 835 } |
OLD | NEW |