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