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