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

Side by Side Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 1917013002: Use a different string and icon for chrome-extension pages in Page Info Bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build Created 4 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/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>
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/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.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/devtools/devtools_toggle_action.h" 19 #include "chrome/browser/devtools/devtools_toggle_action.h"
20 #include "chrome/browser/devtools/devtools_window.h" 20 #include "chrome/browser/devtools/devtools_window.h"
21 #include "chrome/browser/infobars/infobar_service.h" 21 #include "chrome/browser/infobars/infobar_service.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_dialogs.h" 24 #include "chrome/browser/ui/browser_dialogs.h"
25 #include "chrome/browser/ui/layout_constants.h" 25 #include "chrome/browser/ui/layout_constants.h"
26 #include "chrome/browser/ui/views/collected_cookies_views.h" 26 #include "chrome/browser/ui/views/collected_cookies_views.h"
27 #include "chrome/browser/ui/views/website_settings/chosen_object_view.h" 27 #include "chrome/browser/ui/views/website_settings/chosen_object_view.h"
28 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" 28 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h"
29 #include "chrome/browser/ui/website_settings/website_settings.h" 29 #include "chrome/browser/ui/website_settings/website_settings.h"
30 #include "chrome/browser/ui/website_settings/website_settings_utils.h"
31 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
33 #include "chrome/grit/chromium_strings.h" 32 #include "chrome/grit/chromium_strings.h"
34 #include "chrome/grit/generated_resources.h" 33 #include "chrome/grit/generated_resources.h"
35 #include "components/content_settings/core/common/content_settings_types.h" 34 #include "components/content_settings/core/common/content_settings_types.h"
36 #include "components/prefs/pref_service.h" 35 #include "components/prefs/pref_service.h"
37 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
38 #include "content/public/browser/cert_store.h" 37 #include "content/public/browser/cert_store.h"
39 #include "content/public/browser/user_metrics.h" 38 #include "content/public/browser/user_metrics.h"
39 #include "extensions/common/constants.h"
40 #include "grit/components_chromium_strings.h" 40 #include "grit/components_chromium_strings.h"
41 #include "grit/components_google_chrome_strings.h" 41 #include "grit/components_google_chrome_strings.h"
42 #include "grit/components_strings.h" 42 #include "grit/components_strings.h"
43 #include "grit/theme_resources.h" 43 #include "grit/theme_resources.h"
44 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
45 #include "ui/base/models/simple_menu_model.h" 45 #include "ui/base/models/simple_menu_model.h"
46 #include "ui/base/resource/resource_bundle.h" 46 #include "ui/base/resource/resource_bundle.h"
47 #include "ui/gfx/canvas.h" 47 #include "ui/gfx/canvas.h"
48 #include "ui/gfx/font_list.h" 48 #include "ui/gfx/font_list.h"
49 #include "ui/gfx/geometry/insets.h" 49 #include "ui/gfx/geometry/insets.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 }; 155 };
156 156
157 // Website Settings are not supported for internal Chrome pages. Instead of the 157 // Website Settings are not supported for internal Chrome pages. Instead of the
158 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is 158 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is
159 // displayed. 159 // displayed.
160 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView { 160 class InternalPageInfoPopupView : public views::BubbleDialogDelegateView {
161 public: 161 public:
162 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be 162 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be
163 // provided to ensure this bubble is closed when the parent closes. 163 // provided to ensure this bubble is closed when the parent closes.
164 InternalPageInfoPopupView(views::View* anchor_view, 164 InternalPageInfoPopupView(views::View* anchor_view,
165 gfx::NativeView parent_window); 165 gfx::NativeView parent_window,
166 bool is_extension_page);
166 ~InternalPageInfoPopupView() override; 167 ~InternalPageInfoPopupView() override;
167 168
168 // views::BubbleDialogDelegateView: 169 // views::BubbleDialogDelegateView:
169 views::NonClientFrameView* CreateNonClientFrameView( 170 views::NonClientFrameView* CreateNonClientFrameView(
170 views::Widget* widget) override; 171 views::Widget* widget) override;
171 void OnWidgetDestroying(views::Widget* widget) override; 172 void OnWidgetDestroying(views::Widget* widget) override;
172 int GetDialogButtons() const override; 173 int GetDialogButtons() const override;
173 174
174 private: 175 private:
175 friend class WebsiteSettingsPopupView; 176 friend class WebsiteSettingsPopupView;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 314
314 InvalidateLayout(); 315 InvalidateLayout();
315 } 316 }
316 317
317 //////////////////////////////////////////////////////////////////////////////// 318 ////////////////////////////////////////////////////////////////////////////////
318 // InternalPageInfoPopupView 319 // InternalPageInfoPopupView
319 //////////////////////////////////////////////////////////////////////////////// 320 ////////////////////////////////////////////////////////////////////////////////
320 321
321 InternalPageInfoPopupView::InternalPageInfoPopupView( 322 InternalPageInfoPopupView::InternalPageInfoPopupView(
322 views::View* anchor_view, 323 views::View* anchor_view,
323 gfx::NativeView parent_window) 324 gfx::NativeView parent_window,
325 bool is_extension_page)
324 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { 326 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
325 set_parent_window(parent_window); 327 set_parent_window(parent_window);
326 328
327 // Compensate for built-in vertical padding in the anchor view's image. 329 // Compensate for built-in vertical padding in the anchor view's image.
328 set_anchor_view_insets(gfx::Insets( 330 set_anchor_view_insets(gfx::Insets(
329 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 331 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
330 332
331 const int kSpacing = 16; 333 const int kSpacing = 16;
332 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, 334 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing,
333 kSpacing, kSpacing)); 335 kSpacing, kSpacing));
334 set_margins(gfx::Insets()); 336 set_margins(gfx::Insets());
335 views::ImageView* icon_view = new views::ImageView(); 337 views::ImageView* icon_view = new views::ImageView();
336 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 338 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
337 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_16)); 339 icon_view->SetImage(rb.GetImageSkiaNamed(
340 is_extension_page ? IDR_PLUGINS_FAVICON : IDR_PRODUCT_LOGO_16));
338 AddChildView(icon_view); 341 AddChildView(icon_view);
339 342
340 views::Label* label = 343 views::Label* label = new views::Label(l10n_util::GetStringUTF16(
341 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); 344 is_extension_page ? IDS_PAGE_INFO_EXTENSION_PAGE
345 : IDS_PAGE_INFO_INTERNAL_PAGE));
342 label->SetMultiLine(true); 346 label->SetMultiLine(true);
343 label->SetAllowCharacterBreak(true); 347 label->SetAllowCharacterBreak(true);
344 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 348 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
345 AddChildView(label); 349 AddChildView(label);
346 350
347 views::BubbleDialogDelegateView::CreateBubble(this); 351 views::BubbleDialogDelegateView::CreateBubble(this);
348 } 352 }
349 353
350 InternalPageInfoPopupView::~InternalPageInfoPopupView() { 354 InternalPageInfoPopupView::~InternalPageInfoPopupView() {
351 } 355 }
(...skipping 27 matching lines...) Expand all
379 void WebsiteSettingsPopupView::ShowPopup( 383 void WebsiteSettingsPopupView::ShowPopup(
380 views::View* anchor_view, 384 views::View* anchor_view,
381 const gfx::Rect& anchor_rect, 385 const gfx::Rect& anchor_rect,
382 Profile* profile, 386 Profile* profile,
383 content::WebContents* web_contents, 387 content::WebContents* web_contents,
384 const GURL& url, 388 const GURL& url,
385 const security_state::SecurityStateModel::SecurityInfo& security_info) { 389 const security_state::SecurityStateModel::SecurityInfo& security_info) {
386 is_popup_showing = true; 390 is_popup_showing = true;
387 gfx::NativeView parent_window = 391 gfx::NativeView parent_window =
388 anchor_view ? nullptr : web_contents->GetNativeView(); 392 anchor_view ? nullptr : web_contents->GetNativeView();
389 if (InternalChromePage(url)) { 393 if (url.SchemeIs(content::kChromeUIScheme) ||
394 url.SchemeIs(extensions::kExtensionScheme)) {
390 // Use the concrete type so that |SetAnchorRect| can be called as a friend. 395 // Use the concrete type so that |SetAnchorRect| can be called as a friend.
391 InternalPageInfoPopupView* popup = 396 InternalPageInfoPopupView* popup = new InternalPageInfoPopupView(
392 new InternalPageInfoPopupView(anchor_view, parent_window); 397 anchor_view, parent_window, url.SchemeIs(extensions::kExtensionScheme));
393 if (!anchor_view) 398 if (!anchor_view)
394 popup->SetAnchorRect(anchor_rect); 399 popup->SetAnchorRect(anchor_rect);
395 popup->GetWidget()->Show(); 400 popup->GetWidget()->Show();
396 } else { 401 return;
397 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView(
398 anchor_view, parent_window, profile, web_contents, url, security_info);
399 if (!anchor_view)
400 popup->SetAnchorRect(anchor_rect);
401 popup->GetWidget()->Show();
402 } 402 }
403 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView(
404 anchor_view, parent_window, profile, web_contents, url, security_info);
405 if (!anchor_view)
406 popup->SetAnchorRect(anchor_rect);
407 popup->GetWidget()->Show();
403 } 408 }
404 409
405 // static 410 // static
406 bool WebsiteSettingsPopupView::IsPopupShowing() { 411 bool WebsiteSettingsPopupView::IsPopupShowing() {
407 return is_popup_showing; 412 return is_popup_showing;
408 } 413 }
409 414
410 WebsiteSettingsPopupView::WebsiteSettingsPopupView( 415 WebsiteSettingsPopupView::WebsiteSettingsPopupView(
411 views::View* anchor_view, 416 views::View* anchor_view,
412 gfx::NativeView parent_window, 417 gfx::NativeView parent_window,
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 gfx::NativeWindow parent = 813 gfx::NativeWindow parent =
809 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr; 814 anchor_widget() ? anchor_widget()->GetNativeWindow() : nullptr;
810 presenter_->RecordWebsiteSettingsAction( 815 presenter_->RecordWebsiteSettingsAction(
811 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); 816 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
812 ShowCertificateViewerByID(web_contents_, parent, cert_id_); 817 ShowCertificateViewerByID(web_contents_, parent, cert_id_);
813 } else { 818 } else {
814 DevToolsWindow::OpenDevToolsWindow( 819 DevToolsWindow::OpenDevToolsWindow(
815 web_contents_, DevToolsToggleAction::ShowSecurityPanel()); 820 web_contents_, DevToolsToggleAction::ShowSecurityPanel());
816 } 821 }
817 } 822 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698