Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/ui/views/page_info/page_info_bubble_view.cc

Issue 2846913002: Add a Certificate Viewer link to the Page Info dropdown (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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| is a UI element (view) that shows information and
msw 2017/04/27 19:47:55 nit: remove copied comment, the class comment abov
elawrence 2017/04/27 21:44:25 Done.
310 // a link to more details. It is used for the Certificate and Cookie
311 // information.
312 InspectLinkView::InspectLinkView(const gfx::Image& image_icon,
313 const base::string16& title,
314 const base::string16& text_link,
315 views::LinkListener* link_listener,
316 const int link_id) {
317 views::GridLayout* layout = new views::GridLayout(this);
318 SetLayoutManager(layout);
319
320 const int column = 0;
321 views::ColumnSet* column_set = layout->AddColumnSet(column);
322 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
323 views::GridLayout::FIXED, kPermissionIconColumnWidth,
324 0);
325 column_set->AddPaddingColumn(0, kPermissionImageSpacing);
326 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0,
327 views::GridLayout::USE_PREF, 0, 0);
328
329 layout->AddPaddingRow(0, kSubViewsVerticalPadding);
330
331 layout->StartRow(1, column);
332
333 views::ImageView* icon = new NonAccessibleImageView();
334 icon->SetImage(image_icon.ToImageSkia());
335 layout->AddView(
336 icon, 1, 2, views::GridLayout::FILL,
337 // TODO(lgarron): The vertical alignment may change to CENTER once
338 // Harmony is implemented. See https://crbug.com/512442#c48
339 views::GridLayout::LEADING);
340
341 views::Label* title_label = new views::Label(title, CONTEXT_BODY_TEXT_LARGE);
342 layout->AddView(title_label);
343 layout->StartRow(1, column);
344 layout->SkipColumns(1);
345
346 link_inspect_ = new views::Link(text_link);
347 link_inspect_->set_id(link_id);
348 link_inspect_->set_listener(link_listener);
349 layout->AddView(link_inspect_);
350 }
351
352 InspectLinkView::~InspectLinkView() {}
353
354 void InspectLinkView::SetLinkText(const base::string16& text_link) {
355 link_inspect_->SetText(text_link);
356 InvalidateLayout();
msw 2017/04/27 19:47:55 q: Is this needed? Perhaps GridLayout just does th
elawrence 2017/04/27 21:44:25 Apparently it is not needed.
elawrence 2017/04/28 17:00:48 Upon retesting on Windows Views, we actually do ne
357 }
358
359 void InspectLinkView::SetLinkTooltip(const base::string16& text_tooltip) {
360 link_inspect_->SetTooltipText(text_tooltip);
361 }
362
363 ////////////////////////////////////////////////////////////////////////////////
281 // InternalPageInfoBubbleView 364 // InternalPageInfoBubbleView
282 //////////////////////////////////////////////////////////////////////////////// 365 ////////////////////////////////////////////////////////////////////////////////
283 366
284 InternalPageInfoBubbleView::InternalPageInfoBubbleView( 367 InternalPageInfoBubbleView::InternalPageInfoBubbleView(
285 views::View* anchor_view, 368 views::View* anchor_view,
286 gfx::NativeView parent_window, 369 gfx::NativeView parent_window,
287 const GURL& url) 370 const GURL& url)
288 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { 371 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
289 g_shown_bubble_type = PageInfoBubbleView::BUBBLE_INTERNAL_PAGE; 372 g_shown_bubble_type = PageInfoBubbleView::BUBBLE_INTERNAL_PAGE;
290 set_parent_window(parent_window); 373 set_parent_window(parent_window);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 Profile* profile, 465 Profile* profile,
383 content::WebContents* web_contents, 466 content::WebContents* web_contents,
384 const GURL& url, 467 const GURL& url,
385 const security_state::SecurityInfo& security_info) 468 const security_state::SecurityInfo& security_info)
386 : content::WebContentsObserver(web_contents), 469 : content::WebContentsObserver(web_contents),
387 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 470 BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
388 profile_(profile), 471 profile_(profile),
389 header_(nullptr), 472 header_(nullptr),
390 separator_(nullptr), 473 separator_(nullptr),
391 site_settings_view_(nullptr), 474 site_settings_view_(nullptr),
475 certificate_view_(nullptr),
392 cookies_view_(nullptr), 476 cookies_view_(nullptr),
393 cookie_dialog_link_(nullptr),
394 permissions_view_(nullptr), 477 permissions_view_(nullptr),
395 weak_factory_(this) { 478 weak_factory_(this) {
396 g_shown_bubble_type = BUBBLE_PAGE_INFO; 479 g_shown_bubble_type = BUBBLE_PAGE_INFO;
397 set_parent_window(parent_window); 480 set_parent_window(parent_window);
398 481
399 // Compensate for built-in vertical padding in the anchor view's image. 482 // Compensate for built-in vertical padding in the anchor view's image.
400 set_anchor_view_insets(gfx::Insets( 483 set_anchor_view_insets(gfx::Insets(
401 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 484 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
402 485
403 // Capture the default bubble margin, and move it to the Layout classes. This 486 // 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
534 void PageInfoBubbleView::SetCookieInfo(const CookieInfoList& cookie_info_list) { 617 void PageInfoBubbleView::SetCookieInfo(const CookieInfoList& cookie_info_list) {
535 // |cookie_info_list| should only ever have 2 items: first- and third-party 618 // |cookie_info_list| should only ever have 2 items: first- and third-party
536 // cookies. 619 // cookies.
537 DCHECK_EQ(cookie_info_list.size(), 2u); 620 DCHECK_EQ(cookie_info_list.size(), 2u);
538 int total_allowed = 0; 621 int total_allowed = 0;
539 for (const auto& i : cookie_info_list) 622 for (const auto& i : cookie_info_list)
540 total_allowed += i.allowed; 623 total_allowed += i.allowed;
541 base::string16 label_text = l10n_util::GetPluralStringFUTF16( 624 base::string16 label_text = l10n_util::GetPluralStringFUTF16(
542 IDS_PAGE_INFO_NUM_COOKIES, total_allowed); 625 IDS_PAGE_INFO_NUM_COOKIES, total_allowed);
543 626
544 if (!cookie_dialog_link_) { 627 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(); 628 SizeToContents();
599 } 629 }
600 630
601 void PageInfoBubbleView::SetPermissionInfo( 631 void PageInfoBubbleView::SetPermissionInfo(
602 const PermissionInfoList& permission_info_list, 632 const PermissionInfoList& permission_info_list,
603 ChosenObjectInfoList chosen_object_info_list) { 633 ChosenObjectInfoList chosen_object_info_list) {
604 // When a permission is changed, PageInfo::OnSitePermissionChanged() 634 // When a permission is changed, PageInfo::OnSitePermissionChanged()
605 // calls this method with updated permissions. However, PermissionSelectorRow 635 // calls this method with updated permissions. However, PermissionSelectorRow
606 // will have already updated its state, so it's already reflected in the UI. 636 // 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 637 // In addition, if a permission is set to the default setting, PageInfo
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 identity_info.GetSecurityDescription(); 706 identity_info.GetSecurityDescription();
677 707
678 summary_text_ = security_description->summary; 708 summary_text_ = security_description->summary;
679 GetWidget()->UpdateWindowTitle(); 709 GetWidget()->UpdateWindowTitle();
680 710
681 if (identity_info.certificate) { 711 if (identity_info.certificate) {
682 certificate_ = identity_info.certificate; 712 certificate_ = identity_info.certificate;
683 713
684 if (identity_info.show_ssl_decision_revoke_button) 714 if (identity_info.show_ssl_decision_revoke_button)
685 header_->AddResetDecisionsLabel(); 715 header_->AddResetDecisionsLabel();
716
717 if (PageInfoUI::ShouldShowCertificateLink()) {
718 // The text of link to the Certificate Viewer varies depending on the
719 // validity of the Certificate.
720 const base::string16 link_title =
721 l10n_util::GetStringUTF16((identity_info.identity_status ==
722 PageInfo::SITE_IDENTITY_STATUS_ERROR)
723 ? IDS_PAGE_INFO_CERTIFICATE_INVALID_LINK
724 : IDS_PAGE_INFO_CERTIFICATE_VALID_LINK);
725
726 certificate_view_ = new InspectLinkView(
727 PageInfoUI::GetCertificateIcon(),
728 l10n_util::GetStringUTF16(IDS_PAGE_INFO_CERTIFICATE), link_title,
729 this, LINK_CERTIFICATE_VIEWER);
730
731 if (identity_info.identity_status !=
732 PageInfo::SITE_IDENTITY_STATUS_ERROR) {
733 base::string16 issuer = l10n_util::GetStringFUTF16(
734 IDS_PAGE_INFO_CERTIFICATE_VALID_LINK_TOOLTIP,
735 base::UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
736 certificate_view_->SetLinkTooltip(issuer);
737 }
738
739 site_settings_view_->AddChildViewAt(certificate_view_, 0);
msw 2017/04/27 19:47:55 Is SetIdentityInfo potentially called more than on
elawrence 2017/04/27 21:44:25 As far as I can tell, no, SetIdentityInfo() is onl
740 }
686 } 741 }
687 742
688 header_->SetDetails(security_description->details); 743 header_->SetDetails(security_description->details);
689 744
690 Layout(); 745 Layout();
691 SizeToContents(); 746 SizeToContents();
692 } 747 }
693 748
694 views::View* PageInfoBubbleView::CreateSiteSettingsView(int side_margin) { 749 views::View* PageInfoBubbleView::CreateSiteSettingsView(int side_margin) {
695 views::View* site_settings_view = new views::View(); 750 views::View* site_settings_view = new views::View();
696 views::BoxLayout* box_layout = 751 views::BoxLayout* box_layout =
697 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0); 752 new views::BoxLayout(views::BoxLayout::kVertical, side_margin, 0, 0);
698 site_settings_view->SetLayoutManager(box_layout); 753 site_settings_view->SetLayoutManager(box_layout);
699 box_layout->set_cross_axis_alignment( 754 box_layout->set_cross_axis_alignment(
700 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); 755 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
701 756
702 // Add cookies view. 757 // Add cookies view.
703 cookies_view_ = new views::View(); 758 PageInfoUI::PermissionInfo info;
759 info.type = CONTENT_SETTINGS_TYPE_COOKIES;
760 info.setting = CONTENT_SETTING_ALLOW;
761 info.is_incognito =
762 Profile::FromBrowserContext(web_contents()->GetBrowserContext())
763 ->IsOffTheRecord();
764
765 const base::string16 link_title =
766 l10n_util::GetPluralStringFUTF16(IDS_PAGE_INFO_NUM_COOKIES, 0);
767
768 cookies_view_ = new InspectLinkView(
769 PageInfoUI::GetPermissionIcon(info),
770 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA), link_title,
771 this, LINK_COOKIE_DIALOG);
704 site_settings_view->AddChildView(cookies_view_); 772 site_settings_view->AddChildView(cookies_view_);
705 773
706 return site_settings_view; 774 return site_settings_view;
707 } 775 }
708 776
709 void PageInfoBubbleView::HandleLinkClickedAsync(views::Link* source) { 777 void PageInfoBubbleView::HandleLinkClickedAsync(views::Link* source) {
710 // Both switch cases require accessing web_contents(), so we check it here. 778 // All switch cases require accessing web_contents(), so we check it here.
711 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed()) 779 if (web_contents() == nullptr || web_contents()->IsBeingDestroyed())
712 return; 780 return;
713 switch (source->id()) { 781 switch (source->id()) {
714 case LINK_SITE_SETTINGS: 782 case LINK_SITE_SETTINGS:
715 // TODO(crbug.com/655876): This opens the general Content Settings pane, 783 // 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 784 // 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 785 // 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. 786 // that's available on desktop we should link to that here, too.
719 web_contents()->OpenURL(content::OpenURLParams( 787 web_contents()->OpenURL(content::OpenURLParams(
720 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), 788 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
721 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, 789 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
722 false)); 790 false));
723 presenter_->RecordPageInfoAction( 791 presenter_->RecordPageInfoAction(
724 PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); 792 PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
725 break; 793 break;
726 case LINK_COOKIE_DIALOG: 794 case LINK_COOKIE_DIALOG:
727 // Count how often the Collected Cookies dialog is opened. 795 // Count how often the Collected Cookies dialog is opened.
728 presenter_->RecordPageInfoAction( 796 presenter_->RecordPageInfoAction(
729 PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); 797 PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED);
730 new CollectedCookiesViews(web_contents()); 798 new CollectedCookiesViews(web_contents());
731 break; 799 break;
800 case LINK_CERTIFICATE_VIEWER: {
801 gfx::NativeWindow top_window = web_contents()->GetTopLevelNativeWindow();
802 if (certificate_ && top_window) {
803 presenter_->RecordPageInfoAction(
804 PageInfo::PAGE_INFO_CERTIFICATE_DIALOG_OPENED);
805 ShowCertificateViewer(web_contents(), top_window, certificate_.get());
806 }
807 } break;
msw 2017/04/27 19:47:55 nit: break on next line (git cl format?)
elawrence 2017/04/27 21:44:25 Yes, running "git cl format" moves the break to th
732 default: 808 default:
733 NOTREACHED(); 809 NOTREACHED();
734 } 810 }
735 } 811 }
736 812
737 void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label, 813 void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
738 const gfx::Range& range, 814 const gfx::Range& range,
739 int event_flags) { 815 int event_flags) {
740 switch (label->id()) { 816 switch (label->id()) {
741 case STYLED_LABEL_SECURITY_DETAILS: 817 case STYLED_LABEL_SECURITY_DETAILS:
742 web_contents()->OpenURL(content::OpenURLParams( 818 web_contents()->OpenURL(content::OpenURLParams(
743 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), 819 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(),
744 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, 820 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
745 false)); 821 false));
746 presenter_->RecordPageInfoAction( 822 presenter_->RecordPageInfoAction(
747 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED); 823 PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED);
748 break; 824 break;
749 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS: 825 case STYLED_LABEL_RESET_CERTIFICATE_DECISIONS:
750 presenter_->OnRevokeSSLErrorBypassButtonPressed(); 826 presenter_->OnRevokeSSLErrorBypassButtonPressed();
751 GetWidget()->Close(); 827 GetWidget()->Close();
752 break; 828 break;
753 default: 829 default:
754 NOTREACHED(); 830 NOTREACHED();
755 } 831 }
756 } 832 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698