Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/installer/util/google_update_settings.cc

Issue 372473004: Retrieve client_id from GoogleUpdateSettings when its missing from Local State. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: put dependency back for installer_util_nacl_win64 fixes compile?! Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 base::string16 client_id_16;
301 bool rv = ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &metrics_id16); 301 if (!ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &client_id_16) ||
302 *metrics_id = base::UTF16ToUTF8(metrics_id16); 302 client_id_16.empty()) {
303 return rv; 303 return scoped_ptr<metrics::ClientInfo>();
304 }
305
306 scoped_ptr<metrics::ClientInfo> client_info(new metrics::ClientInfo);
307 client_info->client_id = base::UTF16ToUTF8(client_id_16);
308
309 base::string16 installation_date_str;
310 if (ReadGoogleUpdateStrKey(google_update::kRegMetricsIdInstallDate,
311 &installation_date_str)) {
312 base::StringToInt64(installation_date_str, &client_info->installation_date);
313 }
314
315 base::string16 reporting_enbaled_date_date_str;
316 if (ReadGoogleUpdateStrKey(google_update::kRegMetricsIdEnabledDate,
317 &reporting_enbaled_date_date_str)) {
318 base::StringToInt64(reporting_enbaled_date_date_str,
319 &client_info->reporting_enabled_date);
320 }
321
322 return client_info.Pass();
304 } 323 }
305 324
306 bool GoogleUpdateSettings::StoreMetricsClientId(const std::string& metrics_id) { 325 void GoogleUpdateSettings::StoreMetricsClientInfo(
307 base::string16 metrics_id16 = base::UTF8ToUTF16(metrics_id); 326 const metrics::ClientInfo& client_info) {
308 return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id16); 327 // Attempt a best-effort at backing |client_info| in the registry (but don't
328 // handle/report failures).
329 WriteGoogleUpdateStrKey(google_update::kRegMetricsId,
330 base::UTF8ToUTF16(client_info.client_id));
331 WriteGoogleUpdateStrKey(google_update::kRegMetricsIdInstallDate,
332 base::Int64ToString16(client_info.installation_date));
333 WriteGoogleUpdateStrKey(
334 google_update::kRegMetricsIdEnabledDate,
335 base::Int64ToString16(client_info.reporting_enabled_date));
309 } 336 }
310 337
311 // EULA consent is only relevant for system-level installs. 338 // EULA consent is only relevant for system-level installs.
312 bool GoogleUpdateSettings::SetEULAConsent( 339 bool GoogleUpdateSettings::SetEULAConsent(
313 const InstallationState& machine_state, 340 const InstallationState& machine_state,
314 BrowserDistribution* dist, 341 BrowserDistribution* dist,
315 bool consented) { 342 bool consented) {
316 DCHECK(dist); 343 DCHECK(dist);
317 const DWORD eula_accepted = consented ? 1 : 0; 344 const DWORD eula_accepted = consented ? 1 : 0;
318 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; 345 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY;
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } 911 }
885 912
886 // If the key or value was not present, return the empty string. 913 // If the key or value was not present, return the empty string.
887 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { 914 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) {
888 experiment_labels->clear(); 915 experiment_labels->clear();
889 return true; 916 return true;
890 } 917 }
891 918
892 return result == ERROR_SUCCESS; 919 return result == ERROR_SUCCESS;
893 } 920 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698