| 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/extensions/api/content_settings/content_settings_api.h" | 5 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 bool GetResourceIdentifiersFunction::RunImpl() { | 252 bool GetResourceIdentifiersFunction::RunImpl() { |
| 253 ContentSettingsType content_type; | 253 ContentSettingsType content_type; |
| 254 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 254 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 255 | 255 |
| 256 if (content_type != CONTENT_SETTINGS_TYPE_PLUGINS) { | 256 if (content_type != CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 257 SendResponse(true); | 257 SendResponse(true); |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 | 260 |
| 261 if (!g_testing_plugins_) { | 261 if (!g_testing_plugins_) { |
| 262 PluginFinder::GetPluginsAndPluginFinder( | 262 PluginService::GetInstance()->GetPlugins( |
| 263 base::Bind(&GetResourceIdentifiersFunction::OnGotPlugins, this)); | 263 base::Bind(&GetResourceIdentifiersFunction::OnGotPlugins, this)); |
| 264 } else { | 264 } else { |
| 265 PluginFinder::Get( | 265 OnGotPlugins(*g_testing_plugins_); |
| 266 base::Bind(&GetResourceIdentifiersFunction::OnGotPlugins, this, | |
| 267 *g_testing_plugins_)); | |
| 268 } | 266 } |
| 269 return true; | 267 return true; |
| 270 } | 268 } |
| 271 | 269 |
| 272 void GetResourceIdentifiersFunction::OnGotPlugins( | 270 void GetResourceIdentifiersFunction::OnGotPlugins( |
| 273 const std::vector<webkit::WebPluginInfo>& plugins, | 271 const std::vector<webkit::WebPluginInfo>& plugins) { |
| 274 PluginFinder* finder) { | 272 PluginFinder* finder = PluginFinder::GetInstance(); |
| 275 std::set<std::string> group_identifiers; | 273 std::set<std::string> group_identifiers; |
| 276 ListValue* list = new ListValue(); | 274 ListValue* list = new ListValue(); |
| 277 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); | 275 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); |
| 278 it != plugins.end(); ++it) { | 276 it != plugins.end(); ++it) { |
| 279 PluginInstaller* installer = finder->GetPluginInstaller(*it); | 277 PluginMetadata* plugin_metadata = finder->GetPluginMetadata(*it); |
| 280 const std::string& group_identifier = installer->identifier(); | 278 const std::string& group_identifier = plugin_metadata->identifier(); |
| 281 if (group_identifiers.find(group_identifier) != group_identifiers.end()) | 279 if (group_identifiers.find(group_identifier) != group_identifiers.end()) |
| 282 continue; | 280 continue; |
| 283 | 281 |
| 284 group_identifiers.insert(group_identifier); | 282 group_identifiers.insert(group_identifier); |
| 285 DictionaryValue* dict = new DictionaryValue(); | 283 DictionaryValue* dict = new DictionaryValue(); |
| 286 dict->SetString(keys::kIdKey, group_identifier); | 284 dict->SetString(keys::kIdKey, group_identifier); |
| 287 dict->SetString(keys::kDescriptionKey, installer->name()); | 285 dict->SetString(keys::kDescriptionKey, plugin_metadata->name()); |
| 288 list->Append(dict); | 286 list->Append(dict); |
| 289 } | 287 } |
| 290 SetResult(list); | 288 SetResult(list); |
| 291 BrowserThread::PostTask( | 289 BrowserThread::PostTask( |
| 292 BrowserThread::UI, FROM_HERE, base::Bind( | 290 BrowserThread::UI, FROM_HERE, base::Bind( |
| 293 &GetResourceIdentifiersFunction::SendResponse, this, true)); | 291 &GetResourceIdentifiersFunction::SendResponse, this, true)); |
| 294 } | 292 } |
| 295 | 293 |
| 296 // static | 294 // static |
| 297 void GetResourceIdentifiersFunction::SetPluginsForTesting( | 295 void GetResourceIdentifiersFunction::SetPluginsForTesting( |
| 298 const std::vector<webkit::WebPluginInfo>* plugins) { | 296 const std::vector<webkit::WebPluginInfo>* plugins) { |
| 299 g_testing_plugins_ = plugins; | 297 g_testing_plugins_ = plugins; |
| 300 } | 298 } |
| 301 | 299 |
| 302 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |