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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 << google_update::kRegUsageStatsField << "; result: " << result; | 289 << google_update::kRegUsageStatsField << "; result: " << result; |
| 290 } else { | 290 } else { |
| 291 result = key.WriteValue(google_update::kRegUsageStatsField, value); | 291 result = key.WriteValue(google_update::kRegUsageStatsField, value); |
| 292 LOG_IF(ERROR, result != ERROR_SUCCESS) << "Failed setting " | 292 LOG_IF(ERROR, result != ERROR_SUCCESS) << "Failed setting " |
| 293 << google_update::kRegUsageStatsField << " in key " << reg_path | 293 << google_update::kRegUsageStatsField << " in key " << reg_path |
| 294 << "; result: " << result; | 294 << "; result: " << result; |
| 295 } | 295 } |
| 296 return (result == ERROR_SUCCESS); | 296 return (result == ERROR_SUCCESS); |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool GoogleUpdateSettings::LoadMetricsClientId(std::string* metrics_id) { | 299 scoped_ptr<metrics::ClientInfo> GoogleUpdateSettings::LoadMetricsClientInfo() { |
| 300 base::string16 metrics_id16; | 300 |
|
Alexei Svitkine (slow)
2014/07/15 12:53:25
Nit: Remove empty line.
gab
2014/07/15 20:50:05
Done.
| |
| 301 bool rv = ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &metrics_id16); | 301 base::string16 client_id_16; |
| 302 *metrics_id = base::UTF16ToUTF8(metrics_id16); | 302 if (!ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &client_id_16) || |
| 303 return rv; | 303 client_id_16.empty()) { |
| 304 return scoped_ptr<metrics::ClientInfo>(); | |
| 305 } | |
| 306 | |
| 307 scoped_ptr<metrics::ClientInfo> client_info(new metrics::ClientInfo); | |
| 308 client_info->client_id = base::UTF16ToUTF8(client_id_16); | |
| 309 | |
| 310 base::string16 installation_date_str; | |
| 311 if (ReadGoogleUpdateStrKey(google_update::kRegMetricsIdInstallDate, | |
| 312 &installation_date_str)) { | |
|
Alexei Svitkine (slow)
2014/07/15 12:53:25
Nit: Align.
gab
2014/07/15 20:50:05
Done.
| |
| 313 base::StringToInt64(installation_date_str, &client_info->installation_date); | |
| 314 } | |
| 315 | |
| 316 base::string16 reporting_enbaled_date_date_str; | |
| 317 if (ReadGoogleUpdateStrKey(google_update::kRegMetricsIdEnabledDate, | |
| 318 &reporting_enbaled_date_date_str)) { | |
|
Alexei Svitkine (slow)
2014/07/15 12:53:25
Nit: Align.
gab
2014/07/15 20:50:05
Done.
| |
| 319 base::StringToInt64(reporting_enbaled_date_date_str, | |
| 320 &client_info->reporting_enabled_date); | |
| 321 } | |
| 322 | |
| 323 return client_info.Pass(); | |
| 304 } | 324 } |
| 305 | 325 |
| 306 bool GoogleUpdateSettings::StoreMetricsClientId(const std::string& metrics_id) { | 326 void GoogleUpdateSettings::StoreMetricsClientInfo( |
| 307 base::string16 metrics_id16 = base::UTF8ToUTF16(metrics_id); | 327 const metrics::ClientInfo& client_info) { |
| 308 return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id16); | 328 WriteGoogleUpdateStrKey(google_update::kRegMetricsId, |
|
Alexei Svitkine (slow)
2014/07/15 12:53:25
Is it okay to not check for errors for these? If s
gab
2014/07/15 20:50:06
The method used to return bool, but no callers wou
| |
| 329 base::UTF8ToUTF16(client_info.client_id)); | |
| 330 WriteGoogleUpdateStrKey(google_update::kRegMetricsIdInstallDate, | |
| 331 base::Int64ToString16(client_info.installation_date)); | |
| 332 WriteGoogleUpdateStrKey( | |
| 333 google_update::kRegMetricsIdEnabledDate, | |
| 334 base::Int64ToString16(client_info.reporting_enabled_date)); | |
| 309 } | 335 } |
| 310 | 336 |
| 311 // EULA consent is only relevant for system-level installs. | 337 // EULA consent is only relevant for system-level installs. |
| 312 bool GoogleUpdateSettings::SetEULAConsent( | 338 bool GoogleUpdateSettings::SetEULAConsent( |
| 313 const InstallationState& machine_state, | 339 const InstallationState& machine_state, |
| 314 BrowserDistribution* dist, | 340 BrowserDistribution* dist, |
| 315 bool consented) { | 341 bool consented) { |
| 316 DCHECK(dist); | 342 DCHECK(dist); |
| 317 const DWORD eula_accepted = consented ? 1 : 0; | 343 const DWORD eula_accepted = consented ? 1 : 0; |
| 318 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; | 344 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 } | 910 } |
| 885 | 911 |
| 886 // If the key or value was not present, return the empty string. | 912 // If the key or value was not present, return the empty string. |
| 887 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 913 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
| 888 experiment_labels->clear(); | 914 experiment_labels->clear(); |
| 889 return true; | 915 return true; |
| 890 } | 916 } |
| 891 | 917 |
| 892 return result == ERROR_SUCCESS; | 918 return result == ERROR_SUCCESS; |
| 893 } | 919 } |
| OLD | NEW |