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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_GTK_H_ 7 8 #include <gtk/gtk.h> 9 10 #include "base/basictypes.h" 11 #include "base/compiler_specific.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_vector.h" 14 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 15 #include "chrome/browser/ui/gtk/website_settings/permission_selector_observer.h" 16 #include "chrome/browser/ui/website_settings/website_settings_ui.h" 17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_registrar.h" 19 20 class Browser; 21 class CustomDrawButton; 22 class GtkThemeService; 23 class GURL; 24 class PermissionSelector; 25 class Profile; 26 class WebsiteSettings; 27 28 namespace content { 29 struct SSLStatus; 30 class WebContents; 31 } 32 33 // GTK implementation of the website settings UI. 34 class WebsiteSettingsPopupGtk : public WebsiteSettingsUI, 35 public PermissionSelectorObserver, 36 public BubbleDelegateGtk, 37 public content::NotificationObserver { 38 public: 39 // Creates a |WebsiteSettingsPopupGtk| and displays the UI. The |url| 40 // contains the omnibox URL of the currently active tab, |parent| contains 41 // the currently active window, |profile| contains the currently active 42 // profile and |ssl| contains the |SSLStatus| of the connection to the 43 // website in the currently active tab that is wrapped by the 44 // |web_contents|. 45 static void Show(gfx::NativeWindow parent, 46 Profile* profile, 47 content::WebContents* web_contents, 48 const GURL& url, 49 const content::SSLStatus& ssl); 50 51 virtual ~WebsiteSettingsPopupGtk(); 52 53 private: 54 WebsiteSettingsPopupGtk(gfx::NativeWindow parent, 55 Profile* profile, 56 content::WebContents* web_contents, 57 const GURL& url, 58 const content::SSLStatus& ssl); 59 60 // WebsiteSettingsUI implementations. 61 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE; 62 virtual void SetPermissionInfo( 63 const PermissionInfoList& permission_info_list) OVERRIDE; 64 virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE; 65 virtual void SetFirstVisit(const string16& first_visit) OVERRIDE; 66 virtual void SetSelectedTab(WebsiteSettingsUI::TabId tab_id) OVERRIDE; 67 68 // PermissionSelectorObserver implementations. 69 virtual void OnPermissionChanged(PermissionSelector* selector) OVERRIDE; 70 71 // BubbleDelegateGtk implementation. 72 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; 73 74 // content::NotificationObserver implementation. 75 virtual void Observe(int type, 76 const content::NotificationSource& source, 77 const content::NotificationDetails& details) OVERRIDE; 78 79 // Layouts the different sections retrieved from the model. 80 void InitContents(); 81 82 // Creates a tab for the tabstrip with label indicated by |ids|. This tab 83 // is not used in GTK theme mode. 84 GtkWidget* BuildTab(int ids); 85 86 // Gives the index in the notebook for the given tab widget. 87 int TabstripButtonToTabIndex(GtkWidget* tab); 88 89 // Callbacks for the link buttons. 90 CHROMEGTK_CALLBACK_1(WebsiteSettingsPopupGtk, gboolean, 91 OnTabButtonPress, GdkEvent*); 92 CHROMEGTK_CALLBACK_1(WebsiteSettingsPopupGtk, gboolean, 93 OnTabExpose, GdkEventExpose*); 94 CHROMEGTK_CALLBACK_1(WebsiteSettingsPopupGtk, gboolean, 95 OnTabstripExpose, GdkEventExpose*); 96 CHROMEGTK_CALLBACK_0(WebsiteSettingsPopupGtk, void, OnCookiesLinkClicked); 97 CHROMEGTK_CALLBACK_0(WebsiteSettingsPopupGtk, void, OnViewCertLinkClicked); 98 CHROMEGTK_CALLBACK_0(WebsiteSettingsPopupGtk, void, OnCloseButtonClicked); 99 CHROMEGTK_CALLBACK_0(WebsiteSettingsPopupGtk, void, OnHelpLinkClicked); 100 101 // Parent window. 102 GtkWindow* parent_; 103 104 // The container that contains the content of the popup. 105 GtkWidget* contents_; 106 107 // The widget relative to which the popup is positioned. 108 GtkWidget* anchor_; 109 110 // Provides colors and stuff. 111 GtkThemeService* theme_service_; 112 113 // The popup bubble container. 114 BubbleGtk* bubble_; 115 116 Profile* profile_; 117 118 content::WebContents* web_contents_; 119 120 // The browser object of the current window. This is needed to open the 121 // settings page in a new tab. 122 Browser* browser_; 123 124 // For secure connection |cert_id_| is set to the ID of the server 125 // certificate. For non secure connections |cert_id_| is 0. 126 int cert_id_; 127 128 // Container for the popup header content. 129 GtkWidget* header_box_; 130 131 // Close button for the bubble. 132 scoped_ptr<CustomDrawButton> close_button_; 133 134 // Container for the cookies and site data section content. 135 GtkWidget* cookies_section_contents_; 136 137 // Container for the permissions section content. 138 GtkWidget* permissions_section_contents_; 139 140 // Container for the remote host (website) identity section of the connection 141 // tab. 142 GtkWidget* identity_contents_; 143 144 // Container for the connection section of the connection tab. 145 GtkWidget* connection_contents_; 146 147 // Container for the information about the first visit date of the website. 148 GtkWidget* first_visit_contents_; 149 150 // The widget that wraps the tabstrip. 151 GtkWidget* tabstrip_alignment_; 152 153 // The widget that contains the tabs display on the popup. 154 GtkWidget* notebook_; 155 156 // The UI translates user actions to specific events and forwards them to the 157 // |presenter_|. The |presenter_| handles these events and updates the UI. 158 scoped_ptr<WebsiteSettings> presenter_; 159 160 // The permission selectors that allow the user to change individual 161 // permissions. 162 ScopedVector<PermissionSelector> selectors_; 163 164 content::NotificationRegistrar registrar_; 165 166 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupGtk); 167 }; 168 169 #endif // CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_GTK_H_ 170