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

Unified Diff: chrome/browser/plugin_finder.cc

Issue 10881002: [2] Adding a method to PluginFinder to get a PluginInstaller by WebPluginInfo. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing Windows Compilation Error 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
« no previous file with comments | « chrome/browser/plugin_finder.h ('k') | chrome/browser/plugin_installer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/plugin_finder.cc
diff --git a/chrome/browser/plugin_finder.cc b/chrome/browser/plugin_finder.cc
index 59a5052950cf60ac6ac7d8b85a1689af4106de23..c1b7a3a9a00822e7d9831b4b0fc9f10e4a041768 100644
--- a/chrome/browser/plugin_finder.cc
+++ b/chrome/browser/plugin_finder.cc
@@ -8,6 +8,8 @@
#include "base/json/json_reader.h"
#include "base/message_loop.h"
#include "base/stl_util.h"
+#include "base/sys_string_conversions.h"
+#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/plugin_installer.h"
@@ -21,6 +23,33 @@
using base::DictionaryValue;
+namespace {
+
+// Gets the base name of the file path as the identifier.
+static std::string GetIdentifier(const webkit::WebPluginInfo& plugin) {
+#if defined(OS_POSIX)
+ return plugin.path.BaseName().value();
+#elif defined(OS_WIN)
+ return base::SysWideToUTF8(plugin.path.BaseName().value());
+#endif
+}
+
+// Gets the plug-in group name as the plug-in name if it is not empty or
+// the filename without extension if the name is empty.
+static string16 GetGroupName(const webkit::WebPluginInfo& plugin) {
+ if (!plugin.name.empty())
+ return plugin.name;
+
+ FilePath::StringType path = plugin.path.BaseName().RemoveExtension().value();
+#if defined(OS_POSIX)
+ return UTF8ToUTF16(path);
+#elif defined(OS_WIN)
+ return WideToUTF16(path);
+#endif
+}
+
+} // namespace
+
// static
void PluginFinder::Get(const base::Callback<void(PluginFinder*)>& cb) {
// At a later point we might want to do intialization here that needs to be
@@ -129,12 +158,16 @@ PluginInstaller* PluginFinder::CreateInstaller(
DCHECK(success);
bool display_url = false;
plugin_dict->GetBoolean("displayurl", &display_url);
+ string16 group_name_matcher;
+ success = plugin_dict->GetString("group_name_matcher", &group_name_matcher);
+ DCHECK(success);
PluginInstaller* installer = new PluginInstaller(identifier,
name,
display_url,
GURL(url),
- GURL(help_url));
+ GURL(help_url),
+ group_name_matcher);
const ListValue* versions = NULL;
if (plugin_dict->GetList("versions", &versions)) {
for (ListValue::const_iterator it = versions->begin();
@@ -161,3 +194,36 @@ PluginInstaller* PluginFinder::CreateInstaller(
installers_[identifier] = installer;
return installer;
}
+
+PluginInstaller* PluginFinder::GetPluginInstaller(
+ const webkit::WebPluginInfo& plugin) {
+ if (name_installers_.find(plugin.name) != name_installers_.end())
+ return name_installers_[plugin.name];
+
+ for (DictionaryValue::Iterator plugin_it(*plugin_list_);
+ plugin_it.HasNext(); plugin_it.Advance()) {
+ // This method triggers the lazy initialization for all PluginInstallers.
+ FindPluginWithIdentifier(plugin_it.key());
+ }
+
+ // Use the group name matcher to find the plug-in installer we want.
+ for (std::map<std::string, PluginInstaller*>::const_iterator it =
+ installers_.begin(); it != installers_.end(); ++it) {
+ if (!it->second->MatchesPlugin(plugin))
+ continue;
+
+ name_installers_[plugin.name] = it->second;
+ return it->second;
+ }
+
+ // The plug-in installer was not found, create a dummy one holding
+ // the name, identifier and group name only.
+ std::string identifier = GetIdentifier(plugin);
+ PluginInstaller* installer = new PluginInstaller(identifier,
+ GetGroupName(plugin),
+ false, GURL(), GURL(),
+ GetGroupName(plugin));
+ installers_[identifier] = installer;
+ name_installers_[plugin.name] = installer;
+ return installer;
+}
« no previous file with comments | « chrome/browser/plugin_finder.h ('k') | chrome/browser/plugin_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698