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

Unified Diff: chrome/common/chrome_content_client.cc

Issue 1867833003: Prefer System Flash over non-local component updated Flash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review comments Created 4 years, 8 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/common/chrome_content_client.cc
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index 9854e9261278c37f957c650756f96adb80958ee6..23c26a24d22af1a0525c8f92768641a5a75e5d5f 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -20,6 +20,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"
@@ -198,16 +199,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);
@@ -250,7 +266,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)
@@ -284,7 +301,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)
@@ -313,7 +330,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;
@@ -340,18 +358,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))
@@ -383,8 +389,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)
@@ -464,17 +473,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.empty())
+ 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;
cpu_(ooo_6.6-7.5) 2016/04/20 19:23:14 mmm... clever but obscure, I don't know what the l
Will Harris 2016/04/20 23:50:21 yup less is implemented by "Compares lhs and rhs l
}
#endif // defined(ENABLE_PLUGINS)

Powered by Google App Engine
This is Rietveld 408576698