| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/webui/plugins/plugins_handler.h" | 5 #include "chrome/browser/ui/webui/plugins/plugins_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 system_flash_path.value())) { | 78 system_flash_path.value())) { |
| 79 if (chrome::IsSystemFlashScriptDebuggerPresent()) | 79 if (chrome::IsSystemFlashScriptDebuggerPresent()) |
| 80 desc += base::ASCIIToUTF16(" Debug"); | 80 desc += base::ASCIIToUTF16(" Debug"); |
| 81 else | 81 else |
| 82 desc += base::ASCIIToUTF16(" System"); | 82 desc += base::ASCIIToUTF16(" System"); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 return desc; | 85 return desc; |
| 86 } | 86 } |
| 87 | 87 |
| 88 mojo::Array<mojom::MimeTypePtr> GeneratePluginMimeTypes( | 88 std::vector<mojom::MimeTypePtr> GeneratePluginMimeTypes( |
| 89 const WebPluginInfo& plugin) { | 89 const WebPluginInfo& plugin) { |
| 90 mojo::Array<mojom::MimeTypePtr> mime_types; | 90 std::vector<mojom::MimeTypePtr> mime_types; |
| 91 mime_types.reserve(plugin.mime_types.size()); |
| 91 for (const auto& plugin_mime_type : plugin.mime_types) { | 92 for (const auto& plugin_mime_type : plugin.mime_types) { |
| 92 mojom::MimeTypePtr mime_type(mojom::MimeType::New()); | 93 mojom::MimeTypePtr mime_type(mojom::MimeType::New()); |
| 93 mime_type->description = mojo::String::From(plugin_mime_type.description); | 94 mime_type->description = base::UTF16ToUTF8(plugin_mime_type.description); |
| 94 | 95 mime_type->mime_type = plugin_mime_type.mime_type; |
| 95 mime_type->mime_type = mojo::String::From(plugin_mime_type.mime_type); | 96 mime_type->file_extensions = plugin_mime_type.file_extensions; |
| 96 mime_type->file_extensions = | |
| 97 mojo::Array<mojo::String>::From(plugin_mime_type.file_extensions); | |
| 98 mime_types.push_back(std::move(mime_type)); | 97 mime_types.push_back(std::move(mime_type)); |
| 99 } | 98 } |
| 100 | 99 |
| 101 return mime_types; | 100 return mime_types; |
| 102 } | 101 } |
| 103 | 102 |
| 104 } // namespace | 103 } // namespace |
| 105 | 104 |
| 106 PluginsPageHandler::PluginsPageHandler( | 105 PluginsPageHandler::PluginsPageHandler( |
| 107 content::WebUI* web_ui, | 106 content::WebUI* web_ui, |
| 108 mojo::InterfaceRequest<mojom::PluginsPageHandler> request) | 107 mojo::InterfaceRequest<mojom::PluginsPageHandler> request) |
| 109 : web_ui_(web_ui), | 108 : web_ui_(web_ui), |
| 110 binding_(this, std::move(request)), | 109 binding_(this, std::move(request)), |
| 111 weak_ptr_factory_(this) { | 110 weak_ptr_factory_(this) { |
| 112 Profile* profile = Profile::FromWebUI(web_ui_); | 111 Profile* profile = Profile::FromWebUI(web_ui_); |
| 113 PrefService* prefs = profile->GetPrefs(); | 112 PrefService* prefs = profile->GetPrefs(); |
| 114 show_details_.Init(prefs::kPluginsShowDetails, prefs); | 113 show_details_.Init(prefs::kPluginsShowDetails, prefs); |
| 115 | 114 |
| 116 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 115 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 117 content::Source<Profile>(profile)); | 116 content::Source<Profile>(profile)); |
| 118 } | 117 } |
| 119 | 118 |
| 120 PluginsPageHandler::~PluginsPageHandler() {} | 119 PluginsPageHandler::~PluginsPageHandler() {} |
| 121 | 120 |
| 122 void PluginsPageHandler::SetPluginEnabled(const mojo::String& plugin_path, | 121 void PluginsPageHandler::SetPluginEnabled(const std::string& plugin_path, |
| 123 bool enable) { | 122 bool enable) { |
| 124 Profile* profile = Profile::FromWebUI(web_ui_); | 123 Profile* profile = Profile::FromWebUI(web_ui_); |
| 125 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); | 124 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); |
| 126 plugin_prefs->EnablePlugin( | 125 plugin_prefs->EnablePlugin( |
| 127 enable, base::FilePath(plugin_path.To<base::FilePath::StringType>()), | 126 enable, base::FilePath( |
| 127 mojo::String(plugin_path).To<base::FilePath::StringType>()), |
| 128 base::Bind(&AssertPluginEnabled)); | 128 base::Bind(&AssertPluginEnabled)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void PluginsPageHandler::SetPluginGroupEnabled(const mojo::String& group_name, | 131 void PluginsPageHandler::SetPluginGroupEnabled(const std::string& group_name, |
| 132 bool enable) { | 132 bool enable) { |
| 133 Profile* profile = Profile::FromWebUI(web_ui_); | 133 Profile* profile = Profile::FromWebUI(web_ui_); |
| 134 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); | 134 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); |
| 135 base::string16 group_name_as_string16 = group_name.To<base::string16>(); | 135 base::string16 group_name_as_string16 = base::UTF8ToUTF16(group_name); |
| 136 plugin_prefs->EnablePluginGroup(enable, group_name_as_string16); | 136 plugin_prefs->EnablePluginGroup(enable, group_name_as_string16); |
| 137 if (!enable) { | 137 if (!enable) { |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 | 140 |
| 141 // See http://crbug.com/50105 for background. | 141 // See http://crbug.com/50105 for background. |
| 142 base::string16 adobereader = | 142 base::string16 adobereader = |
| 143 base::ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName); | 143 base::ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName); |
| 144 base::string16 internalpdf = | 144 base::string16 internalpdf = |
| 145 base::ASCIIToUTF16(ChromeContentClient::kPDFPluginName); | 145 base::ASCIIToUTF16(ChromeContentClient::kPDFPluginName); |
| 146 if (group_name_as_string16 == adobereader) | 146 if (group_name_as_string16 == adobereader) |
| 147 plugin_prefs->EnablePluginGroup(false, internalpdf); | 147 plugin_prefs->EnablePluginGroup(false, internalpdf); |
| 148 else if (group_name_as_string16 == internalpdf) | 148 else if (group_name_as_string16 == internalpdf) |
| 149 plugin_prefs->EnablePluginGroup(false, adobereader); | 149 plugin_prefs->EnablePluginGroup(false, adobereader); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void PluginsPageHandler::GetShowDetails( | 152 void PluginsPageHandler::GetShowDetails( |
| 153 const GetShowDetailsCallback& callback) { | 153 const GetShowDetailsCallback& callback) { |
| 154 callback.Run(show_details_.GetValue()); | 154 callback.Run(show_details_.GetValue()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void PluginsPageHandler::SaveShowDetailsToPrefs(bool details_mode) { | 157 void PluginsPageHandler::SaveShowDetailsToPrefs(bool details_mode) { |
| 158 show_details_.SetValue(details_mode); | 158 show_details_.SetValue(details_mode); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void PluginsPageHandler::SetPluginAlwaysAllowed(const mojo::String& plugin, | 161 void PluginsPageHandler::SetPluginAlwaysAllowed(const std::string& plugin, |
| 162 bool allowed) { | 162 bool allowed) { |
| 163 Profile* profile = Profile::FromWebUI(web_ui_); | 163 Profile* profile = Profile::FromWebUI(web_ui_); |
| 164 HostContentSettingsMapFactory::GetForProfile(profile) | 164 HostContentSettingsMapFactory::GetForProfile(profile) |
| 165 ->SetContentSettingCustomScope( | 165 ->SetContentSettingCustomScope( |
| 166 ContentSettingsPattern::Wildcard(), | 166 ContentSettingsPattern::Wildcard(), |
| 167 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_PLUGINS, | 167 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_PLUGINS, |
| 168 plugin.get(), | 168 plugin, allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_DEFAULT); |
| 169 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_DEFAULT); | |
| 170 | 169 |
| 171 // Keep track of the whitelist separately, so that we can distinguish plugins | 170 // Keep track of the whitelist separately, so that we can distinguish plugins |
| 172 // whitelisted by the user from automatically whitelisted ones. | 171 // whitelisted by the user from automatically whitelisted ones. |
| 173 DictionaryPrefUpdate update(profile->GetPrefs(), | 172 DictionaryPrefUpdate update(profile->GetPrefs(), |
| 174 prefs::kContentSettingsPluginWhitelist); | 173 prefs::kContentSettingsPluginWhitelist); |
| 175 update->SetBoolean(plugin.get(), allowed); | 174 update->SetBoolean(plugin, allowed); |
| 176 } | 175 } |
| 177 | 176 |
| 178 void PluginsPageHandler::GetPluginsData( | 177 void PluginsPageHandler::GetPluginsData( |
| 179 const GetPluginsDataCallback& callback) { | 178 const GetPluginsDataCallback& callback) { |
| 180 if (weak_ptr_factory_.HasWeakPtrs()) | 179 if (weak_ptr_factory_.HasWeakPtrs()) |
| 181 return; | 180 return; |
| 182 | 181 |
| 183 content::PluginService::GetInstance()->GetPlugins( | 182 content::PluginService::GetInstance()->GetPlugins( |
| 184 base::Bind(&PluginsPageHandler::RespondWithPluginsData, | 183 base::Bind(&PluginsPageHandler::RespondWithPluginsData, |
| 185 weak_ptr_factory_.GetWeakPtr(), callback)); | 184 weak_ptr_factory_.GetWeakPtr(), callback)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 207 const std::vector<WebPluginInfo>& plugins) { | 206 const std::vector<WebPluginInfo>& plugins) { |
| 208 callback.Run(GeneratePluginsData(plugins)); | 207 callback.Run(GeneratePluginsData(plugins)); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void PluginsPageHandler::NotifyWithPluginsData( | 210 void PluginsPageHandler::NotifyWithPluginsData( |
| 212 const std::vector<WebPluginInfo>& plugins) { | 211 const std::vector<WebPluginInfo>& plugins) { |
| 213 if (page_) | 212 if (page_) |
| 214 page_->OnPluginsUpdated(GeneratePluginsData(plugins)); | 213 page_->OnPluginsUpdated(GeneratePluginsData(plugins)); |
| 215 } | 214 } |
| 216 | 215 |
| 217 mojo::Array<mojom::PluginDataPtr> PluginsPageHandler::GeneratePluginsData( | 216 std::vector<mojom::PluginDataPtr> PluginsPageHandler::GeneratePluginsData( |
| 218 const std::vector<WebPluginInfo>& plugins) { | 217 const std::vector<WebPluginInfo>& plugins) { |
| 219 Profile* profile = Profile::FromWebUI(web_ui_); | 218 Profile* profile = Profile::FromWebUI(web_ui_); |
| 220 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); | 219 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); |
| 221 | 220 |
| 222 PluginFinder* plugin_finder = PluginFinder::GetInstance(); | 221 PluginFinder* plugin_finder = PluginFinder::GetInstance(); |
| 223 // Group plugins by identifier. This is done to be able to display | 222 // Group plugins by identifier. This is done to be able to display |
| 224 // the plugins in UI in a grouped fashion. | 223 // the plugins in UI in a grouped fashion. |
| 225 PluginGroups groups; | 224 PluginGroups groups; |
| 226 for (size_t i = 0; i < plugins.size(); ++i) { | 225 for (size_t i = 0; i < plugins.size(); ++i) { |
| 227 std::unique_ptr<PluginMetadata> plugin( | 226 std::unique_ptr<PluginMetadata> plugin( |
| 228 plugin_finder->GetPluginMetadata(plugins[i])); | 227 plugin_finder->GetPluginMetadata(plugins[i])); |
| 229 groups[plugin->identifier()].push_back(&plugins[i]); | 228 groups[plugin->identifier()].push_back(&plugins[i]); |
| 230 } | 229 } |
| 231 | 230 |
| 232 mojo::Array<mojom::PluginDataPtr> plugins_data; | 231 std::vector<mojom::PluginDataPtr> plugins_data; |
| 233 | 232 plugins_data.reserve(groups.size()); |
| 234 for (PluginGroups::const_iterator it = groups.begin(); it != groups.end(); | 233 for (PluginGroups::const_iterator it = groups.begin(); it != groups.end(); |
| 235 ++it) { | 234 ++it) { |
| 236 mojom::PluginDataPtr plugin_data(mojom::PluginData::New()); | 235 mojom::PluginDataPtr plugin_data(mojom::PluginData::New()); |
| 237 const std::vector<const WebPluginInfo*>& group_plugins = it->second; | 236 const std::vector<const WebPluginInfo*>& group_plugins = it->second; |
| 238 | 237 |
| 239 std::unique_ptr<PluginMetadata> plugin_metadata( | 238 std::unique_ptr<PluginMetadata> plugin_metadata( |
| 240 plugin_finder->GetPluginMetadata(*group_plugins[0])); | 239 plugin_finder->GetPluginMetadata(*group_plugins[0])); |
| 241 std::string group_identifier = plugin_metadata->identifier(); | 240 std::string group_identifier = plugin_metadata->identifier(); |
| 242 plugin_data->id = mojo::String::From(group_identifier); | 241 plugin_data->id = group_identifier; |
| 243 | 242 |
| 244 const WebPluginInfo* active_plugin = nullptr; | 243 const WebPluginInfo* active_plugin = nullptr; |
| 245 bool group_enabled = false; | 244 bool group_enabled = false; |
| 246 | 245 |
| 247 mojo::Array<mojom::PluginFilePtr> plugin_files; | 246 std::vector<mojom::PluginFilePtr> plugin_files; |
| 247 plugin_files.reserve(group_plugins.size()); |
| 248 for (const auto* group_plugin : group_plugins) { | 248 for (const auto* group_plugin : group_plugins) { |
| 249 bool plugin_enabled = plugin_prefs->IsPluginEnabled(*group_plugin); | 249 bool plugin_enabled = plugin_prefs->IsPluginEnabled(*group_plugin); |
| 250 | 250 |
| 251 plugin_files.push_back(GeneratePluginFile( | 251 plugin_files.push_back(GeneratePluginFile( |
| 252 *group_plugin, plugin_metadata->name(), plugin_enabled)); | 252 *group_plugin, plugin_metadata->name(), plugin_enabled)); |
| 253 | 253 |
| 254 // Update |active_plugin| and |group_enabled|. | 254 // Update |active_plugin| and |group_enabled|. |
| 255 if (!active_plugin || (plugin_enabled && !group_enabled)) | 255 if (!active_plugin || (plugin_enabled && !group_enabled)) |
| 256 active_plugin = group_plugin; | 256 active_plugin = group_plugin; |
| 257 group_enabled = plugin_enabled || group_enabled; | 257 group_enabled = plugin_enabled || group_enabled; |
| 258 } | 258 } |
| 259 | 259 |
| 260 plugin_data->enabled_mode = mojo::String::From( | 260 plugin_data->enabled_mode = |
| 261 GetPluginGroupEnabledMode(plugin_files, group_enabled)); | 261 GetPluginGroupEnabledMode(plugin_files, group_enabled); |
| 262 | 262 |
| 263 plugin_data->always_allowed = false; | 263 plugin_data->always_allowed = false; |
| 264 plugin_data->trusted = false; | 264 plugin_data->trusted = false; |
| 265 plugin_data->policy_click_to_play = GetClickToPlayPolicyEnabled(); | 265 plugin_data->policy_click_to_play = GetClickToPlayPolicyEnabled(); |
| 266 | 266 |
| 267 if (group_enabled) { | 267 if (group_enabled) { |
| 268 if (plugin_metadata->GetSecurityStatus(*active_plugin) == | 268 if (plugin_metadata->GetSecurityStatus(*active_plugin) == |
| 269 PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { | 269 PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { |
| 270 plugin_data->trusted = true; | 270 plugin_data->trusted = true; |
| 271 plugin_data->always_allowed = true; | 271 plugin_data->always_allowed = true; |
| 272 } else if (!GetClickToPlayPolicyEnabled()) { | 272 } else if (!GetClickToPlayPolicyEnabled()) { |
| 273 const base::DictionaryValue* whitelist = | 273 const base::DictionaryValue* whitelist = |
| 274 profile->GetPrefs()->GetDictionary( | 274 profile->GetPrefs()->GetDictionary( |
| 275 prefs::kContentSettingsPluginWhitelist); | 275 prefs::kContentSettingsPluginWhitelist); |
| 276 whitelist->GetBoolean(group_identifier, &plugin_data->always_allowed); | 276 whitelist->GetBoolean(group_identifier, &plugin_data->always_allowed); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 plugin_data->critical = false; | 280 plugin_data->critical = false; |
| 281 plugin_data->update_url = ""; | 281 plugin_data->update_url = ""; |
| 282 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 282 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
| 283 bool out_of_date = plugin_metadata->GetSecurityStatus(*active_plugin) == | 283 bool out_of_date = plugin_metadata->GetSecurityStatus(*active_plugin) == |
| 284 PluginMetadata::SECURITY_STATUS_OUT_OF_DATE; | 284 PluginMetadata::SECURITY_STATUS_OUT_OF_DATE; |
| 285 plugin_data->critical = out_of_date; | 285 plugin_data->critical = out_of_date; |
| 286 plugin_data->update_url = plugin_metadata->plugin_url().spec(); | 286 plugin_data->update_url = plugin_metadata->plugin_url().spec(); |
| 287 #endif | 287 #endif |
| 288 | 288 |
| 289 plugin_data->description = mojo::String::From(active_plugin->desc); | 289 plugin_data->description = base::UTF16ToUTF8(active_plugin->desc); |
| 290 plugin_data->name = base::UTF16ToUTF8(plugin_metadata->name()); | 290 plugin_data->name = base::UTF16ToUTF8(plugin_metadata->name()); |
| 291 plugin_data->plugin_files = std::move(plugin_files); | 291 plugin_data->plugin_files = std::move(plugin_files); |
| 292 plugin_data->version = mojo::String::From(active_plugin->version); | 292 plugin_data->version = base::UTF16ToUTF8(active_plugin->version); |
| 293 plugins_data.push_back(std::move(plugin_data)); | 293 plugins_data.push_back(std::move(plugin_data)); |
| 294 } | 294 } |
| 295 | 295 |
| 296 return plugins_data; | 296 return plugins_data; |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool PluginsPageHandler::GetClickToPlayPolicyEnabled() const { | 299 bool PluginsPageHandler::GetClickToPlayPolicyEnabled() const { |
| 300 Profile* profile = Profile::FromWebUI(web_ui_); | 300 Profile* profile = Profile::FromWebUI(web_ui_); |
| 301 HostContentSettingsMap* map = | 301 HostContentSettingsMap* map = |
| 302 HostContentSettingsMapFactory::GetForProfile(profile); | 302 HostContentSettingsMapFactory::GetForProfile(profile); |
| 303 std::string provider_id; | 303 std::string provider_id; |
| 304 ContentSetting setting = map->GetDefaultContentSetting( | 304 ContentSetting setting = map->GetDefaultContentSetting( |
| 305 CONTENT_SETTINGS_TYPE_PLUGINS, &provider_id); | 305 CONTENT_SETTINGS_TYPE_PLUGINS, &provider_id); |
| 306 return (setting == CONTENT_SETTING_ASK && provider_id == "policy"); | 306 return (setting == CONTENT_SETTING_ASK && provider_id == "policy"); |
| 307 } | 307 } |
| 308 | 308 |
| 309 mojom::PluginFilePtr PluginsPageHandler::GeneratePluginFile( | 309 mojom::PluginFilePtr PluginsPageHandler::GeneratePluginFile( |
| 310 const WebPluginInfo& plugin, | 310 const WebPluginInfo& plugin, |
| 311 const base::string16& group_name, | 311 const base::string16& group_name, |
| 312 bool plugin_enabled) const { | 312 bool plugin_enabled) const { |
| 313 mojom::PluginFilePtr plugin_file(mojom::PluginFile::New()); | 313 mojom::PluginFilePtr plugin_file(mojom::PluginFile::New()); |
| 314 plugin_file->description = mojo::String::From(GetPluginDescription(plugin)); | 314 plugin_file->description = base::UTF16ToUTF8(GetPluginDescription(plugin)); |
| 315 plugin_file->enabled_mode = mojo::String::From( | 315 plugin_file->enabled_mode = |
| 316 GetPluginEnabledMode(plugin.name, group_name, plugin_enabled)); | 316 GetPluginEnabledMode(plugin.name, group_name, plugin_enabled); |
| 317 plugin_file->name = mojo::String::From(plugin.name); | 317 plugin_file->name = base::UTF16ToUTF8(plugin.name); |
| 318 plugin_file->path = mojo::String::From(plugin.path.value()); | 318 plugin_file->path = mojo::String::From(plugin.path.value()); |
| 319 plugin_file->type = mojo::String::From(PluginTypeToString(plugin.type)); | 319 plugin_file->type = base::UTF16ToUTF8(PluginTypeToString(plugin.type)); |
| 320 plugin_file->version = mojo::String::From(plugin.version); | 320 plugin_file->version = base::UTF16ToUTF8(plugin.version); |
| 321 plugin_file->mime_types = GeneratePluginMimeTypes(plugin); | 321 plugin_file->mime_types = GeneratePluginMimeTypes(plugin); |
| 322 | 322 |
| 323 return plugin_file; | 323 return plugin_file; |
| 324 } | 324 } |
| 325 | 325 |
| 326 std::string PluginsPageHandler::GetPluginEnabledMode( | 326 std::string PluginsPageHandler::GetPluginEnabledMode( |
| 327 const base::string16& plugin_name, | 327 const base::string16& plugin_name, |
| 328 const base::string16& group_name, | 328 const base::string16& group_name, |
| 329 bool plugin_enabled) const { | 329 bool plugin_enabled) const { |
| 330 Profile* profile = Profile::FromWebUI(web_ui_); | 330 Profile* profile = Profile::FromWebUI(web_ui_); |
| 331 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); | 331 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); |
| 332 PluginPrefs::PolicyStatus plugin_status = | 332 PluginPrefs::PolicyStatus plugin_status = |
| 333 plugin_prefs->PolicyStatusForPlugin(plugin_name); | 333 plugin_prefs->PolicyStatusForPlugin(plugin_name); |
| 334 PluginPrefs::PolicyStatus group_status = | 334 PluginPrefs::PolicyStatus group_status = |
| 335 plugin_prefs->PolicyStatusForPlugin(group_name); | 335 plugin_prefs->PolicyStatusForPlugin(group_name); |
| 336 | 336 |
| 337 if (plugin_status == PluginPrefs::POLICY_ENABLED || | 337 if (plugin_status == PluginPrefs::POLICY_ENABLED || |
| 338 group_status == PluginPrefs::POLICY_ENABLED) { | 338 group_status == PluginPrefs::POLICY_ENABLED) { |
| 339 return "enabledByPolicy"; | 339 return "enabledByPolicy"; |
| 340 } | 340 } |
| 341 if (plugin_status == PluginPrefs::POLICY_DISABLED || | 341 if (plugin_status == PluginPrefs::POLICY_DISABLED || |
| 342 group_status == PluginPrefs::POLICY_DISABLED) { | 342 group_status == PluginPrefs::POLICY_DISABLED) { |
| 343 return "disabledByPolicy"; | 343 return "disabledByPolicy"; |
| 344 } | 344 } |
| 345 return plugin_enabled ? "enabledByUser" : "disabledByUser"; | 345 return plugin_enabled ? "enabledByUser" : "disabledByUser"; |
| 346 } | 346 } |
| 347 | 347 |
| 348 std::string PluginsPageHandler::GetPluginGroupEnabledMode( | 348 std::string PluginsPageHandler::GetPluginGroupEnabledMode( |
| 349 const mojo::Array<mojom::PluginFilePtr>& plugin_files, | 349 const std::vector<mojom::PluginFilePtr>& plugin_files, |
| 350 bool group_enabled) const { | 350 bool group_enabled) const { |
| 351 bool plugins_enabled_by_policy = true; | 351 bool plugins_enabled_by_policy = true; |
| 352 bool plugins_disabled_by_policy = true; | 352 bool plugins_disabled_by_policy = true; |
| 353 bool plugins_managed_by_policy = true; | 353 bool plugins_managed_by_policy = true; |
| 354 | 354 |
| 355 for (size_t i = 0; i < plugin_files.size(); i++) { | 355 for (size_t i = 0; i < plugin_files.size(); i++) { |
| 356 std::string plugin_enabled_mode = plugin_files[i]->enabled_mode; | 356 std::string plugin_enabled_mode = plugin_files[i]->enabled_mode; |
| 357 | 357 |
| 358 plugins_enabled_by_policy = | 358 plugins_enabled_by_policy = |
| 359 plugins_enabled_by_policy && plugin_enabled_mode == "enabledByPolicy"; | 359 plugins_enabled_by_policy && plugin_enabled_mode == "enabledByPolicy"; |
| 360 plugins_disabled_by_policy = | 360 plugins_disabled_by_policy = |
| 361 plugins_disabled_by_policy && plugin_enabled_mode == "disabledByPolicy"; | 361 plugins_disabled_by_policy && plugin_enabled_mode == "disabledByPolicy"; |
| 362 plugins_managed_by_policy = plugins_managed_by_policy && | 362 plugins_managed_by_policy = plugins_managed_by_policy && |
| 363 (plugin_enabled_mode == "enabledByPolicy" || | 363 (plugin_enabled_mode == "enabledByPolicy" || |
| 364 plugin_enabled_mode == "disabledByPolicy"); | 364 plugin_enabled_mode == "disabledByPolicy"); |
| 365 } | 365 } |
| 366 | 366 |
| 367 if (plugins_enabled_by_policy) | 367 if (plugins_enabled_by_policy) |
| 368 return "enabledByPolicy"; | 368 return "enabledByPolicy"; |
| 369 if (plugins_disabled_by_policy) | 369 if (plugins_disabled_by_policy) |
| 370 return "disabledByPolicy"; | 370 return "disabledByPolicy"; |
| 371 if (plugins_managed_by_policy) | 371 if (plugins_managed_by_policy) |
| 372 return "managedByPolicy"; | 372 return "managedByPolicy"; |
| 373 return group_enabled ? "enabledByUser" : "disabledByUser"; | 373 return group_enabled ? "enabledByUser" : "disabledByUser"; |
| 374 } | 374 } |
| OLD | NEW |