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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); | 153 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); |
154 if (!key.HasValue(name)) | 154 if (!key.HasValue(name)) |
155 return true; | 155 return true; |
156 return (key.DeleteValue(name) == ERROR_SUCCESS); | 156 return (key.DeleteValue(name) == ERROR_SUCCESS); |
157 } | 157 } |
158 | 158 |
159 // Initializes |channel_info| based on |system_install| and |dist|. Also | 159 // Initializes |channel_info| based on |system_install| and |dist|. Also |
160 // returns whether the install is a multi-install via output parameter | 160 // returns whether the install is a multi-install via output parameter |
161 // |is_multi_install|. Returns false on failure. | 161 // |is_multi_install|. Returns false on failure. |
162 bool InitChannelInfo(bool system_install, | 162 bool InitChannelInfo(bool system_install, |
163 BrowserDistribution* dist, | |
164 installer::ChannelInfo* channel_info, | 163 installer::ChannelInfo* channel_info, |
165 bool* is_multi_install) { | 164 bool* is_multi_install) { |
166 // Determine whether or not chrome is multi-install. If so, updates are | 165 // Determine whether or not chrome is multi-install. If so, updates are |
167 // delivered under the binaries' app guid, so that's where the relevant | 166 // delivered under the binaries' app guid, so that's where the relevant |
168 // channel is found. | 167 // channel is found. |
169 installer::ProductState state; | 168 installer::ProductState state; |
170 ignore_result(state.Initialize(system_install, dist)); | 169 ignore_result(state.Initialize(system_install)); |
171 if (!state.is_multi_install()) { | 170 if (!state.is_multi_install()) { |
172 // Use the channel info that was just read for this single-install chrome. | 171 // Use the channel info that was just read for this single-install chrome. |
173 *channel_info = state.channel(); | 172 *channel_info = state.channel(); |
174 } else { | 173 } else { |
175 // Read the channel info from the binaries' state key. | 174 // Read the channel info from the binaries' state key. |
176 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 175 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
177 dist = BrowserDistribution::GetSpecificDistribution( | 176 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
178 BrowserDistribution::CHROME_BINARIES); | 177 BrowserDistribution::CHROME_BINARIES); |
179 RegKey key(root_key, dist->GetStateKey().c_str(), | 178 RegKey key(root_key, dist->GetStateKey().c_str(), |
180 KEY_READ | KEY_WOW64_32KEY); | 179 KEY_READ | KEY_WOW64_32KEY); |
181 | 180 |
182 if (!channel_info->Initialize(key)) | 181 if (!channel_info->Initialize(key)) |
183 return false; | 182 return false; |
184 } | 183 } |
185 *is_multi_install = state.is_multi_install(); | 184 *is_multi_install = state.is_multi_install(); |
186 return true; | 185 return true; |
187 } | 186 } |
188 | 187 |
189 bool GetChromeChannelInternal(bool system_install, | 188 bool GetChromeChannelInternal(bool system_install, |
190 bool add_multi_modifier, | 189 bool add_multi_modifier, |
191 base::string16* channel) { | 190 base::string16* channel) { |
192 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 191 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
193 | 192 |
194 // Shortcut in case this distribution knows what channel it is (canary). | 193 // Shortcut in case this distribution knows what channel it is (canary). |
195 if (dist->GetChromeChannel(channel)) | 194 if (dist->GetChromeChannel(channel)) |
196 return true; | 195 return true; |
197 | 196 |
198 installer::ChannelInfo channel_info; | 197 installer::ChannelInfo channel_info; |
199 bool is_multi_install = false; | 198 bool is_multi_install = false; |
200 if (!InitChannelInfo(system_install, dist, &channel_info, | 199 if (!InitChannelInfo(system_install, &channel_info, &is_multi_install)) { |
201 &is_multi_install)) { | |
202 channel->assign(installer::kChromeChannelUnknown); | 200 channel->assign(installer::kChromeChannelUnknown); |
203 return false; | 201 return false; |
204 } | 202 } |
205 | 203 |
206 if (!channel_info.GetChannelName(channel)) | 204 if (!channel_info.GetChannelName(channel)) |
207 channel->assign(installer::kChromeChannelUnknown); | 205 channel->assign(installer::kChromeChannelUnknown); |
208 | 206 |
209 // Tag the channel name if this is a multi-install. | 207 // Tag the channel name if this is a multi-install. |
210 if (add_multi_modifier && is_multi_install) { | 208 if (add_multi_modifier && is_multi_install) { |
211 if (!channel->empty()) | 209 if (!channel->empty()) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // When opting out, clear registry backup of client id and related values. | 351 // When opting out, clear registry backup of client id and related values. |
354 if (result == ERROR_SUCCESS && !consented) | 352 if (result == ERROR_SUCCESS && !consented) |
355 StoreMetricsClientInfo(metrics::ClientInfo()); | 353 StoreMetricsClientInfo(metrics::ClientInfo()); |
356 | 354 |
357 return (result == ERROR_SUCCESS); | 355 return (result == ERROR_SUCCESS); |
358 } | 356 } |
359 | 357 |
360 // static | 358 // static |
361 bool GoogleUpdateSettings::GetCollectStatsConsentDefault( | 359 bool GoogleUpdateSettings::GetCollectStatsConsentDefault( |
362 bool* stats_consent_default) { | 360 bool* stats_consent_default) { |
363 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
364 installer::ChannelInfo channel_info; | 361 installer::ChannelInfo channel_info; |
365 bool is_multi_install = false; | 362 bool is_multi_install = false; |
366 if (InitChannelInfo(IsSystemInstall(), dist, &channel_info, | 363 if (InitChannelInfo(IsSystemInstall(), &channel_info, &is_multi_install)) { |
367 &is_multi_install)) { | |
368 base::string16 stats_default = channel_info.GetStatsDefault(); | 364 base::string16 stats_default = channel_info.GetStatsDefault(); |
369 if (stats_default == L"0" || stats_default == L"1") { | 365 if (stats_default == L"0" || stats_default == L"1") { |
370 *stats_consent_default = (stats_default == L"1"); | 366 *stats_consent_default = (stats_default == L"1"); |
371 return true; | 367 return true; |
372 } | 368 } |
373 } | 369 } |
374 return false; | 370 return false; |
375 } | 371 } |
376 | 372 |
377 std::unique_ptr<metrics::ClientInfo> | 373 std::unique_ptr<metrics::ClientInfo> |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1029 } |
1034 | 1030 |
1035 // If the key or value was not present, return the empty string. | 1031 // If the key or value was not present, return the empty string. |
1036 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 1032 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
1037 experiment_labels->clear(); | 1033 experiment_labels->clear(); |
1038 return true; | 1034 return true; |
1039 } | 1035 } |
1040 | 1036 |
1041 return result == ERROR_SUCCESS; | 1037 return result == ERROR_SUCCESS; |
1042 } | 1038 } |
OLD | NEW |