| 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/page_info/permission_menu_model.h" | 5 #include "chrome/browser/ui/page_info/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" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 IDS_PAGE_INFO_MENU_ITEM_SUBRESOURCE_FILTER_BLOCK); | 111 IDS_PAGE_INFO_MENU_ITEM_SUBRESOURCE_FILTER_BLOCK); |
| 112 } | 112 } |
| 113 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 113 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 114 label = PageInfoUI::PermissionActionToUIString( | 114 label = PageInfoUI::PermissionActionToUIString( |
| 115 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, | 115 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, |
| 116 info.source); | 116 info.source); |
| 117 } | 117 } |
| 118 AddCheckItem(CONTENT_SETTING_BLOCK, label); | 118 AddCheckItem(CONTENT_SETTING_BLOCK, label); |
| 119 } | 119 } |
| 120 | 120 |
| 121 PermissionMenuModel::PermissionMenuModel(Profile* profile, | |
| 122 const GURL& url, | |
| 123 ContentSetting setting, | |
| 124 const ChangeCallback& callback) | |
| 125 : ui::SimpleMenuModel(this), | |
| 126 host_content_settings_map_( | |
| 127 HostContentSettingsMapFactory::GetForProfile(profile)), | |
| 128 callback_(callback) { | |
| 129 DCHECK(setting == CONTENT_SETTING_ALLOW || setting == CONTENT_SETTING_BLOCK); | |
| 130 permission_.type = CONTENT_SETTINGS_TYPE_DEFAULT; | |
| 131 permission_.setting = setting; | |
| 132 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; | |
| 133 AddCheckItem(CONTENT_SETTING_ALLOW, | |
| 134 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); | |
| 135 AddCheckItem(CONTENT_SETTING_BLOCK, | |
| 136 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); | |
| 137 } | |
| 138 | |
| 139 PermissionMenuModel::~PermissionMenuModel() {} | 121 PermissionMenuModel::~PermissionMenuModel() {} |
| 140 | 122 |
| 141 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { | 123 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { |
| 142 ContentSetting setting = permission_.setting; | 124 ContentSetting setting = permission_.setting; |
| 143 | 125 |
| 144 #if BUILDFLAG(ENABLE_PLUGINS) | 126 #if BUILDFLAG(ENABLE_PLUGINS) |
| 145 setting = PluginsFieldTrial::EffectiveContentSetting( | 127 setting = PluginsFieldTrial::EffectiveContentSetting( |
| 146 host_content_settings_map_, permission_.type, permission_.setting); | 128 host_content_settings_map_, permission_.type, permission_.setting); |
| 147 #endif // BUILDFLAG(ENABLE_PLUGINS) | 129 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 148 | 130 |
| 149 return setting == command_id; | 131 return setting == command_id; |
| 150 } | 132 } |
| 151 | 133 |
| 152 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { | 134 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { |
| 153 return true; | 135 return true; |
| 154 } | 136 } |
| 155 | 137 |
| 156 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { | 138 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { |
| 157 permission_.setting = static_cast<ContentSetting>(command_id); | 139 permission_.setting = static_cast<ContentSetting>(command_id); |
| 158 callback_.Run(permission_); | 140 callback_.Run(permission_); |
| 159 } | 141 } |
| OLD | NEW |