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

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

Issue 2618583005: Remove support for non-browser products from InstallationState and ProductState. (Closed)
Patch Set: fix Created 3 years, 11 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
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 <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
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // When opting out, clear registry backup of client id and related values. 353 // When opting out, clear registry backup of client id and related values.
356 if (result == ERROR_SUCCESS && !consented) 354 if (result == ERROR_SUCCESS && !consented)
357 StoreMetricsClientInfo(metrics::ClientInfo()); 355 StoreMetricsClientInfo(metrics::ClientInfo());
358 356
359 return (result == ERROR_SUCCESS); 357 return (result == ERROR_SUCCESS);
360 } 358 }
361 359
362 // static 360 // static
363 bool GoogleUpdateSettings::GetCollectStatsConsentDefault( 361 bool GoogleUpdateSettings::GetCollectStatsConsentDefault(
364 bool* stats_consent_default) { 362 bool* stats_consent_default) {
365 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
366 installer::ChannelInfo channel_info; 363 installer::ChannelInfo channel_info;
367 bool is_multi_install = false; 364 bool is_multi_install = false;
368 if (InitChannelInfo(IsSystemInstall(), dist, &channel_info, 365 if (InitChannelInfo(IsSystemInstall(), &channel_info, &is_multi_install)) {
369 &is_multi_install)) {
370 base::string16 stats_default = channel_info.GetStatsDefault(); 366 base::string16 stats_default = channel_info.GetStatsDefault();
371 if (stats_default == L"0" || stats_default == L"1") { 367 if (stats_default == L"0" || stats_default == L"1") {
372 *stats_consent_default = (stats_default == L"1"); 368 *stats_consent_default = (stats_default == L"1");
373 return true; 369 return true;
374 } 370 }
375 } 371 }
376 return false; 372 return false;
377 } 373 }
378 374
379 std::unique_ptr<metrics::ClientInfo> 375 std::unique_ptr<metrics::ClientInfo>
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 } 1031 }
1036 1032
1037 // If the key or value was not present, return the empty string. 1033 // If the key or value was not present, return the empty string.
1038 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { 1034 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) {
1039 experiment_labels->clear(); 1035 experiment_labels->clear();
1040 return true; 1036 return true;
1041 } 1037 }
1042 1038
1043 return result == ERROR_SUCCESS; 1039 return result == ERROR_SUCCESS;
1044 } 1040 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698