Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 << google_update::kRegUsageStatsField << "; result: " << result; | 291 << google_update::kRegUsageStatsField << "; result: " << result; |
| 292 } else { | 292 } else { |
| 293 result = key.WriteValue(google_update::kRegUsageStatsField, value); | 293 result = key.WriteValue(google_update::kRegUsageStatsField, value); |
| 294 LOG_IF(ERROR, result != ERROR_SUCCESS) << "Failed setting " | 294 LOG_IF(ERROR, result != ERROR_SUCCESS) << "Failed setting " |
| 295 << google_update::kRegUsageStatsField << " in key " << reg_path | 295 << google_update::kRegUsageStatsField << " in key " << reg_path |
| 296 << "; result: " << result; | 296 << "; result: " << result; |
| 297 } | 297 } |
| 298 return (result == ERROR_SUCCESS); | 298 return (result == ERROR_SUCCESS); |
| 299 } | 299 } |
| 300 | 300 |
| 301 bool GoogleUpdateSettings::RetrieveMetricsID(std::string* metrics_id) { | 301 bool GoogleUpdateSettings::RetrieveMetricsInfo(std::string* metrics_id, |
| 302 std::wstring metrics_id_w; | 302 int64* installation_date) { |
| 303 bool rv = ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &metrics_id_w); | 303 bool success = true; |
| 304 *metrics_id = base::WideToUTF8(metrics_id_w); | 304 if (metrics_id) { |
|
Ilya Sherman
2014/07/08 01:10:21
Does it ever make sense to call this method with a
gab
2014/07/09 19:16:59
Not really, changed the model anyways as we want t
| |
| 305 return rv; | 305 base::string16 metrics_id_16; |
| 306 if (ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &metrics_id_16)) | |
| 307 *metrics_id = base::UTF16ToUTF8(metrics_id_16); | |
| 308 else | |
| 309 success = false; | |
| 310 } | |
| 311 if (installation_date) { | |
| 312 base::string16 installation_date_s; | |
|
Ilya Sherman
2014/07/08 01:10:21
Optional nit: I'd prefer "str" to just "s".
gab
2014/07/09 19:16:59
Done.
| |
| 313 if (!ReadGoogleUpdateStrKey(google_update::kRegMetricsIdDate, | |
| 314 &installation_date_s) || | |
| 315 !base::StringToInt64(installation_date_s, installation_date)) { | |
| 316 *installation_date = 0; | |
| 317 } | |
| 318 } | |
| 319 return success; | |
| 306 } | 320 } |
| 307 | 321 |
| 308 bool GoogleUpdateSettings::SaveMetricsID(const std::string& metrics_id) { | 322 bool GoogleUpdateSettings::SaveMetricsInfo(const std::string& metrics_id, |
| 309 std::wstring metrics_id_w = base::UTF8ToWide(metrics_id); | 323 int64 installation_date) { |
| 310 return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id_w); | 324 return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, |
| 325 base::UTF8ToUTF16(metrics_id)) && | |
| 326 WriteGoogleUpdateStrKey(google_update::kRegMetricsIdDate, | |
| 327 base::Int64ToString16(installation_date)); | |
| 311 } | 328 } |
| 312 | 329 |
| 313 // EULA consent is only relevant for system-level installs. | 330 // EULA consent is only relevant for system-level installs. |
| 314 bool GoogleUpdateSettings::SetEULAConsent( | 331 bool GoogleUpdateSettings::SetEULAConsent( |
| 315 const InstallationState& machine_state, | 332 const InstallationState& machine_state, |
| 316 BrowserDistribution* dist, | 333 BrowserDistribution* dist, |
| 317 bool consented) { | 334 bool consented) { |
| 318 DCHECK(dist); | 335 DCHECK(dist); |
| 319 const DWORD eula_accepted = consented ? 1 : 0; | 336 const DWORD eula_accepted = consented ? 1 : 0; |
| 320 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; | 337 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 } | 903 } |
| 887 | 904 |
| 888 // If the key or value was not present, return the empty string. | 905 // If the key or value was not present, return the empty string. |
| 889 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 906 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
| 890 experiment_labels->clear(); | 907 experiment_labels->clear(); |
| 891 return true; | 908 return true; |
| 892 } | 909 } |
| 893 | 910 |
| 894 return result == ERROR_SUCCESS; | 911 return result == ERROR_SUCCESS; |
| 895 } | 912 } |
| OLD | NEW |