| 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 <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 17 #include "chrome/browser/plugins/plugin_finder.h" | 17 #include "chrome/browser/plugins/plugin_finder.h" |
| 18 #include "chrome/browser/plugins/plugin_metadata.h" | 18 #include "chrome/browser/plugins/plugin_metadata.h" |
| 19 #include "chrome/browser/plugins/plugin_prefs.h" | 19 #include "chrome/browser/plugins/plugin_prefs.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/common/chrome_content_client.h" | 21 #include "chrome/common/chrome_content_client.h" |
| 22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 mojo::Array<mojom::PluginDataPtr> PluginsHandler::GeneratePluginsData( | 216 mojo::Array<mojom::PluginDataPtr> PluginsHandler::GeneratePluginsData( |
| 217 const std::vector<WebPluginInfo>& plugins) { | 217 const std::vector<WebPluginInfo>& plugins) { |
| 218 Profile* profile = Profile::FromWebUI(web_ui_); | 218 Profile* profile = Profile::FromWebUI(web_ui_); |
| 219 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); | 219 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile).get(); |
| 220 | 220 |
| 221 PluginFinder* plugin_finder = PluginFinder::GetInstance(); | 221 PluginFinder* plugin_finder = PluginFinder::GetInstance(); |
| 222 // 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 |
| 223 // the plugins in UI in a grouped fashion. | 223 // the plugins in UI in a grouped fashion. |
| 224 PluginGroups groups; | 224 PluginGroups groups; |
| 225 for (size_t i = 0; i < plugins.size(); ++i) { | 225 for (size_t i = 0; i < plugins.size(); ++i) { |
| 226 scoped_ptr<PluginMetadata> plugin( | 226 std::unique_ptr<PluginMetadata> plugin( |
| 227 plugin_finder->GetPluginMetadata(plugins[i])); | 227 plugin_finder->GetPluginMetadata(plugins[i])); |
| 228 groups[plugin->identifier()].push_back(&plugins[i]); | 228 groups[plugin->identifier()].push_back(&plugins[i]); |
| 229 } | 229 } |
| 230 | 230 |
| 231 mojo::Array<mojom::PluginDataPtr> plugins_data; | 231 mojo::Array<mojom::PluginDataPtr> plugins_data; |
| 232 | 232 |
| 233 for (PluginGroups::const_iterator it = groups.begin(); it != groups.end(); | 233 for (PluginGroups::const_iterator it = groups.begin(); it != groups.end(); |
| 234 ++it) { | 234 ++it) { |
| 235 mojom::PluginDataPtr plugin_data(mojom::PluginData::New()); | 235 mojom::PluginDataPtr plugin_data(mojom::PluginData::New()); |
| 236 const std::vector<const WebPluginInfo*>& group_plugins = it->second; | 236 const std::vector<const WebPluginInfo*>& group_plugins = it->second; |
| 237 | 237 |
| 238 scoped_ptr<PluginMetadata> plugin_metadata( | 238 std::unique_ptr<PluginMetadata> plugin_metadata( |
| 239 plugin_finder->GetPluginMetadata(*group_plugins[0])); | 239 plugin_finder->GetPluginMetadata(*group_plugins[0])); |
| 240 std::string group_identifier = plugin_metadata->identifier(); | 240 std::string group_identifier = plugin_metadata->identifier(); |
| 241 plugin_data->id = mojo::String::From(group_identifier); | 241 plugin_data->id = mojo::String::From(group_identifier); |
| 242 | 242 |
| 243 const WebPluginInfo* active_plugin = nullptr; | 243 const WebPluginInfo* active_plugin = nullptr; |
| 244 bool group_enabled = false; | 244 bool group_enabled = false; |
| 245 | 245 |
| 246 mojo::Array<mojom::PluginFilePtr> plugin_files; | 246 mojo::Array<mojom::PluginFilePtr> plugin_files; |
| 247 for (const auto& group_plugin : group_plugins) { | 247 for (const auto& group_plugin : group_plugins) { |
| 248 bool plugin_enabled = plugin_prefs->IsPluginEnabled(*group_plugin); | 248 bool plugin_enabled = plugin_prefs->IsPluginEnabled(*group_plugin); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 if (plugins_enabled_by_policy) | 355 if (plugins_enabled_by_policy) |
| 356 return "enabledByPolicy"; | 356 return "enabledByPolicy"; |
| 357 if (plugins_disabled_by_policy) | 357 if (plugins_disabled_by_policy) |
| 358 return "disabledByPolicy"; | 358 return "disabledByPolicy"; |
| 359 if (plugins_managed_by_policy) | 359 if (plugins_managed_by_policy) |
| 360 return "managedByPolicy"; | 360 return "managedByPolicy"; |
| 361 return group_enabled ? "enabledByUser" : "disabledByUser"; | 361 return group_enabled ? "enabledByUser" : "disabledByUser"; |
| 362 } | 362 } |
| OLD | NEW |