| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 *update_policy = static_cast<GoogleUpdateSettings::UpdatePolicy>(value); | 232 *update_policy = static_cast<GoogleUpdateSettings::UpdatePolicy>(value); |
| 233 return true; | 233 return true; |
| 234 default: | 234 default: |
| 235 LOG(WARNING) << "Unexpected update policy override value: " << value; | 235 LOG(WARNING) << "Unexpected update policy override value: " << value; |
| 236 } | 236 } |
| 237 return false; | 237 return false; |
| 238 } | 238 } |
| 239 #endif // defined(GOOGLE_CHROME_BUILD) | 239 #endif // defined(GOOGLE_CHROME_BUILD) |
| 240 | 240 |
| 241 bool UpdateDidRunStateForApp(const AppRegistrationData& app_reg_data, | 241 bool UpdateDidRunStateForApp(const AppRegistrationData& app_reg_data, |
| 242 bool system_level, |
| 242 bool did_run) { | 243 bool did_run) { |
| 244 WritePerUserStat(app_reg_data, system_level, google_update::kRegDidRunStat, |
| 245 did_run ? 1U : 0U); |
| 243 return WriteGoogleUpdateStrKeyInternal( | 246 return WriteGoogleUpdateStrKeyInternal( |
| 244 app_reg_data, google_update::kRegDidRunField, did_run ? L"1" : L"0"); | 247 app_reg_data, google_update::kRegDidRunField, did_run ? L"1" : L"0"); |
| 245 } | 248 } |
| 246 | 249 |
| 247 // Convenience routine: GoogleUpdateSettings::UpdateDidRunStateForApp() | 250 // Convenience routine: GoogleUpdateSettings::UpdateDidRunStateForApp() |
| 248 // specialized for Chrome Binaries. | 251 // specialized for Chrome Binaries. |
| 249 bool UpdateDidRunStateForBinaries(bool did_run) { | 252 bool UpdateDidRunStateForBinaries(bool system_level, bool did_run) { |
| 250 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 253 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
| 251 BrowserDistribution::CHROME_BINARIES); | 254 BrowserDistribution::CHROME_BINARIES); |
| 252 return UpdateDidRunStateForApp(dist->GetAppRegistrationData(), did_run); | 255 return UpdateDidRunStateForApp(dist->GetAppRegistrationData(), system_level, |
| 256 did_run); |
| 253 } | 257 } |
| 254 | 258 |
| 255 } // namespace | 259 } // namespace |
| 256 | 260 |
| 257 bool GoogleUpdateSettings::IsSystemInstall() { | 261 bool GoogleUpdateSettings::IsSystemInstall() { |
| 258 bool system_install = false; | 262 bool system_install = false; |
| 259 base::FilePath module_dir; | 263 base::FilePath module_dir; |
| 260 if (!PathService::Get(base::DIR_MODULE, &module_dir)) { | 264 if (!PathService::Get(base::DIR_MODULE, &module_dir)) { |
| 261 LOG(WARNING) | 265 LOG(WARNING) |
| 262 << "Failed to get directory of module; assuming per-user install."; | 266 << "Failed to get directory of module; assuming per-user install."; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 return ReadGoogleUpdateStrKey(google_update::kRegReferralField, referral); | 505 return ReadGoogleUpdateStrKey(google_update::kRegReferralField, referral); |
| 502 } | 506 } |
| 503 | 507 |
| 504 bool GoogleUpdateSettings::ClearReferral() { | 508 bool GoogleUpdateSettings::ClearReferral() { |
| 505 return ClearGoogleUpdateStrKey(google_update::kRegReferralField); | 509 return ClearGoogleUpdateStrKey(google_update::kRegReferralField); |
| 506 } | 510 } |
| 507 | 511 |
| 508 bool GoogleUpdateSettings::UpdateDidRunState(bool did_run, bool system_level) { | 512 bool GoogleUpdateSettings::UpdateDidRunState(bool did_run, bool system_level) { |
| 509 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 513 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 510 bool result = UpdateDidRunStateForApp(dist->GetAppRegistrationData(), | 514 bool result = UpdateDidRunStateForApp(dist->GetAppRegistrationData(), |
| 511 did_run); | 515 system_level, did_run); |
| 512 // Update state for binaries, even if the previous call was unsuccessful. | 516 // Update state for binaries, even if the previous call was unsuccessful. |
| 513 if (InstallUtil::IsMultiInstall(dist, system_level)) | 517 if (InstallUtil::IsMultiInstall(dist, system_level)) |
| 514 result = UpdateDidRunStateForBinaries(did_run) && result; | 518 result = UpdateDidRunStateForBinaries(system_level, did_run) && result; |
| 515 return result; | 519 return result; |
| 516 } | 520 } |
| 517 | 521 |
| 518 base::string16 GoogleUpdateSettings::GetChromeChannel(bool system_install) { | 522 base::string16 GoogleUpdateSettings::GetChromeChannel(bool system_install) { |
| 519 base::string16 channel; | 523 base::string16 channel; |
| 520 GetChromeChannelInternal(system_install, false, &channel); | 524 GetChromeChannelInternal(system_install, false, &channel); |
| 521 return channel; | 525 return channel; |
| 522 } | 526 } |
| 523 | 527 |
| 524 bool GoogleUpdateSettings::GetChromeChannelAndModifiers( | 528 bool GoogleUpdateSettings::GetChromeChannelAndModifiers( |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 } | 1057 } |
| 1054 | 1058 |
| 1055 // If the key or value was not present, return the empty string. | 1059 // If the key or value was not present, return the empty string. |
| 1056 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 1060 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
| 1057 experiment_labels->clear(); | 1061 experiment_labels->clear(); |
| 1058 return true; | 1062 return true; |
| 1059 } | 1063 } |
| 1060 | 1064 |
| 1061 return result == ERROR_SUCCESS; | 1065 return result == ERROR_SUCCESS; |
| 1062 } | 1066 } |
| OLD | NEW |