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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 Version version(proposed_version.c_str()); | 113 Version version(proposed_version.c_str()); |
114 if (!version.IsValid()) | 114 if (!version.IsValid()) |
115 return false; | 115 return false; |
116 if (current_version_.CompareTo(version) >= 0) | 116 if (current_version_.CompareTo(version) >= 0) |
117 return false; | 117 return false; |
118 | 118 |
119 // Passed the basic tests. Copy the installation to a permanent directory. | 119 // Passed the basic tests. Copy the installation to a permanent directory. |
120 base::FilePath path; | 120 base::FilePath path; |
121 if (!PathService::Get(DIR_RECOVERY_BASE, &path)) | 121 if (!PathService::Get(DIR_RECOVERY_BASE, &path)) |
122 return false; | 122 return false; |
| 123 if (!base::PathExists(path)) { |
| 124 if (!base::CreateDirectory(path)) { |
| 125 return false; |
| 126 } |
| 127 } |
123 path = path.AppendASCII(version.GetString()); | 128 path = path.AppendASCII(version.GetString()); |
124 if (base::PathExists(path) && !base::DeleteFile(path, true)) | 129 if (base::PathExists(path) && !base::DeleteFile(path, true)) |
125 return false; | 130 return false; |
126 if (!base::Move(unpack_path, path)) { | 131 if (!base::Move(unpack_path, path)) { |
127 DVLOG(1) << "Recovery component move failed."; | 132 DVLOG(1) << "Recovery component move failed."; |
128 return false; | 133 return false; |
129 } | 134 } |
130 | 135 |
131 base::FilePath main_file = path.Append(kRecoveryFileName); | 136 base::FilePath main_file = path.Append(kRecoveryFileName); |
132 if (!base::PathExists(main_file)) | 137 if (!base::PathExists(main_file)) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 base::Bind(&RecoveryRegisterHelper, cus, prefs), | 173 base::Bind(&RecoveryRegisterHelper, cus, prefs), |
169 base::TimeDelta::FromSeconds(6)); | 174 base::TimeDelta::FromSeconds(6)); |
170 #endif | 175 #endif |
171 } | 176 } |
172 | 177 |
173 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) { | 178 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) { |
174 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0"); | 179 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0"); |
175 } | 180 } |
176 | 181 |
177 } // namespace component_updater | 182 } // namespace component_updater |
OLD | NEW |