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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 if (!base::win::GetUserSidString(&uniquename)) { | 83 if (!base::win::GetUserSidString(&uniquename)) { |
| 84 NOTREACHED(); | 84 NOTREACHED(); |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 | 87 |
| 88 base::string16 reg_path(app_reg_data.GetStateMediumKey()); | 88 base::string16 reg_path(app_reg_data.GetStateMediumKey()); |
| 89 reg_path.append(L"\\"); | 89 reg_path.append(L"\\"); |
| 90 reg_path.append(name); | 90 reg_path.append(name); |
| 91 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), kAccess); | 91 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), kAccess); |
| 92 key.WriteValue(google_update::kRegAggregateMethod, aggregate); | 92 key.WriteValue(google_update::kRegAggregateMethod, aggregate); |
| 93 return (key.WriteValue(uniquename.c_str(), value) == ERROR_SUCCESS); | 93 return (key.WriteValue(uniquename.c_str(), value) == ERROR_SUCCESS); |
|
grt (UTC plus 2)
2015/02/24 17:57:00
presumably this is using the DWORD WriteValue, whe
Mike Lerman
2015/02/25 15:00:12
Ah, great! I didn't realize DWORDs were unsigned.
| |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Updates a registry key |name| to be |value| for the given |app_reg_data|. | 96 // Updates a registry key |name| to be |value| for the given |app_reg_data|. |
| 97 bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, | 97 bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, |
| 98 const wchar_t* const name, | 98 const wchar_t* const name, |
| 99 const base::string16& value) { | 99 const base::string16& value) { |
| 100 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; | 100 const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; |
| 101 RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), kAccess); | 101 RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), kAccess); |
| 102 return (key.WriteValue(name, value.c_str()) == ERROR_SUCCESS); | 102 return (key.WriteValue(name, value.c_str()) == ERROR_SUCCESS); |
| 103 } | 103 } |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 | 539 |
| 540 if (value->SetMultiFailSuffix(false)) { | 540 if (value->SetMultiFailSuffix(false)) { |
| 541 VLOG(1) << "Removed multi-install failure key; switching to channel: " | 541 VLOG(1) << "Removed multi-install failure key; switching to channel: " |
| 542 << value->value(); | 542 << value->value(); |
| 543 modified = true; | 543 modified = true; |
| 544 } | 544 } |
| 545 | 545 |
| 546 return modified; | 546 return modified; |
| 547 } | 547 } |
| 548 | 548 |
| 549 void GoogleUpdateSettings::UpdateProfileCounts(int profiles_active, | 549 void GoogleUpdateSettings::UpdateProfileCounts(size_t profiles_active, |
| 550 int profiles_signedin) { | 550 size_t profiles_signedin) { |
| 551 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 551 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 552 // System-level installs must write into the ClientStateMedium key shared by | 552 // System-level installs must write into the ClientStateMedium key shared by |
| 553 // all users. Special treatment is used to aggregate across those users. | 553 // all users. Special treatment is used to aggregate across those users. |
| 554 if (IsSystemInstall()) { | 554 if (IsSystemInstall()) { |
| 555 // Write the counts as ints that get aggregated across all users via | 555 // Write the counts as ints that get aggregated across all users via |
| 556 // summation for system-level installs. | 556 // summation for system-level installs. |
| 557 WriteGoogleUpdateAggregateNumKeyInternal( | 557 WriteGoogleUpdateAggregateNumKeyInternal( |
| 558 dist->GetAppRegistrationData(), | 558 dist->GetAppRegistrationData(), |
| 559 google_update::kRegProfilesActive, | 559 google_update::kRegProfilesActive, |
| 560 profiles_active, | 560 (int)profiles_active, |
| 561 L"sum()"); | 561 L"sum()"); |
| 562 WriteGoogleUpdateAggregateNumKeyInternal( | 562 WriteGoogleUpdateAggregateNumKeyInternal( |
| 563 dist->GetAppRegistrationData(), | 563 dist->GetAppRegistrationData(), |
| 564 google_update::kRegProfilesSignedIn, | 564 google_update::kRegProfilesSignedIn, |
| 565 profiles_signedin, | 565 (int)profiles_signedin, |
| 566 L"sum()"); | 566 L"sum()"); |
| 567 } else { | 567 } else { |
| 568 // Write the counts as strings since no aggregation function is needed for | 568 // Write the counts as strings since no aggregation function is needed for |
| 569 // user-level installs. | 569 // user-level installs. |
| 570 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(), | 570 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(), |
| 571 google_update::kRegProfilesActive, | 571 google_update::kRegProfilesActive, |
| 572 base::IntToString16(profiles_active)); | 572 base::SizeTToString16(profiles_active)); |
| 573 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(), | 573 WriteGoogleUpdateStrKeyInternal(dist->GetAppRegistrationData(), |
| 574 google_update::kRegProfilesSignedIn, | 574 google_update::kRegProfilesSignedIn, |
| 575 base::IntToString16(profiles_signedin)); | 575 base::SizeTToString16(profiles_signedin)); |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { | 579 int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { |
| 580 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 580 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 581 base::string16 reg_path = dist->GetStateKey(); | 581 base::string16 reg_path = dist->GetStateKey(); |
| 582 | 582 |
| 583 // Minimum access needed is to be able to write to this key. | 583 // Minimum access needed is to be able to write to this key. |
| 584 RegKey reg_key( | 584 RegKey reg_key( |
| 585 HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); | 585 HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 } | 958 } |
| 959 | 959 |
| 960 // If the key or value was not present, return the empty string. | 960 // If the key or value was not present, return the empty string. |
| 961 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 961 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
| 962 experiment_labels->clear(); | 962 experiment_labels->clear(); |
| 963 return true; | 963 return true; |
| 964 } | 964 } |
| 965 | 965 |
| 966 return result == ERROR_SUCCESS; | 966 return result == ERROR_SUCCESS; |
| 967 } | 967 } |
| OLD | NEW |