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/installer/util/google_update_settings.h" | 5 #include "chrome/installer/util/google_update_settings.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 case GoogleUpdateSettings::AUTO_UPDATES_ONLY: | 215 case GoogleUpdateSettings::AUTO_UPDATES_ONLY: |
216 *update_policy = static_cast<GoogleUpdateSettings::UpdatePolicy>(value); | 216 *update_policy = static_cast<GoogleUpdateSettings::UpdatePolicy>(value); |
217 return true; | 217 return true; |
218 default: | 218 default: |
219 LOG(WARNING) << "Unexpected update policy override value: " << value; | 219 LOG(WARNING) << "Unexpected update policy override value: " << value; |
220 } | 220 } |
221 return false; | 221 return false; |
222 } | 222 } |
223 #endif // defined(GOOGLE_CHROME_BUILD) | 223 #endif // defined(GOOGLE_CHROME_BUILD) |
224 | 224 |
| 225 bool UpdateDidRunStateForApp(const AppRegistrationData& app_reg_data, |
| 226 bool did_run) { |
| 227 return WriteGoogleUpdateStrKeyInternal( |
| 228 app_reg_data, google_update::kRegDidRunField, did_run ? L"1" : L"0"); |
| 229 } |
| 230 |
225 // Convenience routine: GoogleUpdateSettings::UpdateDidRunStateForApp() | 231 // Convenience routine: GoogleUpdateSettings::UpdateDidRunStateForApp() |
226 // specialized for Chrome Binaries. | 232 // specialized for Chrome Binaries. |
227 bool UpdateDidRunStateForBinaries(bool did_run) { | 233 bool UpdateDidRunStateForBinaries(bool did_run) { |
228 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 234 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
229 BrowserDistribution::CHROME_BINARIES); | 235 BrowserDistribution::CHROME_BINARIES); |
230 return GoogleUpdateSettings::UpdateDidRunStateForApp( | 236 return UpdateDidRunStateForApp(dist->GetAppRegistrationData(), did_run); |
231 dist->GetAppRegistrationData(), did_run); | |
232 } | 237 } |
233 | 238 |
234 } // namespace | 239 } // namespace |
235 | 240 |
236 bool GoogleUpdateSettings::IsSystemInstall() { | 241 bool GoogleUpdateSettings::IsSystemInstall() { |
237 bool system_install = false; | 242 bool system_install = false; |
238 base::FilePath module_dir; | 243 base::FilePath module_dir; |
239 if (!PathService::Get(base::DIR_MODULE, &module_dir)) { | 244 if (!PathService::Get(base::DIR_MODULE, &module_dir)) { |
240 LOG(WARNING) | 245 LOG(WARNING) |
241 << "Failed to get directory of module; assuming per-user install."; | 246 << "Failed to get directory of module; assuming per-user install."; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 477 } |
473 | 478 |
474 bool GoogleUpdateSettings::GetReferral(base::string16* referral) { | 479 bool GoogleUpdateSettings::GetReferral(base::string16* referral) { |
475 return ReadGoogleUpdateStrKey(google_update::kRegReferralField, referral); | 480 return ReadGoogleUpdateStrKey(google_update::kRegReferralField, referral); |
476 } | 481 } |
477 | 482 |
478 bool GoogleUpdateSettings::ClearReferral() { | 483 bool GoogleUpdateSettings::ClearReferral() { |
479 return ClearGoogleUpdateStrKey(google_update::kRegReferralField); | 484 return ClearGoogleUpdateStrKey(google_update::kRegReferralField); |
480 } | 485 } |
481 | 486 |
482 bool GoogleUpdateSettings::UpdateDidRunStateForApp( | |
483 const AppRegistrationData& app_reg_data, | |
484 bool did_run) { | |
485 return WriteGoogleUpdateStrKeyInternal(app_reg_data, | |
486 google_update::kRegDidRunField, | |
487 did_run ? L"1" : L"0"); | |
488 } | |
489 | |
490 bool GoogleUpdateSettings::UpdateDidRunState(bool did_run, bool system_level) { | 487 bool GoogleUpdateSettings::UpdateDidRunState(bool did_run, bool system_level) { |
491 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 488 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
492 bool result = UpdateDidRunStateForApp(dist->GetAppRegistrationData(), | 489 bool result = UpdateDidRunStateForApp(dist->GetAppRegistrationData(), |
493 did_run); | 490 did_run); |
494 // Update state for binaries, even if the previous call was unsuccessful. | 491 // Update state for binaries, even if the previous call was unsuccessful. |
495 if (InstallUtil::IsMultiInstall(dist, system_level)) | 492 if (InstallUtil::IsMultiInstall(dist, system_level)) |
496 result = UpdateDidRunStateForBinaries(did_run) && result; | 493 result = UpdateDidRunStateForBinaries(did_run) && result; |
497 return result; | 494 return result; |
498 } | 495 } |
499 | 496 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 } | 1029 } |
1033 | 1030 |
1034 // If the key or value was not present, return the empty string. | 1031 // If the key or value was not present, return the empty string. |
1035 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 1032 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
1036 experiment_labels->clear(); | 1033 experiment_labels->clear(); |
1037 return true; | 1034 return true; |
1038 } | 1035 } |
1039 | 1036 |
1040 return result == ERROR_SUCCESS; | 1037 return result == ERROR_SUCCESS; |
1041 } | 1038 } |
OLD | NEW |