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

Unified Diff: chrome/common/chrome_content_client.cc

Issue 1261333004: Add support for Flash Player Component updates on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 57a0b4fb552457cea54628742084625a63c94616..26b979f9f92d9bafebb91c90ef342953a1796900 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -4,6 +4,8 @@
#include "chrome/common/chrome_content_client.h"
+#include <fcntl.h>
+
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/files/file_util.h"
@@ -21,6 +23,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/component_flash_hint_file.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/pepper_flash.h"
#include "chrome/common/secure_origin_whitelist.h"
@@ -31,6 +34,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
+#include "crypto/sha2.h"
#include "extensions/common/constants.h"
#include "gpu/config/gpu_info.h"
#include "net/http/http_util.h"
@@ -281,6 +285,43 @@ void AddPepperFlashFromCommandLine(
CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
}
+#if defined(OS_LINUX)
+bool IsUserDataDirAvailable() {
+ base::FilePath user_data_dir;
+ if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
+ return false;
+ return base::PathExists(user_data_dir);
+}
+#endif // defined(OS_LINUX)
+
+// This method is used on Linux only because of architectural differences in how
+// it loads the component updated flash plugin, and not because the other
+// platforms do not support component updated flash. On other platforms, the
+// component updater sends an IPC message to all threads, at undefined points in
+// time, with the URL of the component updated flash. Because the linux zygote
+// thread has no access to the file system after it warms up, it must preload
+// the component updated flash.
+#if defined(OS_LINUX)
+bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) {
+#if defined(FLAPPER_AVAILABLE)
+ base::FilePath flash_path;
+ std::string version;
+ if (chrome::ComponentFlashHintFile::DoesHintFileExist()) {
+ bool verified =
+ chrome::ComponentFlashHintFile::VerifyAndReturnFlashLocation(
+ &flash_path, &version);
+ if (verified) {
+ *plugin = CreatePepperFlashInfo(flash_path, version);
+ return true;
rickyz (no longer on Chrome) 2015/07/31 00:13:56 Is there any handling for when DIR_USER_DATA is on
Greg K 2015/08/04 00:21:17 Done.
+ }
+ }
+ return false;
+#else
+ return false;
+#endif // defined(FLAPPER_AVAILABLE)
+}
+#endif // defined(OS_LINUX)
+
bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
#if defined(FLAPPER_AVAILABLE)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -465,11 +506,41 @@ void ChromeContentClient::AddPepperPlugins(
ComputeBuiltInPlugins(plugins);
AddPepperFlashFromCommandLine(plugins);
- content::PepperPluginInfo plugin;
- if (GetBundledPepperFlash(&plugin))
- plugins->push_back(plugin);
- if (GetSystemPepperFlash(&plugin))
- plugins->push_back(plugin);
+#if defined(OS_LINUX)
+ // Depending on the sandbox configurtion, the user data directory
+ // is not always available. If it is not available, do not try and load and
+ // flash plugin. It may incorrectly try to load the system flash plugin in
+ // this case.
+ if (!IsUserDataDirAvailable()) {
+ return;
+ }
+#endif
+
+ std::vector<content::PepperPluginInfo*> flash_versions;
+
+#if defined(OS_LINUX)
+ content::PepperPluginInfo component_flash;
+ if (GetComponentUpdatedPepperFlash(&component_flash))
+ flash_versions.push_back(&component_flash);
+#endif
+
+ content::PepperPluginInfo bundled_flash;
+ if (GetBundledPepperFlash(&bundled_flash))
+ flash_versions.push_back(&bundled_flash);
+
+ content::PepperPluginInfo system_flash;
+ if (GetSystemPepperFlash(&system_flash))
+ flash_versions.push_back(&system_flash);
+
+ // Now sort the list and add the most recent flash plugin to the plugins list.
+ std::sort(flash_versions.begin(), flash_versions.end(),
+ [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) {
+ Version version_x(x->version);
+ DCHECK(version_x.IsValid());
+ return version_x.IsOlderThan(y->version);
+ });
+ // Use the last element in the list, which will be the most recent flash.
+ plugins->push_back(*flash_versions.back());
#endif
}

Powered by Google App Engine
This is Rietveld 408576698