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

Unified Diff: chrome/browser/component_updater/recovery_component_installer.cc

Issue 334783002: Componentize component_updater: Move some paths/constants to component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
Index: chrome/browser/component_updater/recovery_component_installer.cc
diff --git a/chrome/browser/component_updater/recovery_component_installer.cc b/chrome/browser/component_updater/recovery_component_installer.cc
index 4baa3666db5b1d6e3a8e2e4ab269c5ae4fb8d7f7..d70393d4897f741363752502bd4bfd19a78a1058 100644
--- a/chrome/browser/component_updater/recovery_component_installer.cc
+++ b/chrome/browser/component_updater/recovery_component_installer.cc
@@ -20,9 +20,7 @@
#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/component_updater/component_updater_service.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/pref_names.h"
+#include "components/component_updater/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@@ -52,7 +50,8 @@ const char kRecoveryManifestName[] = "ChromeRecovery";
class RecoveryComponentInstaller : public ComponentInstaller {
public:
explicit RecoveryComponentInstaller(const Version& version,
- PrefService* prefs);
+ PrefService* prefs,
+ const base::FilePath& base_dir);
virtual ~RecoveryComponentInstaller() {}
@@ -67,9 +66,11 @@ class RecoveryComponentInstaller : public ComponentInstaller {
private:
Version current_version_;
PrefService* prefs_;
+ base::FilePath base_dir_;
};
-void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) {
+void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs,
+ const base::FilePath& base_dir) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
Version version(prefs->GetString(prefs::kRecoveryComponentVersion));
if (!version.IsValid()) {
@@ -79,7 +80,8 @@ void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) {
CrxComponent recovery;
recovery.name = "recovery";
- recovery.installer = new RecoveryComponentInstaller(version, prefs);
+ recovery.installer = new RecoveryComponentInstaller(version, prefs,
+ base_dir);
recovery.version = version;
recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]);
if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) {
@@ -92,9 +94,13 @@ void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) {
prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString());
}
-RecoveryComponentInstaller::RecoveryComponentInstaller(const Version& version,
- PrefService* prefs)
- : current_version_(version), prefs_(prefs) {
+RecoveryComponentInstaller::RecoveryComponentInstaller(
+ const Version& version,
+ PrefService* prefs,
+ const base::FilePath& base_dir)
+ : current_version_(version),
+ prefs_(prefs),
+ base_dir_(base_dir) {
DCHECK(version.IsValid());
}
@@ -117,10 +123,8 @@ bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest,
return false;
// Passed the basic tests. Copy the installation to a permanent directory.
- base::FilePath path;
- if (!PathService::Get(chrome::DIR_RECOVERY_BASE, &path))
- return false;
- path = path.AppendASCII(version.GetString());
+ base::FilePath path =
+ base_dir_.AppendASCII(version.GetString());
if (base::PathExists(path) && !base::DeleteFile(path, true))
return false;
if (!base::Move(unpack_path, path)) {
@@ -158,14 +162,15 @@ bool RecoveryComponentInstaller::GetInstalledFile(
}
void RegisterRecoveryComponent(ComponentUpdateService* cus,
- PrefService* prefs) {
+ PrefService* prefs,
+ const base::FilePath& base_dir) {
#if !defined(OS_CHROMEOS)
// We delay execute the registration because we are not required in
// the critical path during browser startup.
BrowserThread::PostDelayedTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&RecoveryRegisterHelper, cus, prefs),
+ base::Bind(&RecoveryRegisterHelper, cus, prefs, base_dir),
base::TimeDelta::FromSeconds(6));
#endif
}

Powered by Google App Engine
This is Rietveld 408576698