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

Unified Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 2232453002: Show a custom message in the page info bubble for view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The Created 4 years, 4 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
Index: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc
diff --git a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc
index ac90cc17e7dcd8a8e4fe33b98eb3fd1457520fdd..af3e6960f8da06a6f97c7ed929803167b1edc5e9 100644
--- a/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc
+++ b/chrome/browser/ui/views/website_settings/website_settings_popup_view.cc
@@ -153,16 +153,16 @@ class PopupHeaderView : public views::View {
DISALLOW_COPY_AND_ASSIGN(PopupHeaderView);
};
-// Website Settings are not supported for internal Chrome pages. Instead of the
-// |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is
-// displayed.
+// Website Settings are not supported for internal Chrome pages and extension
+// pages. Instead of the |WebsiteSettingsPopupView|, the
+// |InternalPageInfoPopupView| is displayed.
class InternalPageInfoPopupView : public views::BubbleDialogDelegateView {
public:
// If |anchor_view| is nullptr, or has no Widget, |parent_window| may be
// provided to ensure this bubble is closed when the parent closes.
InternalPageInfoPopupView(views::View* anchor_view,
gfx::NativeView parent_window,
- bool is_extension_page);
+ const GURL& url);
~InternalPageInfoPopupView() override;
// views::BubbleDialogDelegateView:
@@ -324,10 +324,23 @@ void PopupHeaderView::AddResetDecisionsButton() {
InternalPageInfoPopupView::InternalPageInfoPopupView(
views::View* anchor_view,
gfx::NativeView parent_window,
- bool is_extension_page)
+ const GURL& url)
: BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
set_parent_window(parent_window);
+ int text = IDS_PAGE_INFO_INTERNAL_PAGE;
+ int icon = IDR_PRODUCT_LOGO_16;
+ if (url.SchemeIs(extensions::kExtensionScheme)) {
+ text = IDS_PAGE_INFO_EXTENSION_PAGE;
+ icon = IDR_PLUGINS_FAVICON;
+ } else if (url.SchemeIs(content::kViewSourceScheme)) {
+ text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE;
+ // view-source scheme uses the same icon as chrome:// pages.
+ icon = IDR_PRODUCT_LOGO_16;
+ } else if (!url.SchemeIs(content::kChromeUIScheme)) {
+ NOTREACHED();
+ }
+
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_view_insets(gfx::Insets(
GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
@@ -338,13 +351,10 @@ InternalPageInfoPopupView::InternalPageInfoPopupView(
set_margins(gfx::Insets());
views::ImageView* icon_view = new views::ImageView();
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- icon_view->SetImage(rb.GetImageSkiaNamed(
- is_extension_page ? IDR_PLUGINS_FAVICON : IDR_PRODUCT_LOGO_16));
+ icon_view->SetImage(rb.GetImageSkiaNamed(icon));
AddChildView(icon_view);
- views::Label* label = new views::Label(l10n_util::GetStringUTF16(
- is_extension_page ? IDS_PAGE_INFO_EXTENSION_PAGE
- : IDS_PAGE_INFO_INTERNAL_PAGE));
+ views::Label* label = new views::Label(l10n_util::GetStringUTF16(text));
label->SetMultiLine(true);
label->SetAllowCharacterBreak(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
@@ -393,10 +403,11 @@ void WebsiteSettingsPopupView::ShowPopup(
gfx::NativeView parent_window =
anchor_view ? nullptr : web_contents->GetNativeView();
if (url.SchemeIs(content::kChromeUIScheme) ||
- url.SchemeIs(extensions::kExtensionScheme)) {
+ url.SchemeIs(extensions::kExtensionScheme) ||
+ url.SchemeIs(content::kViewSourceScheme)) {
// Use the concrete type so that |SetAnchorRect| can be called as a friend.
- InternalPageInfoPopupView* popup = new InternalPageInfoPopupView(
- anchor_view, parent_window, url.SchemeIs(extensions::kExtensionScheme));
+ InternalPageInfoPopupView* popup =
+ new InternalPageInfoPopupView(anchor_view, parent_window, url);
if (!anchor_view)
popup->SetAnchorRect(anchor_rect);
popup->GetWidget()->Show();

Powered by Google App Engine
This is Rietveld 408576698