| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
| 23 #include "base/process/kill.h" | 23 #include "base/process/kill.h" |
| 24 #include "base/process/launch.h" | 24 #include "base/process/launch.h" |
| 25 #include "base/process/process.h" | 25 #include "base/process/process.h" |
| 26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "components/component_updater/component_updater_paths.h" | 29 #include "components/component_updater/component_updater_paths.h" |
| 30 #include "components/component_updater/component_updater_service.h" | 30 #include "components/component_updater/component_updater_service.h" |
| 31 #include "components/component_updater/pref_names.h" | 31 #include "components/component_updater/pref_names.h" |
| 32 #include "components/update_client/update_client.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 | 34 |
| 34 using content::BrowserThread; | 35 using content::BrowserThread; |
| 35 | 36 |
| 36 namespace component_updater { | 37 namespace component_updater { |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 // CRX hash. The extension id is: npdjjkjlcidkjlamlmmdelcjbcpdjocm. | 41 // CRX hash. The extension id is: npdjjkjlcidkjlamlmmdelcjbcpdjocm. |
| 41 const uint8_t kSha2Hash[] = {0xdf, 0x39, 0x9a, 0x9b, 0x28, 0x3a, 0x9b, 0x0c, | 42 const uint8_t kSha2Hash[] = {0xdf, 0x39, 0x9a, 0x9b, 0x28, 0x3a, 0x9b, 0x0c, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 166 |
| 166 // Component installer that is responsible to repair the chrome installation | 167 // Component installer that is responsible to repair the chrome installation |
| 167 // or repair the Google update installation. This is a last resort safety | 168 // or repair the Google update installation. This is a last resort safety |
| 168 // mechanism. | 169 // mechanism. |
| 169 // For user Chrome, recovery component just installs silently. For machine | 170 // For user Chrome, recovery component just installs silently. For machine |
| 170 // Chrome, elevation may be needed. If that happens, the installer will set | 171 // Chrome, elevation may be needed. If that happens, the installer will set |
| 171 // preference flag prefs::kRecoveryComponentNeedsElevation to request that. | 172 // preference flag prefs::kRecoveryComponentNeedsElevation to request that. |
| 172 // There is a global error service monitors this flag and will pop up | 173 // There is a global error service monitors this flag and will pop up |
| 173 // bubble if the flag is set to true. | 174 // bubble if the flag is set to true. |
| 174 // See chrome/browser/recovery/recovery_install_global_error.cc for details. | 175 // See chrome/browser/recovery/recovery_install_global_error.cc for details. |
| 175 class RecoveryComponentInstaller : public ComponentInstaller { | 176 class RecoveryComponentInstaller : public update_client::ComponentInstaller { |
| 176 public: | 177 public: |
| 177 RecoveryComponentInstaller(const Version& version, PrefService* prefs); | 178 RecoveryComponentInstaller(const Version& version, PrefService* prefs); |
| 178 ~RecoveryComponentInstaller() override {} | 179 ~RecoveryComponentInstaller() override {} |
| 179 | 180 |
| 180 void OnUpdateError(int error) override; | 181 void OnUpdateError(int error) override; |
| 181 | 182 |
| 182 bool Install(const base::DictionaryValue& manifest, | 183 bool Install(const base::DictionaryValue& manifest, |
| 183 const base::FilePath& unpack_path) override; | 184 const base::FilePath& unpack_path) override; |
| 184 | 185 |
| 185 bool GetInstalledFile(const std::string& file, | 186 bool GetInstalledFile(const std::string& file, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 198 } | 199 } |
| 199 | 200 |
| 200 void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) { | 201 void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) { |
| 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 202 Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); | 203 Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); |
| 203 if (!version.IsValid()) { | 204 if (!version.IsValid()) { |
| 204 NOTREACHED(); | 205 NOTREACHED(); |
| 205 return; | 206 return; |
| 206 } | 207 } |
| 207 | 208 |
| 208 CrxComponent recovery; | 209 update_client::CrxComponent recovery; |
| 209 recovery.name = "recovery"; | 210 recovery.name = "recovery"; |
| 210 recovery.installer = new RecoveryComponentInstaller(version, prefs); | 211 recovery.installer = new RecoveryComponentInstaller(version, prefs); |
| 211 recovery.version = version; | 212 recovery.version = version; |
| 212 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); | 213 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); |
| 213 if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) { | 214 if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) { |
| 214 NOTREACHED() << "Recovery component registration failed."; | 215 NOTREACHED() << "Recovery component registration failed."; |
| 215 } | 216 } |
| 216 } | 217 } |
| 217 | 218 |
| 218 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) { | 219 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 #endif // OS_WIN | 394 #endif // OS_WIN |
| 394 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 395 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 395 } | 396 } |
| 396 | 397 |
| 397 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { | 398 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { |
| 398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 399 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 400 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 400 } | 401 } |
| 401 | 402 |
| 402 } // namespace component_updater | 403 } // namespace component_updater |
| OLD | NEW |