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

Unified Diff: chrome/browser/component_updater/pepper_flash_component_installer.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: Use SecureHash, fix up unit tests, general cleanup Created 5 years, 4 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
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | chrome/chrome_common.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/pepper_flash_component_installer.cc
diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc
index 2ebbb31854080d51bc574bc9aebdb89ad23aa79e..abc0c649ffd1fe5bc192593cdc6c36d08343c982 100644
--- a/chrome/browser/component_updater/pepper_flash_component_installer.cc
+++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc
@@ -15,6 +15,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -25,6 +26,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/pepper_flash.h"
#include "chrome/common/ppapi_utils.h"
#include "components/component_updater/component_updater_service.h"
@@ -43,7 +45,7 @@ namespace component_updater {
namespace {
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#if defined(GOOGLE_CHROME_BUILD)
// CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb.
const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20,
0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11,
@@ -53,7 +55,7 @@ const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20,
// If we don't have a Pepper Flash component, this is the version we claim.
const char kNullVersion[] = "0.0.0.0";
-#endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#endif // defined(GOOGLE_CHROME_BUILD)
// The base directory on Windows looks like:
// <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\.
@@ -63,7 +65,7 @@ base::FilePath GetPepperFlashBaseDirectory() {
return result;
}
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#if defined(GOOGLE_CHROME_BUILD)
// Pepper Flash plugins have the version encoded in the path itself
// so we need to enumerate the directories to find the full path.
// On success, |latest_dir| returns something like:
@@ -99,8 +101,9 @@ bool GetPepperFlashDirectory(base::FilePath* latest_dir,
}
return found;
}
-#endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#endif // defined(GOOGLE_CHROME_BUILD)
+#if !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD)
jln (very slow on Chromium) 2015/08/06 18:48:14 Why is this needed? Wasn't this building unconditi
Greg K 2015/08/07 21:15:28 On Linux, because PepperFlashComponentInstaller::I
bool MakePepperFlashPluginInfo(const base::FilePath& flash_path,
const Version& flash_version,
bool out_of_process,
@@ -177,6 +180,7 @@ void RegisterPepperFlashWithChrome(const base::FilePath& path,
plugin_info.ToWebPluginInfo(), true);
PluginService::GetInstance()->RefreshPlugins();
}
+#endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD)
} // namespace
@@ -219,24 +223,42 @@ bool PepperFlashComponentInstaller::Install(
return false;
if (current_version_.CompareTo(version) > 0)
return false;
- if (!base::PathExists(unpack_path.Append(chrome::kPepperFlashPluginFilename)))
+ const base::FilePath unpacked_plugin =
+ unpack_path.Append(chrome::kPepperFlashPluginFilename);
+ if (!base::PathExists(unpacked_plugin))
return false;
// Passed the basic tests. Time to install it.
base::FilePath path =
GetPepperFlashBaseDirectory().AppendASCII(version.GetString());
if (base::PathExists(path))
return false;
+ current_version_ = version;
+
if (!base::Move(unpack_path, path))
return false;
+#if defined(OS_LINUX)
+ const base::FilePath flash_path =
+ path.Append(chrome::kPepperFlashPluginFilename);
+ // Populate the component updated flash hint file so that the zygote can
+ // locate and preload the latest version of flash.
+ if (!chrome::ComponentFlashHintFile::RecordFlashUpdate(flash_path, flash_path,
+ version.GetString())) {
+ if (!base::DeleteFile(path, true))
+ LOG(WARNING) << "Hint file creation failed, but unable to delete "
jln (very slow on Chromium) 2015/08/06 18:48:14 I would upgrade to ERROR, but your choice.
Greg K 2015/08/07 21:15:28 Done.
+ "installed flash plugin.";
+ return false;
+ }
+#else
// Installation is done. Now tell the rest of chrome. Both the path service
- // and to the plugin service.
- current_version_ = version;
+ // and to the plugin service. On Linux, a restart is required to use the new
+ // Flash version, so we do not do this.
PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path);
path = path.Append(chrome::kPepperFlashPluginFilename);
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&RegisterPepperFlashWithChrome, path, version));
+#endif // !defined(OS_LINUX)
return true;
}
@@ -254,7 +276,7 @@ bool PepperFlashComponentInstaller::Uninstall() {
namespace {
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#if defined(GOOGLE_CHROME_BUILD)
void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus,
const Version& version) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -311,12 +333,12 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) {
base::DeleteFile(*iter, true);
}
}
-#endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#endif // defined(GOOGLE_CHROME_BUILD)
} // namespace
void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
+#if defined(GOOGLE_CHROME_BUILD)
// Component updated flash supersedes bundled flash therefore if that one
// is disabled then this one should never install.
base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
@@ -325,7 +347,7 @@ void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
base::Bind(&StartPepperFlashUpdateRegistration, cus));
-#endif
+#endif // defined(GOOGLE_CHROME_BUILD)
}
} // namespace component_updater
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | chrome/chrome_common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698