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 6f732f5cbeecbc30b151739076179d98fa3ebce3..ec2a1b23cb8a3c6b9e9fbcdeb3e5f0440b4ef422 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,44 @@ 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); |
| +} |
| + |
| +// 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. |
| +bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { |
| +#if defined(FLAPPER_AVAILABLE) |
| + if (chrome::ComponentFlashHintFile::DoesHintFileExist()) { |
| + base::FilePath flash_path; |
| + std::string version; |
| + const bool verified = |
| + chrome::ComponentFlashHintFile::VerifyAndReturnFlashLocation( |
| + &flash_path, &version); |
| + // In case the user's home directory is mounted NOEXEC, or the plugin could |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
s/NOEXEC/noexec/
Greg K
2015/08/07 21:15:28
Done.
|
| + // not be verified, do not use the plugin. |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
Log an error if !verified?
Greg K
2015/08/07 21:15:28
Yes, although it's misleading because that functio
|
| + if (verified && |
| + chrome::ComponentFlashHintFile::TestExecutableMapping(flash_path)) { |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
Explain why it's useful to bail early in case we c
Greg K
2015/08/07 21:15:28
Done.
|
| + *plugin = CreatePepperFlashInfo(flash_path, version); |
| + return true; |
| + } |
| + } |
| + return false; |
| +#else |
| + return false; |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
Nit: return false outside of the #if #else seems a
Greg K
2015/08/07 21:15:28
Done.
|
| +#endif // defined(FLAPPER_AVAILABLE) |
| +} |
| +#endif // defined(OS_LINUX) |
| + |
| bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { |
| #if defined(FLAPPER_AVAILABLE) |
| base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| @@ -464,12 +505,43 @@ void ChromeContentClient::AddPepperPlugins( |
| ComputeBuiltInPlugins(plugins); |
| AddPepperFlashFromCommandLine(plugins); |
| - content::PepperPluginInfo plugin; |
| - if (GetBundledPepperFlash(&plugin)) |
| - plugins->push_back(plugin); |
| - if (GetSystemPepperFlash(&plugin)) |
| - plugins->push_back(plugin); |
| -#endif |
| +#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. |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
What happens in this case? Is it falling back to t
Greg K
2015/08/07 21:15:28
I clarified that it will continue to use whatever
|
| + if (!IsUserDataDirAvailable()) { |
| + return; |
| + } |
| +#endif // defined(OS_LINUX) |
| + |
| + std::vector<content::PepperPluginInfo*> flash_versions; |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
This is a little strange because this vector will
Greg K
2015/08/07 21:15:28
Done.
|
| + |
| +#if defined(OS_LINUX) |
| + content::PepperPluginInfo component_flash; |
| + if (GetComponentUpdatedPepperFlash(&component_flash)) |
| + flash_versions.push_back(&component_flash); |
| +#endif // defined(OS_LINUX) |
| + |
| + content::PepperPluginInfo bundled_flash; |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
How is this logic affecting other platforms than L
Greg K
2015/08/07 21:15:28
Will do, answer: it shouldn't affect other platfor
|
| + 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(), |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
I wonder if version comparison shouldn't be it's o
Greg K
2015/08/07 21:15:28
Done.
|
| + [](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) |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
It looks like you only need max_element, not a ful
Greg K
2015/08/07 21:15:28
Done.
|
| + plugins->push_back(*flash_versions.back()); |
| +#endif // defined(ENABLE_PLUGINS) |
| } |
| void ChromeContentClient::AddAdditionalSchemes( |