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

Unified Diff: chrome/browser/ui/views/page_info/page_info_bubble_view.cc

Issue 2737413004: Add a Certificate Viewer link to the Page Info dropdown (Closed)
Patch Set: Rebase, update tooltip Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/page_info/page_info_bubble_view.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/page_info/page_info_bubble_view.cc
diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view.cc
index 12777bad3ac4687db742565dd5eea693085828a5..26093209ce08bb13cd2c5c5392550057dfb25ec1 100644
--- a/chrome/browser/ui/views/page_info/page_info_bubble_view.cc
+++ b/chrome/browser/ui/views/page_info/page_info_bubble_view.cc
@@ -7,7 +7,7 @@
#include <stddef.h>
#include <algorithm>
-#include <vector>
+#include <utility>
#include "base/i18n/rtl.h"
#include "base/macros.h"
@@ -89,8 +89,8 @@ const int kHeaderLabelSpacing = 4;
// Site Settings Section -------------------------------------------------------
-// Spacing above and below the cookies view.
-const int kCookiesViewVerticalPadding = 6;
+// Spacing above and below the cookies and certificate views.
+const int kSubViewsVerticalPadding = 6;
// Spacing between a permission image and the text.
const int kPermissionImageSpacing = 6;
@@ -107,6 +107,7 @@ const int STYLED_LABEL_SECURITY_DETAILS = 1338;
const int STYLED_LABEL_RESET_CERTIFICATE_DECISIONS = 1339;
const int LINK_COOKIE_DIALOG = 1340;
const int LINK_SITE_SETTINGS = 1341;
+const int LINK_CERTIFICATE_VIEWER = 1342;
// The default, ui::kTitleFontSizeDelta, is too large for the page info
// bubble (e.g. +3). Use +1 to obtain a smaller font.
@@ -160,6 +161,30 @@ class BubbleHeaderView : public views::View {
DISALLOW_COPY_AND_ASSIGN(BubbleHeaderView);
};
+// |InspectLinkView| is a UI element (view) that shows information and
+// a link to more details. It is used for the Certificate and Cookie
+// subviews.
+class InspectLinkView : public views::View {
+ public:
+ InspectLinkView(const gfx::Image& image_icon,
+ const base::string16& title,
+ const base::string16& text_link,
+ views::LinkListener* link_listener,
+ const int link_id);
+ ~InspectLinkView() override;
+
+ // Update the text of the link.
+ void SetLinkText(const base::string16& text_link);
+
+ // Update the tooltip of the link.
+ void SetLinkTooltip(const base::string16& text_tooltip);
+
+ private:
+ views::Link* link_inspect_;
+
+ DISALLOW_COPY_AND_ASSIGN(InspectLinkView);
+};
+
// The regular PageInfoBubbleView is not supported for internal Chrome pages and
// extension pages. Instead of the |PageInfoBubbleView|, the
// |InternalPageInfoBubbleView| is displayed.
@@ -278,6 +303,64 @@ void BubbleHeaderView::AddResetDecisionsLabel() {
}
////////////////////////////////////////////////////////////////////////////////
+// InspectLinkView
+////////////////////////////////////////////////////////////////////////////////
+
+// |InspectLinkView| is a UI element (view) that shows information and
+// a link to more details. It is used for the Certificate and Cookie
+// information.
+InspectLinkView::InspectLinkView(const gfx::Image& image_icon,
+ const base::string16& title,
+ const base::string16& text_link,
+ views::LinkListener* link_listener,
+ const int link_id) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+
+ const int column = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(column);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
+ views::GridLayout::FIXED, kPermissionIconColumnWidth,
+ 0);
+ column_set->AddPaddingColumn(0, kPermissionImageSpacing);
+ column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0,
+ views::GridLayout::USE_PREF, 0, 0);
+
+ layout->AddPaddingRow(0, kSubViewsVerticalPadding);
+
+ layout->StartRow(1, column);
+
+ views::ImageView* icon = new NonAccessibleImageView();
+ icon->SetImage(image_icon.ToImageSkia());
+ layout->AddView(
+ icon, 1, 2, views::GridLayout::FILL,
+ // TODO(lgarron): The vertical alignment may change to CENTER once
+ // Harmony is implemented. See https://crbug.com/512442#c48
+ views::GridLayout::LEADING);
+
+ views::Label* title_label = new views::Label(title, CONTEXT_BODY_TEXT_LARGE);
+ layout->AddView(title_label);
+ layout->StartRow(1, column);
+ layout->SkipColumns(1);
+
+ link_inspect_ = new views::Link(text_link);
+ link_inspect_->set_id(link_id);
+ link_inspect_->set_listener(link_listener);
+ layout->AddView(link_inspect_);
+}
+
+InspectLinkView::~InspectLinkView() {}
+
+void InspectLinkView::SetLinkText(const base::string16& text_link) {
+ link_inspect_->SetText(text_link);
+ InvalidateLayout();
+}
+
+void InspectLinkView::SetLinkTooltip(const base::string16& text_tooltip) {
+ link_inspect_->SetTooltipText(text_tooltip);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// InternalPageInfoBubbleView
////////////////////////////////////////////////////////////////////////////////
@@ -389,8 +472,8 @@ PageInfoBubbleView::PageInfoBubbleView(
header_(nullptr),
separator_(nullptr),
site_settings_view_(nullptr),
+ certificate_view_(nullptr),
cookies_view_(nullptr),
- cookie_dialog_link_(nullptr),
permissions_view_(nullptr),
weak_factory_(this) {
g_shown_bubble_type = BUBBLE_PAGE_INFO;
@@ -541,60 +624,7 @@ void PageInfoBubbleView::SetCookieInfo(const CookieInfoList& cookie_info_list) {
base::string16 label_text = l10n_util::GetPluralStringFUTF16(
IDS_PAGE_INFO_NUM_COOKIES, total_allowed);
- if (!cookie_dialog_link_) {
- cookie_dialog_link_ = new views::Link(label_text);
- cookie_dialog_link_->set_id(LINK_COOKIE_DIALOG);
- cookie_dialog_link_->set_listener(this);
- } else {
- cookie_dialog_link_->SetText(label_text);
- }
-
- views::GridLayout* layout =
- static_cast<views::GridLayout*>(cookies_view_->GetLayoutManager());
- if (!layout) {
- layout = new views::GridLayout(cookies_view_);
- cookies_view_->SetLayoutManager(layout);
-
- const int cookies_view_column = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(cookies_view_column);
- column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
- views::GridLayout::FIXED, kPermissionIconColumnWidth,
- 0);
- column_set->AddPaddingColumn(0, kPermissionImageSpacing);
- column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
- 0, views::GridLayout::USE_PREF, 0, 0);
-
- layout->AddPaddingRow(0, kCookiesViewVerticalPadding);
-
- layout->StartRow(1, cookies_view_column);
- PageInfoUI::PermissionInfo info;
- info.type = CONTENT_SETTINGS_TYPE_COOKIES;
- info.setting = CONTENT_SETTING_ALLOW;
- info.is_incognito =
- Profile::FromBrowserContext(web_contents()->GetBrowserContext())
- ->IsOffTheRecord();
- views::ImageView* icon = new NonAccessibleImageView();
- const gfx::Image& image = PageInfoUI::GetPermissionIcon(info);
- icon->SetImage(image.ToImageSkia());
- layout->AddView(
- icon, 1, 2, views::GridLayout::FILL,
- // TODO: The vertical alignment may change to CENTER once Harmony is
- // implemented. See https://crbug.com/512442#c48
- views::GridLayout::LEADING);
-
- views::Label* cookies_label = new views::Label(
- l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA),
- CONTEXT_BODY_TEXT_LARGE);
- layout->AddView(cookies_label);
- layout->StartRow(1, cookies_view_column);
- layout->SkipColumns(1);
-
- layout->AddView(cookie_dialog_link_);
-
- layout->AddPaddingRow(0, kCookiesViewVerticalPadding);
- }
-
- layout->Layout(cookies_view_);
+ cookies_view_->SetLinkText(label_text);
SizeToContents();
}
@@ -683,6 +713,31 @@ void PageInfoBubbleView::SetIdentityInfo(const IdentityInfo& identity_info) {
if (identity_info.show_ssl_decision_revoke_button)
header_->AddResetDecisionsLabel();
+
+ if (PageInfoUI::ShouldShowCertificateLink()) {
+ // The text of link to the Certificate Viewer varies depending on the
+ // validity of the Certificate.
+ const base::string16 link_title =
+ l10n_util::GetStringUTF16((identity_info.identity_status ==
+ PageInfo::SITE_IDENTITY_STATUS_ERROR)
+ ? IDS_PAGE_INFO_CERTIFICATE_INVALID_LINK
+ : IDS_PAGE_INFO_CERTIFICATE_VALID_LINK);
+
+ certificate_view_ = new InspectLinkView(
+ PageInfoUI::GetCertificateIcon(),
+ l10n_util::GetStringUTF16(IDS_PAGE_INFO_CERTIFICATE), link_title,
+ this, LINK_CERTIFICATE_VIEWER);
+
+ if (identity_info.identity_status !=
+ PageInfo::SITE_IDENTITY_STATUS_ERROR) {
+ base::string16 issuer = l10n_util::GetStringFUTF16(
+ IDS_PAGE_INFO_CERTIFICATE_VALID_LINK_TOOLTIP,
+ base::UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
+ certificate_view_->SetLinkTooltip(issuer);
+ }
+
+ site_settings_view_->AddChildViewAt(certificate_view_, 0);
+ }
}
header_->SetDetails(security_description->details);
@@ -700,14 +755,27 @@ views::View* PageInfoBubbleView::CreateSiteSettingsView(int side_margin) {
views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
// Add cookies view.
- cookies_view_ = new views::View();
+ PageInfoUI::PermissionInfo info;
+ info.type = CONTENT_SETTINGS_TYPE_COOKIES;
+ info.setting = CONTENT_SETTING_ALLOW;
+ info.is_incognito =
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext())
+ ->IsOffTheRecord();
+
+ const base::string16 link_title =
+ l10n_util::GetPluralStringFUTF16(IDS_PAGE_INFO_NUM_COOKIES, 0);
+
+ cookies_view_ = new InspectLinkView(
+ PageInfoUI::GetPermissionIcon(info),
+ l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA), link_title,
+ this, LINK_COOKIE_DIALOG);
site_settings_view->AddChildView(cookies_view_);
return site_settings_view;
}
void PageInfoBubbleView::HandleLinkClickedAsync(views::Link* source) {
- // Both switch cases require accessing web_contents(), so we check it here.
+ // All switch cases require accessing web_contents(), so we check it here.
if (web_contents() == nullptr || web_contents()->IsBeingDestroyed())
return;
switch (source->id()) {
@@ -729,6 +797,14 @@ void PageInfoBubbleView::HandleLinkClickedAsync(views::Link* source) {
PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED);
new CollectedCookiesViews(web_contents());
break;
+ case LINK_CERTIFICATE_VIEWER: {
+ gfx::NativeWindow top_window = web_contents()->GetTopLevelNativeWindow();
+ if (certificate_ && top_window) {
+ presenter_->RecordPageInfoAction(
+ PageInfo::PAGE_INFO_CERTIFICATE_DIALOG_OPENED);
+ ShowCertificateViewer(web_contents(), top_window, certificate_.get());
+ }
+ } break;
default:
NOTREACHED();
}
« no previous file with comments | « chrome/browser/ui/views/page_info/page_info_bubble_view.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698