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

Side by Side 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 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/website_settings/website_settings_popup_view.h " 5 #include "chrome/browser/ui/views/website_settings/website_settings_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 <vector>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 views::ButtonListener* button_listener_; 146 views::ButtonListener* button_listener_;
147 147
148 // A container for the button for resetting cert decisions. The button is only 148 // A container for the button for resetting cert decisions. The button is only
149 // shown sometimes, so we use a container to keep track of where to place it 149 // shown sometimes, so we use a container to keep track of where to place it
150 // (if needed). 150 // (if needed).
151 views::View* reset_decisions_button_container_; 151 views::View* reset_decisions_button_container_;
152 152
153 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); 153 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView);
154 }; 154 };
155 155
156 // Website Settings are not supported for internal Chrome pages. Instead of the 156 // Website Settings are not supported for internal Chrome pages and extension
157 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is 157 // pages. Instead of the |WebsiteSettingsPopupView|, the
158 // displayed. 158 // |InternalPageInfoPopupView| is displayed.
159 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { 159 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView {
160 public: 160 public:
161 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be 161 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be
162 // provided to ensure this bubble is closed when the parent closes. 162 // provided to ensure this bubble is closed when the parent closes.
163 InternalPageInfoPopupView(views::View* anchor_view, 163 InternalPageInfoPopupView(views::View* anchor_view,
164 gfx::NativeView parent_window, 164 gfx::NativeView parent_window,
165 bool is_extension_page); 165 const GURL& url);
166 ~InternalPageInfoPopupView() override; 166 ~InternalPageInfoPopupView() override;
167 167
168 // views::BubbleDialogDelegateView: 168 // views::BubbleDialogDelegateView:
169 views::NonClientFrameView* CreateNonClientFrameView( 169 views::NonClientFrameView* CreateNonClientFrameView(
170 views::Widget* widget) override; 170 views::Widget* widget) override;
171 void OnWidgetDestroying(views::Widget* widget) override; 171 void OnWidgetDestroying(views::Widget* widget) override;
172 int GetDialogButtons() const override; 172 int GetDialogButtons() const override;
173 173
174 private: 174 private:
175 friend class WebsiteSettingsPopupView; 175 friend class WebsiteSettingsPopupView;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 InvalidateLayout(); 317 InvalidateLayout();
318 } 318 }
319 319
320 //////////////////////////////////////////////////////////////////////////////// 320 ////////////////////////////////////////////////////////////////////////////////
321 // InternalPageInfoPopupView 321 // InternalPageInfoPopupView
322 //////////////////////////////////////////////////////////////////////////////// 322 ////////////////////////////////////////////////////////////////////////////////
323 323
324 InternalPageInfoPopupView::InternalPageInfoPopupView( 324 InternalPageInfoPopupView::InternalPageInfoPopupView(
325 views::View* anchor_view, 325 views::View* anchor_view,
326 gfx::NativeView parent_window, 326 gfx::NativeView parent_window,
327 bool is_extension_page) 327 const GURL& url)
328 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { 328 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
329 set_parent_window(parent_window); 329 set_parent_window(parent_window);
330 330
331 int text = IDS_PAGE_INFO_INTERNAL_PAGE;
332 int icon = IDR_PRODUCT_LOGO_16;
333 if (url.SchemeIs(extensions::kExtensionScheme)) {
334 text = IDS_PAGE_INFO_EXTENSION_PAGE;
335 icon = IDR_PLUGINS_FAVICON;
336 } else if (url.SchemeIs(content::kViewSourceScheme)) {
337 text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE;
338 // view-source scheme uses the same icon as chrome:// pages.
339 icon = IDR_PRODUCT_LOGO_16;
340 } else if (!url.SchemeIs(content::kChromeUIScheme)) {
341 NOTREACHED();
342 }
343
331 // Compensate for built-in vertical padding in the anchor view's image. 344 // Compensate for built-in vertical padding in the anchor view's image.
332 set_anchor_view_insets(gfx::Insets( 345 set_anchor_view_insets(gfx::Insets(
333 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 346 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
334 347
335 const int kSpacing = 16; 348 const int kSpacing = 16;
336 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, 349 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing,
337 kSpacing, kSpacing)); 350 kSpacing, kSpacing));
338 set_margins(gfx::Insets()); 351 set_margins(gfx::Insets());
339 views::ImageView* icon_view = new views::ImageView(); 352 views::ImageView* icon_view = new views::ImageView();
340 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 353 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
341 icon_view->SetImage(rb.GetImageSkiaNamed( 354 icon_view->SetImage(rb.GetImageSkiaNamed(icon));
342 is_extension_page ? IDR_PLUGINS_FAVICON : IDR_PRODUCT_LOGO_16));
343 AddChildView(icon_view); 355 AddChildView(icon_view);
344 356
345 views::Label* label = new views::Label(l10n_util::GetStringUTF16( 357 views::Label* label = new views::Label(l10n_util::GetStringUTF16(text));
346 is_extension_page ? IDS_PAGE_INFO_EXTENSION_PAGE
347 : IDS_PAGE_INFO_INTERNAL_PAGE));
348 label->SetMultiLine(true); 358 label->SetMultiLine(true);
349 label->SetAllowCharacterBreak(true); 359 label->SetAllowCharacterBreak(true);
350 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 360 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
351 AddChildView(label); 361 AddChildView(label);
352 362
353 views::BubbleDialogDelegateView::CreateBubble(this); 363 views::BubbleDialogDelegateView::CreateBubble(this);
354 } 364 }
355 365
356 InternalPageInfoPopupView::~InternalPageInfoPopupView() { 366 InternalPageInfoPopupView::~InternalPageInfoPopupView() {
357 } 367 }
(...skipping 28 matching lines...) Expand all
386 views::View* anchor_view, 396 views::View* anchor_view,
387 const gfx::Rect& anchor_rect, 397 const gfx::Rect& anchor_rect,
388 Profile* profile, 398 Profile* profile,
389 content::WebContents* web_contents, 399 content::WebContents* web_contents,
390 const GURL& url, 400 const GURL& url,
391 const security_state::SecurityStateModel::SecurityInfo& security_info) { 401 const security_state::SecurityStateModel::SecurityInfo& security_info) {
392 is_popup_showing = true; 402 is_popup_showing = true;
393 gfx::NativeView parent_window = 403 gfx::NativeView parent_window =
394 anchor_view ? nullptr : web_contents->GetNativeView(); 404 anchor_view ? nullptr : web_contents->GetNativeView();
395 if (url.SchemeIs(content::kChromeUIScheme) || 405 if (url.SchemeIs(content::kChromeUIScheme) ||
396 url.SchemeIs(extensions::kExtensionScheme)) { 406 url.SchemeIs(extensions::kExtensionScheme) ||
407 url.SchemeIs(content::kViewSourceScheme)) {
397 // Use the concrete type so that |SetAnchorRect| can be called as a friend. 408 // Use the concrete type so that |SetAnchorRect| can be called as a friend.
398 InternalPageInfoPopupView* popup = new InternalPageInfoPopupView( 409 InternalPageInfoPopupView* popup =
399 anchor_view, parent_window, url.SchemeIs(extensions::kExtensionScheme)); 410 new InternalPageInfoPopupView(anchor_view, parent_window, url);
400 if (!anchor_view) 411 if (!anchor_view)
401 popup->SetAnchorRect(anchor_rect); 412 popup->SetAnchorRect(anchor_rect);
402 popup->GetWidget()->Show(); 413 popup->GetWidget()->Show();
403 return; 414 return;
404 } 415 }
405 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView( 416 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView(
406 anchor_view, parent_window, profile, web_contents, url, security_info); 417 anchor_view, parent_window, profile, web_contents, url, security_info);
407 if (!anchor_view) 418 if (!anchor_view)
408 popup->SetAnchorRect(anchor_rect); 419 popup->SetAnchorRect(anchor_rect);
409 popup->GetWidget()->Show(); 420 popup->GetWidget()->Show();
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 gfx::NativeWindow parent = 824 gfx::NativeWindow parent =
814 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; 825 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr;
815 presenter_->RecordWebsiteSettingsAction( 826 presenter_->RecordWebsiteSettingsAction(
816 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); 827 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
817 ShowCertificateViewerByID(web_contents_, parent, cert_id_); 828 ShowCertificateViewerByID(web_contents_, parent, cert_id_);
818 } else { 829 } else {
819 DevToolsWindow::OpenDevToolsWindow( 830 DevToolsWindow::OpenDevToolsWindow(
820 web_contents_, DevToolsToggleAction::ShowSecurityPanel()); 831 web_contents_, DevToolsToggleAction::ShowSecurityPanel());
821 } 832 }
822 } 833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698