Index: chrome/common/chrome_content_client.cc |
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc |
index 6f732f5cbeecbc30b151739076179d98fa3ebce3..140bee482a577e3228668c35753a551041b808b0 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" |
@@ -20,6 +22,7 @@ |
#include "chrome/common/chrome_constants.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.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" |
@@ -281,6 +284,46 @@ 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) |
+ if (chrome::ComponentFlashHintFile::DoesHintFileExist()) { |
+ base::FilePath flash_path; |
+ std::string version; |
+ bool verified = |
+ chrome::ComponentFlashHintFile::VerifyAndReturnFlashLocation( |
+ &flash_path, &version); |
+ // In case the user's home directory is mounted NOEXEC, or the plugin could |
+ // not be verified, do not use the plugin. |
+ if (verified && |
+ chrome::ComponentFlashHintFile::TestExecutableMapping(flash_path)) { |
+ *plugin = CreatePepperFlashInfo(flash_path, version); |
+ return true; |
+ } |
+ } |
+ return false; |
+#else |
+ return false; |
+#endif // defined(FLAPPER_AVAILABLE) |
jln (very slow on Chromium)
2015/08/04 01:08:33
You should return something even if !FLAPPER_AVAIL
Greg K
2015/08/04 18:30:00
Yes, if I #undef FLAPPER_AVAILABLE it still builds
|
+} |
+#endif // defined(OS_LINUX) |
+ |
bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { |
#if defined(FLAPPER_AVAILABLE) |
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
@@ -464,11 +507,42 @@ 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 |
jln (very slow on Chromium)
2015/08/04 01:08:33
// defined(OS_LINUX)
Greg K
2015/08/04 18:30:00
Done.
|
+ |
+ 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 |
jln (very slow on Chromium)
2015/08/04 01:08:33
// defined(OS_LINUX)
Greg K
2015/08/04 18:30:00
Done.
|
+ |
+ 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. |
+ if (flash_versions.size() > 0) |
+ plugins->push_back(*flash_versions.back()); |
#endif |
jln (very slow on Chromium)
2015/08/04 01:08:33
// defined(ENABLE_PLUGINS)
Greg K
2015/08/04 18:30:00
Done.
|
} |