| 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 #include "chrome/browser/ui/website_settings/permission_menu_model.h" | 5 #include "chrome/browser/ui/website_settings/permission_menu_model.h" |
| 6 | 6 |
| 7 #include "chrome/browser/plugins/plugins_field_trial.h" | |
| 8 #include "chrome/grit/generated_resources.h" | 7 #include "chrome/grit/generated_resources.h" |
| 8 #include "components/content_settings/core/browser/plugins_field_trial.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 | 10 |
| 11 PermissionMenuModel::PermissionMenuModel( | 11 PermissionMenuModel::PermissionMenuModel( |
| 12 const GURL& url, | 12 const GURL& url, |
| 13 const WebsiteSettingsUI::PermissionInfo& info, | 13 const WebsiteSettingsUI::PermissionInfo& info, |
| 14 const ChangeCallback& callback) | 14 const ChangeCallback& callback) |
| 15 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { | 15 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { |
| 16 DCHECK(!callback_.is_null()); | 16 DCHECK(!callback_.is_null()); |
| 17 base::string16 label; | 17 base::string16 label; |
| 18 | 18 |
| 19 ContentSetting effective_default_setting = permission_.default_setting; | 19 ContentSetting effective_default_setting = permission_.default_setting; |
| 20 | 20 |
| 21 #if defined(ENABLE_PLUGINS) | 21 #if defined(ENABLE_PLUGINS) |
| 22 effective_default_setting = PluginsFieldTrial::EffectiveContentSetting( | 22 effective_default_setting = |
| 23 permission_.type, permission_.default_setting); | 23 content_settings::PluginsFieldTrial::EffectiveContentSetting( |
| 24 permission_.type, permission_.default_setting); |
| 24 #endif // defined(ENABLE_PLUGINS) | 25 #endif // defined(ENABLE_PLUGINS) |
| 25 | 26 |
| 26 switch (effective_default_setting) { | 27 switch (effective_default_setting) { |
| 27 case CONTENT_SETTING_ALLOW: | 28 case CONTENT_SETTING_ALLOW: |
| 28 label = l10n_util::GetStringUTF16( | 29 label = l10n_util::GetStringUTF16( |
| 29 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); | 30 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); |
| 30 break; | 31 break; |
| 31 case CONTENT_SETTING_BLOCK: | 32 case CONTENT_SETTING_BLOCK: |
| 32 label = l10n_util::GetStringUTF16( | 33 label = l10n_util::GetStringUTF16( |
| 33 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); | 34 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 AddCheckItem(CONTENT_SETTING_BLOCK, | 93 AddCheckItem(CONTENT_SETTING_BLOCK, |
| 93 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); | 94 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 PermissionMenuModel::~PermissionMenuModel() {} | 97 PermissionMenuModel::~PermissionMenuModel() {} |
| 97 | 98 |
| 98 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { | 99 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { |
| 99 ContentSetting setting = permission_.setting; | 100 ContentSetting setting = permission_.setting; |
| 100 | 101 |
| 101 #if defined(ENABLE_PLUGINS) | 102 #if defined(ENABLE_PLUGINS) |
| 102 setting = PluginsFieldTrial::EffectiveContentSetting(permission_.type, | 103 setting = content_settings::PluginsFieldTrial::EffectiveContentSetting( |
| 103 permission_.setting); | 104 permission_.type, permission_.setting); |
| 104 #endif // defined(ENABLE_PLUGINS) | 105 #endif // defined(ENABLE_PLUGINS) |
| 105 | 106 |
| 106 return setting == command_id; | 107 return setting == command_id; |
| 107 } | 108 } |
| 108 | 109 |
| 109 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 110 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
| 110 return true; | 111 return true; |
| 111 } | 112 } |
| 112 | 113 |
| 113 bool PermissionMenuModel::GetAcceleratorForCommandId( | 114 bool PermissionMenuModel::GetAcceleratorForCommandId( |
| 114 int command_id, | 115 int command_id, |
| 115 ui::Accelerator* accelerator) { | 116 ui::Accelerator* accelerator) { |
| 116 // Accelerators are not supported. | 117 // Accelerators are not supported. |
| 117 return false; | 118 return false; |
| 118 } | 119 } |
| 119 | 120 |
| 120 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 121 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
| 121 permission_.setting = static_cast<ContentSetting>(command_id); | 122 permission_.setting = static_cast<ContentSetting>(command_id); |
| 122 callback_.Run(permission_); | 123 callback_.Run(permission_); |
| 123 } | 124 } |
| OLD | NEW |