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

Unified Diff: chrome/browser/plugin_installer.cc

Issue 10823434: [6] Moves CreateVersionFromString to plugin_utils and updates the callers. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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/plugin_installer.cc
diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc
index bcfbecc28a1c8ec5f3d6f4e161b6d66bd7c8f229..17379a2bea802eb20acb0ce92b33caffa394ac56 100644
--- a/chrome/browser/plugin_installer.cc
+++ b/chrome/browser/plugin_installer.cc
@@ -8,10 +8,12 @@
#include "base/bind_helpers.h"
#include "base/file_util.h"
#include "base/process.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/platform_util.h"
+#include "chrome/browser/plugin_finder.h"
#include "chrome/browser/plugin_installer_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -72,9 +74,11 @@ PluginInstaller::PluginInstaller(const std::string& identifier,
const string16& name,
bool url_for_display,
const GURL& plugin_url,
- const GURL& help_url)
+ const GURL& help_url,
+ const string16& group_name_matcher)
: identifier_(identifier),
name_(name),
+ group_name_matcher_(group_name_matcher),
url_for_display_(url_for_display),
plugin_url_(plugin_url),
help_url_(help_url),
@@ -97,7 +101,7 @@ PluginInstaller::SecurityStatus PluginInstaller::GetSecurityStatus(
return SECURITY_STATUS_REQUIRES_AUTHORIZATION;
Version version;
- webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version, &version);
+ webkit::WebPluginInfo::CreateVersionFromString(plugin.version, &version);
if (!version.IsValid())
version = Version("0");
@@ -250,3 +254,54 @@ void PluginInstaller::DownloadCancelled() {
state_ = INSTALLER_STATE_IDLE;
FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled());
}
+
+/*static*/
Bernhard Bauer 2012/08/21 12:30:18 Nit: The rest of the file uses // static.
ibraaaa 2012/08/21 14:26:04 Done.
+string16 PluginInstaller::GetGroupName(const webkit::WebPluginInfo& plugin) {
+ PluginInstaller* plugin_installer = MatchWithConfiguredPlugins(plugin);
+ if (plugin_installer != NULL) {
Bernhard Bauer 2012/08/21 12:30:18 Nit: Braces aren't required for single-line statem
ibraaaa 2012/08/21 14:26:04 Done.
+ return plugin_installer->name();
+ }
+
+ 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
+}
+
+/*static*/
+std::string PluginInstaller::GetIdentifier(
+ const webkit::WebPluginInfo& plugin) {
+ PluginInstaller* plugin_installer = MatchWithConfiguredPlugins(plugin);
+ if (plugin_installer != NULL) {
+ return plugin_installer->identifier();
+ }
+
+ FilePath path = plugin.path;
+#if defined(OS_POSIX)
+ return path.BaseName().value();
+#elif defined(OS_WIN)
+ return base::SysWideToUTF8(path.BaseName().value());
+#endif
+}
+
+/*static*/
+PluginInstaller* PluginInstaller::MatchWithConfiguredPlugins(
+ const webkit::WebPluginInfo& plugin) {
+ const std::map<std::string, PluginInstaller*>& plugins =
+ PluginFinder::GetInstance()->GetAllPluginInstallers();
Bernhard Bauer 2012/08/21 12:30:18 Ok, this is where stuff gets complicated. Right n
ibraaaa 2012/08/21 14:26:04 I want to confirm something, places where I need a
Bernhard Bauer 2012/08/21 19:14:52 If by that you mean that we're going to need to ma
+ for (std::map<std::string, PluginInstaller*>::const_iterator it =
+ plugins.begin(); it != plugins.end(); ++it) {
+ if (plugin.name.find(it->second->group_name_matcher()) == std::string::npos)
+ continue;
+ return it->second;
+ }
+
+ // Not found.
+ return NULL;
+}

Powered by Google App Engine
This is Rietveld 408576698