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/page_info/page_info_popup_view.h" | 5 #include "chrome/browser/ui/views/page_info/page_info_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 <utility> |
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/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 | 80 |
81 // Margin and padding values for the |PopupHeaderView|. | 81 // Margin and padding values for the |PopupHeaderView|. |
82 const int kHeaderMarginBottom = 10; | 82 const int kHeaderMarginBottom = 10; |
83 const int kHeaderPaddingBottom = 13; | 83 const int kHeaderPaddingBottom = 13; |
84 | 84 |
85 // Spacing between labels in the header. | 85 // Spacing between labels in the header. |
86 const int kHeaderLabelSpacing = 4; | 86 const int kHeaderLabelSpacing = 4; |
87 | 87 |
88 // Site Settings Section ------------------------------------------------------- | 88 // Site Settings Section ------------------------------------------------------- |
89 | 89 |
90 // Spacing above and below the cookies view. | 90 // Spacing above and below the cookies and certificate views. |
91 const int kCookiesViewVerticalPadding = 6; | 91 const int kSubViewsVerticalPadding = 6; |
92 | 92 |
93 // Spacing between a permission image and the text. | 93 // Spacing between a permission image and the text. |
94 const int kPermissionImageSpacing = 6; | 94 const int kPermissionImageSpacing = 6; |
95 | 95 |
96 // Spacing between rows in the site settings section | 96 // Spacing between rows in the site settings section |
97 const int kPermissionsVerticalSpacing = 12; | 97 const int kPermissionsVerticalSpacing = 12; |
98 | 98 |
99 // Spacing between the label and the menu. | 99 // Spacing between the label and the menu. |
100 const int kPermissionMenuSpacing = 16; | 100 const int kPermissionMenuSpacing = 16; |
101 | 101 |
102 // Button/styled label/link IDs ------------------------------------------------ | 102 // Button/styled label/link IDs ------------------------------------------------ |
103 const int BUTTON_CLOSE = 1337; | 103 const int BUTTON_CLOSE = 1337; |
104 const int STYLED_LABEL_SECURITY_DETAILS = 1338; | 104 const int STYLED_LABEL_SECURITY_DETAILS = 1338; |
105 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; | 105 const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339; |
106 const int LINK_COOKIE_DIALOG = 1340; | 106 const int LINK_COOKIE_DIALOG = 1340; |
107 const int LINK_SITE_SETTINGS = 1341; | 107 const int LINK_SITE_SETTINGS = 1341; |
108 const int LINK_CERTIFICATE_VIEWER = 1342; | |
108 | 109 |
109 // The default, ui::kTitleFontSizeDelta, is too large for the page info | 110 // The default, ui::kTitleFontSizeDelta, is too large for the page info |
110 // bubble (e.g. +3). Use +1 to obtain a smaller font. | 111 // bubble (e.g. +3). Use +1 to obtain a smaller font. |
111 constexpr int kSummaryFontSizeDelta = 1; | 112 constexpr int kSummaryFontSizeDelta = 1; |
112 | 113 |
113 // Adds a ColumnSet on |layout| with a single View column and padding columns | 114 // Adds a ColumnSet on |layout| with a single View column and padding columns |
114 // on either side of it with |margin| width. | 115 // on either side of it with |margin| width. |
115 void AddColumnWithSideMargin(views::GridLayout* layout, int margin, int id) { | 116 void AddColumnWithSideMargin(views::GridLayout* layout, int margin, int id) { |
116 views::ColumnSet* column_set = layout->AddColumnSet(id); | 117 views::ColumnSet* column_set = layout->AddColumnSet(id); |
117 column_set->AddPaddingColumn(0, margin); | 118 column_set->AddPaddingColumn(0, margin); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 | 152 |
152 // A container for the styled label with a link for resetting cert decisions. | 153 // A container for the styled label with a link for resetting cert decisions. |
153 // This is only shown sometimes, so we use a container to keep track of | 154 // This is only shown sometimes, so we use a container to keep track of |
154 // where to place it (if needed). | 155 // where to place it (if needed). |
155 views::View* reset_decisions_label_container_; | 156 views::View* reset_decisions_label_container_; |
156 views::StyledLabel* reset_decisions_label_; | 157 views::StyledLabel* reset_decisions_label_; |
157 | 158 |
158 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 159 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
159 }; | 160 }; |
160 | 161 |
162 // |InspectLinkView| is a UI element (view) that shows information and | |
163 // a link to more details. It is used for the Certificate and Cookie | |
164 // subviews. | |
165 class InspectLinkView : public views::View { | |
166 public: | |
167 InspectLinkView(const gfx::Image& image_icon, | |
168 const base::string16& title, | |
169 const base::string16& text_link, | |
170 views::LinkListener* link_listener, | |
171 const int link_id); | |
172 ~InspectLinkView() override; | |
173 | |
174 // Update the text of the link. | |
175 void SetLinkText(const base::string16& text_link); | |
176 | |
177 // Update the tooltip of the link. | |
178 void SetLinkTooltip(const base::string16& text_tooltip); | |
179 | |
180 private: | |
181 views::Link* link_inspect_; | |
182 | |
183 DISALLOW_COPY_AND_ASSIGN(InspectLinkView); | |
184 }; | |
185 | |
161 // The regular PageInfoPopupView is not supported for internal Chrome pages and | 186 // The regular PageInfoPopupView is not supported for internal Chrome pages and |
162 // extension pages. Instead of the |PageInfoPopupView|, the | 187 // extension pages. Instead of the |PageInfoPopupView|, the |
163 // |InternalPageInfoPopupView| is displayed. | 188 // |InternalPageInfoPopupView| is displayed. |
164 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { | 189 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { |
165 public: | 190 public: |
166 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be | 191 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be |
167 // provided to ensure this bubble is closed when the parent closes. | 192 // provided to ensure this bubble is closed when the parent closes. |
168 InternalPageInfoPopupView(views::View* anchor_view, | 193 InternalPageInfoPopupView(views::View* anchor_view, |
169 gfx::NativeView parent_window, | 194 gfx::NativeView parent_window, |
170 const GURL& url); | 195 const GURL& url); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 reset_decisions_label_container_->AddChildView(reset_decisions_label_); | 294 reset_decisions_label_container_->AddChildView(reset_decisions_label_); |
270 | 295 |
271 // Now that it contains a label, the container needs padding at the top. | 296 // Now that it contains a label, the container needs padding at the top. |
272 reset_decisions_label_container_->SetBorder( | 297 reset_decisions_label_container_->SetBorder( |
273 views::CreateEmptyBorder(8, 0, 0, 0)); | 298 views::CreateEmptyBorder(8, 0, 0, 0)); |
274 | 299 |
275 InvalidateLayout(); | 300 InvalidateLayout(); |
276 } | 301 } |
277 | 302 |
278 //////////////////////////////////////////////////////////////////////////////// | 303 //////////////////////////////////////////////////////////////////////////////// |
304 // InspectLinkView | |
305 //////////////////////////////////////////////////////////////////////////////// | |
306 | |
307 // |InspectLinkView| is a UI element (view) that shows information and | |
308 // a link to more details. It is used for the Certificate and Cookie | |
309 // information. | |
310 InspectLinkView::InspectLinkView(const gfx::Image& image_icon, | |
311 const base::string16& title, | |
312 const base::string16& text_link, | |
313 views::LinkListener* link_listener, | |
314 const int link_id) { | |
315 views::GridLayout* layout = new views::GridLayout(this); | |
316 SetLayoutManager(layout); | |
317 | |
318 const int column = 0; | |
319 views::ColumnSet* column_set = layout->AddColumnSet(column); | |
320 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | |
321 views::GridLayout::FIXED, kPermissionIconColumnWidth, | |
322 0); | |
323 column_set->AddPaddingColumn(0, kPermissionImageSpacing); | |
324 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, | |
325 views::GridLayout::USE_PREF, 0, 0); | |
326 | |
327 layout->AddPaddingRow(0, kSubViewsVerticalPadding); | |
328 | |
329 layout->StartRow(1, column); | |
330 | |
331 views::ImageView* icon = new NonAccessibleImageView(); | |
332 icon->SetImage(image_icon.ToImageSkia()); | |
333 layout->AddView( | |
334 icon, 1, 2, views::GridLayout::FILL, | |
335 // TODO(lgarron): The vertical alignment may change to CENTER once | |
336 // Harmony is implemented. See https://crbug.com/512442#c48 | |
337 views::GridLayout::LEADING); | |
338 | |
339 views::Label* title_label = new views::Label(title, CONTEXT_BODY_TEXT_LARGE); | |
340 layout->AddView(title_label); | |
341 layout->StartRow(1, column); | |
342 layout->SkipColumns(1); | |
343 | |
344 link_inspect_ = new views::Link(text_link); | |
345 link_inspect_->set_id(link_id); | |
346 link_inspect_->set_listener(link_listener); | |
347 layout->AddView(link_inspect_); | |
348 } | |
349 | |
350 InspectLinkView::~InspectLinkView() {} | |
351 | |
352 void InspectLinkView::SetLinkText(const base::string16& text_link) { | |
353 link_inspect_->SetText(text_link); | |
354 InvalidateLayout(); | |
355 } | |
356 | |
357 void InspectLinkView::SetLinkTooltip(const base::string16& text_tooltip) { | |
358 link_inspect_->SetTooltipText(text_tooltip); | |
359 } | |
360 | |
361 //////////////////////////////////////////////////////////////////////////////// | |
279 // InternalPageInfoPopupView | 362 // InternalPageInfoPopupView |
280 //////////////////////////////////////////////////////////////////////////////// | 363 //////////////////////////////////////////////////////////////////////////////// |
281 | 364 |
282 InternalPageInfoPopupView::InternalPageInfoPopupView( | 365 InternalPageInfoPopupView::InternalPageInfoPopupView( |
283 views::View* anchor_view, | 366 views::View* anchor_view, |
284 gfx::NativeView parent_window, | 367 gfx::NativeView parent_window, |
285 const GURL& url) | 368 const GURL& url) |
286 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | 369 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { |
287 g_shown_popup_type = PageInfoPopupView::POPUP_INTERNAL_PAGE; | 370 g_shown_popup_type = PageInfoPopupView::POPUP_INTERNAL_PAGE; |
288 set_parent_window(parent_window); | 371 set_parent_window(parent_window); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 Profile* profile, | 463 Profile* profile, |
381 content::WebContents* web_contents, | 464 content::WebContents* web_contents, |
382 const GURL& url, | 465 const GURL& url, |
383 const security_state::SecurityInfo& security_info) | 466 const security_state::SecurityInfo& security_info) |
384 : content::WebContentsObserver(web_contents), | 467 : content::WebContentsObserver(web_contents), |
385 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 468 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
386 profile_(profile), | 469 profile_(profile), |
387 header_(nullptr), | 470 header_(nullptr), |
388 separator_(nullptr), | 471 separator_(nullptr), |
389 site_settings_view_(nullptr), | 472 site_settings_view_(nullptr), |
473 certificate_view_(nullptr), | |
390 cookies_view_(nullptr), | 474 cookies_view_(nullptr), |
391 cookie_dialog_link_(nullptr), | |
392 permissions_view_(nullptr), | 475 permissions_view_(nullptr), |
393 weak_factory_(this) { | 476 weak_factory_(this) { |
394 g_shown_popup_type = POPUP_PAGE_INFO; | 477 g_shown_popup_type = POPUP_PAGE_INFO; |
395 set_parent_window(parent_window); | 478 set_parent_window(parent_window); |
396 | 479 |
397 // Compensate for built-in vertical padding in the anchor view's image. | 480 // Compensate for built-in vertical padding in the anchor view's image. |
398 set_anchor_view_insets(gfx::Insets( | 481 set_anchor_view_insets(gfx::Insets( |
399 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 482 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
400 | 483 |
401 // Capture the default bubble margin, and move it to the Layout classes. This | 484 // Capture the default bubble margin, and move it to the Layout classes. This |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 void PageInfoPopupView::SetCookieInfo(const CookieInfoList& cookie_info_list) { | 615 void PageInfoPopupView::SetCookieInfo(const CookieInfoList& cookie_info_list) { |
533 // |cookie_info_list| should only ever have 2 items: first- and third-party | 616 // |cookie_info_list| should only ever have 2 items: first- and third-party |
534 // cookies. | 617 // cookies. |
535 DCHECK_EQ(cookie_info_list.size(), 2u); | 618 DCHECK_EQ(cookie_info_list.size(), 2u); |
536 int total_allowed = 0; | 619 int total_allowed = 0; |
537 for (const auto& i : cookie_info_list) | 620 for (const auto& i : cookie_info_list) |
538 total_allowed += i.allowed; | 621 total_allowed += i.allowed; |
539 base::string16 label_text = l10n_util::GetPluralStringFUTF16( | 622 base::string16 label_text = l10n_util::GetPluralStringFUTF16( |
540 IDS_PAGE_INFO_NUM_COOKIES, total_allowed); | 623 IDS_PAGE_INFO_NUM_COOKIES, total_allowed); |
541 | 624 |
542 if (!cookie_dialog_link_) { | 625 cookies_view_->SetLinkText(label_text); |
543 cookie_dialog_link_ = new views::Link(label_text); | |
544 cookie_dialog_link_->set_id(LINK_COOKIE_DIALOG); | |
545 cookie_dialog_link_->set_listener(this); | |
546 } else { | |
547 cookie_dialog_link_->SetText(label_text); | |
548 } | |
549 | |
550 views::GridLayout* layout = | |
551 static_cast<views::GridLayout*>(cookies_view_->GetLayoutManager()); | |
552 if (!layout) { | |
553 layout = new views::GridLayout(cookies_view_); | |
554 cookies_view_->SetLayoutManager(layout); | |
555 | |
556 const int cookies_view_column = 0; | |
557 views::ColumnSet* column_set = layout->AddColumnSet(cookies_view_column); | |
558 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | |
559 views::GridLayout::FIXED, kPermissionIconColumnWidth, | |
560 0); | |
561 column_set->AddPaddingColumn(0, kPermissionImageSpacing); | |
562 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | |
563 0, views::GridLayout::USE_PREF, 0, 0); | |
564 | |
565 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); | |
566 | |
567 layout->StartRow(1, cookies_view_column); | |
568 PageInfoUI::PermissionInfo info; | |
569 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | |
570 info.setting = CONTENT_SETTING_ALLOW; | |
571 info.is_incognito = | |
572 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | |
573 ->IsOffTheRecord(); | |
574 views::ImageView* icon = new NonAccessibleImageView(); | |
575 const gfx::Image& image = PageInfoUI::GetPermissionIcon(info); | |
576 icon->SetImage(image.ToImageSkia()); | |
577 layout->AddView( | |
578 icon, 1, 2, views::GridLayout::FILL, | |
579 // TODO: The vertical alignment may change to CENTER once Harmony is | |
580 // implemented. See https://crbug.com/512442#c48 | |
581 views::GridLayout::LEADING); | |
582 | |
583 views::Label* cookies_label = new views::Label( | |
584 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA), | |
585 CONTEXT_BODY_TEXT_LARGE); | |
586 layout->AddView(cookies_label); | |
587 layout->StartRow(1, cookies_view_column); | |
588 layout->SkipColumns(1); | |
589 | |
590 layout->AddView(cookie_dialog_link_); | |
591 | |
592 layout->AddPaddingRow(0, kCookiesViewVerticalPadding); | |
593 } | |
594 | |
595 layout->Layout(cookies_view_); | |
596 SizeToContents(); | 626 SizeToContents(); |
597 } | 627 } |
598 | 628 |
599 void PageInfoPopupView::SetPermissionInfo( | 629 void PageInfoPopupView::SetPermissionInfo( |
600 const PermissionInfoList& permission_info_list, | 630 const PermissionInfoList& permission_info_list, |
601 ChosenObjectInfoList chosen_object_info_list) { | 631 ChosenObjectInfoList chosen_object_info_list) { |
602 // When a permission is changed, PageInfo::OnSitePermissionChanged() | 632 // When a permission is changed, PageInfo::OnSitePermissionChanged() |
603 // calls this method with updated permissions. However, PermissionSelectorRow | 633 // calls this method with updated permissions. However, PermissionSelectorRow |
604 // will have already updated its state, so it's already reflected in the UI. | 634 // will have already updated its state, so it's already reflected in the UI. |
605 // In addition, if a permission is set to the default setting, PageInfo | 635 // In addition, if a permission is set to the default setting, PageInfo |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 identity_info.GetSecurityDescription(); | 704 identity_info.GetSecurityDescription(); |
675 | 705 |
676 summary_text_ = security_description->summary; | 706 summary_text_ = security_description->summary; |
677 GetWidget()->UpdateWindowTitle(); | 707 GetWidget()->UpdateWindowTitle(); |
678 | 708 |
679 if (identity_info.certificate) { | 709 if (identity_info.certificate) { |
680 certificate_ = identity_info.certificate; | 710 certificate_ = identity_info.certificate; |
681 | 711 |
682 if (identity_info.show_ssl_decision_revoke_button) | 712 if (identity_info.show_ssl_decision_revoke_button) |
683 header_->AddResetDecisionsLabel(); | 713 header_->AddResetDecisionsLabel(); |
714 | |
715 if (PageInfoUI::ShouldShowCertificateLink()) { | |
716 // The text of link to the Certificate Viewer varies depending on the | |
717 // validity of the Certificate. | |
718 const base::string16 link_title = | |
719 l10n_util::GetStringUTF16((identity_info.identity_status == | |
720 PageInfo::SITE_IDENTITY_STATUS_ERROR) | |
721 ? IDS_PAGE_INFO_CERTIFICATE_INVALID_LINK | |
722 : IDS_PAGE_INFO_CERTIFICATE_VALID_LINK); | |
723 | |
724 certificate_view_ = new InspectLinkView( | |
725 PageInfoUI::GetCertificateIcon(), | |
726 l10n_util::GetStringUTF16(IDS_PAGE_INFO_CERTIFICATE), link_title, | |
727 this, LINK_CERTIFICATE_VIEWER); | |
728 | |
729 if (identity_info.identity_status != | |
730 PageInfo::SITE_IDENTITY_STATUS_ERROR) { | |
731 base::string16 issuer = l10n_util::GetStringFUTF16( | |
732 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, | |
733 base::UTF8ToUTF16(certificate_->issuer().GetDisplayName())); | |
734 certificate_view_->SetLinkTooltip(issuer); | |
lgarron
2017/04/20 19:12:56
Is it common to add information like this in a too
elawrence
2017/04/27 14:56:34
Done.
| |
735 } | |
736 | |
737 site_settings_view_->AddChildViewAt(certificate_view_, 0); | |
738 } | |
684 } | 739 } |
685 | 740 |
686 header_->SetDetails(security_description->details); | 741 header_->SetDetails(security_description->details); |
687 | 742 |
688 Layout(); | 743 Layout(); |
689 SizeToContents(); | 744 SizeToContents(); |
690 } | 745 } |
691 | 746 |
692 views::View* PageInfoPopupView::CreateSiteSettingsView(int side_margin) { | 747 views::View* PageInfoPopupView::CreateSiteSettingsView(int side_margin) { |
693 views::View* site_settings_view = new views::View(); | 748 views::View* site_settings_view = new views::View(); |
694 views::BoxLayout* box_layout = | 749 views::BoxLayout* box_layout = |
695 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); | 750 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); |
696 site_settings_view->SetLayoutManager(box_layout); | 751 site_settings_view->SetLayoutManager(box_layout); |
697 box_layout->set_cross_axis_alignment( | 752 box_layout->set_cross_axis_alignment( |
698 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 753 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
699 | 754 |
700 // Add cookies view. | 755 // Add cookies view. |
701 cookies_view_ = new views::View(); | 756 PageInfoUI::PermissionInfo info; |
757 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | |
758 info.setting = CONTENT_SETTING_ALLOW; | |
759 info.is_incognito = | |
760 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | |
761 ->IsOffTheRecord(); | |
762 | |
763 const base::string16 link_title = | |
764 l10n_util::GetPluralStringFUTF16(IDS_PAGE_INFO_NUM_COOKIES, 0); | |
765 | |
766 cookies_view_ = new InspectLinkView( | |
767 PageInfoUI::GetPermissionIcon(info), | |
768 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA), link_title, | |
769 this, LINK_COOKIE_DIALOG); | |
702 site_settings_view->AddChildView(cookies_view_); | 770 site_settings_view->AddChildView(cookies_view_); |
703 | 771 |
704 return site_settings_view; | 772 return site_settings_view; |
705 } | 773 } |
706 | 774 |
707 void PageInfoPopupView::HandleLinkClickedAsync(views::Link* source) { | 775 void PageInfoPopupView::HandleLinkClickedAsync(views::Link* source) { |
708 // Both switch cases require accessing web_contents(), so we check it here. | 776 // All switch cases require accessing web_contents(), so we check it here. |
709 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) | 777 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) |
710 return; | 778 return; |
711 switch (source->id()) { | 779 switch (source->id()) { |
712 case LINK_SITE_SETTINGS: | 780 case LINK_SITE_SETTINGS: |
713 // TODO(crbug.com/655876): This opens the general Content Settings pane, | 781 // TODO(crbug.com/655876): This opens the general Content Settings pane, |
714 // which is OK for now. But on Android, it opens a page specific to a | 782 // which is OK for now. But on Android, it opens a page specific to a |
715 // given origin that shows all of the settings for that origin. If/when | 783 // given origin that shows all of the settings for that origin. If/when |
716 // that's available on desktop we should link to that here, too. | 784 // that's available on desktop we should link to that here, too. |
717 web_contents()->OpenURL(content::OpenURLParams( | 785 web_contents()->OpenURL(content::OpenURLParams( |
718 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 786 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
719 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 787 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
720 false)); | 788 false)); |
721 presenter_->RecordPageInfoAction( | 789 presenter_->RecordPageInfoAction( |
722 PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); | 790 PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); |
723 break; | 791 break; |
724 case LINK_COOKIE_DIALOG: | 792 case LINK_COOKIE_DIALOG: |
725 // Count how often the Collected Cookies dialog is opened. | 793 // Count how often the Collected Cookies dialog is opened. |
726 presenter_->RecordPageInfoAction( | 794 presenter_->RecordPageInfoAction( |
727 PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); | 795 PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); |
728 new CollectedCookiesViews(web_contents()); | 796 new CollectedCookiesViews(web_contents()); |
729 break; | 797 break; |
798 case LINK_CERTIFICATE_VIEWER: { | |
799 gfx::NativeWindow top_window = web_contents()->GetTopLevelNativeWindow(); | |
800 if (certificate_ && top_window) { | |
801 presenter_->RecordPageInfoAction( | |
802 PageInfo::PAGE_INFO_CERTIFICATE_DIALOG_OPENED); | |
803 ShowCertificateViewer(web_contents(), top_window, certificate_.get()); | |
804 } | |
805 } break; | |
730 default: | 806 default: |
731 NOTREACHED(); | 807 NOTREACHED(); |
732 } | 808 } |
733 } | 809 } |
734 | 810 |
735 void PageInfoPopupView::StyledLabelLinkClicked(views::StyledLabel* label, | 811 void PageInfoPopupView::StyledLabelLinkClicked(views::StyledLabel* label, |
736 const gfx::Range& range, | 812 const gfx::Range& range, |
737 int event_flags) { | 813 int event_flags) { |
738 switch (label->id()) { | 814 switch (label->id()) { |
739 case STYLED_LABEL_SECURITY_DETAILS: | 815 case STYLED_LABEL_SECURITY_DETAILS: |
740 web_contents()->OpenURL(content::OpenURLParams( | 816 web_contents()->OpenURL(content::OpenURLParams( |
741 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), | 817 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), |
742 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 818 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
743 false)); | 819 false)); |
744 presenter_->RecordPageInfoAction( | 820 presenter_->RecordPageInfoAction( |
745 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); | 821 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); |
746 break; | 822 break; |
747 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: | 823 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: |
748 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 824 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
749 GetWidget()->Close(); | 825 GetWidget()->Close(); |
750 break; | 826 break; |
751 default: | 827 default: |
752 NOTREACHED(); | 828 NOTREACHED(); |
753 } | 829 } |
754 } | 830 } |
OLD | NEW |