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

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: 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
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | chrome/common/chrome_content_client.cc » ('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..c9dc6ca04f61a7d59a374975dc8aae04bf69ab62 100644
--- a/chrome/browser/component_updater/pepper_flash_component_installer.cc
+++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc
@@ -13,8 +13,11 @@
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/files/important_file_writer.h"
rickyz (no longer on Chrome) 2015/07/31 00:13:56 Are these still used in this file?
Greg K 2015/08/04 00:21:16 Done.
+#include "base/files/memory_mapped_file.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 +28,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"
@@ -33,6 +37,7 @@
#include "content/public/browser/plugin_service.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/pepper_plugin_info.h"
+#include "crypto/sha2.h"
#include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT
#include "ppapi/shared_impl/ppapi_permissions.h"
@@ -43,7 +48,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 +58,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 +68,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 +104,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)
bool MakePepperFlashPluginInfo(const base::FilePath& flash_path,
const Version& flash_version,
bool out_of_process,
@@ -177,6 +183,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 +226,47 @@ bool PepperFlashComponentInstaller::Install(
return false;
if (current_version_.CompareTo(version) > 0)
return false;
- if (!base::PathExists(unpack_path.Append(chrome::kPepperFlashPluginFilename)))
+ 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 defined(OS_LINUX)
+ // Populate the component updated flash hint file so that the zygote can
+ // locate and preload the latest version of flash.
+ base::FilePath flash_path = path.Append(chrome::kPepperFlashPluginFilename);
+ chrome::ComponentFlashHintFile hint_file;
+ if (!hint_file.RecordFlashUpdate(unpacked_plugin, flash_path,
rickyz (no longer on Chrome) 2015/07/31 00:13:56 I'd probably prefer to write the new flash library
Greg K 2015/08/04 00:21:17 It's a valid point. As you say, I will need to mak
+ version.GetString()))
+ return false;
+
+ if (!base::Move(unpack_path, path)) {
+ // If the install failed, try to put the previous hint file back.
+ if (!hint_file.Revert())
+ LOG(WARNING) << "Could not move updated component flash into place, and "
+ "failed to revert the component flash hint file.";
+ return false;
+ }
+#else
if (!base::Move(unpack_path, path))
return false;
+ path = path.Append(chrome::kPepperFlashPluginFilename);
// 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 +284,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 +341,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();
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | chrome/common/chrome_content_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698