Chromium Code Reviews| 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_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ | |
| 7 | |
| 8 #include "ui/base/models/simple_menu_model.h" | |
| 9 #include "chrome/common/content_settings.h" | |
| 10 #include "chrome/common/content_settings_types.h" | |
| 11 | |
| 12 class PermissionMenuModel : public ui::SimpleMenuModel, | |
| 13 public ui::SimpleMenuModel::Delegate { | |
| 14 public: | |
| 15 class PermissionMenuDelegate { | |
|
Ben Goodger (Google)
2012/08/29 15:52:29
Delegate or Observer?
markusheintz_
2012/08/29 16:15:22
Done.
| |
| 16 public: | |
| 17 virtual void OnPermissionSelected() = 0; | |
| 18 }; | |
| 19 | |
| 20 PermissionMenuModel(PermissionMenuDelegate* delegate, | |
| 21 ContentSettingsType site_permission, | |
| 22 ContentSetting default_setting, | |
| 23 ContentSetting current_setting); | |
| 24 | |
| 25 ContentSettingsType type() const { return type_; } | |
| 26 ContentSetting default_setting() const { return default_setting_; } | |
| 27 ContentSetting current_setting() const { return current_setting_; } | |
| 28 | |
| 29 // Overridden from ui::SimpleMenuModel::Delegate: | |
| 30 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
| 31 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
| 32 virtual bool GetAcceleratorForCommandId( | |
| 33 int command_id, | |
| 34 ui::Accelerator* accelerator) OVERRIDE; | |
| 35 virtual void ExecuteCommand(int command_id) OVERRIDE; | |
| 36 | |
| 37 private: | |
| 38 enum CommandID { | |
| 39 COMMAND_SET_TO_DEFAULT, | |
| 40 COMMAND_SET_TO_ALLOW, | |
| 41 COMMAND_SET_TO_BLOCK, | |
| 42 }; | |
| 43 | |
| 44 // The delegate of the |PermissionMenuModel|. |delegate_| can be NULL. | |
| 45 PermissionMenuDelegate* delegate_; | |
| 46 | |
| 47 // The site permission (the |ContentSettingsType|) for which the menu model | |
| 48 // provides settings. | |
| 49 ContentSettingsType type_; | |
| 50 | |
| 51 // The global default setting for the |site_permission_|. | |
| 52 ContentSetting default_setting_; | |
| 53 | |
| 54 // The currently active setting for the |site_permission|. | |
| 55 ContentSetting current_setting_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(PermissionMenuModel); | |
| 58 }; | |
| 59 | |
| 60 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_MENU_MODEL_H_ | |
| OLD | NEW |