diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-14 05:24:44 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-14 05:24:44 +0000 |
commit | 91d9f3d52a1e55a9938416b258e08d3cc445eae4 (patch) | |
tree | 41a281011d4ba9e327fb4e167528c99e0faec018 /webkit/plugins | |
parent | 3c8f946c38d15238f5b0793123c06859a8bc2352 (diff) | |
download | chromium_src-91d9f3d52a1e55a9938416b258e08d3cc445eae4.zip chromium_src-91d9f3d52a1e55a9938416b258e08d3cc445eae4.tar.gz chromium_src-91d9f3d52a1e55a9938416b258e08d3cc445eae4.tar.bz2 |
Make WebPluginInfo more generic
- To account for pepper plugins, it grows a type field
- move WebPluginInfo from webkit::npapi to webkit:: and move the files as well.
This will allow us to remove hacks to get pepper plugins to load soon
BUG=89248
TEST=none
Review URL: http://codereview.chromium.org/7648017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/npapi/plugin_group.cc | 2 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_group.h | 32 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_group_unittest.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_host.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_lib.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_lib.h | 14 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.cc | 47 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.h | 37 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list_win.cc | 12 | ||||
-rw-r--r-- | webkit/plugins/webplugininfo.cc (renamed from webkit/plugins/npapi/webplugininfo.cc) | 13 | ||||
-rw-r--r-- | webkit/plugins/webplugininfo.h (renamed from webkit/plugins/npapi/webplugininfo.h) | 21 |
11 files changed, 101 insertions, 89 deletions
diff --git a/webkit/plugins/npapi/plugin_group.cc b/webkit/plugins/npapi/plugin_group.cc index 5a7803d..7904f93 100644 --- a/webkit/plugins/npapi/plugin_group.cc +++ b/webkit/plugins/npapi/plugin_group.cc @@ -13,7 +13,7 @@ #include "base/values.h" #include "base/version.h" #include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/npapi/webplugininfo.h" +#include "webkit/plugins/webplugininfo.h" namespace webkit { namespace npapi { diff --git a/webkit/plugins/npapi/plugin_group.h b/webkit/plugins/npapi/plugin_group.h index 354c486..24d8c4c 100644 --- a/webkit/plugins/npapi/plugin_group.h +++ b/webkit/plugins/npapi/plugin_group.h @@ -14,7 +14,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/string16.h" -#include "webkit/plugins/npapi/webplugininfo.h" +#include "webkit/plugins/webplugininfo.h" class FilePath; class PluginExceptionsTableModelTest; @@ -116,10 +116,10 @@ class PluginGroup { static bool IsPluginNameEnabledByPolicy(const string16& plugin_name); // Returns true if the given plugin matches this group. - bool Match(const WebPluginInfo& plugin) const; + bool Match(const webkit::WebPluginInfo& plugin) const; // Adds the given plugin to this group. - void AddPlugin(const WebPluginInfo& plugin); + void AddPlugin(const webkit::WebPluginInfo& plugin); // Removes a plugin from the group by its path. bool RemovePlugin(const FilePath& filename); @@ -156,7 +156,7 @@ class PluginGroup { string16 GetGroupName() const; // Returns all plugins added to the group. - const std::vector<WebPluginInfo>& web_plugins_info() const { + const std::vector<webkit::WebPluginInfo>& web_plugins_info() const { return web_plugin_infos_; } @@ -198,7 +198,9 @@ class PluginGroup { // in accepting weird version strings than Version::GetFromString(). static Version* CreateVersionFromString(const string16& version_string); - std::vector<WebPluginInfo> web_plugin_infos() { return web_plugin_infos_; } + std::vector<webkit::WebPluginInfo> web_plugin_infos() { + return web_plugin_infos_; + } private: friend class PluginList; @@ -208,11 +210,11 @@ class PluginGroup { FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated); // Generates the (short) identifier string for the given plugin. - static std::string GetIdentifier(const WebPluginInfo& wpi); + static std::string GetIdentifier(const webkit::WebPluginInfo& wpi); // Generates the long identifier (based on the full file path) for the given // plugin, to be called when the short identifier is not unique. - static std::string GetLongIdentifier(const WebPluginInfo& wpi); + static std::string GetLongIdentifier(const webkit::WebPluginInfo& wpi); // Creates a PluginGroup from a PluginGroupDefinition. The caller takes // ownership of the created PluginGroup. @@ -221,7 +223,7 @@ class PluginGroup { // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of // the created PluginGroup. - static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); + static PluginGroup* FromWebPluginInfo(const webkit::WebPluginInfo& wpi); // Returns |true| if |version| is contained in [low, high) of |range|. static bool IsVersionInRange(const Version& version, @@ -241,11 +243,11 @@ class PluginGroup { // Set the description and version for this plugin group from the // given plug-in. - void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); + void UpdateDescriptionAndVersion(const webkit::WebPluginInfo& plugin); // Updates the active plugin in the group. The active plugin is the first // enabled one, or if all plugins are disabled, simply the first one. - void UpdateActivePlugin(const WebPluginInfo& plugin); + void UpdateActivePlugin(const webkit::WebPluginInfo& plugin); // Resets the group state to its default value (as if the group was empty). // After calling this method, calling |UpdateActivePlugin| with all plugins @@ -254,20 +256,20 @@ class PluginGroup { // Enables the plugin if not already enabled and if policy allows it to. // Returns true on success. Does not update the group state. - static bool Enable(WebPluginInfo* plugin, int reason); + static bool Enable(webkit::WebPluginInfo* plugin, int reason); // Disables the plugin if not already disabled and if policy allows it to. // Returns true on success. Does not update the group state. - static bool Disable(WebPluginInfo* plugin, int reason); + static bool Disable(webkit::WebPluginInfo* plugin, int reason); // Helper function to implement the functions above. - static bool SetPluginState(WebPluginInfo* plugin, + static bool SetPluginState(webkit::WebPluginInfo* plugin, int new_reason, bool state_changes); // Returns a non-const vector of all plugins in the group. This is only used // by PluginList. - std::vector<WebPluginInfo>& GetPluginsContainer() { + std::vector<webkit::WebPluginInfo>& GetPluginsContainer() { return web_plugin_infos_; } @@ -287,7 +289,7 @@ class PluginGroup { bool enabled_; std::vector<VersionRange> version_ranges_; scoped_ptr<Version> version_; - std::vector<WebPluginInfo> web_plugin_infos_; + std::vector<webkit::WebPluginInfo> web_plugin_infos_; }; } // namespace npapi diff --git a/webkit/plugins/npapi/plugin_group_unittest.cc b/webkit/plugins/npapi/plugin_group_unittest.cc index 4e4eee5..4e7704f 100644 --- a/webkit/plugins/npapi/plugin_group_unittest.cc +++ b/webkit/plugins/npapi/plugin_group_unittest.cc @@ -13,7 +13,7 @@ #include "base/values.h" #include "base/version.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/plugins/npapi/webplugininfo.h" +#include "webkit/plugins/webplugininfo.h" namespace webkit { namespace npapi { @@ -150,7 +150,7 @@ TEST_F(PluginGroupTest, PluginGroupDescription) { { // Disable the second plugin. plugin3045.enabled = - webkit::npapi::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; + webkit::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( plugindefs[i])); EXPECT_TRUE(group->Match(plugin3043)); diff --git a/webkit/plugins/npapi/plugin_host.cc b/webkit/plugins/npapi/plugin_host.cc index 2af729e..b679d3a 100644 --- a/webkit/plugins/npapi/plugin_host.cc +++ b/webkit/plugins/npapi/plugin_host.cc @@ -27,7 +27,7 @@ #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/plugin_stream_url.h" #include "webkit/plugins/npapi/webplugin_delegate.h" -#include "webkit/plugins/npapi/webplugininfo.h" +#include "webkit/plugins/webplugininfo.h" #if defined(OS_MACOSX) #include "base/mac/mac_util.h" @@ -601,7 +601,7 @@ const char* NPN_UserAgent(NPP id) { if (id) plugin = FindInstance(id); if (plugin.get()) { - webkit::npapi::WebPluginInfo plugin_info = + webkit::WebPluginInfo plugin_info = plugin->plugin_lib()->plugin_info(); if (plugin_info.name == ASCIIToUTF16("Silverlight Plug-In") && StartsWith(plugin_info.version, ASCIIToUTF16("4."), false)) { diff --git a/webkit/plugins/npapi/plugin_lib.cc b/webkit/plugins/npapi/plugin_lib.cc index 28d6b6c..f333f8e 100644 --- a/webkit/plugins/npapi/plugin_lib.cc +++ b/webkit/plugins/npapi/plugin_lib.cc @@ -34,7 +34,7 @@ PluginLib* PluginLib::CreatePluginLib(const FilePath& filename) { return (*g_loaded_libs)[i]; } - WebPluginInfo info; + webkit::WebPluginInfo info; const PluginEntryPoints* entry_points = NULL; if (!PluginList::Singleton()->ReadPluginInfo(filename, &info, &entry_points)) return NULL; @@ -65,7 +65,7 @@ void PluginLib::ShutdownAllPlugins() { } } -PluginLib::PluginLib(const WebPluginInfo& info, +PluginLib::PluginLib(const webkit::WebPluginInfo& info, const PluginEntryPoints* entry_points) : web_plugin_info_(info), library_(NULL), diff --git a/webkit/plugins/npapi/plugin_lib.h b/webkit/plugins/npapi/plugin_lib.h index e501ccb..3ae5d9e 100644 --- a/webkit/plugins/npapi/plugin_lib.h +++ b/webkit/plugins/npapi/plugin_lib.h @@ -16,7 +16,6 @@ #include "webkit/plugins/npapi/webplugin.h" class FilePath; -struct WebPluginInfo; namespace webkit { namespace npapi { @@ -32,18 +31,19 @@ class PluginLib : public base::RefCounted<PluginLib> { // Creates a WebPluginInfo structure given a plugin's path. On success // returns true, with the information being put into "info". // Returns false if the library couldn't be found, or if it's not a plugin. - static bool ReadWebPluginInfo(const FilePath& filename, WebPluginInfo* info); + static bool ReadWebPluginInfo(const FilePath& filename, + webkit::WebPluginInfo* info); #if defined(OS_POSIX) && !defined(OS_MACOSX) // Parse the result of an NP_GetMIMEDescription() call. // This API is only used on Unixes, and is exposed here for testing. static void ParseMIMEDescription(const std::string& description, - std::vector<WebPluginMimeType>* mime_types); + std::vector<webkit::WebPluginMimeType>* mime_types); // Extract a version number from a description string. // This API is only used on Unixes, and is exposed here for testing. static void ExtractVersionString(const std::string& version, - WebPluginInfo* info); + webkit::WebPluginInfo* info); #endif // Unloads all the loaded plugin libraries and cleans up the plugin map. @@ -63,7 +63,7 @@ class PluginLib : public base::RefCounted<PluginLib> { // Gets information about this plugin and the mime types that it // supports. - const WebPluginInfo& plugin_info() { return web_plugin_info_; } + const webkit::WebPluginInfo& plugin_info() { return web_plugin_info_; } bool internal() { return internal_; } @@ -102,7 +102,7 @@ class PluginLib : public base::RefCounted<PluginLib> { // Creates a new PluginLib. // |entry_points| is non-NULL for internal plugins. - PluginLib(const WebPluginInfo& info, + PluginLib(const webkit::WebPluginInfo& info, const PluginEntryPoints* entry_points); virtual ~PluginLib(); @@ -119,7 +119,7 @@ class PluginLib : public base::RefCounted<PluginLib> { private: bool internal_; // True for plugins that are built-in into chrome binaries. - WebPluginInfo web_plugin_info_; // Supported mime types, description + webkit::WebPluginInfo web_plugin_info_; // Supported mime types, description base::NativeLibrary library_; // The opened library reference. NPPluginFuncs plugin_funcs_; // The struct of plugin side functions. bool initialized_; // Is the plugin initialized? diff --git a/webkit/plugins/npapi/plugin_list.cc b/webkit/plugins/npapi/plugin_list.cc index 1fae6b3..197cb80 100644 --- a/webkit/plugins/npapi/plugin_list.cc +++ b/webkit/plugins/npapi/plugin_list.cc @@ -210,7 +210,7 @@ void PluginList::AddExtraPluginDir(const FilePath& plugin_dir) { #endif } -void PluginList::RegisterInternalPlugin(const WebPluginInfo& info) { +void PluginList::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { PluginEntryPoints entry_points = {0}; InternalPlugin plugin = { info, entry_points }; @@ -230,9 +230,9 @@ void PluginList::RegisterInternalPlugin(const FilePath& filename, plugin.info.name = ASCIIToUTF16(name); plugin.info.version = ASCIIToUTF16("1"); plugin.info.desc = ASCIIToUTF16(description); - plugin.info.enabled = WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; + plugin.info.enabled = webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; - WebPluginMimeType mime_type; + webkit::WebPluginMimeType mime_type; mime_type.mime_type = mime_type_str; plugin.info.mime_types.push_back(mime_type); @@ -256,7 +256,7 @@ void PluginList::UnregisterInternalPlugin(const FilePath& path) { } bool PluginList::ReadPluginInfo(const FilePath& filename, - WebPluginInfo* info, + webkit::WebPluginInfo* info, const PluginEntryPoints** entry_points) { { base::AutoLock lock(lock_); @@ -280,7 +280,7 @@ bool PluginList::ParseMimeTypes( const std::string& mime_types_str, const std::string& file_extensions_str, const string16& mime_type_descriptions_str, - std::vector<WebPluginMimeType>* parsed_mime_types) { + std::vector<webkit::WebPluginMimeType>* parsed_mime_types) { std::vector<std::string> mime_types, file_extensions; std::vector<string16> descriptions; base::SplitString(mime_types_str, '|', &mime_types); @@ -411,9 +411,9 @@ void PluginList::LoadPlugins() { base::AutoLock lock(lock_); // Grab all plugins that were found before to copy enabled statuses. - std::vector<WebPluginInfo> old_plugins; + std::vector<webkit::WebPluginInfo> old_plugins; for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<WebPluginInfo>& gr_plugins = + const std::vector<webkit::WebPluginInfo>& gr_plugins = plugin_groups_[i]->web_plugins_info(); old_plugins.insert(old_plugins.end(), gr_plugins.begin(), gr_plugins.end()); } @@ -422,7 +422,8 @@ void PluginList::LoadPlugins() { PluginGroup* group = new_plugin_groups[i]; string16 group_name = group->GetGroupName(); - std::vector<WebPluginInfo>& gr_plugins = group->GetPluginsContainer(); + std::vector<webkit::WebPluginInfo>& gr_plugins = + group->GetPluginsContainer(); for (size_t j = 0; j < gr_plugins.size(); ++j) { int plugin_found = -1; for (size_t k = 0; k < old_plugins.size(); ++k) { @@ -495,7 +496,7 @@ void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { LoadPlugins(); base::AutoLock lock(lock_); for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<WebPluginInfo>& gr_plugins = + const std::vector<webkit::WebPluginInfo>& gr_plugins = plugin_groups_[i]->web_plugins_info(); plugins->insert(plugins->end(), gr_plugins.begin(), gr_plugins.end()); } @@ -506,7 +507,7 @@ void PluginList::GetPluginInfoArray( const std::string& mime_type, bool allow_wildcard, bool* use_stale, - std::vector<WebPluginInfo>* info, + std::vector<webkit::WebPluginInfo>* info, std::vector<std::string>* actual_mime_types) { DCHECK(mime_type == StringToLowerASCII(mime_type)); DCHECK(info); @@ -524,7 +525,7 @@ void PluginList::GetPluginInfoArray( // Add in enabled plugins by mime type. for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = plugin_groups_[i]->web_plugins_info(); for (size_t i = 0; i < plugins.size(); ++i) { if (IsPluginEnabled(plugins[i]) && SupportsType(plugins[i], @@ -547,7 +548,7 @@ void PluginList::GetPluginInfoArray( std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); std::string actual_mime_type; for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = plugin_groups_[i]->web_plugins_info(); for (size_t i = 0; i < plugins.size(); ++i) { if (IsPluginEnabled(plugins[i]) && @@ -566,7 +567,7 @@ void PluginList::GetPluginInfoArray( // Add in disabled plugins by mime type. for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = plugin_groups_[i]->web_plugins_info(); for (size_t i = 0; i < plugins.size(); ++i) { if (!IsPluginEnabled(plugins[i]) && @@ -593,7 +594,7 @@ void PluginList::GetPluginInfoArray( kDefaultPluginLibraryName) == 0) { #endif DCHECK_NE(0U, plugin_groups_[i]->web_plugins_info().size()); - const WebPluginInfo& default_info = + const webkit::WebPluginInfo& default_info = plugin_groups_[i]->web_plugins_info()[0]; if (SupportsType(default_info, mime_type, allow_wildcard)) { info->push_back(default_info); @@ -605,11 +606,11 @@ void PluginList::GetPluginInfoArray( } bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path, - WebPluginInfo* info) { + webkit::WebPluginInfo* info) { LoadPlugins(); base::AutoLock lock(lock_); for (size_t i = 0; i < plugin_groups_.size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = plugin_groups_[i]->web_plugins_info(); for (size_t i = 0; i < plugins.size(); ++i) { if (plugins[i].path == plugin_path) { @@ -638,7 +639,7 @@ void PluginList::GetPluginGroups( } const PluginGroup* PluginList::GetPluginGroup( - const WebPluginInfo& web_plugin_info) { + const webkit::WebPluginInfo& web_plugin_info) { base::AutoLock lock(lock_); return AddToPluginGroups(web_plugin_info, &plugin_groups_); } @@ -652,7 +653,7 @@ string16 PluginList::GetPluginGroupName(const std::string& identifier) { } std::string PluginList::GetPluginGroupIdentifier( - const WebPluginInfo& web_plugin_info) { + const webkit::WebPluginInfo& web_plugin_info) { base::AutoLock lock(lock_); PluginGroup* group = AddToPluginGroups(web_plugin_info, &plugin_groups_); return group->identifier(); @@ -666,7 +667,7 @@ void PluginList::AddHardcodedPluginGroups(ScopedVector<PluginGroup>* groups) { } PluginGroup* PluginList::AddToPluginGroups( - const WebPluginInfo& web_plugin_info, + const webkit::WebPluginInfo& web_plugin_info, ScopedVector<PluginGroup>* plugin_groups) { PluginGroup* group = NULL; for (size_t i = 0; i < plugin_groups->size(); ++i) { @@ -747,7 +748,7 @@ bool PluginList::EnableGroup(bool enable, const string16& group_name) { return group->EnableGroup(enable); } -bool PluginList::SupportsType(const WebPluginInfo& plugin, +bool PluginList::SupportsType(const webkit::WebPluginInfo& plugin, const std::string& mime_type, bool allow_wildcard) { // Webkit will ask for a plugin to handle empty mime types. @@ -755,7 +756,7 @@ bool PluginList::SupportsType(const WebPluginInfo& plugin, return false; for (size_t i = 0; i < plugin.mime_types.size(); ++i) { - const WebPluginMimeType& mime_info = plugin.mime_types[i]; + const webkit::WebPluginMimeType& mime_info = plugin.mime_types[i]; if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { if (!allow_wildcard && mime_info.mime_type == "*") continue; @@ -765,11 +766,11 @@ bool PluginList::SupportsType(const WebPluginInfo& plugin, return false; } -bool PluginList::SupportsExtension(const WebPluginInfo& plugin, +bool PluginList::SupportsExtension(const webkit::WebPluginInfo& plugin, const std::string& extension, std::string* actual_mime_type) { for (size_t i = 0; i < plugin.mime_types.size(); ++i) { - const WebPluginMimeType& mime_type = plugin.mime_types[i]; + const webkit::WebPluginMimeType& mime_type = plugin.mime_types[i]; for (size_t j = 0; j < mime_type.file_extensions.size(); ++j) { if (mime_type.file_extensions[j] == extension) { if (actual_mime_type) diff --git a/webkit/plugins/npapi/plugin_list.h b/webkit/plugins/npapi/plugin_list.h index 46c0bf6..3e5a804 100644 --- a/webkit/plugins/npapi/plugin_list.h +++ b/webkit/plugins/npapi/plugin_list.h @@ -17,7 +17,7 @@ #include "base/synchronization/lock.h" #include "third_party/npapi/bindings/nphostapi.h" #include "webkit/plugins/npapi/plugin_group.h" -#include "webkit/plugins/npapi/webplugininfo.h" +#include "webkit/plugins/webplugininfo.h" class GURL; @@ -80,7 +80,7 @@ class PluginList { // Register an internal plugin with the specified plugin information. // An internal plugin must be registered before it can // be loaded using PluginList::LoadPlugin(). - void RegisterInternalPlugin(const WebPluginInfo& info); + void RegisterInternalPlugin(const webkit::WebPluginInfo& info); // This second version is for "plugins" that have been compiled // directly into the binary -- callers must provide the metadata and @@ -105,20 +105,21 @@ class PluginList { // internally-owned PluginEntryPoints pointer. // Returns false if the library couldn't be found, or if it's not a plugin. bool ReadPluginInfo(const FilePath& filename, - WebPluginInfo* info, + webkit::WebPluginInfo* info, const PluginEntryPoints** entry_points); // In Windows plugins, the mime types are passed as a specially formatted list // of strings. This function parses those strings into a WebPluginMimeType // vector. // TODO(evan): move this code into plugin_list_win. - static bool ParseMimeTypes(const std::string& mime_types, - const std::string& file_extensions, - const string16& mime_type_descriptions, - std::vector<WebPluginMimeType>* parsed_mime_types); + static bool ParseMimeTypes( + const std::string& mime_types, + const std::string& file_extensions, + const string16& mime_type_descriptions, + std::vector<webkit::WebPluginMimeType>* parsed_mime_types); // Get all the plugins. - void GetPlugins(std::vector<WebPluginInfo>* plugins); + void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins); // Returns a list in |info| containing plugins that are found for // the given url and mime type (including disabled plugins, for @@ -137,13 +138,13 @@ class PluginList { const std::string& mime_type, bool allow_wildcard, bool* use_stale, - std::vector<WebPluginInfo>* info, + std::vector<webkit::WebPluginInfo>* info, std::vector<std::string>* actual_mime_types); // Get plugin info by plugin path (including disabled plugins). Returns true // if the plugin is found and WebPluginInfo has been filled in |info|. bool GetPluginInfoByPath(const FilePath& plugin_path, - WebPluginInfo* info); + webkit::WebPluginInfo* info); // Populates the given vector with all available plugin groups. void GetPluginGroups(bool load_if_necessary, @@ -157,7 +158,8 @@ class PluginList { // call to |GetPlugins()|, |GetEnabledPlugins()|, |GetPluginInfoArray()|, // |GetPluginInfoByPath()|, or |GetPluginGroups(true, _)|. It is the caller's // responsibility to make sure this doesn't happen. - const PluginGroup* GetPluginGroup(const WebPluginInfo& web_plugin_info); + const PluginGroup* GetPluginGroup( + const webkit::WebPluginInfo& web_plugin_info); // Returns the name of the PluginGroup with the given identifier. // If no such group exists, an empty string is returned. @@ -166,7 +168,8 @@ class PluginList { // Returns the identifier string of the PluginGroup corresponding to the given // WebPluginInfo. If no such group exists, it is created and added to the // cache. - std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info); + std::string GetPluginGroupIdentifier( + const webkit::WebPluginInfo& web_plugin_info); // Load a specific plugin with full path. void LoadPlugin(const FilePath& filename, @@ -206,7 +209,7 @@ class PluginList { // Adds the given WebPluginInfo to its corresponding group, creating it if // necessary, and returns the group. // Callers need to protect calls to this method by a lock themselves. - PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info, + PluginGroup* AddToPluginGroups(const webkit::WebPluginInfo& web_plugin_info, ScopedVector<PluginGroup>* plugin_groups); private: @@ -240,7 +243,7 @@ class PluginList { // 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 WebPluginInfo& info, + bool ShouldLoadPlugin(const webkit::WebPluginInfo& info, ScopedVector<PluginGroup>* plugins); // Return whether a plug-in group with the given name should be disabled, @@ -251,7 +254,7 @@ class PluginList { // Returns true if the plugin supports |mime_type|. |mime_type| should be all // lower case. - bool SupportsType(const WebPluginInfo& plugin, + bool SupportsType(const webkit::WebPluginInfo& plugin, const std::string& mime_type, bool allow_wildcard); @@ -259,7 +262,7 @@ class PluginList { // |extension| should be all lower case. If |mime_type| is not NULL, it will // be set to the MIME type if found. The MIME type which corresponds to the // extension is optionally returned back. - bool SupportsExtension(const WebPluginInfo& plugin, + bool SupportsExtension(const webkit::WebPluginInfo& plugin, const std::string& extension, std::string* actual_mime_type); @@ -298,7 +301,7 @@ class PluginList { std::vector<FilePath> extra_plugin_dirs_; struct InternalPlugin { - WebPluginInfo info; + webkit::WebPluginInfo info; PluginEntryPoints entry_points; }; // Holds information about internal plugins. diff --git a/webkit/plugins/npapi/plugin_list_win.cc b/webkit/plugins/npapi/plugin_list_win.cc index cbd16ca..b739771 100644 --- a/webkit/plugins/npapi/plugin_list_win.cc +++ b/webkit/plugins/npapi/plugin_list_win.cc @@ -313,8 +313,8 @@ void PluginList::LoadPluginsFromRegistry( // Returns true if the given plugins share at least one mime type. This is used // to differentiate newer versions of a plugin vs two plugins which happen to // have the same filename. -bool HaveSharedMimeType(const WebPluginInfo& plugin1, - const WebPluginInfo& plugin2) { +bool HaveSharedMimeType(const webkit::WebPluginInfo& plugin1, + const webkit::WebPluginInfo& plugin2) { for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { for (size_t j = 0; j < plugin2.mime_types.size(); ++j) { if (plugin1.mime_types[i].mime_type == plugin2.mime_types[j].mime_type) @@ -352,12 +352,12 @@ bool IsNewerVersion(const std::wstring& a, const std::wstring& b) { return false; } -bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, +bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info, ScopedVector<PluginGroup>* plugin_groups) { // Version check for (size_t i = 0; i < plugin_groups->size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = (*plugin_groups)[i]->web_plugins_info(); for (size_t j = 0; j < plugins.size(); ++j) { std::wstring plugin1 = @@ -419,7 +419,7 @@ bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, return false; for (size_t i = 0; i < plugin_groups->size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = (*plugin_groups)[i]->web_plugins_info(); for (size_t j = 0; j < plugins.size(); ++j) { if (plugins[j].path.BaseName().value() == kOldWMPPlugin) { @@ -430,7 +430,7 @@ bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, } } else if (filename == kOldWMPPlugin) { for (size_t i = 0; i < plugin_groups->size(); ++i) { - const std::vector<WebPluginInfo>& plugins = + const std::vector<webkit::WebPluginInfo>& plugins = (*plugin_groups)[i]->web_plugins_info(); for (size_t j = 0; j < plugins.size(); ++j) { if (plugins[j].path.BaseName().value() == kNewWMPPlugin) diff --git a/webkit/plugins/npapi/webplugininfo.cc b/webkit/plugins/webplugininfo.cc index 94fb8548..fb30646 100644 --- a/webkit/plugins/npapi/webplugininfo.cc +++ b/webkit/plugins/webplugininfo.cc @@ -2,13 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/plugins/npapi/webplugininfo.h" +#include "webkit/plugins/webplugininfo.h" #include "base/logging.h" #include "base/utf_string_conversions.h" namespace webkit { -namespace npapi { WebPluginMimeType::WebPluginMimeType() {} @@ -24,7 +23,7 @@ WebPluginMimeType::WebPluginMimeType(const std::string& m, WebPluginMimeType::~WebPluginMimeType() {} WebPluginInfo::WebPluginInfo() - : enabled(USER_DISABLED_POLICY_UNMANAGED) { + : enabled(USER_DISABLED_POLICY_UNMANAGED), type(PLUGIN_TYPE_NPAPI) { } WebPluginInfo::WebPluginInfo(const WebPluginInfo& rhs) @@ -33,7 +32,8 @@ WebPluginInfo::WebPluginInfo(const WebPluginInfo& rhs) version(rhs.version), desc(rhs.desc), mime_types(rhs.mime_types), - enabled(rhs.enabled) { + enabled(rhs.enabled), + type(rhs.type) { } WebPluginInfo::~WebPluginInfo() {} @@ -45,6 +45,7 @@ WebPluginInfo& WebPluginInfo::operator=(const WebPluginInfo& rhs) { desc = rhs.desc; mime_types = rhs.mime_types; enabled = rhs.enabled; + type = rhs.type; return *this; } @@ -57,7 +58,8 @@ WebPluginInfo::WebPluginInfo(const string16& fake_name, version(fake_version), desc(fake_desc), mime_types(), - enabled(USER_ENABLED_POLICY_UNMANAGED) { + enabled(USER_ENABLED_POLICY_UNMANAGED), + type(PLUGIN_TYPE_NPAPI) { } bool IsPluginEnabled(const WebPluginInfo& plugin) { @@ -65,5 +67,4 @@ bool IsPluginEnabled(const WebPluginInfo& plugin) { plugin.enabled == WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED); } -} // namespace npapi } // namespace webkit diff --git a/webkit/plugins/npapi/webplugininfo.h b/webkit/plugins/webplugininfo.h index 1cb625a..35427a9 100644 --- a/webkit/plugins/npapi/webplugininfo.h +++ b/webkit/plugins/webplugininfo.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_PLUGINS_NPAPI_WEBPLUGININFO_H_ -#define WEBKIT_PLUGINS_NPAPI_WEBPLUGININFO_H_ +#ifndef WEBKIT_PLUGINS_WEBPLUGININFO_H_ +#define WEBKIT_PLUGINS_WEBPLUGININFO_H_ #include <string> #include <vector> @@ -12,10 +12,7 @@ #include "base/file_path.h" namespace webkit { -namespace npapi { -// Describes a mime type entry for a plugin. -// TODO(viettrungluu): This isn't NPAPI-specific. Move this somewhere else. struct WebPluginMimeType { WebPluginMimeType(); // A constructor for the common case of a single file extension and an ASCII @@ -39,7 +36,7 @@ struct WebPluginMimeType { std::vector<string16> additional_param_values; }; -// Describes an available NPAPI plugin. +// Describes an available NPAPI or Pepper plugin. struct WebPluginInfo { // Defines the possible enabled state a plugin can have. // The enum values actually represent a 3-bit bitfield : @@ -67,6 +64,12 @@ struct WebPluginInfo { POLICY_UNMANAGED = -1 }; + enum PluginType { + PLUGIN_TYPE_NPAPI, + PLUGIN_TYPE_PEPPER_IN_PROCESS, + PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS + }; + WebPluginInfo(); WebPluginInfo(const WebPluginInfo& rhs); ~WebPluginInfo(); @@ -95,12 +98,14 @@ struct WebPluginInfo { // Enabled state of the plugin. See the EnabledStates enum. int enabled; + + // Plugin type. See the PluginType enum. + int type; }; // Checks whether a plugin is enabled either by the user or by policy. bool IsPluginEnabled(const WebPluginInfo& plugin); -} // namespace npapi } // namespace webkit -#endif // WEBKIT_PLUGINS_NPAPI_WEBPLUGININFO_H_ +#endif // WEBKIT_PLUGINS_WEBPLUGININFO_H_ |