Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/gtk/website_settings_popup_gtk.h" | 5 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/certificate_viewer.h" | 10 #include "chrome/browser/certificate_viewer.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 13 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 14 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 14 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 15 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" | 15 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 17 #include "chrome/browser/ui/gtk/gtk_util.h" | 17 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 21 #include "chrome/browser/ui/website_settings/website_settings.h" | 21 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 22 #include "chrome/browser/ui/website_settings/website_settings_utils.h" | |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "content/public/browser/cert_store.h" | 24 #include "content/public/browser/cert_store.h" |
| 24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 26 #include "grit/chromium_strings.h" | |
| 25 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 26 #include "grit/locale_settings.h" | 28 #include "grit/locale_settings.h" |
| 27 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 28 #include "ui/base/gtk/gtk_hig_constants.h" | 30 #include "ui/base/gtk/gtk_hig_constants.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 31 | 33 |
| 32 using content::OpenURLParams; | 34 using content::OpenURLParams; |
| 33 | 35 |
| 34 namespace { | 36 namespace { |
| 35 | 37 |
| 36 // The background color of the tabs if a theme other than the native GTK theme | 38 // The background color of the tabs if a theme other than the native GTK theme |
| 37 // is selected. | 39 // is selected. |
| 38 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); | 40 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); |
| 39 | 41 |
| 42 class InternalPageInfoPopupGtk : public BubbleDelegateGtk { | |
| 43 public: | |
| 44 explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent, | |
| 45 Profile* profile); | |
| 46 virtual ~InternalPageInfoPopupGtk(); | |
| 47 | |
| 48 private: | |
| 49 // BubbleDelegateGtk implementation. | |
| 50 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; | |
| 51 | |
| 52 // The popup bubble container. | |
| 53 BubbleGtk* bubble_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupGtk); | |
| 56 }; | |
| 57 | |
| 58 InternalPageInfoPopupGtk::InternalPageInfoPopupGtk( | |
| 59 gfx::NativeWindow parent, Profile* profile) { | |
| 60 GtkWidget* contents = gtk_hbox_new(FALSE, ui::kContentAreaSpacing); | |
| 61 gtk_container_set_border_width(GTK_CONTAINER(contents), | |
| 62 ui::kContentAreaBorder); | |
| 63 // Add the popup icon. | |
| 64 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 65 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26).ToGdkPixbuf(); | |
| 66 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); | |
| 67 gtk_box_pack_start(GTK_BOX(contents), image, FALSE, FALSE, 0); | |
| 68 gtk_misc_set_alignment(GTK_MISC(image), 0, 0); | |
| 69 | |
| 70 // Add the popup text. | |
| 71 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); | |
| 72 GtkWidget* label = theme_service->BuildLabel( | |
| 73 l10n_util::GetStringUTF8(IDS_PAGE_INFO_INTERNAL_PAGE), ui::kGdkBlack); | |
| 74 gtk_label_set_selectable(GTK_LABEL(label), FALSE); | |
| 75 PangoAttrList* attributes = pango_attr_list_new(); | |
| 76 pango_attr_list_insert(attributes, | |
| 77 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); | |
| 78 gtk_box_pack_start(GTK_BOX(contents), label, FALSE, FALSE, 0); | |
| 79 | |
| 80 gtk_widget_show_all(contents); | |
| 81 | |
| 82 // Create the bubble. | |
| 83 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? | |
| 84 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : | |
| 85 BubbleGtk::ARROW_LOCATION_TOP_LEFT; | |
| 86 BrowserWindowGtk* browser_window = | |
| 87 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); | |
| 88 GtkWidget* anchor = browser_window-> | |
| 89 GetToolbar()->GetLocationBarView()->location_icon_widget(); | |
| 90 bubble_ = BubbleGtk::Show(anchor, | |
| 91 NULL, // |rect| | |
| 92 contents, | |
| 93 arrow_location, | |
| 94 BubbleGtk::MATCH_SYSTEM_THEME | | |
| 95 BubbleGtk::POPUP_WINDOW | | |
| 96 BubbleGtk::GRAB_INPUT, | |
| 97 theme_service, | |
| 98 this); // |delegate| | |
| 99 DCHECK(bubble_); | |
| 100 } | |
| 101 | |
| 102 InternalPageInfoPopupGtk::~InternalPageInfoPopupGtk() { | |
| 103 } | |
| 104 | |
| 105 void InternalPageInfoPopupGtk::BubbleClosing(BubbleGtk* bubble, | |
| 106 bool closed_by_escape) { | |
|
Elliot Glaysher
2012/08/09 16:41:56
indentation doesn't align
markusheintz_
2012/08/09 16:51:13
Done.
| |
| 107 delete this; | |
| 108 } | |
| 109 | |
| 40 } // namespace | 110 } // namespace |
| 41 | 111 |
| 42 // static | 112 // static |
| 43 void WebsiteSettingsPopupGtk::Show(gfx::NativeWindow parent, | 113 void WebsiteSettingsPopupGtk::Show(gfx::NativeWindow parent, |
| 44 Profile* profile, | 114 Profile* profile, |
| 45 TabContents* tab_contents, | 115 TabContents* tab_contents, |
| 46 const GURL& url, | 116 const GURL& url, |
| 47 const content::SSLStatus& ssl) { | 117 const content::SSLStatus& ssl) { |
| 48 new WebsiteSettingsPopupGtk(parent, profile, tab_contents, url, ssl); | 118 if (InternalChromePage(url)) |
| 119 new InternalPageInfoPopupGtk(parent, profile); | |
| 120 else | |
| 121 new WebsiteSettingsPopupGtk(parent, profile, tab_contents, url, ssl); | |
| 49 } | 122 } |
| 50 | 123 |
| 51 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( | 124 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( |
| 52 gfx::NativeWindow parent, | 125 gfx::NativeWindow parent, |
| 53 Profile* profile, | 126 Profile* profile, |
| 54 TabContents* tab_contents, | 127 TabContents* tab_contents, |
| 55 const GURL& url, | 128 const GURL& url, |
| 56 const content::SSLStatus& ssl) | 129 const content::SSLStatus& ssl) |
| 57 : parent_(parent), | 130 : parent_(parent), |
| 58 contents_(NULL), | 131 contents_(NULL), |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 presenter_->OnSitePermissionChanged(ContentSettingsType(type), | 582 presenter_->OnSitePermissionChanged(ContentSettingsType(type), |
| 510 ContentSetting(value)); | 583 ContentSetting(value)); |
| 511 } | 584 } |
| 512 | 585 |
| 513 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { | 586 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { |
| 514 DCHECK_NE(cert_id_, 0); | 587 DCHECK_NE(cert_id_, 0); |
| 515 ShowCertificateViewerByID( | 588 ShowCertificateViewerByID( |
| 516 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); | 589 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); |
| 517 bubble_->Close(); | 590 bubble_->Close(); |
| 518 } | 591 } |
| OLD | NEW |