Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / website_settings / permission_selector.h
bloba8c575c5ff6b702f0ff8a995c3fe86380eec5224
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_PERMISSION_SELECTOR_H_
6 #define CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_
8 #include <gtk/gtk.h>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
15 #include "chrome/browser/ui/gtk/website_settings/permission_selector_observer.h"
16 #include "chrome/common/content_settings.h"
17 #include "chrome/common/content_settings_types.h"
18 #include "ui/base/gtk/gtk_signal.h"
20 class MenuGtk;
21 class GtkThemeService;
23 // The class |PermissionSelector| allows to change the permission |setting| of a
24 // given permission |type|.
25 class PermissionSelector : public PermissionMenuModel::Delegate {
26 public:
27 // Creates a |PermissionSelector| for the given permission |type|. |setting|
28 // is the current permissions setting. It is possible to pass
29 // |CONTENT_SETTING_DEFAULT| as value for |setting|. |default_setting| is the
30 // effective default setting for the given permission |type|. It is not
31 // allowed to pass |CONTENT_SETTING_DEFAULT| as value for |default_setting|.
32 PermissionSelector(GtkThemeService* theme_service,
33 const GURL& url,
34 ContentSettingsType type,
35 ContentSetting setting,
36 ContentSetting default_setting,
37 content_settings::SettingSource source);
38 virtual ~PermissionSelector();
40 // Returns the container widget that contains all |PermissionSelector| UI
41 // widgets.
42 GtkWidget* widget() { return widget_; }
44 // Adds an |observer|.
45 void AddObserver(PermissionSelectorObserver* observer);
47 // Returns the current permission setting.
48 ContentSetting GetSetting() const;
50 // Returns the permissions type.
51 ContentSettingsType GetType() const;
53 private:
54 // Gtk callback to intercept mouse clicks to the menu buttons.
55 CHROMEGTK_CALLBACK_1(PermissionSelector, gboolean, OnMenuButtonPressEvent,
56 GdkEventButton*);
58 // PermissionMenuModel::Delegate implementation.
59 virtual void ExecuteCommand(int command_id) OVERRIDE;
60 virtual bool IsCommandIdChecked(int command_id) OVERRIDE;
62 // The container widget that contains the PermissionSelecter UI widgets.
63 GtkWidget* widget_; // Owned by the widget hierarchy.
65 // The button that toggles the permission |menu_|.
66 GtkWidget* menu_button_; // Owned by the widget hierarchy.
68 // The menu that provides the permission settings.
69 scoped_ptr<MenuGtk> menu_;
71 // The model for the permission |menu_|.
72 scoped_ptr<PermissionMenuModel> menu_model_;
74 // The permission type icon. The icon is changed depending on the selected
75 // setting.
76 // Owned by the widget hierarchy created by the CreateUI method.
77 GtkWidget* icon_;
79 // The site permission (the |ContentSettingsType|) for which the menu model
80 // provides settings.
81 ContentSettingsType type_;
83 // The global default setting for the permission |type_|.
84 ContentSetting default_setting_;
86 // The currently active setting for the permission |type_|.
87 ContentSetting setting_;
89 ObserverList<PermissionSelectorObserver, false> observer_list_;
91 DISALLOW_COPY_AND_ASSIGN(PermissionSelector);
94 #endif // CHROME_BROWSER_UI_GTK_WEBSITE_SETTINGS_PERMISSION_SELECTOR_H_