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

Side by Side Diff: chrome/browser/component_updater/recovery_component_installer.cc

Issue 14320035: Minor code cleanup of component updater. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/component_updater/recovery_component_installer.h" 5 #include "chrome/browser/component_updater/recovery_component_installer.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/process_util.h" 17 #include "base/process_util.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/component_updater/component_updater_service.h" 20 #include "chrome/browser/component_updater/component_updater_service.h"
21 #include "chrome/common/chrome_version_info.h" 21 #include "chrome/common/chrome_version_info.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 24
25 using content::BrowserThread; 25 using content::BrowserThread;
26 26
27 namespace { 27 namespace {
28 28
29 // CRX hash. The extension id is: npdjjkjlcidkjlamlmmdelcjbcpdjocm. 29 // CRX hash. The extension id is: npdjjkjlcidkjlamlmmdelcjbcpdjocm.
30 const uint8 sha2_hash[] = {0xdf, 0x39, 0x9a, 0x9b, 0x28, 0x3a, 0x9b, 0x0c, 30 const uint8 kSha2Hash[] = {0xdf, 0x39, 0x9a, 0x9b, 0x28, 0x3a, 0x9b, 0x0c,
31 0xbc, 0xc3, 0x4b, 0x29, 0x12, 0xf3, 0x9e, 0x2c, 31 0xbc, 0xc3, 0x4b, 0x29, 0x12, 0xf3, 0x9e, 0x2c,
32 0x19, 0x7a, 0x71, 0x4b, 0x0a, 0x7c, 0x80, 0x1c, 32 0x19, 0x7a, 0x71, 0x4b, 0x0a, 0x7c, 0x80, 0x1c,
33 0xf6, 0x29, 0x7c, 0x0a, 0x5f, 0xea, 0x67, 0xb7}; 33 0xf6, 0x29, 0x7c, 0x0a, 0x5f, 0xea, 0x67, 0xb7};
34 34
35 // File name of the recovery binary on different platforms. 35 // File name of the recovery binary on different platforms.
36 const base::FilePath::CharType kRecoveryFileName[] = 36 const base::FilePath::CharType kRecoveryFileName[] =
37 #if defined(OS_WIN) 37 #if defined(OS_WIN)
38 FILE_PATH_LITERAL("ChromeRecovery.exe"); 38 FILE_PATH_LITERAL("ChromeRecovery.exe");
39 #else // OS_LINUX, OS_MACOSX, etc. 39 #else // OS_LINUX, OS_MACOSX, etc.
40 FILE_PATH_LITERAL("ChromeRecovery"); 40 FILE_PATH_LITERAL("ChromeRecovery");
(...skipping 26 matching lines...) Expand all
67 Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); 67 Version version(prefs->GetString(prefs::kRecoveryComponentVersion));
68 if (!version.IsValid()) { 68 if (!version.IsValid()) {
69 NOTREACHED(); 69 NOTREACHED();
70 return; 70 return;
71 } 71 }
72 72
73 CrxComponent recovery; 73 CrxComponent recovery;
74 recovery.name = "recovery"; 74 recovery.name = "recovery";
75 recovery.installer = new RecoveryComponentInstaller(version, prefs); 75 recovery.installer = new RecoveryComponentInstaller(version, prefs);
76 recovery.version = version; 76 recovery.version = version;
77 recovery.pk_hash.assign(sha2_hash, &sha2_hash[sizeof(sha2_hash)]); 77 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]);
78 if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) { 78 if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) {
79 NOTREACHED() << "Recovery component registration failed."; 79 NOTREACHED() << "Recovery component registration failed.";
80 } 80 }
81 } 81 }
82 82
83 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) { 83 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) {
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
85 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString()); 85 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString());
86 } 86 }
87 87
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 BrowserThread::UI, 139 BrowserThread::UI,
140 FROM_HERE, 140 FROM_HERE,
141 base::Bind(&RecoveryRegisterHelper, cus, prefs), 141 base::Bind(&RecoveryRegisterHelper, cus, prefs),
142 base::TimeDelta::FromSeconds(6)); 142 base::TimeDelta::FromSeconds(6));
143 #endif 143 #endif
144 } 144 }
145 145
146 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) { 146 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) {
147 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0"); 147 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0");
148 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698