OLD | NEW |
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_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ |
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 9 #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
10 #include "components/content_settings/core/common/content_settings.h" | 10 #include "components/content_settings/core/common/content_settings.h" |
11 #include "components/content_settings/core/common/content_settings_types.h" | 11 #include "components/content_settings/core/common/content_settings_types.h" |
12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 class PermissionMenuModel : public ui::SimpleMenuModel, | 15 class PermissionMenuModel : public ui::SimpleMenuModel, |
16 public ui::SimpleMenuModel::Delegate { | 16 public ui::SimpleMenuModel::Delegate { |
17 public: | 17 public: |
18 typedef base::Callback<void(const WebsiteSettingsUI::PermissionInfo&)> | 18 typedef base::Callback<void(const WebsiteSettingsUI::PermissionInfo&)> |
19 ChangeCallback; | 19 ChangeCallback; |
20 | 20 |
21 // Create a new menu model for permission settings. | 21 // Create a new menu model for permission settings. |
22 PermissionMenuModel(const GURL& url, | 22 PermissionMenuModel(const GURL& url, |
23 const WebsiteSettingsUI::PermissionInfo& info, | 23 const WebsiteSettingsUI::PermissionInfo& info, |
| 24 bool is_incognito, |
24 const ChangeCallback& callback); | 25 const ChangeCallback& callback); |
25 // Creates a special-case menu model that only has the allow and block | 26 // Creates a special-case menu model that only has the allow and block |
26 // options. It does not track a permission type. |setting| is the | 27 // options. It does not track a permission type. |setting| is the |
27 // initial selected option. It must be either CONTENT_SETTING_ALLOW or | 28 // initial selected option. It must be either CONTENT_SETTING_ALLOW or |
28 // CONTENT_SETTING_BLOCK. | 29 // CONTENT_SETTING_BLOCK. |
29 PermissionMenuModel(const GURL& url, | 30 PermissionMenuModel(const GURL& url, |
30 ContentSetting setting, | 31 ContentSetting setting, |
31 const ChangeCallback& callback); | 32 const ChangeCallback& callback); |
32 ~PermissionMenuModel() override; | 33 ~PermissionMenuModel() override; |
33 | 34 |
34 // Overridden from ui::SimpleMenuModel::Delegate: | 35 // Overridden from ui::SimpleMenuModel::Delegate: |
35 bool IsCommandIdChecked(int command_id) const override; | 36 bool IsCommandIdChecked(int command_id) const override; |
36 bool IsCommandIdEnabled(int command_id) const override; | 37 bool IsCommandIdEnabled(int command_id) const override; |
37 bool GetAcceleratorForCommandId(int command_id, | 38 bool GetAcceleratorForCommandId(int command_id, |
38 ui::Accelerator* accelerator) override; | 39 ui::Accelerator* accelerator) override; |
39 void ExecuteCommand(int command_id, int event_flags) override; | 40 void ExecuteCommand(int command_id, int event_flags) override; |
40 | 41 |
41 private: | 42 private: |
42 // The permission info represented by the menu model. | 43 // The permission info represented by the menu model. |
43 WebsiteSettingsUI::PermissionInfo permission_; | 44 WebsiteSettingsUI::PermissionInfo permission_; |
44 | 45 |
45 // Callback to be called when the permission's setting is changed. | 46 // Callback to be called when the permission's setting is changed. |
46 ChangeCallback callback_; | 47 ChangeCallback callback_; |
47 | 48 |
48 DISALLOW_COPY_AND_ASSIGN(PermissionMenuModel); | 49 DISALLOW_COPY_AND_ASSIGN(PermissionMenuModel); |
49 }; | 50 }; |
50 | 51 |
51 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ | 52 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ |
OLD | NEW |