OLD | NEW |
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_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.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/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/component_updater/component_updater_service.h" | 18 #include "chrome/browser/component_updater/component_updater_service.h" |
| 19 #include "chrome/browser/prefs/pref_registry_simple.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
23 | 24 |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // CRX hash. The extension id is: npdjjkjlcidkjlamlmmdelcjbcpdjocm. | 29 // CRX hash. The extension id is: npdjjkjlcidkjlamlmmdelcjbcpdjocm. |
(...skipping 25 matching lines...) Expand all Loading... |
54 | 55 |
55 virtual bool Install(base::DictionaryValue* manifest, | 56 virtual bool Install(base::DictionaryValue* manifest, |
56 const FilePath& unpack_path) OVERRIDE; | 57 const FilePath& unpack_path) OVERRIDE; |
57 | 58 |
58 private: | 59 private: |
59 Version current_version_; | 60 Version current_version_; |
60 PrefService* prefs_; | 61 PrefService* prefs_; |
61 }; | 62 }; |
62 | 63 |
63 void RecoveryRegisterHelper(ComponentUpdateService* cus, | 64 void RecoveryRegisterHelper(ComponentUpdateService* cus, |
64 PrefServiceSimple* prefs) { | 65 PrefService* prefs) { |
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
66 // TODO(joi): Registrations for local state prefs shouldn't happen | 67 // TODO(joi): Registrations for local state prefs shouldn't happen |
67 // like this, they should be done via | 68 // like this, they should be done via |
68 // browser_prefs::RegisterLocalState. | 69 // browser_prefs::RegisterLocalState. |
69 prefs->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0"); | 70 static_cast<PrefRegistrySimple*>( |
| 71 prefs->DeprecatedGetPrefRegistry())->RegisterStringPref( |
| 72 prefs::kRecoveryComponentVersion, "0.0.0.0"); |
70 Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); | 73 Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); |
71 if (!version.IsValid()) { | 74 if (!version.IsValid()) { |
72 NOTREACHED(); | 75 NOTREACHED(); |
73 return; | 76 return; |
74 } | 77 } |
75 | 78 |
76 CrxComponent recovery; | 79 CrxComponent recovery; |
77 recovery.name = "recovery"; | 80 recovery.name = "recovery"; |
78 recovery.installer = new RecoveryComponentInstaller(version, prefs); | 81 recovery.installer = new RecoveryComponentInstaller(version, prefs); |
79 recovery.version = version; | 82 recovery.version = version; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 130 } |
128 current_version_ = version; | 131 current_version_ = version; |
129 if (prefs_) { | 132 if (prefs_) { |
130 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 133 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
131 base::Bind(&RecoveryUpdateVersionHelper, version, prefs_)); | 134 base::Bind(&RecoveryUpdateVersionHelper, version, prefs_)); |
132 } | 135 } |
133 return base::LaunchProcess(cmdline, base::LaunchOptions(), NULL); | 136 return base::LaunchProcess(cmdline, base::LaunchOptions(), NULL); |
134 } | 137 } |
135 | 138 |
136 void RegisterRecoveryComponent(ComponentUpdateService* cus, | 139 void RegisterRecoveryComponent(ComponentUpdateService* cus, |
137 PrefServiceSimple* prefs) { | 140 PrefService* prefs) { |
138 #if !defined(OS_CHROMEOS) | 141 #if !defined(OS_CHROMEOS) |
139 // We delay execute the registration because we are not required in | 142 // We delay execute the registration because we are not required in |
140 // the critical path during browser startup. | 143 // the critical path during browser startup. |
141 BrowserThread::PostDelayedTask( | 144 BrowserThread::PostDelayedTask( |
142 BrowserThread::UI, | 145 BrowserThread::UI, |
143 FROM_HERE, | 146 FROM_HERE, |
144 base::Bind(&RecoveryRegisterHelper, cus, prefs), | 147 base::Bind(&RecoveryRegisterHelper, cus, prefs), |
145 base::TimeDelta::FromSeconds(6)); | 148 base::TimeDelta::FromSeconds(6)); |
146 #endif | 149 #endif |
147 } | 150 } |
OLD | NEW |