Commit 3406aa57 authored by cpu@chromium.org's avatar cpu@chromium.org

Deploy win flapper via component updater

- Flapper specific installer
- a small bug fix on the updater_configurator
- wired into chrome startup in browser_init
- changes to chrome_paths to override flapper path


TEST=see bug
BUG=89248
Review URL: http://codereview.chromium.org/7604023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96247 0039d316-1c4b-4281-b951-d872f2087c98
parent b29a608b
...@@ -93,7 +93,7 @@ net::URLRequestContextGetter* ChromeConfigurator::RequestContext() { ...@@ -93,7 +93,7 @@ net::URLRequestContextGetter* ChromeConfigurator::RequestContext() {
} }
bool ChromeConfigurator::InProcess() { bool ChromeConfigurator::InProcess() {
return out_of_process_; return !out_of_process_;
} }
ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator(
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/component_updater/pepper_flash_component_installer.h"
#include "base/base_paths.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/values.h"
#include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/common/chrome_paths.h"
#include "content/browser/browser_thread.h"
namespace {
// CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb.
const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20,
0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11,
0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70,
0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c};
// File name of the Pepper Flash plugin on different platforms.
const FilePath::CharType kPepperFlashPluginFileName[] =
#if defined(OS_MACOSX)
FILE_PATH_LITERAL("PepperFlashPlayer.plugin");
#elif defined(OS_WIN)
FILE_PATH_LITERAL("pepflashplayer.dll");
#else // OS_LINUX, etc.
FILE_PATH_LITERAL("libpepflashplayer.so");
#endif
// File name of the Pepper Flash component manifest on different platforms.
const char kPepperFlashManifestName[] =
#if defined(OS_MACOSX)
"MacFlapper";
#elif defined(OS_WIN)
"WinFlapper";
#else // OS_LINUX, etc.
"NixFlapper";
#endif
// The pepper flash plugins are in a directory with this name.
const FilePath::CharType kPepperFlashBaseDirectory[] =
FILE_PATH_LITERAL("PepperFlash");
// If we don't have a flash pepper component, this is the version we claim.
const char kNullVersion[] = "0.0.0.0";
// The base directory on windows looks like:
// <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\.
FilePath GetPepperFlashBaseDirectory() {
FilePath result;
PathService::Get(chrome::DIR_USER_DATA, &result);
return result.Append(kPepperFlashBaseDirectory);
}
// 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 it returns something like:
// <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\.
bool GetLatestPepperFlashDirectory(FilePath* result, Version* latest) {
*result = GetPepperFlashBaseDirectory();
bool found = false;
file_util::FileEnumerator
file_enumerator(*result, false, file_util::FileEnumerator::DIRECTORIES);
for (FilePath path = file_enumerator.Next(); !path.value().empty();
path = file_enumerator.Next()) {
Version version(path.BaseName().MaybeAsASCII());
if (!version.IsValid())
continue;
if (version.CompareTo(*latest) > 0) {
*latest = version;
*result = path;
found = true;
}
}
return found;
}
} // namespace
class PepperFlashComponentInstaller : public ComponentInstaller {
public:
explicit PepperFlashComponentInstaller(const Version& version);
virtual ~PepperFlashComponentInstaller() {}
virtual void OnUpdateError(int error) OVERRIDE;
virtual bool Install(base::DictionaryValue* manifest,
const FilePath& unpack_path) OVERRIDE;
private:
Version current_version_;
};
PepperFlashComponentInstaller::PepperFlashComponentInstaller(
const Version& version) : current_version_(version) {
DCHECK(version.IsValid());
}
void PepperFlashComponentInstaller::OnUpdateError(int error) {
NOTREACHED() << "pepper flash update error :" << error;
}
bool PepperFlashComponentInstaller::Install(base::DictionaryValue* manifest,
const FilePath& unpack_path) {
std::string name;
manifest->GetStringASCII("name", &name);
if (name != kPepperFlashManifestName)
return false;
std::string proposed_version;
manifest->GetStringASCII("version", &proposed_version);
Version version(proposed_version.c_str());
if (!version.IsValid())
return false;
if (current_version_.CompareTo(version) > 0)
return false;
if (!file_util::PathExists(unpack_path.Append(kPepperFlashPluginFileName)))
return false;
// Passed the basic tests. Time to install it.
FilePath path =
GetPepperFlashBaseDirectory().AppendASCII(version.GetString());
if (file_util::PathExists(path))
return false;
if (!file_util::Move(unpack_path, path))
return false;
// Installation is done. Now update the path service.
current_version_ = version;
path = path.Append(kPepperFlashPluginFileName);
PathService::Override(chrome::FILE_PEPPER_FLASH_PLUGIN, path);
return true;
}
void FinishPepperFlashRegistration(ComponentUpdateService* cus,
const Version& version) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CrxComponent pepflash;
pepflash.name = "pepper_flash";
pepflash.installer = new PepperFlashComponentInstaller(version);
pepflash.version = version;
pepflash.pk_hash.assign(sha2_hash, &sha2_hash[sizeof(sha2_hash)]);
if (cus->RegisterComponent(pepflash) != ComponentUpdateService::kOk) {
NOTREACHED() << "pepper flash component registration fail";
}
}
void StartPepperFlashRegistration(ComponentUpdateService* cus) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath path = GetPepperFlashBaseDirectory();
if (!file_util::PathExists(path)) {
if (!file_util::CreateDirectory(path)) {
NOTREACHED() << "cannot create pepper flash directory";
return;
}
}
Version version(kNullVersion);
if (GetLatestPepperFlashDirectory(&path, &version)) {
path = path.Append(kPepperFlashPluginFileName);
if (file_util::PathExists(path))
PathService::Override(chrome::FILE_PEPPER_FLASH_PLUGIN, path);
else
version = Version(kNullVersion);
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
NewRunnableFunction(&FinishPepperFlashRegistration, cus, version));
}
void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// TODO(cpu): support Mac and Linux flash pepper.
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
NewRunnableFunction(&StartPepperFlashRegistration, cus));
#endif
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_COMPONENT_UPDATER_PEPPER_FLASH_COMPONENT_INSTALLER_H_
#define CHROME_BROWSER_COMPONENT_UPDATER_PEPPER_FLASH_COMPONENT_INSTALLER_H_
#pragma once
class ComponentUpdateService;
class FilePath;
// Our job is to 1) find what pepper flash is installed (if any) and 2) register
// with the component updater to download the latest version when available.
// The first part is IO intensive so we do it asynchronously in the file thread.
void RegisterPepperFlashComponent(ComponentUpdateService* cus);
#endif // CHROME_BROWSER_COMPONENT_UPDATER_PEPPER_FLASH_COMPONENT_INSTALLER_H_
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
#include "chrome/browser/automation/chrome_frame_automation_provider.h" #include "chrome/browser/automation/chrome_frame_automation_provider.h"
#include "chrome/browser/automation/testing_automation_provider.h" #include "chrome/browser/automation/testing_automation_provider.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/defaults.h" #include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/browser/component_updater/pepper_flash_component_installer.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_creator.h" #include "chrome/browser/extensions/extension_creator.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/pack_extension_job.h" #include "chrome/browser/extensions/pack_extension_job.h"
...@@ -510,6 +512,17 @@ void RecordAppLaunches( ...@@ -510,6 +512,17 @@ void RecordAppLaunches(
} }
} }
void RegisterComponentsForUpdate() {
ComponentUpdateService* cus = g_browser_process->component_updater();
if (!cus)
return;
// Registration can be before of after cus->Start() so it is ok to post
// a task to the UI thread to do registration once you done the necessary
// file IO to know your current version.
RegisterPepperFlashComponent(cus);
cus->Start();
}
} // namespace } // namespace
...@@ -1334,6 +1347,8 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line, ...@@ -1334,6 +1347,8 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
if (command_line.HasSwitch(switches::kDisablePromptOnRepost)) if (command_line.HasSwitch(switches::kDisablePromptOnRepost))
NavigationController::DisablePromptOnRepost(); NavigationController::DisablePromptOnRepost();
RegisterComponentsForUpdate();
// Look for the testing channel ID ONLY during process startup // Look for the testing channel ID ONLY during process startup
if (command_line.HasSwitch(switches::kTestingChannelID)) { if (command_line.HasSwitch(switches::kTestingChannelID)) {
std::string testing_channel_id = command_line.GetSwitchValueASCII( std::string testing_channel_id = command_line.GetSwitchValueASCII(
......
...@@ -787,6 +787,8 @@ ...@@ -787,6 +787,8 @@
'browser/component_updater/component_unpacker.h', 'browser/component_updater/component_unpacker.h',
'browser/component_updater/component_updater_service.cc', 'browser/component_updater/component_updater_service.cc',
'browser/component_updater/component_updater_service.h', 'browser/component_updater/component_updater_service.h',
'browser/component_updater/pepper_flash_component_installer.cc',
'browser/component_updater/pepper_flash_component_installer.h',
'browser/content_settings/content_settings_details.cc', 'browser/content_settings/content_settings_details.cc',
'browser/content_settings/content_settings_details.h', 'browser/content_settings/content_settings_details.h',
'browser/content_settings/content_settings_extension_provider.cc', 'browser/content_settings/content_settings_extension_provider.cc',
......
...@@ -31,20 +31,6 @@ const FilePath::CharType kInternalFlashPluginFileName[] = ...@@ -31,20 +31,6 @@ const FilePath::CharType kInternalFlashPluginFileName[] =
FILE_PATH_LITERAL("libgcflashplayer.so"); FILE_PATH_LITERAL("libgcflashplayer.so");
#endif #endif
// File name of the pepper Flash plugin on different platforms.
const FilePath::CharType kPepperFlashPluginFileName[] =
#if defined(OS_MACOSX)
FILE_PATH_LITERAL("PepperFlashPlayer.plugin");
#elif defined(OS_WIN)
FILE_PATH_LITERAL("pepflashplayer.dll");
#else // OS_LINUX, etc.
FILE_PATH_LITERAL("libpepflashplayer.so");
#endif
// The pepper flash plugins are in a directory with this name.
const FilePath::CharType kPepperFlashBaseDirectory[] =
FILE_PATH_LITERAL("PepperFlash");
// File name of the internal PDF plugin on different platforms. // File name of the internal PDF plugin on different platforms.
const FilePath::CharType kInternalPDFPluginFileName[] = const FilePath::CharType kInternalPDFPluginFileName[] =
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -88,30 +74,6 @@ bool GetInternalPluginsDirectory(FilePath* result) { ...@@ -88,30 +74,6 @@ bool GetInternalPluginsDirectory(FilePath* result) {
return PathService::Get(base::DIR_MODULE, result); return PathService::Get(base::DIR_MODULE, result);
} }
// Pepper flash plugins have the version encoded in the path itself
// so we need to enumerate the directories to find the full path
bool GetPepperFlashDirectory(FilePath* result) {
if (!GetInternalPluginsDirectory(result))
return false;
*result = result->Append(kPepperFlashBaseDirectory);
Version latest("0.0");
bool found = false;
file_util::FileEnumerator
file_enumerator(*result, false, file_util::FileEnumerator::DIRECTORIES);
for (FilePath path = file_enumerator.Next(); !path.value().empty();
path = file_enumerator.Next()) {
Version version(path.BaseName().MaybeAsASCII());
if (!version.IsValid())
continue;
if (version.CompareTo(latest) > 0) {
latest = version;
*result = path;
found = true;
}
}
return found;
}
bool PathProvider(int key, FilePath* result) { bool PathProvider(int key, FilePath* result) {
// Some keys are just aliases... // Some keys are just aliases...
switch (key) { switch (key) {
...@@ -260,10 +222,6 @@ bool PathProvider(int key, FilePath* result) { ...@@ -260,10 +222,6 @@ bool PathProvider(int key, FilePath* result) {
return false; return false;
break; break;
case chrome::FILE_PEPPER_FLASH_PLUGIN: case chrome::FILE_PEPPER_FLASH_PLUGIN:
if (!GetPepperFlashDirectory(&cur))
return false;
cur = cur.Append(kPepperFlashPluginFileName);
if (!file_util::PathExists(cur))
return false; return false;
break; break;
case chrome::FILE_PDF_PLUGIN: case chrome::FILE_PDF_PLUGIN:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment