OLD | NEW |
(Empty) | |
| 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_PERMISSION_SELECTOR_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/observer_list.h" |
| 11 #include "chrome/browser/ui/gtk/website_settings/permission_selector_observer.h" |
| 12 #include "chrome/common/content_settings.h" |
| 13 #include "chrome/common/content_settings_types.h" |
| 14 #include "ui/base/gtk/gtk_signal.h" |
| 15 |
| 16 class GtkThemeService; |
| 17 typedef struct _GParamSpec GParamSpec; |
| 18 typedef struct _GtkWidget GtkWidget; |
| 19 |
| 20 // The class |PermissionSelector| allows to change the permission |setting| of a |
| 21 // given permission |type|. |
| 22 class PermissionSelector { |
| 23 public: |
| 24 // Creates a |PermissionSelector| for the given permission |type|. |setting| |
| 25 // is the current permissions setting. It is possible to pass |
| 26 // |CONTENT_SETTING_DEFAULT| as value for |setting|. |default_setting| is the |
| 27 // effective default setting for the given permission |type|. It is not |
| 28 // allowed to pass |CONTENT_SETTING_DEFAULT| as value for |default_setting|. |
| 29 PermissionSelector(GtkThemeService* theme_service_, |
| 30 ContentSettingsType type, |
| 31 ContentSetting setting, |
| 32 ContentSetting default_setting); |
| 33 ~PermissionSelector(); |
| 34 |
| 35 // Creates the UI for the |PermissionSelector| and returns the widget that |
| 36 // contains the UI elements. The ownership of the widget is transfered to the |
| 37 // caller. |
| 38 GtkWidget* CreateUI(); |
| 39 |
| 40 // Adds an |observer|. |
| 41 void AddObserver(PermissionSelectorObserver* observer); |
| 42 |
| 43 // Returns the current permission setting. |
| 44 ContentSetting setting() const { return setting_; } |
| 45 |
| 46 // Returns the permissions type. |
| 47 ContentSettingsType type() const { return type_; } |
| 48 |
| 49 private: |
| 50 CHROMEGTK_CALLBACK_0(PermissionSelector, void, OnPermissionChanged); |
| 51 CHROMEGTK_CALLBACK_1(PermissionSelector, void, OnComboBoxShown, GParamSpec*); |
| 52 |
| 53 GtkThemeService* theme_service_; |
| 54 |
| 55 // The permission type. |
| 56 ContentSettingsType type_; |
| 57 // The current permission setting. |
| 58 ContentSetting setting_; |
| 59 // The effective default setting. This is required to create the proper UI |
| 60 // string for the default setting. |
| 61 ContentSetting default_setting_; |
| 62 |
| 63 // The permission type icon. The icon is changed depending on the selected |
| 64 // setting. |
| 65 // Owned by the widget hierarchy created by the CreateUI method. |
| 66 GtkWidget* icon_; |
| 67 |
| 68 ObserverList<PermissionSelectorObserver, false> observer_list_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(PermissionSelector); |
| 71 }; |
| 72 |
| 73 #endif // CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_ |
OLD | NEW |