Commit 68b63bc6 authored by ibraaaa@google.com's avatar ibraaaa@google.com

1st CL in a series to remove PluginGroup. Updates PluginList.

This is the first CL in a series that aims at removing PluginGroup class and moving harded coded group definition data to .json config files. This CL updates PluginList class with new methods not relying on PluginGroup class, these methods are to be called by upper layer methods instead of PluginGroup dependent methods. Changes in upper layer will be introduced in upcoming CLs. The last CL in the series should remove PluginGroup class and all its dependencies.


BUG=124396

Review URL: https://chromiumcodereview.appspot.com/10860044

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152399 0039d316-1c4b-4281-b951-d872f2087c98
parent a9e0d141
......@@ -29,11 +29,19 @@ bool MockPluginList::GetPluginsNoRefresh(
return true;
}
// TODO(ibraaaa): DELETE. http://crbug.com/124396
void MockPluginList::LoadPluginsInternal(
ScopedVector<PluginGroup>* plugin_groups) {
for (size_t i = 0; i < plugins_to_load_.size(); ++i)
AddToPluginGroups(plugins_to_load_[i], plugin_groups);
}
void MockPluginList::LoadPluginsIntoPluginListInternal(
std::vector<webkit::WebPluginInfo>* plugins) {
for (size_t i = 0; i < plugins_to_load_.size(); ++i) {
plugins->push_back(plugins_to_load_[i]);
}
}
} // npapi
} // webkit
......@@ -29,8 +29,13 @@ class MockPluginList : public PluginList {
std::vector<WebPluginInfo> plugins_to_load_;
// PluginList methods:
// TODO(ibraaaa): DELETE. http://crbug.com/124396
virtual void LoadPluginsInternal(
ScopedVector<PluginGroup>* plugin_groups) OVERRIDE;
virtual void LoadPluginsIntoPluginListInternal(
std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE;
};
} // npapi
......
This diff is collapsed.
......@@ -148,32 +148,43 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
std::vector<webkit::WebPluginInfo>* info,
std::vector<std::string>* actual_mime_types);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Populates the given vector with all available plugin groups. If
// |load_if_necessary| is true, this will potentially load the plugin list
// synchronously.
void GetPluginGroups(bool load_if_necessary,
std::vector<PluginGroup>* plugin_groups);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Returns a copy of the PluginGroup corresponding to the given WebPluginInfo.
// The caller takes ownership of the returned PluginGroup.
PluginGroup* GetPluginGroup(const webkit::WebPluginInfo& web_plugin_info);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Returns the name of the PluginGroup with the given identifier.
// If no such group exists, an empty string is returned.
string16 GetPluginGroupName(const std::string& identifier);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Load a specific plugin with full path. Return true iff loading the plug-in
// was successful.
bool LoadPlugin(const FilePath& filename,
ScopedVector<PluginGroup>* plugin_groups,
webkit::WebPluginInfo* plugin_info);
// Load a specific plugin with full path. Return true iff loading the plug-in
// was successful.
bool LoadPluginIntoPluginList(const FilePath& filename,
std::vector<webkit::WebPluginInfo>* plugins,
webkit::WebPluginInfo* plugin_info);
// The following functions are used to support probing for WebPluginInfo
// using a different instance of this class.
// Computes a list of all plugins to potentially load from all sources.
void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Returns the list of hardcoded plug-in groups for testing.
const std::vector<PluginGroup*>& GetHardcodedPluginGroups() const;
......@@ -185,10 +196,12 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
virtual ~PluginList();
protected:
// TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396
// This constructor is used in unit tests to override the platform-dependent
// real-world plugin group definitions with custom ones.
PluginList(const PluginGroupDefinition* definitions, size_t num_definitions);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Adds the given WebPluginInfo to its corresponding group, creating it if
// necessary, and returns the group.
PluginGroup* AddToPluginGroups(const webkit::WebPluginInfo& web_plugin_info,
......@@ -213,11 +226,13 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
// Constructors are private for singletons.
PluginList();
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Creates PluginGroups for the hardcoded group definitions, and stores them
// in |hardcoded_plugin_groups_|.
void AddHardcodedPluginGroups(const PluginGroupDefinition* group_definitions,
size_t num_group_definitions);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Creates a new PluginGroup either from a hardcoded group definition, or from
// the plug-in information.
// Caller takes ownership of the returned PluginGroup.
......@@ -228,6 +243,11 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
// test classes can mock these out.
virtual void LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups);
// Implements all IO dependent operations of the LoadPlugins method so that
// test classes can mock these out.
virtual void LoadPluginsIntoPluginListInternal(
std::vector<webkit::WebPluginInfo>* plugins);
// Load all plugins from the default plugins directory.
void LoadPlugins();
......@@ -235,12 +255,20 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
// load in that directory.
void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins);
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Returns true if we should load the given plugin, or false otherwise.
// |plugins| is the list of plugins we have crawled in the current plugin
// loading run.
bool ShouldLoadPlugin(const webkit::WebPluginInfo& info,
ScopedVector<PluginGroup>* plugins);
// Returns true if we should load the given plugin, or false otherwise.
// |plugins| is the list of plugins we have crawled in the current plugin
// loading run.
bool ShouldLoadPluginUsingPluginList(
const webkit::WebPluginInfo& info,
std::vector<webkit::WebPluginInfo>* plugins);
// Returns true if the plugin supports |mime_type|. |mime_type| should be all
// lower case.
bool SupportsType(const webkit::WebPluginInfo& plugin,
......@@ -255,6 +283,10 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
const std::string& extension,
std::string* actual_mime_type);
// Removes a plug-in from |plugins_list_| by its path.
static bool RemovePlugin(const FilePath& filename,
std::vector<webkit::WebPluginInfo>* plugins);
//
// Platform functions
//
......@@ -293,6 +325,7 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
// Holds information about internal plugins.
std::vector<InternalPlugin> internal_plugins_;
// TODO(ibraaaa): DELETE. http://crbug.com/124396
// Holds the currently available plugin groups.
ScopedVector<PluginGroup> plugin_groups_;
......@@ -300,6 +333,9 @@ class WEBKIT_PLUGINS_EXPORT PluginList {
// This should only be modified during construction of the PluginList.
ScopedVector<PluginGroup> hardcoded_plugin_groups_;
// A list holding all plug-ins.
std::vector<webkit::WebPluginInfo> plugins_list_;
// Callback that is invoked whenever the PluginList will reload the plugins.
base::Closure will_load_plugins_callback_;
......
......@@ -87,10 +87,17 @@ void PluginList::GetPluginsInDir(
}
}
// TODO(ibraaaa): DELETE. http://crbug.com/124396
bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
ScopedVector<PluginGroup>* plugin_groups) {
return !IsBlacklistedPlugin(info);
}
bool PluginList::ShouldLoadPluginUsingPluginList(
const WebPluginInfo& info,
std::vector<webkit::WebPluginInfo>* plugins) {
return !IsBlacklistedPlugin(info);
}
} // namespace npapi
} // namespace webkit
......@@ -266,6 +266,7 @@ void PluginList::GetPluginsInDir(
}
}
// TODO(ibraaaa): DELETE. http://crbug.com/124396
bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
ScopedVector<PluginGroup>* plugin_groups) {
LOG_IF(ERROR, PluginList::DebugPluginLoading())
......@@ -300,5 +301,35 @@ bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
return true;
}
bool PluginList::ShouldLoadPluginUsingPluginList(
const WebPluginInfo& info, std::vector<webkit::WebPluginInfo>* plugins) {
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< "Considering " << info.path.value() << " (" << info.name << ")";
if (IsUndesirablePlugin(info)) {
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< info.path.value() << " is undesirable.";
// See if we have a better version of this plugin.
for (size_t j = 0; j < plugins->size(); ++j) {
if ((*plugins)[j].name == info.name &&
!IsUndesirablePlugin((*plugins)[j])) {
// Skip the current undesirable one so we can use the better one
// we just found.
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< "Skipping " << info.path.value() << ", preferring "
<< (*plugins)[j].path.value();
return false;
}
}
}
// TODO(evanm): prefer the newest version of flash, etc. here?
VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value();
return true;
}
} // namespace npapi
} // namespace webkit
......@@ -335,8 +335,10 @@ bool IsNewerVersion(const std::wstring& a, const std::wstring& b) {
return false;
}
bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info,
ScopedVector<PluginGroup>* plugin_groups) {
// TODO(ibraaaa): DELETE. http://crbug.com/124396
bool PluginList::ShouldLoadPlugin(
const webkit::WebPluginInfo& info,
ScopedVector<PluginGroup>* plugin_groups) {
// Version check
for (size_t i = 0; i < plugin_groups->size(); ++i) {
......@@ -442,5 +444,103 @@ bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info,
return load_plugin;
}
bool PluginList::ShouldLoadPluginUsingPluginList(
const webkit::WebPluginInfo& info,
std::vector<webkit::WebPluginInfo>* plugins) {
// Version check
for (size_t j = 0; j < plugins->size(); ++j) {
FilePath::StringType plugin1 =
StringToLowerASCII((*plugins)[j].path.BaseName().value());
FilePath::StringType plugin2 =
StringToLowerASCII(info.path.BaseName().value());
if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) ||
(plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) ||
(plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) {
if (!IsNewerVersion((*plugins)[j].version, info.version))
return false; // We have loaded a plugin whose version is newer.
PluginList::RemovePlugin((*plugins)[j].path, plugins);
break;
}
}
// Troublemakers
FilePath::StringType filename =
StringToLowerASCII(info.path.BaseName().value());
// Depends on XPCOM.
if (filename == kMozillaActiveXPlugin)
return false;
// Disable the Yahoo Application State plugin as it crashes the plugin
// process on return from NPObjectStub::OnInvoke. Please refer to
// http://b/issue?id=1372124 for more information.
if (filename == kYahooApplicationStatePlugin)
return false;
// Disable the WangWang protocol handler plugin (npww.dll) as it crashes
// chrome during shutdown. Firefox also disables this plugin.
// Please refer to http://code.google.com/p/chromium/issues/detail?id=3953
// for more information.
if (filename == kWanWangProtocolHandlerPlugin)
return false;
// We only work with newer versions of the Java plugin which use NPAPI only
// and don't depend on XPCOM.
if (filename == kJavaPlugin1 || filename == kJavaPlugin2) {
std::vector<FilePath::StringType> ver;
base::SplitString(info.version, '.', &ver);
int major, minor, update;
if (ver.size() == 4 &&
base::StringToInt(ver[0], &major) &&
base::StringToInt(ver[1], &minor) &&
base::StringToInt(ver[2], &update)) {
if (major == 6 && minor == 0 && update < 120)
return false; // Java SE6 Update 11 or older.
}
}
if (base::win::IsMetroProcess()) {
// In metro mode we only allow pepper plugins.
if (info.type == WebPluginInfo::PLUGIN_TYPE_NPAPI)
return false;
}
// Special WMP handling
// If both the new and old WMP plugins exist, only load the new one.
if (filename == kNewWMPPlugin) {
if (dont_load_new_wmp_)
return false;
for (size_t j = 0; j < plugins->size(); ++j) {
if ((*plugins)[j].path.BaseName().value() == kOldWMPPlugin) {
PluginList::RemovePlugin((*plugins)[j].path, plugins);
break;
}
}
} else if (filename == kOldWMPPlugin) {
for (size_t j = 0; j < plugins->size(); ++j) {
if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin)
return false;
}
}
HMODULE plugin_dll = NULL;
bool load_plugin = true;
// The plugin list could contain a 64 bit plugin which we cannot load.
for (size_t i = 0; i < internal_plugins_.size(); ++i) {
if (info.path == internal_plugins_[i].info.path)
continue;
if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path)))
load_plugin = false;
break;
}
return load_plugin;
}
} // namespace npapi
} // namespace webkit
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment