Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2858)

Unified Diff: chrome/browser/extensions/api/content_settings/content_settings_api.cc

Issue 10876083: [4] Changing content_settings_api to use PluginFinder's async interface (Closed) Base URL: http://git.chromium.org/chromium/src.git@async_start
Patch Set: Addressed review comments by Mattias Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/content_settings/content_settings_api.cc
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
index 7b734e5cbddb077add3cbd985205881595fee4dc..5d995813cc75b2df8b953f28a308e1578cfee7ab 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/hash_tables.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_api_constants.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_helpers.h"
@@ -17,6 +18,7 @@
#include "chrome/browser/extensions/extension_preference_api_constants.h"
#include "chrome/browser/extensions/extension_preference_helpers.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/plugin_installer.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
@@ -36,7 +38,7 @@ namespace pref_keys = extension_preference_api_constants;
namespace {
-const std::vector<webkit::npapi::PluginGroup>* g_testing_plugin_groups_;
+const std::vector<webkit::WebPluginInfo>* g_testing_plugins_;
bool RemoveContentType(ListValue* args, ContentSettingsType* content_type) {
std::string content_type_str;
@@ -251,12 +253,8 @@ bool GetResourceIdentifiersFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type));
if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) {
- if (g_testing_plugin_groups_) {
- OnGotPluginGroups(*g_testing_plugin_groups_);
- } else {
- PluginService::GetInstance()->GetPluginGroups(
- base::Bind(&GetResourceIdentifiersFunction::OnGotPluginGroups, this));
- }
+ PluginFinder::Get(base::Bind(
+ &GetResourceIdentifiersFunction::GetPluginFinderForRunImpl, this));
} else {
SendResponse(true);
}
@@ -264,15 +262,33 @@ bool GetResourceIdentifiersFunction::RunImpl() {
return true;
}
-void GetResourceIdentifiersFunction::OnGotPluginGroups(
- const std::vector<webkit::npapi::PluginGroup>& groups) {
+void GetResourceIdentifiersFunction::GetPluginFinderForRunImpl(
+ PluginFinder* finder) {
+ if (g_testing_plugins_) {
+ OnGotPlugins(finder, *g_testing_plugins_);
+ return;
+ }
+ PluginService::GetInstance()->GetPlugins(
+ base::Bind(&GetResourceIdentifiersFunction::OnGotPlugins, this,
+ finder));
+}
+
+void GetResourceIdentifiersFunction::OnGotPlugins(
+ PluginFinder* finder,
+ const std::vector<webkit::WebPluginInfo>& plugins) {
+ base::hash_set<std::string> group_identifiers;
Bernhard Bauer 2012/08/29 12:56:54 I think using a std::set for this is more idiomati
ibraaaa 2012/08/29 16:39:37 Done.
ListValue* list = new ListValue();
- for (std::vector<webkit::npapi::PluginGroup>::const_iterator it =
- groups.begin();
- it != groups.end(); ++it) {
+ for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin();
+ it != plugins.end(); ++it) {
+ PluginInstaller* installer = finder->GetPluginInstaller(*it);
+ const std::string& group_identifier = installer->identifier();
+ if (group_identifiers.find(group_identifier) != group_identifiers.end())
+ continue;
+
+ group_identifiers.insert(group_identifier);
DictionaryValue* dict = new DictionaryValue();
- dict->SetString(keys::kIdKey, it->identifier());
- dict->SetString(keys::kDescriptionKey, it->GetGroupName());
+ dict->SetString(keys::kIdKey, group_identifier);
+ dict->SetString(keys::kDescriptionKey, installer->name());
list->Append(dict);
}
SetResult(list);
@@ -282,9 +298,9 @@ void GetResourceIdentifiersFunction::OnGotPluginGroups(
}
// static
-void GetResourceIdentifiersFunction::SetPluginGroupsForTesting(
- const std::vector<webkit::npapi::PluginGroup>* plugin_groups) {
- g_testing_plugin_groups_ = plugin_groups;
+void GetResourceIdentifiersFunction::SetPluginsForTesting(
+ const std::vector<webkit::WebPluginInfo>* plugins) {
+ g_testing_plugins_ = plugins;
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698