| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 if (!active_plugin || (plugin_enabled && !group_enabled)) | 254 if (!active_plugin || (plugin_enabled && !group_enabled)) |
| 255 active_plugin = group_plugin; | 255 active_plugin = group_plugin; |
| 256 group_enabled = plugin_enabled || group_enabled; | 256 group_enabled = plugin_enabled || group_enabled; |
| 257 } | 257 } |
| 258 | 258 |
| 259 plugin_data->enabled_mode = mojo::String::From( | 259 plugin_data->enabled_mode = mojo::String::From( |
| 260 GetPluginGroupEnabledMode(plugin_files, group_enabled)); | 260 GetPluginGroupEnabledMode(plugin_files, group_enabled)); |
| 261 | 261 |
| 262 plugin_data->always_allowed = false; | 262 plugin_data->always_allowed = false; |
| 263 plugin_data->trusted = false; | 263 plugin_data->trusted = false; |
| 264 plugin_data->policy_click_to_play = GetClickToPlayPolicyEnabled(); |
| 264 | 265 |
| 265 if (group_enabled) { | 266 if (group_enabled) { |
| 266 if (plugin_metadata->GetSecurityStatus(*active_plugin) == | 267 if (plugin_metadata->GetSecurityStatus(*active_plugin) == |
| 267 PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { | 268 PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { |
| 268 plugin_data->trusted = true; | 269 plugin_data->trusted = true; |
| 269 plugin_data->always_allowed = true; | 270 plugin_data->always_allowed = true; |
| 270 } else { | 271 } else if (!GetClickToPlayPolicyEnabled()) { |
| 271 const base::DictionaryValue* whitelist = | 272 const base::DictionaryValue* whitelist = |
| 272 profile->GetPrefs()->GetDictionary( | 273 profile->GetPrefs()->GetDictionary( |
| 273 prefs::kContentSettingsPluginWhitelist); | 274 prefs::kContentSettingsPluginWhitelist); |
| 274 whitelist->GetBoolean(group_identifier, &plugin_data->always_allowed); | 275 whitelist->GetBoolean(group_identifier, &plugin_data->always_allowed); |
| 275 } | 276 } |
| 276 } | 277 } |
| 277 | 278 |
| 278 plugin_data->critical = false; | 279 plugin_data->critical = false; |
| 279 plugin_data->update_url = ""; | 280 plugin_data->update_url = ""; |
| 280 #if defined(ENABLE_PLUGIN_INSTALLATION) | 281 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 281 bool out_of_date = plugin_metadata->GetSecurityStatus(*active_plugin) == | 282 bool out_of_date = plugin_metadata->GetSecurityStatus(*active_plugin) == |
| 282 PluginMetadata::SECURITY_STATUS_OUT_OF_DATE; | 283 PluginMetadata::SECURITY_STATUS_OUT_OF_DATE; |
| 283 plugin_data->critical = out_of_date; | 284 plugin_data->critical = out_of_date; |
| 284 plugin_data->update_url = plugin_metadata->plugin_url().spec(); | 285 plugin_data->update_url = plugin_metadata->plugin_url().spec(); |
| 285 #endif | 286 #endif |
| 286 | 287 |
| 287 plugin_data->description = mojo::String::From(active_plugin->desc); | 288 plugin_data->description = mojo::String::From(active_plugin->desc); |
| 288 plugin_data->name = base::UTF16ToUTF8(plugin_metadata->name()); | 289 plugin_data->name = base::UTF16ToUTF8(plugin_metadata->name()); |
| 289 plugin_data->plugin_files = std::move(plugin_files); | 290 plugin_data->plugin_files = std::move(plugin_files); |
| 290 plugin_data->version = mojo::String::From(active_plugin->version); | 291 plugin_data->version = mojo::String::From(active_plugin->version); |
| 291 plugins_data.push_back(std::move(plugin_data)); | 292 plugins_data.push_back(std::move(plugin_data)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 return plugins_data; | 295 return plugins_data; |
| 295 } | 296 } |
| 296 | 297 |
| 298 bool PluginsPageHandler::GetClickToPlayPolicyEnabled() const { |
| 299 Profile* profile = Profile::FromWebUI(web_ui_); |
| 300 HostContentSettingsMap* map = |
| 301 HostContentSettingsMapFactory::GetForProfile(profile); |
| 302 std::string provider_id; |
| 303 ContentSetting setting = map->GetDefaultContentSetting( |
| 304 CONTENT_SETTINGS_TYPE_PLUGINS, &provider_id); |
| 305 return (setting == CONTENT_SETTING_ASK && provider_id == "policy"); |
| 306 } |
| 307 |
| 297 mojom::PluginFilePtr PluginsPageHandler::GeneratePluginFile( | 308 mojom::PluginFilePtr PluginsPageHandler::GeneratePluginFile( |
| 298 const WebPluginInfo& plugin, | 309 const WebPluginInfo& plugin, |
| 299 const base::string16& group_name, | 310 const base::string16& group_name, |
| 300 bool plugin_enabled) const { | 311 bool plugin_enabled) const { |
| 301 mojom::PluginFilePtr plugin_file(mojom::PluginFile::New()); | 312 mojom::PluginFilePtr plugin_file(mojom::PluginFile::New()); |
| 302 plugin_file->description = mojo::String::From(GetPluginDescription(plugin)); | 313 plugin_file->description = mojo::String::From(GetPluginDescription(plugin)); |
| 303 plugin_file->enabled_mode = mojo::String::From( | 314 plugin_file->enabled_mode = mojo::String::From( |
| 304 GetPluginEnabledMode(plugin.name, group_name, plugin_enabled)); | 315 GetPluginEnabledMode(plugin.name, group_name, plugin_enabled)); |
| 305 plugin_file->name = mojo::String::From(plugin.name); | 316 plugin_file->name = mojo::String::From(plugin.name); |
| 306 plugin_file->path = mojo::String::From(plugin.path.value()); | 317 plugin_file->path = mojo::String::From(plugin.path.value()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 364 } |
| 354 | 365 |
| 355 if (plugins_enabled_by_policy) | 366 if (plugins_enabled_by_policy) |
| 356 return "enabledByPolicy"; | 367 return "enabledByPolicy"; |
| 357 if (plugins_disabled_by_policy) | 368 if (plugins_disabled_by_policy) |
| 358 return "disabledByPolicy"; | 369 return "disabledByPolicy"; |
| 359 if (plugins_managed_by_policy) | 370 if (plugins_managed_by_policy) |
| 360 return "managedByPolicy"; | 371 return "managedByPolicy"; |
| 361 return group_enabled ? "enabledByUser" : "disabledByUser"; | 372 return group_enabled ? "enabledByUser" : "disabledByUser"; |
| 362 } | 373 } |
| OLD | NEW |