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

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: felt comment 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 // view-source scheme uses the same icon as other internal pages.
338 text = IDS_PAGE_INFO_VIEW_SOURCE_PAGE;
felt 2016/08/12 23:58:43 can you copy the same logic here too, with the com
339 }
340
331 // Compensate for built-in vertical padding in the anchor view's image. 341 // Compensate for built-in vertical padding in the anchor view's image.
332 set_anchor_view_insets(gfx::Insets( 342 set_anchor_view_insets(gfx::Insets(
333 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 343 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
334 344
335 const int kSpacing = 16; 345 const int kSpacing = 16;
336 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, 346 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing,
337 kSpacing, kSpacing)); 347 kSpacing, kSpacing));
338 set_margins(gfx::Insets()); 348 set_margins(gfx::Insets());
339 views::ImageView* icon_view = new views::ImageView(); 349 views::ImageView* icon_view = new views::ImageView();
340 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 350 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
341 icon_view->SetImage(rb.GetImageSkiaNamed( 351 icon_view->SetImage(rb.GetImageSkiaNamed(icon));
342 is_extension_page ? IDR_PLUGINS_FAVICON : IDR_PRODUCT_LOGO_16));
343 AddChildView(icon_view); 352 AddChildView(icon_view);
344 353
345 views::Label* label = new views::Label(l10n_util::GetStringUTF16( 354 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); 355 label->SetMultiLine(true);
349 label->SetAllowCharacterBreak(true); 356 label->SetAllowCharacterBreak(true);
350 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 357 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
351 AddChildView(label); 358 AddChildView(label);
352 359
353 views::BubbleDialogDelegateView::CreateBubble(this); 360 views::BubbleDialogDelegateView::CreateBubble(this);
354 } 361 }
355 362
356 InternalPageInfoPopupView::~InternalPageInfoPopupView() { 363 InternalPageInfoPopupView::~InternalPageInfoPopupView() {
357 } 364 }
(...skipping 28 matching lines...) Expand all
386 views::View* anchor_view, 393 views::View* anchor_view,
387 const gfx::Rect& anchor_rect, 394 const gfx::Rect& anchor_rect,
388 Profile* profile, 395 Profile* profile,
389 content::WebContents* web_contents, 396 content::WebContents* web_contents,
390 const GURL& url, 397 const GURL& url,
391 const security_state::SecurityStateModel::SecurityInfo& security_info) { 398 const security_state::SecurityStateModel::SecurityInfo& security_info) {
392 is_popup_showing = true; 399 is_popup_showing = true;
393 gfx::NativeView parent_window = 400 gfx::NativeView parent_window =
394 anchor_view ? nullptr : web_contents->GetNativeView(); 401 anchor_view ? nullptr : web_contents->GetNativeView();
395 if (url.SchemeIs(content::kChromeUIScheme) || 402 if (url.SchemeIs(content::kChromeUIScheme) ||
396 url.SchemeIs(extensions::kExtensionScheme)) { 403 url.SchemeIs(extensions::kExtensionScheme) ||
404 url.SchemeIs(content::kViewSourceScheme)) {
397 // Use the concrete type so that |SetAnchorRect| can be called as a friend. 405 // Use the concrete type so that |SetAnchorRect| can be called as a friend.
398 InternalPageInfoPopupView* popup = new InternalPageInfoPopupView( 406 InternalPageInfoPopupView* popup =
399 anchor_view, parent_window, url.SchemeIs(extensions::kExtensionScheme)); 407 new InternalPageInfoPopupView(anchor_view, parent_window, url);
400 if (!anchor_view) 408 if (!anchor_view)
401 popup->SetAnchorRect(anchor_rect); 409 popup->SetAnchorRect(anchor_rect);
402 popup->GetWidget()->Show(); 410 popup->GetWidget()->Show();
403 return; 411 return;
404 } 412 }
405 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView( 413 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView(
406 anchor_view, parent_window, profile, web_contents, url, security_info); 414 anchor_view, parent_window, profile, web_contents, url, security_info);
407 if (!anchor_view) 415 if (!anchor_view)
408 popup->SetAnchorRect(anchor_rect); 416 popup->SetAnchorRect(anchor_rect);
409 popup->GetWidget()->Show(); 417 popup->GetWidget()->Show();
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 gfx::NativeWindow parent = 821 gfx::NativeWindow parent =
814 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; 822 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr;
815 presenter_->RecordWebsiteSettingsAction( 823 presenter_->RecordWebsiteSettingsAction(
816 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); 824 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
817 ShowCertificateViewerByID(web_contents_, parent, cert_id_); 825 ShowCertificateViewerByID(web_contents_, parent, cert_id_);
818 } else { 826 } else {
819 DevToolsWindow::OpenDevToolsWindow( 827 DevToolsWindow::OpenDevToolsWindow(
820 web_contents_, DevToolsToggleAction::ShowSecurityPanel()); 828 web_contents_, DevToolsToggleAction::ShowSecurityPanel());
821 } 829 }
822 } 830 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698