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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 bool RecoveryComponentInstaller::DoInstall( | 412 bool RecoveryComponentInstaller::DoInstall( |
413 const base::DictionaryValue& manifest, | 413 const base::DictionaryValue& manifest, |
414 const base::FilePath& unpack_path) { | 414 const base::FilePath& unpack_path) { |
415 std::string name; | 415 std::string name; |
416 manifest.GetStringASCII("name", &name); | 416 manifest.GetStringASCII("name", &name); |
417 if (name != kRecoveryManifestName) | 417 if (name != kRecoveryManifestName) |
418 return false; | 418 return false; |
419 std::string proposed_version; | 419 std::string proposed_version; |
420 manifest.GetStringASCII("version", &proposed_version); | 420 manifest.GetStringASCII("version", &proposed_version); |
421 base::Version version(proposed_version.c_str()); | 421 base::Version version(proposed_version); |
422 if (!version.IsValid()) | 422 if (!version.IsValid()) |
423 return false; | 423 return false; |
424 if (current_version_.CompareTo(version) >= 0) | 424 if (current_version_.CompareTo(version) >= 0) |
425 return false; | 425 return false; |
426 | 426 |
427 // Passed the basic tests. Copy the installation to a permanent directory. | 427 // Passed the basic tests. Copy the installation to a permanent directory. |
428 base::FilePath path; | 428 base::FilePath path; |
429 if (!PathService::Get(DIR_RECOVERY_BASE, &path)) | 429 if (!PathService::Get(DIR_RECOVERY_BASE, &path)) |
430 return false; | 430 return false; |
431 if (!base::PathExists(path) && !base::CreateDirectory(path)) | 431 if (!base::PathExists(path) && !base::CreateDirectory(path)) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 527 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
528 } | 528 } |
529 | 529 |
530 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { | 530 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { |
531 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 531 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
532 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 532 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
533 } | 533 } |
534 | 534 |
535 } // namespace component_updater | 535 } // namespace component_updater |
OLD | NEW |