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.
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_
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"
21 class CustomDrawButton
;
22 class GtkThemeService
;
24 class PermissionSelector
;
26 class WebsiteSettings
;
33 // GTK implementation of the website settings UI.
34 class WebsiteSettingsPopupGtk
: public WebsiteSettingsUI
,
35 public PermissionSelectorObserver
,
36 public BubbleDelegateGtk
,
37 public content::NotificationObserver
{
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
45 static void Show(gfx::NativeWindow parent
,
47 content::WebContents
* web_contents
,
49 const content::SSLStatus
& ssl
);
51 virtual ~WebsiteSettingsPopupGtk();
54 WebsiteSettingsPopupGtk(gfx::NativeWindow parent
,
56 content::WebContents
* web_contents
,
58 const content::SSLStatus
& ssl
);
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 base::string16
& first_visit
) OVERRIDE
;
66 virtual void SetSelectedTab(WebsiteSettingsUI::TabId tab_id
) OVERRIDE
;
68 // PermissionSelectorObserver implementations.
69 virtual void OnPermissionChanged(PermissionSelector
* selector
) OVERRIDE
;
71 // BubbleDelegateGtk implementation.
72 virtual void BubbleClosing(BubbleGtk
* bubble
, bool closed_by_escape
) OVERRIDE
;
74 // content::NotificationObserver implementation.
75 virtual void Observe(int type
,
76 const content::NotificationSource
& source
,
77 const content::NotificationDetails
& details
) OVERRIDE
;
79 // Layouts the different sections retrieved from the model.
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
);
86 // Gives the index in the notebook for the given tab widget.
87 int TabstripButtonToTabIndex(GtkWidget
* tab
);
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
);
104 // The container that contains the content of the popup.
105 GtkWidget
* contents_
;
107 // The widget relative to which the popup is positioned.
110 // Provides colors and stuff.
111 GtkThemeService
* theme_service_
;
113 // The popup bubble container.
118 content::WebContents
* web_contents_
;
120 // The browser object of the current window. This is needed to open the
121 // settings page in a new tab.
124 // For secure connection |cert_id_| is set to the ID of the server
125 // certificate. For non secure connections |cert_id_| is 0.
128 // Container for the popup header content.
129 GtkWidget
* header_box_
;
131 // Close button for the bubble.
132 scoped_ptr
<CustomDrawButton
> close_button_
;
134 // Container for the cookies and site data section content.
135 GtkWidget
* cookies_section_contents_
;
137 // Container for the permissions section content.
138 GtkWidget
* permissions_section_contents_
;
140 // Container for the remote host (website) identity section of the connection
142 GtkWidget
* identity_contents_
;
144 // Container for the connection section of the connection tab.
145 GtkWidget
* connection_contents_
;
147 // Container for the information about the first visit date of the website.
148 GtkWidget
* first_visit_contents_
;
150 // The widget that wraps the tabstrip.
151 GtkWidget
* tabstrip_alignment_
;
153 // The widget that contains the tabs display on the popup.
154 GtkWidget
* notebook_
;
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_
;
160 // The permission selectors that allow the user to change individual
162 ScopedVector
<PermissionSelector
> selectors_
;
164 content::NotificationRegistrar registrar_
;
166 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupGtk
);
169 #endif // CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_GTK_H_