| 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/content_settings/host_content_settings_map_factory.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 8 #include "chrome/browser/plugins/plugin_utils.h" | 8 #include "chrome/browser/plugins/plugin_utils.h" |
| 9 #include "chrome/browser/plugins/plugins_field_trial.h" | 9 #include "chrome/browser/plugins/plugins_field_trial.h" |
| 10 #include "chrome/common/chrome_features.h" | 10 #include "chrome/common/chrome_features.h" |
| 11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "content/public/common/origin_util.h" | 12 #include "content/public/common/origin_util.h" |
| 13 #include "ppapi/features/features.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 14 | 15 |
| 15 PermissionMenuModel::PermissionMenuModel( | 16 PermissionMenuModel::PermissionMenuModel( |
| 16 Profile* profile, | 17 Profile* profile, |
| 17 const GURL& url, | 18 const GURL& url, |
| 18 const WebsiteSettingsUI::PermissionInfo& info, | 19 const WebsiteSettingsUI::PermissionInfo& info, |
| 19 const ChangeCallback& callback) | 20 const ChangeCallback& callback) |
| 20 : ui::SimpleMenuModel(this), | 21 : ui::SimpleMenuModel(this), |
| 21 host_content_settings_map_( | 22 host_content_settings_map_( |
| 22 HostContentSettingsMapFactory::GetForProfile(profile)), | 23 HostContentSettingsMapFactory::GetForProfile(profile)), |
| 23 permission_(info), | 24 permission_(info), |
| 24 callback_(callback) { | 25 callback_(callback) { |
| 25 DCHECK(!callback_.is_null()); | 26 DCHECK(!callback_.is_null()); |
| 26 base::string16 label; | 27 base::string16 label; |
| 27 | 28 |
| 28 ContentSetting effective_default_setting = permission_.default_setting; | 29 ContentSetting effective_default_setting = permission_.default_setting; |
| 29 | 30 |
| 30 #if defined(ENABLE_PLUGINS) | 31 #if BUILDFLAG(ENABLE_PLUGINS) |
| 31 effective_default_setting = PluginsFieldTrial::EffectiveContentSetting( | 32 effective_default_setting = PluginsFieldTrial::EffectiveContentSetting( |
| 32 host_content_settings_map_, permission_.type, | 33 host_content_settings_map_, permission_.type, |
| 33 permission_.default_setting); | 34 permission_.default_setting); |
| 34 #endif // defined(ENABLE_PLUGINS) | 35 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 35 | 36 |
| 36 switch (effective_default_setting) { | 37 switch (effective_default_setting) { |
| 37 case CONTENT_SETTING_ALLOW: | 38 case CONTENT_SETTING_ALLOW: |
| 38 label = l10n_util::GetStringUTF16( | 39 label = l10n_util::GetStringUTF16( |
| 39 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); | 40 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); |
| 40 break; | 41 break; |
| 41 case CONTENT_SETTING_BLOCK: | 42 case CONTENT_SETTING_BLOCK: |
| 42 label = l10n_util::GetStringUTF16( | 43 label = l10n_util::GetStringUTF16( |
| 43 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); | 44 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); |
| 44 break; | 45 break; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); | 108 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); |
| 108 AddCheckItem(CONTENT_SETTING_BLOCK, | 109 AddCheckItem(CONTENT_SETTING_BLOCK, |
| 109 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); | 110 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); |
| 110 } | 111 } |
| 111 | 112 |
| 112 PermissionMenuModel::~PermissionMenuModel() {} | 113 PermissionMenuModel::~PermissionMenuModel() {} |
| 113 | 114 |
| 114 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { | 115 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { |
| 115 ContentSetting setting = permission_.setting; | 116 ContentSetting setting = permission_.setting; |
| 116 | 117 |
| 117 #if defined(ENABLE_PLUGINS) | 118 #if BUILDFLAG(ENABLE_PLUGINS) |
| 118 setting = PluginsFieldTrial::EffectiveContentSetting( | 119 setting = PluginsFieldTrial::EffectiveContentSetting( |
| 119 host_content_settings_map_, permission_.type, permission_.setting); | 120 host_content_settings_map_, permission_.type, permission_.setting); |
| 120 #endif // defined(ENABLE_PLUGINS) | 121 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 121 | 122 |
| 122 return setting == command_id; | 123 return setting == command_id; |
| 123 } | 124 } |
| 124 | 125 |
| 125 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 126 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
| 126 return true; | 127 return true; |
| 127 } | 128 } |
| 128 | 129 |
| 129 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 130 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
| 130 permission_.setting = static_cast<ContentSetting>(command_id); | 131 permission_.setting = static_cast<ContentSetting>(command_id); |
| 131 callback_.Run(permission_); | 132 callback_.Run(permission_); |
| 132 } | 133 } |
| OLD | NEW |