| 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> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 if (!base::PathExists(main_file) || !base::PathExists(manifest_file)) | 166 if (!base::PathExists(main_file) || !base::PathExists(manifest_file)) |
| 167 return; | 167 return; |
| 168 | 168 |
| 169 std::unique_ptr<base::DictionaryValue> manifest(ReadManifest(manifest_file)); | 169 std::unique_ptr<base::DictionaryValue> manifest(ReadManifest(manifest_file)); |
| 170 std::string name; | 170 std::string name; |
| 171 manifest->GetStringASCII("name", &name); | 171 manifest->GetStringASCII("name", &name); |
| 172 if (name != kRecoveryManifestName) | 172 if (name != kRecoveryManifestName) |
| 173 return; | 173 return; |
| 174 std::string proposed_version; | 174 std::string proposed_version; |
| 175 manifest->GetStringASCII("version", &proposed_version); | 175 manifest->GetStringASCII("version", &proposed_version); |
| 176 const base::Version version(proposed_version.c_str()); | 176 const base::Version version(proposed_version); |
| 177 if (!version.IsValid()) | 177 if (!version.IsValid()) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 const bool is_deferred_run = true; | 180 const bool is_deferred_run = true; |
| 181 #if defined(OS_WIN) | 181 #if defined(OS_WIN) |
| 182 const auto cmdline = BuildRecoveryInstallCommandLine( | 182 const auto cmdline = BuildRecoveryInstallCommandLine( |
| 183 main_file, *manifest, is_deferred_run, version); | 183 main_file, *manifest, is_deferred_run, version); |
| 184 | 184 |
| 185 RecordRecoveryComponentUMAEvent(RCE_RUNNING_ELEVATED); | 185 RecordRecoveryComponentUMAEvent(RCE_RUNNING_ELEVATED); |
| 186 | 186 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 bool RecoveryComponentInstaller::DoInstall( | 421 bool RecoveryComponentInstaller::DoInstall( |
| 422 const base::DictionaryValue& manifest, | 422 const base::DictionaryValue& manifest, |
| 423 const base::FilePath& unpack_path) { | 423 const base::FilePath& unpack_path) { |
| 424 std::string name; | 424 std::string name; |
| 425 manifest.GetStringASCII("name", &name); | 425 manifest.GetStringASCII("name", &name); |
| 426 if (name != kRecoveryManifestName) | 426 if (name != kRecoveryManifestName) |
| 427 return false; | 427 return false; |
| 428 std::string proposed_version; | 428 std::string proposed_version; |
| 429 manifest.GetStringASCII("version", &proposed_version); | 429 manifest.GetStringASCII("version", &proposed_version); |
| 430 base::Version version(proposed_version.c_str()); | 430 base::Version version(proposed_version); |
| 431 if (!version.IsValid()) | 431 if (!version.IsValid()) |
| 432 return false; | 432 return false; |
| 433 if (current_version_.CompareTo(version) >= 0) | 433 if (current_version_.CompareTo(version) >= 0) |
| 434 return false; | 434 return false; |
| 435 | 435 |
| 436 // Passed the basic tests. Copy the installation to a permanent directory. | 436 // Passed the basic tests. Copy the installation to a permanent directory. |
| 437 base::FilePath path; | 437 base::FilePath path; |
| 438 if (!PathService::Get(DIR_RECOVERY_BASE, &path)) | 438 if (!PathService::Get(DIR_RECOVERY_BASE, &path)) |
| 439 return false; | 439 return false; |
| 440 if (!base::PathExists(path) && !base::CreateDirectory(path)) | 440 if (!base::PathExists(path) && !base::CreateDirectory(path)) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 #endif // OS_WIN | 527 #endif // OS_WIN |
| 528 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 528 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { | 531 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { |
| 532 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 532 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 533 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 533 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 534 } | 534 } |
| 535 | 535 |
| 536 } // namespace component_updater | 536 } // namespace component_updater |
| OLD | NEW |