| 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 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/json/json_file_value_serializer.h" | 18 #include "base/json/json_file_value_serializer.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/process/kill.h" | 22 #include "base/process/kill.h" |
| 23 #include "base/process/launch.h" | 23 #include "base/process/launch.h" |
| 24 #include "base/process/process.h" | 24 #include "base/process/process.h" |
| 25 #include "base/threading/worker_pool.h" | 25 #include "base/threading/worker_pool.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.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 #if defined(OS_WIN) | |
| 30 #include "chrome/installer/util/install_util.h" | |
| 31 #endif // OS_WIN | |
| 32 #include "components/component_updater/component_updater_paths.h" | 29 #include "components/component_updater/component_updater_paths.h" |
| 33 #include "components/component_updater/component_updater_service.h" | 30 #include "components/component_updater/component_updater_service.h" |
| 34 #include "components/component_updater/pref_names.h" | 31 #include "components/component_updater/pref_names.h" |
| 35 #include "components/prefs/pref_registry_simple.h" | 32 #include "components/prefs/pref_registry_simple.h" |
| 36 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
| 37 #include "components/update_client/update_client.h" | 34 #include "components/update_client/update_client.h" |
| 38 #include "components/update_client/utils.h" | 35 #include "components/update_client/utils.h" |
| 39 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 40 | 37 |
| 41 using content::BrowserThread; | 38 using content::BrowserThread; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, true); | 225 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, true); |
| 229 } | 226 } |
| 230 | 227 |
| 231 void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) { | 228 void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) { |
| 232 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 229 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 233 base::Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); | 230 base::Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); |
| 234 if (!version.IsValid()) { | 231 if (!version.IsValid()) { |
| 235 NOTREACHED(); | 232 NOTREACHED(); |
| 236 return; | 233 return; |
| 237 } | 234 } |
| 238 | |
| 239 update_client::InstallerAttributes installer_attributes; | |
| 240 #if defined(OS_WIN) | |
| 241 base::FilePath exe_path; | |
| 242 PathService::Get(base::FILE_EXE, &exe_path); | |
| 243 installer_attributes["ismachine"] = | |
| 244 InstallUtil::IsPerUserInstall(exe_path) ? "0" : "1"; | |
| 245 #endif // OS_WIN | |
| 246 | |
| 247 update_client::CrxComponent recovery; | 235 update_client::CrxComponent recovery; |
| 248 recovery.name = "recovery"; | 236 recovery.name = "recovery"; |
| 249 recovery.installer = new RecoveryComponentInstaller(version, prefs); | 237 recovery.installer = new RecoveryComponentInstaller(version, prefs); |
| 250 recovery.version = version; | 238 recovery.version = version; |
| 251 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); | 239 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); |
| 252 recovery.supports_group_policy_enable_component_updates = true; | 240 recovery.supports_group_policy_enable_component_updates = true; |
| 253 recovery.requires_network_encryption = false; | 241 recovery.requires_network_encryption = false; |
| 254 recovery.installer_attributes = installer_attributes; | |
| 255 if (!cus->RegisterComponent(recovery)) { | 242 if (!cus->RegisterComponent(recovery)) { |
| 256 NOTREACHED() << "Recovery component registration failed."; | 243 NOTREACHED() << "Recovery component registration failed."; |
| 257 } | 244 } |
| 258 } | 245 } |
| 259 | 246 |
| 260 void RecoveryUpdateVersionHelper( | 247 void RecoveryUpdateVersionHelper( |
| 261 const base::Version& version, PrefService* prefs) { | 248 const base::Version& version, PrefService* prefs) { |
| 262 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 249 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 263 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString()); | 250 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString()); |
| 264 } | 251 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 #endif // OS_WIN | 457 #endif // OS_WIN |
| 471 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 458 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 472 } | 459 } |
| 473 | 460 |
| 474 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { | 461 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { |
| 475 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 462 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 476 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 463 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 477 } | 464 } |
| 478 | 465 |
| 479 } // namespace component_updater | 466 } // namespace component_updater |
| OLD | NEW |