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

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

Issue 8344004: base/win: Add documentation to RegKey::Read/Write functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/path_service.h" 10 #include "base/path_service.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return true; 106 return true;
107 return (key.DeleteValue(name) == ERROR_SUCCESS); 107 return (key.DeleteValue(name) == ERROR_SUCCESS);
108 } 108 }
109 109
110 EulaSearchResult HasEULASetting(HKEY root, const std::wstring& state_key, 110 EulaSearchResult HasEULASetting(HKEY root, const std::wstring& state_key,
111 bool setting) { 111 bool setting) {
112 RegKey key; 112 RegKey key;
113 DWORD previous_value = setting ? 1 : 0; 113 DWORD previous_value = setting ? 1 : 0;
114 if (key.Open(root, state_key.c_str(), KEY_QUERY_VALUE) != ERROR_SUCCESS) 114 if (key.Open(root, state_key.c_str(), KEY_QUERY_VALUE) != ERROR_SUCCESS)
115 return NO_SETTING; 115 return NO_SETTING;
116 if (key.ReadValueDW(google_update::kRegEULAAceptedField, 116 if (key.ReadValue(google_update::kRegEULAAceptedField,
117 &previous_value) != ERROR_SUCCESS) 117 &previous_value) != ERROR_SUCCESS)
118 return FOUND_CLIENT_STATE; 118 return FOUND_CLIENT_STATE;
119 119
120 return ((previous_value != 0) == setting) ? 120 return ((previous_value != 0) == setting) ?
121 FOUND_SAME_SETTING : FOUND_OPPOSITE_SETTING; 121 FOUND_SAME_SETTING : FOUND_OPPOSITE_SETTING;
122 } 122 }
123 123
124 bool GetChromeChannelInternal(bool system_install, 124 bool GetChromeChannelInternal(bool system_install,
125 bool add_multi_modifier, 125 bool add_multi_modifier,
126 std::wstring* channel) { 126 std::wstring* channel) {
127 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 127 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 RegKey key; 200 RegKey key;
201 DWORD value = 0; 201 DWORD value = 0;
202 bool have_value = false; 202 bool have_value = false;
203 203
204 // For system-level installs, try ClientStateMedium first. 204 // For system-level installs, try ClientStateMedium first.
205 have_value = 205 have_value =
206 system_install && 206 system_install &&
207 key.Open(HKEY_LOCAL_MACHINE, dist->GetStateMediumKey().c_str(), 207 key.Open(HKEY_LOCAL_MACHINE, dist->GetStateMediumKey().c_str(),
208 KEY_QUERY_VALUE) == ERROR_SUCCESS && 208 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
209 key.ReadValueDW(google_update::kRegUsageStatsField, 209 key.ReadValue(google_update::kRegUsageStatsField,
210 &value) == ERROR_SUCCESS; 210 &value) == ERROR_SUCCESS;
211 211
212 // Otherwise, try ClientState. 212 // Otherwise, try ClientState.
213 have_value = 213 have_value =
214 !have_value && 214 !have_value &&
215 key.Open(system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, 215 key.Open(system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
216 dist->GetStateKey().c_str(), KEY_QUERY_VALUE) == ERROR_SUCCESS && 216 dist->GetStateKey().c_str(), KEY_QUERY_VALUE) == ERROR_SUCCESS &&
217 key.ReadValueDW(google_update::kRegUsageStatsField, 217 key.ReadValue(google_update::kRegUsageStatsField,
218 &value) == ERROR_SUCCESS; 218 &value) == ERROR_SUCCESS;
219 219
220 // Google Update specifically checks that the value is 1, so we do the same. 220 // Google Update specifically checks that the value is 1, so we do the same.
221 return have_value && value == 1; 221 return have_value && value == 1;
222 } 222 }
223 223
224 bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { 224 bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) {
225 // Google Update writes and expects 1 for true, 0 for false. 225 // Google Update writes and expects 1 for true, 0 for false.
226 DWORD value = consented ? 1 : 0; 226 DWORD value = consented ? 1 : 0;
227 227
228 // Determine whether this is a system-level or a user-level install. 228 // Determine whether this is a system-level or a user-level install.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 KEY_QUERY_VALUE) == ERROR_SUCCESS) { 501 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
502 static const size_t kPrefixLen = 502 static const size_t kPrefixLen =
503 arraysize(kGoogleUpdateUpdateOverrideValuePrefix) - 1; 503 arraysize(kGoogleUpdateUpdateOverrideValuePrefix) - 1;
504 DWORD value; 504 DWORD value;
505 std::wstring app_update_override; 505 std::wstring app_update_override;
506 app_update_override.reserve(kPrefixLen + app_guid.size()); 506 app_update_override.reserve(kPrefixLen + app_guid.size());
507 app_update_override.append(kGoogleUpdateUpdateOverrideValuePrefix, 507 app_update_override.append(kGoogleUpdateUpdateOverrideValuePrefix,
508 kPrefixLen); 508 kPrefixLen);
509 app_update_override.append(app_guid); 509 app_update_override.append(app_guid);
510 // First try to read and comprehend the app-specific override. 510 // First try to read and comprehend the app-specific override.
511 found_override = (policy_key.ReadValueDW(app_update_override.c_str(), 511 found_override = (policy_key.ReadValue(app_update_override.c_str(),
512 &value) == ERROR_SUCCESS && 512 &value) == ERROR_SUCCESS &&
513 GetUpdatePolicyFromDword(value, &update_policy)); 513 GetUpdatePolicyFromDword(value, &update_policy));
514 514
515 // Failing that, try to read and comprehend the default override. 515 // Failing that, try to read and comprehend the default override.
516 if (!found_override && 516 if (!found_override &&
517 policy_key.ReadValueDW(kGoogleUpdateUpdatePolicyValue, 517 policy_key.ReadValue(kGoogleUpdateUpdatePolicyValue,
518 &value) == ERROR_SUCCESS) { 518 &value) == ERROR_SUCCESS) {
519 GetUpdatePolicyFromDword(value, &update_policy); 519 GetUpdatePolicyFromDword(value, &update_policy);
520 } 520 }
521 } 521 }
522 #endif // defined(GOOGLE_CHROME_BUILD) 522 #endif // defined(GOOGLE_CHROME_BUILD)
523 523
524 if (is_overridden != NULL) 524 if (is_overridden != NULL)
525 *is_overridden = found_override; 525 *is_overridden = found_override;
526 526
527 return update_policy; 527 return update_policy;
528 } 528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698