Chromium Code Reviews| Index: chrome/common/chrome_content_client.cc |
| diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc |
| index 4a2456f278f66a9a9ef94f3723c46f458e1cb281..47c622245abfb8d75db1640e728f450e9c824d97 100644 |
| --- a/chrome/common/chrome_content_client.cc |
| +++ b/chrome/common/chrome_content_client.cc |
| @@ -18,6 +18,7 @@ |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "base/tuple.h" |
| #include "build/build_config.h" |
| #include "chrome/common/child_process_logging.h" |
| #include "chrome/common/chrome_constants.h" |
| @@ -197,16 +198,31 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
| // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| } |
| +// Creates a PepperPluginInfo for the specified plugin. |
| +// |path| is the full path to the plugin. |
| +// |version| is a string representation of the plugin version. |
| +// |is_debug| is whether the plugin is the debug version or not. |
| +// |is_external| is whether the plugin is supplied external to Chrome e.g. a |
| +// system installation of Adobe Flash. |
| +// |is_bundled| distinguishes between component updated plugin and a bundled |
| +// plugin. |
| content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, |
| const std::string& version, |
| - bool is_debug) { |
| + bool is_debug, |
| + bool is_external, |
| + bool is_bundled) { |
| content::PepperPluginInfo plugin; |
| plugin.is_out_of_process = true; |
| plugin.name = content::kFlashPluginName; |
| plugin.path = path; |
| +#if defined(OS_WIN) |
| + plugin.is_on_local_drive = !base::IsOnNetworkDrive(path); |
| +#endif |
| plugin.permissions = chrome::kPepperFlashPermissions; |
| plugin.is_debug = is_debug; |
| + plugin.is_external = is_external; |
| + plugin.is_bundled = is_bundled; |
| std::vector<std::string> flash_version_numbers = base::SplitString( |
| version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| @@ -249,7 +265,8 @@ void AddPepperFlashFromCommandLine( |
| switches::kPpapiFlashVersion); |
| plugins->push_back( |
| - CreatePepperFlashInfo(base::FilePath(flash_path), flash_version, false)); |
| + CreatePepperFlashInfo(base::FilePath(flash_path), |
| + flash_version, false, true, false)); |
| } |
| #if defined(OS_LINUX) |
| @@ -283,7 +300,7 @@ bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { |
| "bundled or system plugin."; |
| return false; |
| } |
| - *plugin = CreatePepperFlashInfo(flash_path, version, false); |
| + *plugin = CreatePepperFlashInfo(flash_path, version, false, false, false); |
| return true; |
| } |
| LOG(ERROR) |
| @@ -312,7 +329,8 @@ bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { |
| if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
| return false; |
| - *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING, false); |
| + *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING, false, |
| + false, true); |
| return true; |
| #else |
| return false; |
| @@ -339,18 +357,6 @@ bool IsSystemFlashScriptDebuggerPresent() { |
| bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) { |
| base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| - bool system_flash_is_debug = IsSystemFlashScriptDebuggerPresent(); |
| - |
| -#if defined(FLAPPER_AVAILABLE) |
| - // If flapper is available, only try the system plugin if either: |
| - // --disable-bundled-ppapi-flash is specified, or the system debugger is the |
| - // Flash Script Debugger. |
| - if (!(command_line->HasSwitch(switches::kDisableBundledPpapiFlash) || |
| - system_flash_is_debug)) { |
| - return false; |
| - } |
| -#endif // defined(FLAPPER_AVAILABLE) |
| - |
| // Do not try and find System Pepper Flash if there is a specific path on |
| // the commmand-line. |
| if (command_line->HasSwitch(switches::kPpapiFlashPath)) |
| @@ -382,8 +388,11 @@ bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) { |
| if (!chrome::CheckPepperFlashManifest(*manifest, &version)) |
| return false; |
| - *plugin = CreatePepperFlashInfo(flash_filename, version.GetString(), |
| - system_flash_is_debug); |
| + *plugin = CreatePepperFlashInfo(flash_filename, |
| + version.GetString(), |
| + IsSystemFlashScriptDebuggerPresent(), |
| + true, |
| + false); |
| return true; |
| } |
| #endif // defined(ENABLE_PLUGINS) |
| @@ -463,17 +472,19 @@ void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) { |
| // static |
| content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( |
| const std::vector<content::PepperPluginInfo*>& plugins) { |
| - auto it = std::max_element( |
| - plugins.begin(), plugins.end(), |
| - [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) { |
| - Version version_x(x->version); |
| - Version version_y(y->version); |
| - DCHECK(version_x.IsValid() && version_y.IsValid()); |
| - if (version_x == version_y) |
| - return !x->is_debug && y->is_debug; |
| - return version_x < version_y; |
| - }); |
| - return it != plugins.end() ? *it : nullptr; |
| + if (!plugins.size()) |
|
Lei Zhang
2016/04/15 21:16:36
if (plugins.empty())
Will Harris
2016/04/15 21:43:28
Done.
|
| + return nullptr; |
| + |
| + using PluginSortKey = base::Tuple<base::Version, bool, bool, bool, bool>; |
| + |
| + std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map; |
| + |
| + for (const auto& plugin : plugins) |
| + plugin_map[PluginSortKey(Version(plugin->version), plugin->is_debug, |
| + plugin->is_bundled, plugin->is_on_local_drive, |
| + !plugin->is_external)] = plugin; |
| + |
| + return plugin_map.rbegin()->second; |
| } |
| #endif // defined(ENABLE_PLUGINS) |