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

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

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/win/registry.h" 14 #include "base/win/registry.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/installer/util/browser_distribution.h" 16 #include "chrome/installer/util/browser_distribution.h"
17 #include "chrome/installer/util/channel_info.h" 17 #include "chrome/installer/util/channel_info.h"
18 #include "chrome/installer/util/google_update_constants.h" 18 #include "chrome/installer/util/google_update_constants.h"
19 #include "chrome/installer/util/install_util.h" 19 #include "chrome/installer/util/install_util.h"
20 #include "chrome/installer/util/package.h" 20 #include "chrome/installer/util/installer_state.h"
21 #include "chrome/installer/util/package_properties.h"
22 #include "chrome/installer/util/product.h" 21 #include "chrome/installer/util/product.h"
23 22
24 using base::win::RegKey; 23 using base::win::RegKey;
24 using installer::InstallerState;
25 25
26 namespace { 26 namespace {
27 27
28 // An list of search results in increasing order of desirability. 28 // An list of search results in increasing order of desirability.
29 enum EulaSearchResult { 29 enum EulaSearchResult {
30 NO_SETTING, 30 NO_SETTING,
31 FOUND_CLIENT_STATE, 31 FOUND_CLIENT_STATE,
32 FOUND_OPPOSITE_SETTING, 32 FOUND_OPPOSITE_SETTING,
33 FOUND_SAME_SETTING 33 FOUND_SAME_SETTING
34 }; 34 };
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 bool GoogleUpdateSettings::GetMetricsId(std::wstring* metrics_id) { 120 bool GoogleUpdateSettings::GetMetricsId(std::wstring* metrics_id) {
121 return ReadGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id); 121 return ReadGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id);
122 } 122 }
123 123
124 bool GoogleUpdateSettings::SetMetricsId(const std::wstring& metrics_id) { 124 bool GoogleUpdateSettings::SetMetricsId(const std::wstring& metrics_id) {
125 return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id); 125 return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id);
126 } 126 }
127 127
128 bool GoogleUpdateSettings::SetEULAConsent( 128 bool GoogleUpdateSettings::SetEULAConsent(
129 const installer::Package& package, 129 const InstallerState& installer_state,
130 bool consented) { 130 bool consented) {
131 // If this is a multi install, Google Update will have put eulaaccepted=0 into 131 // If this is a multi install, Google Update will have put eulaaccepted=0 into
132 // the ClientState key of the multi-installer. Conduct a brief search for 132 // the ClientState key of the multi-installer. Conduct a brief search for
133 // this value and store the consent in the corresponding location. 133 // this value and store the consent in the corresponding location.
134 HKEY root = package.system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 134 HKEY root = installer_state.root_key();
135 EulaSearchResult status = NO_SETTING;
136 std::wstring reg_path;
137 std::wstring fallback_reg_path;
135 138
136 std::wstring reg_path = package.properties()->GetStateMediumKey(); 139 if (installer_state.package_type() == InstallerState::MULTI_PACKAGE) {
137 EulaSearchResult status = HasEULASetting( 140 BrowserDistribution* binaries_dist =
138 root, package.properties()->GetStateKey(), !consented); 141 installer_state.multi_package_binaries_distribution();
142 fallback_reg_path = reg_path = binaries_dist->GetStateMediumKey();
143 status = HasEULASetting(root, binaries_dist->GetStateKey(), !consented);
144 }
139 if (status != FOUND_SAME_SETTING) { 145 if (status != FOUND_SAME_SETTING) {
140 EulaSearchResult new_status = NO_SETTING; 146 EulaSearchResult new_status = NO_SETTING;
141 installer::Products::const_iterator scan = package.products().begin(); 147 installer::Products::const_iterator scan =
142 installer::Products::const_iterator end = package.products().end(); 148 installer_state.products().begin();
149 installer::Products::const_iterator end =
150 installer_state.products().end();
143 for (; status != FOUND_SAME_SETTING && scan != end; ++scan) { 151 for (; status != FOUND_SAME_SETTING && scan != end; ++scan) {
144 const installer::Product& product = *(scan->get()); 152 if (fallback_reg_path.empty())
145 new_status = HasEULASetting(root, product.distribution()->GetStateKey(), 153 fallback_reg_path = (*scan)->distribution()->GetStateMediumKey();
154 new_status = HasEULASetting(root, (*scan)->distribution()->GetStateKey(),
146 !consented); 155 !consented);
147 if (new_status > status) { 156 if (new_status > status) {
148 status = new_status; 157 status = new_status;
149 reg_path = product.distribution()->GetStateMediumKey(); 158 reg_path = (*scan)->distribution()->GetStateMediumKey();
150 } 159 }
151 } 160 }
152 if (status == NO_SETTING) { 161 if (status == NO_SETTING) {
153 LOG(WARNING) 162 LOG(WARNING)
154 << "eulaaccepted value not found; setting consent on package"; 163 << "eulaaccepted value not found; setting consent in key "
155 reg_path = package.properties()->GetStateMediumKey(); 164 << fallback_reg_path;
165 reg_path = fallback_reg_path;
156 } 166 }
157 } 167 }
158 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE); 168 RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE);
159 return (key.WriteValue(google_update::kRegEULAAceptedField, 169 return (key.WriteValue(google_update::kRegEULAAceptedField,
160 consented ? 1 : 0) == ERROR_SUCCESS); 170 consented ? 1 : 0) == ERROR_SUCCESS);
161 } 171 }
162 172
163 int GoogleUpdateSettings::GetLastRunTime() { 173 int GoogleUpdateSettings::GetLastRunTime() {
164 std::wstring time_s; 174 std::wstring time_s;
165 if (!ReadGoogleUpdateStrKey(google_update::kRegLastRunTimeField, &time_s)) 175 if (!ReadGoogleUpdateStrKey(google_update::kRegLastRunTimeField, &time_s))
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 }; 369 };
360 const wchar_t** end = &kBrands[arraysize(kBrands)]; 370 const wchar_t** end = &kBrands[arraysize(kBrands)];
361 const wchar_t** found = std::find(&kBrands[0], end, brand); 371 const wchar_t** found = std::find(&kBrands[0], end, brand);
362 if (found != end) 372 if (found != end)
363 return true; 373 return true;
364 if (StartsWith(brand, L"EUB", true) || StartsWith(brand, L"EUC", true) || 374 if (StartsWith(brand, L"EUB", true) || StartsWith(brand, L"EUC", true) ||
365 StartsWith(brand, L"GGR", true)) 375 StartsWith(brand, L"GGR", true))
366 return true; 376 return true;
367 return false; 377 return false;
368 } 378 }
OLDNEW
« no previous file with comments | « chrome/installer/util/google_update_settings.h ('k') | chrome/installer/util/google_update_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698