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_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/views/website_settings/permission_selector_view_observer.h"
14 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
15 #include "chrome/common/content_settings.h"
16 #include "chrome/common/content_settings_types.h"
17 #include "ui/views/controls/button/menu_button_listener.h"
18 #include "ui/views/view.h"
21 class PermissionMenuButton
;
29 // A custom view for selecting a permission setting for the given permission
31 class PermissionSelectorView
: public views::View
,
32 public PermissionMenuModel::Delegate
{
34 PermissionSelectorView(const GURL
& url
,
35 ContentSettingsType type
,
36 ContentSetting default_setting
,
37 ContentSetting current_setting
,
38 content_settings::SettingSource source
);
40 void AddObserver(PermissionSelectorViewObserver
* observer
);
42 // Returns the selected setting.
43 ContentSetting
current_setting() const { return current_setting_
; }
45 // Returns the permission type.
46 ContentSettingsType
type() const { return type_
; }
49 // Overridden from views::View.
50 virtual void ChildPreferredSizeChanged(View
* child
) OVERRIDE
;
53 virtual ~PermissionSelectorView();
55 // Overridden from PermissionMenuModel::Delegate.
56 virtual void ExecuteCommand(int command_id
) OVERRIDE
;
57 virtual bool IsCommandIdChecked(int command_id
) OVERRIDE
;
59 views::ImageView
* icon_
; // Owned by the views hierachy.
60 internal::PermissionMenuButton
* menu_button_
; // Owned by the views hierachy.
61 scoped_ptr
<PermissionMenuModel
> menu_button_model_
;
63 // The site permission (the |ContentSettingsType|) for which the menu model
65 ContentSettingsType type_
;
67 // The global default setting for the permission |type_|.
68 ContentSetting default_setting_
;
70 // The currently active setting for the permission |type_|.
71 ContentSetting current_setting_
;
73 ObserverList
<PermissionSelectorViewObserver
, false> observer_list_
;
75 DISALLOW_COPY_AND_ASSIGN(PermissionSelectorView
);
78 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSION_SELECTOR_VIEW_H_