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

Side by Side Diff: chrome/installer/gcapi/gcapi.cc

Issue 297233010: Revert 273108 "Omaha configuration parameters now use Wow6432Nod..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2017/src/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | chrome/installer/gcapi/gcapi_last_run_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // NOTE: This code is a legacy utility API for partners to check whether 5 // NOTE: This code is a legacy utility API for partners to check whether
6 // Chrome can be installed and launched. Recent updates are being made 6 // Chrome can be installed and launched. Recent updates are being made
7 // to add new functionality. These updates use code from Chromium, the old 7 // to add new functionality. These updates use code from Chromium, the old
8 // coded against the win32 api directly. If you have an itch to shave a 8 // coded against the win32 api directly. If you have an itch to shave a
9 // yak, feel free to re-write the old code too. 9 // yak, feel free to re-write the old code too.
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 197
198 ::RegCloseKey(key); 198 ::RegCloseKey(key);
199 } 199 }
200 200
201 return can_re_offer; 201 return can_re_offer;
202 } 202 }
203 203
204 bool IsChromeInstalled(HKEY root_key) { 204 bool IsChromeInstalled(HKEY root_key) {
205 RegKey key; 205 RegKey key;
206 return key.Open(root_key, 206 return key.Open(root_key, kChromeRegClientsKey, KEY_READ) == ERROR_SUCCESS &&
207 kChromeRegClientsKey,
208 KEY_READ | KEY_WOW64_32KEY) == ERROR_SUCCESS &&
209 key.HasValue(kChromeRegVersion); 207 key.HasValue(kChromeRegVersion);
210 } 208 }
211 209
212 // Returns true if the |subkey| in |root| has the kC1FKey entry set to 1. 210 // Returns true if the |subkey| in |root| has the kC1FKey entry set to 1.
213 bool RegKeyHasC1F(HKEY root, const wchar_t* subkey) { 211 bool RegKeyHasC1F(HKEY root, const wchar_t* subkey) {
214 RegKey key; 212 RegKey key;
215 DWORD value; 213 DWORD value;
216 return key.Open(root, subkey, KEY_READ | KEY_WOW64_32KEY) == ERROR_SUCCESS && 214 return key.Open(root, subkey, KEY_READ) == ERROR_SUCCESS &&
217 key.ReadValueDW(kC1FKey, &value) == ERROR_SUCCESS && 215 key.ReadValueDW(kC1FKey, &value) == ERROR_SUCCESS &&
218 value == static_cast<DWORD>(1); 216 value == static_cast<DWORD>(1);
219 } 217 }
220 218
221 bool IsC1FSent() { 219 bool IsC1FSent() {
222 // The C1F RLZ key can either be in HKCU or in HKLM (the HKLM RLZ key is made 220 // The C1F RLZ key can either be in HKCU or in HKLM (the HKLM RLZ key is made
223 // readable to all-users via rlz_lib::CreateMachineState()) and can either be 221 // readable to all-users via rlz_lib::CreateMachineState()) and can either be
224 // in sent or pending state. Return true if there is a match for any of these 222 // in sent or pending state. Return true if there is a match for any of these
225 // 4 states. 223 // 4 states.
226 return RegKeyHasC1F(HKEY_CURRENT_USER, kC1FSentKey) || 224 return RegKeyHasC1F(HKEY_CURRENT_USER, kC1FSentKey) ||
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return (check == TRUE); 269 return (check == TRUE);
272 } 270 }
273 271
274 bool VerifyHKLMAccess() { 272 bool VerifyHKLMAccess() {
275 wchar_t str[] = L"test"; 273 wchar_t str[] = L"test";
276 bool result = false; 274 bool result = false;
277 DWORD disposition = 0; 275 DWORD disposition = 0;
278 HKEY key = NULL; 276 HKEY key = NULL;
279 277
280 if (::RegCreateKeyEx(HKEY_LOCAL_MACHINE, kGCAPITempKey, 0, NULL, 278 if (::RegCreateKeyEx(HKEY_LOCAL_MACHINE, kGCAPITempKey, 0, NULL,
281 REG_OPTION_NON_VOLATILE, 279 REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL,
282 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY, NULL,
283 &key, &disposition) == ERROR_SUCCESS) { 280 &key, &disposition) == ERROR_SUCCESS) {
284 if (::RegSetValueEx(key, str, 0, REG_SZ, (LPBYTE)str, 281 if (::RegSetValueEx(key, str, 0, REG_SZ, (LPBYTE)str,
285 (DWORD)lstrlen(str)) == ERROR_SUCCESS) { 282 (DWORD)lstrlen(str)) == ERROR_SUCCESS) {
286 result = true; 283 result = true;
287 RegDeleteValue(key, str); 284 RegDeleteValue(key, str);
288 } 285 }
289 286
290 RegCloseKey(key); 287 RegCloseKey(key);
291 288
292 // If we create the main key, delete the entire key. 289 // If we create the main key, delete the entire key.
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 588
592 BOOL __stdcall LaunchGoogleChromeInBackground() { 589 BOOL __stdcall LaunchGoogleChromeInBackground() {
593 return LaunchGoogleChromeWithDimensions(-1, -1, -1, -1, true); 590 return LaunchGoogleChromeWithDimensions(-1, -1, -1, -1, true);
594 } 591 }
595 592
596 int __stdcall GoogleChromeDaysSinceLastRun() { 593 int __stdcall GoogleChromeDaysSinceLastRun() {
597 int days_since_last_run = std::numeric_limits<int>::max(); 594 int days_since_last_run = std::numeric_limits<int>::max();
598 595
599 if (IsChromeInstalled(HKEY_LOCAL_MACHINE) || 596 if (IsChromeInstalled(HKEY_LOCAL_MACHINE) ||
600 IsChromeInstalled(HKEY_CURRENT_USER)) { 597 IsChromeInstalled(HKEY_CURRENT_USER)) {
601 RegKey client_state(HKEY_CURRENT_USER, 598 RegKey client_state(
602 kChromeRegClientStateKey, 599 HKEY_CURRENT_USER, kChromeRegClientStateKey, KEY_QUERY_VALUE);
603 KEY_QUERY_VALUE | KEY_WOW64_32KEY);
604 if (client_state.Valid()) { 600 if (client_state.Valid()) {
605 std::wstring last_run; 601 std::wstring last_run;
606 int64 last_run_value = 0; 602 int64 last_run_value = 0;
607 if (client_state.ReadValue(google_update::kRegLastRunTimeField, 603 if (client_state.ReadValue(google_update::kRegLastRunTimeField,
608 &last_run) == ERROR_SUCCESS && 604 &last_run) == ERROR_SUCCESS &&
609 base::StringToInt64(last_run, &last_run_value)) { 605 base::StringToInt64(last_run, &last_run_value)) {
610 Time last_run_time = Time::FromInternalValue(last_run_value); 606 Time last_run_time = Time::FromInternalValue(last_run_value);
611 TimeDelta difference = Time::NowFromSystemTime() - last_run_time; 607 TimeDelta difference = Time::NowFromSystemTime() - last_run_time;
612 608
613 // We can end up with negative numbers here, given changes in system 609 // We can end up with negative numbers here, given changes in system
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 days_since_last_run < kRelaunchMinDaysDormant) { 741 days_since_last_run < kRelaunchMinDaysDormant) {
746 if (error_code) 742 if (error_code)
747 *error_code = RELAUNCH_ERROR_NOTDORMANT; 743 *error_code = RELAUNCH_ERROR_NOTDORMANT;
748 return FALSE; 744 return FALSE;
749 } 745 }
750 746
751 // e) a minimum period (6 months) must have passed since the previous 747 // e) a minimum period (6 months) must have passed since the previous
752 // relaunch offer for the current user; 748 // relaunch offer for the current user;
753 RegKey key; 749 RegKey key;
754 DWORD min_relaunch_date; 750 DWORD min_relaunch_date;
755 if (key.Open(HKEY_CURRENT_USER, 751 if (key.Open(HKEY_CURRENT_USER, kChromeRegClientStateKey,
756 kChromeRegClientStateKey, 752 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
757 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS &&
758 key.ReadValueDW(kRelaunchAllowedAfterValue, 753 key.ReadValueDW(kRelaunchAllowedAfterValue,
759 &min_relaunch_date) == ERROR_SUCCESS && 754 &min_relaunch_date) == ERROR_SUCCESS &&
760 FormatDateOffsetByMonths(0) < min_relaunch_date) { 755 FormatDateOffsetByMonths(0) < min_relaunch_date) {
761 if (error_code) 756 if (error_code)
762 *error_code = RELAUNCH_ERROR_ALREADY_RELAUNCHED; 757 *error_code = RELAUNCH_ERROR_ALREADY_RELAUNCHED;
763 return FALSE; 758 return FALSE;
764 } 759 }
765 760
766 return TRUE; 761 return TRUE;
767 } 762 }
768 763
769 BOOL __stdcall SetRelaunchOffered(const wchar_t** partner_brandcode_list, 764 BOOL __stdcall SetRelaunchOffered(const wchar_t** partner_brandcode_list,
770 int partner_brandcode_list_length, 765 int partner_brandcode_list_length,
771 const wchar_t* relaunch_brandcode, 766 const wchar_t* relaunch_brandcode,
772 int shell_mode, 767 int shell_mode,
773 DWORD* error_code) { 768 DWORD* error_code) {
774 if (!CanOfferRelaunch(partner_brandcode_list, partner_brandcode_list_length, 769 if (!CanOfferRelaunch(partner_brandcode_list, partner_brandcode_list_length,
775 shell_mode, error_code)) 770 shell_mode, error_code))
776 return FALSE; 771 return FALSE;
777 772
778 // Store the relaunched brand code and the minimum date for relaunch (6 months 773 // Store the relaunched brand code and the minimum date for relaunch (6 months
779 // from now), and set the Omaha experiment label. 774 // from now), and set the Omaha experiment label.
780 RegKey key; 775 RegKey key;
781 if (key.Create(HKEY_CURRENT_USER, 776 if (key.Create(HKEY_CURRENT_USER, kChromeRegClientStateKey,
782 kChromeRegClientStateKey, 777 KEY_SET_VALUE) != ERROR_SUCCESS ||
783 KEY_SET_VALUE | KEY_WOW64_32KEY) != ERROR_SUCCESS ||
784 key.WriteValue(kRelaunchBrandcodeValue, 778 key.WriteValue(kRelaunchBrandcodeValue,
785 relaunch_brandcode) != ERROR_SUCCESS || 779 relaunch_brandcode) != ERROR_SUCCESS ||
786 key.WriteValue(kRelaunchAllowedAfterValue, 780 key.WriteValue(kRelaunchAllowedAfterValue,
787 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || 781 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS ||
788 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { 782 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) {
789 if (error_code) 783 if (error_code)
790 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; 784 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED;
791 return FALSE; 785 return FALSE;
792 } 786 }
793 787
794 return TRUE; 788 return TRUE;
795 } 789 }
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/gcapi/gcapi_last_run_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698