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

Side by Side Diff: chrome/browser/ui/gtk/website_settings/permission_selector.h

Issue 10887027: (GTK only) Replace checkboxes with menus and add support for managed settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 3 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 | Annotate | Revision Log
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 #ifndef CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_
6 #define CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_ 6 #define CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_
7 7
8 #include <gtk/gtk.h>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
11 #include "chrome/browser/ui/gtk/website_settings/permission_selector_observer.h" 15 #include "chrome/browser/ui/gtk/website_settings/permission_selector_observer.h"
12 #include "chrome/common/content_settings.h" 16 #include "chrome/common/content_settings.h"
13 #include "chrome/common/content_settings_types.h" 17 #include "chrome/common/content_settings_types.h"
14 #include "ui/base/gtk/gtk_signal.h" 18 #include "ui/base/gtk/gtk_signal.h"
15 19
20 class MenuGtk;
16 class GtkThemeService; 21 class GtkThemeService;
17 typedef struct _GParamSpec GParamSpec;
18 typedef struct _GtkWidget GtkWidget;
19 22
20 // The class |PermissionSelector| allows to change the permission |setting| of a 23 // The class |PermissionSelector| allows to change the permission |setting| of a
21 // given permission |type|. 24 // given permission |type|.
22 class PermissionSelector { 25 class PermissionSelector : public PermissionMenuModel::PermissionMenuDelegate {
23 public: 26 public:
24 // Creates a |PermissionSelector| for the given permission |type|. |setting| 27 // Creates a |PermissionSelector| for the given permission |type|. |setting|
25 // is the current permissions setting. It is possible to pass 28 // is the current permissions setting. It is possible to pass
26 // |CONTENT_SETTING_DEFAULT| as value for |setting|. |default_setting| is the 29 // |CONTENT_SETTING_DEFAULT| as value for |setting|. |default_setting| is the
27 // effective default setting for the given permission |type|. It is not 30 // effective default setting for the given permission |type|. It is not
28 // allowed to pass |CONTENT_SETTING_DEFAULT| as value for |default_setting|. 31 // allowed to pass |CONTENT_SETTING_DEFAULT| as value for |default_setting|.
29 PermissionSelector(GtkThemeService* theme_service_, 32 PermissionSelector(GtkThemeService* theme_service_,
30 ContentSettingsType type, 33 ContentSettingsType type,
31 ContentSetting setting, 34 ContentSetting setting,
32 ContentSetting default_setting); 35 ContentSetting default_setting,
36 content_settings::SettingSource source);
33 ~PermissionSelector(); 37 ~PermissionSelector();
34 38
35 // Creates the UI for the |PermissionSelector| and returns the widget that 39 // Returns the container widget that contains all |PermissionSelector| UI
36 // contains the UI elements. The ownership of the widget is transfered to the 40 // widgets.
37 // caller. 41 GtkWidget* widget() { return widget_; }
38 GtkWidget* CreateUI();
39 42
40 // Adds an |observer|. 43 // Adds an |observer|.
41 void AddObserver(PermissionSelectorObserver* observer); 44 void AddObserver(PermissionSelectorObserver* observer);
42 45
43 // Returns the current permission setting. 46 // Returns the current permission setting.
44 ContentSetting setting() const { return setting_; } 47 ContentSetting GetSetting() const;
45 48
46 // Returns the permissions type. 49 // Returns the permissions type.
47 ContentSettingsType type() const { return type_; } 50 ContentSettingsType GetType() const;
48 51
49 private: 52 private:
50 CHROMEGTK_CALLBACK_0(PermissionSelector, void, OnPermissionChanged); 53 // Gtk callback to intercept mouse clicks to the menu buttons.
51 CHROMEGTK_CALLBACK_1(PermissionSelector, void, OnComboBoxShown, GParamSpec*); 54 CHROMEGTK_CALLBACK_1(PermissionSelector, gboolean, OnMenuButtonPressEvent,
55 GdkEventButton*);
52 56
53 GtkThemeService* theme_service_; 57 // PermissionMenuModel::PermissionMenuDelegate implementation.
58 virtual void OnPermissionSelected() OVERRIDE;
54 59
55 // The permission type. 60 // The container widget that contains the PermissionSelecter UI widgets.
56 ContentSettingsType type_; 61 GtkWidget* widget_; // Owned by the widget hierarchy.
57 // The current permission setting. 62
58 ContentSetting setting_; 63 // The button that toggles the permission |menu_|.
59 // The effective default setting. This is required to create the proper UI 64 GtkWidget* menu_button_; // Owned by the widget hierarchy.
60 // string for the default setting. 65 // The menu that provides the permission settings.
61 ContentSetting default_setting_; 66 scoped_ptr<MenuGtk> menu_;
67 // The model for the permission |menu_|.
68 scoped_ptr<PermissionMenuModel> menu_model_;
62 69
63 // The permission type icon. The icon is changed depending on the selected 70 // The permission type icon. The icon is changed depending on the selected
64 // setting. 71 // setting.
65 // Owned by the widget hierarchy created by the CreateUI method. 72 // Owned by the widget hierarchy created by the CreateUI method.
66 GtkWidget* icon_; 73 GtkWidget* icon_;
67 74
68 ObserverList<PermissionSelectorObserver, false> observer_list_; 75 ObserverList<PermissionSelectorObserver, false> observer_list_;
69 76
70 DISALLOW_COPY_AND_ASSIGN(PermissionSelector); 77 DISALLOW_COPY_AND_ASSIGN(PermissionSelector);
71 }; 78 };
72 79
73 #endif // CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_ 80 #endif // CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698