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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 GoogleUpdateSettings::AUTOMATIC_UPDATES; | 48 GoogleUpdateSettings::AUTOMATIC_UPDATES; |
49 #else | 49 #else |
50 GoogleUpdateSettings::UPDATES_DISABLED; | 50 GoogleUpdateSettings::UPDATES_DISABLED; |
51 #endif | 51 #endif |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { | 55 bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { |
56 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 56 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
57 std::wstring reg_path = dist->GetStateKey(); | 57 std::wstring reg_path = dist->GetStateKey(); |
58 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); | 58 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WOW64_32KEY); |
59 if (key.ReadValue(name, value) != ERROR_SUCCESS) { | 59 if (key.ReadValue(name, value) != ERROR_SUCCESS) { |
60 RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); | 60 RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), |
| 61 KEY_READ | KEY_WOW64_32KEY); |
61 return (hklm_key.ReadValue(name, value) == ERROR_SUCCESS); | 62 return (hklm_key.ReadValue(name, value) == ERROR_SUCCESS); |
62 } | 63 } |
63 return true; | 64 return true; |
64 } | 65 } |
65 | 66 |
66 // Update a state registry key |name| to be |value| for the given browser | 67 // Update a state registry key |name| to be |value| for the given browser |
67 // |dist|. If this is a |system_install|, then update the value under | 68 // |dist|. If this is a |system_install|, then update the value under |
68 // HKLM (istead of HKCU for user-installs) using a group of keys (one | 69 // HKLM (istead of HKCU for user-installs) using a group of keys (one |
69 // for each OS user) and also include the method to |aggregate| these | 70 // for each OS user) and also include the method to |aggregate| these |
70 // values when reporting. | 71 // values when reporting. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 BrowserDistribution::GetSpecificDistribution( | 120 BrowserDistribution::GetSpecificDistribution( |
120 BrowserDistribution::CHROME_BINARIES); | 121 BrowserDistribution::CHROME_BINARIES); |
121 return | 122 return |
122 WriteGoogleUpdateStrKeyInternal(multi_dist, false, name, value, NULL) && | 123 WriteGoogleUpdateStrKeyInternal(multi_dist, false, name, value, NULL) && |
123 result; | 124 result; |
124 } | 125 } |
125 | 126 |
126 bool ClearGoogleUpdateStrKey(const wchar_t* const name) { | 127 bool ClearGoogleUpdateStrKey(const wchar_t* const name) { |
127 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 128 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
128 std::wstring reg_path = dist->GetStateKey(); | 129 std::wstring reg_path = dist->GetStateKey(); |
129 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE); | 130 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), |
| 131 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); |
130 std::wstring value; | 132 std::wstring value; |
131 if (key.ReadValue(name, &value) != ERROR_SUCCESS) | 133 if (key.ReadValue(name, &value) != ERROR_SUCCESS) |
132 return false; | 134 return false; |
133 return (key.WriteValue(name, L"") == ERROR_SUCCESS); | 135 return (key.WriteValue(name, L"") == ERROR_SUCCESS); |
134 } | 136 } |
135 | 137 |
136 bool RemoveGoogleUpdateStrKey(const wchar_t* const name) { | 138 bool RemoveGoogleUpdateStrKey(const wchar_t* const name) { |
137 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 139 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
138 std::wstring reg_path = dist->GetStateKey(); | 140 std::wstring reg_path = dist->GetStateKey(); |
139 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE); | 141 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), |
| 142 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); |
140 if (!key.HasValue(name)) | 143 if (!key.HasValue(name)) |
141 return true; | 144 return true; |
142 return (key.DeleteValue(name) == ERROR_SUCCESS); | 145 return (key.DeleteValue(name) == ERROR_SUCCESS); |
143 } | 146 } |
144 | 147 |
145 bool GetChromeChannelInternal(bool system_install, | 148 bool GetChromeChannelInternal(bool system_install, |
146 bool add_multi_modifier, | 149 bool add_multi_modifier, |
147 base::string16* channel) { | 150 base::string16* channel) { |
148 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 151 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
149 if (dist->GetChromeChannel(channel)) { | 152 if (dist->GetChromeChannel(channel)) { |
150 return true; | 153 return true; |
151 } | 154 } |
152 | 155 |
153 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 156 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
154 base::string16 reg_path = dist->GetStateKey(); | 157 base::string16 reg_path = dist->GetStateKey(); |
155 RegKey key(root_key, reg_path.c_str(), KEY_READ); | 158 RegKey key(root_key, reg_path.c_str(), KEY_READ | KEY_WOW64_32KEY); |
156 | 159 |
157 installer::ChannelInfo channel_info; | 160 installer::ChannelInfo channel_info; |
158 if (!channel_info.Initialize(key)) { | 161 if (!channel_info.Initialize(key)) { |
159 channel->assign(installer::kChromeChannelUnknown); | 162 channel->assign(installer::kChromeChannelUnknown); |
160 return false; | 163 return false; |
161 } | 164 } |
162 | 165 |
163 if (!channel_info.GetChannelName(channel)) { | 166 if (!channel_info.GetChannelName(channel)) { |
164 channel->assign(installer::kChromeChannelUnknown); | 167 channel->assign(installer::kChromeChannelUnknown); |
165 } | 168 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 DCHECK(archive_type != installer::UNKNOWN_ARCHIVE_TYPE || | 430 DCHECK(archive_type != installer::UNKNOWN_ARCHIVE_TYPE || |
428 install_return_code != 0); | 431 install_return_code != 0); |
429 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 432 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
430 | 433 |
431 RegKey key; | 434 RegKey key; |
432 installer::ChannelInfo channel_info; | 435 installer::ChannelInfo channel_info; |
433 std::wstring reg_key(google_update::kRegPathClientState); | 436 std::wstring reg_key(google_update::kRegPathClientState); |
434 reg_key.append(L"\\"); | 437 reg_key.append(L"\\"); |
435 reg_key.append(product_guid); | 438 reg_key.append(product_guid); |
436 LONG result = key.Open(reg_root, reg_key.c_str(), | 439 LONG result = key.Open(reg_root, reg_key.c_str(), |
437 KEY_QUERY_VALUE | KEY_SET_VALUE); | 440 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
438 if (result == ERROR_SUCCESS) | 441 if (result == ERROR_SUCCESS) |
439 channel_info.Initialize(key); | 442 channel_info.Initialize(key); |
440 else if (result != ERROR_FILE_NOT_FOUND) | 443 else if (result != ERROR_FILE_NOT_FOUND) |
441 LOG(ERROR) << "Failed to open " << reg_key << "; Error: " << result; | 444 LOG(ERROR) << "Failed to open " << reg_key << "; Error: " << result; |
442 | 445 |
443 if (UpdateGoogleUpdateApKey(archive_type, install_return_code, | 446 if (UpdateGoogleUpdateApKey(archive_type, install_return_code, |
444 &channel_info)) { | 447 &channel_info)) { |
445 // We have a modified channel_info value to write. | 448 // We have a modified channel_info value to write. |
446 // Create the app's ClientState key if it doesn't already exist. | 449 // Create the app's ClientState key if it doesn't already exist. |
447 if (!key.Valid()) { | 450 if (!key.Valid()) { |
448 result = key.Open(reg_root, google_update::kRegPathClientState, | 451 result = key.Open(reg_root, google_update::kRegPathClientState, |
449 KEY_CREATE_SUB_KEY); | 452 KEY_CREATE_SUB_KEY | KEY_WOW64_32KEY); |
450 if (result == ERROR_SUCCESS) | 453 if (result == ERROR_SUCCESS) |
451 result = key.CreateKey(product_guid.c_str(), KEY_SET_VALUE); | 454 result = key.CreateKey(product_guid.c_str(), |
| 455 KEY_SET_VALUE | KEY_WOW64_32KEY); |
452 | 456 |
453 if (result != ERROR_SUCCESS) { | 457 if (result != ERROR_SUCCESS) { |
454 LOG(ERROR) << "Failed to create " << reg_key << "; Error: " << result; | 458 LOG(ERROR) << "Failed to create " << reg_key << "; Error: " << result; |
455 return; | 459 return; |
456 } | 460 } |
457 } | 461 } |
458 if (!channel_info.Write(&key)) { | 462 if (!channel_info.Write(&key)) { |
459 LOG(ERROR) << "Failed to write to application's ClientState key " | 463 LOG(ERROR) << "Failed to write to application's ClientState key " |
460 << google_update::kRegApField << " = " << channel_info.value(); | 464 << google_update::kRegApField << " = " << channel_info.value(); |
461 } | 465 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 google_update::kRegProfilesSignedIn, | 516 google_update::kRegProfilesSignedIn, |
513 base::Int64ToString16(profiles_signedin), | 517 base::Int64ToString16(profiles_signedin), |
514 L"sum()"); | 518 L"sum()"); |
515 } | 519 } |
516 | 520 |
517 int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { | 521 int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { |
518 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 522 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
519 std::wstring reg_path = dist->GetStateKey(); | 523 std::wstring reg_path = dist->GetStateKey(); |
520 | 524 |
521 // Minimum access needed is to be able to write to this key. | 525 // Minimum access needed is to be able to write to this key. |
522 RegKey reg_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE); | 526 RegKey reg_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), |
| 527 KEY_SET_VALUE | KEY_WOW64_32KEY); |
523 if (!reg_key.Valid()) | 528 if (!reg_key.Valid()) |
524 return 0; | 529 return 0; |
525 | 530 |
526 HANDLE target_handle = 0; | 531 HANDLE target_handle = 0; |
527 if (!DuplicateHandle(GetCurrentProcess(), reg_key.Handle(), | 532 if (!DuplicateHandle(GetCurrentProcess(), reg_key.Handle(), |
528 GetCurrentProcess(), &target_handle, KEY_SET_VALUE, | 533 GetCurrentProcess(), &target_handle, KEY_SET_VALUE, |
529 TRUE, DUPLICATE_SAME_ACCESS)) { | 534 TRUE, DUPLICATE_SAME_ACCESS)) { |
530 return 0; | 535 return 0; |
531 } | 536 } |
532 return reinterpret_cast<int>(target_handle); | 537 return reinterpret_cast<int>(target_handle); |
(...skipping 12 matching lines...) Expand all Loading... |
545 const std::wstring& app_guid, | 550 const std::wstring& app_guid, |
546 bool* is_overridden) { | 551 bool* is_overridden) { |
547 bool found_override = false; | 552 bool found_override = false; |
548 UpdatePolicy update_policy = kDefaultUpdatePolicy; | 553 UpdatePolicy update_policy = kDefaultUpdatePolicy; |
549 | 554 |
550 #if defined(GOOGLE_CHROME_BUILD) | 555 #if defined(GOOGLE_CHROME_BUILD) |
551 DCHECK(!app_guid.empty()); | 556 DCHECK(!app_guid.empty()); |
552 RegKey policy_key; | 557 RegKey policy_key; |
553 | 558 |
554 // Google Update Group Policy settings are always in HKLM. | 559 // Google Update Group Policy settings are always in HKLM. |
| 560 // TODO(wfh): Check if policies should go into Wow6432Node or not. |
555 if (policy_key.Open(HKEY_LOCAL_MACHINE, kPoliciesKey, KEY_QUERY_VALUE) == | 561 if (policy_key.Open(HKEY_LOCAL_MACHINE, kPoliciesKey, KEY_QUERY_VALUE) == |
556 ERROR_SUCCESS) { | 562 ERROR_SUCCESS) { |
557 DWORD value = 0; | 563 DWORD value = 0; |
558 base::string16 app_update_override(kUpdateOverrideValuePrefix); | 564 base::string16 app_update_override(kUpdateOverrideValuePrefix); |
559 app_update_override.append(app_guid); | 565 app_update_override.append(app_guid); |
560 // First try to read and comprehend the app-specific override. | 566 // First try to read and comprehend the app-specific override. |
561 found_override = (policy_key.ReadValueDW(app_update_override.c_str(), | 567 found_override = (policy_key.ReadValueDW(app_update_override.c_str(), |
562 &value) == ERROR_SUCCESS && | 568 &value) == ERROR_SUCCESS && |
563 GetUpdatePolicyFromDword(value, &update_policy)); | 569 GetUpdatePolicyFromDword(value, &update_policy)); |
564 | 570 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 return cmd_line; | 702 return cmd_line; |
697 } | 703 } |
698 | 704 |
699 Version GoogleUpdateSettings::GetGoogleUpdateVersion(bool system_install) { | 705 Version GoogleUpdateSettings::GetGoogleUpdateVersion(bool system_install) { |
700 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 706 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
701 base::string16 version; | 707 base::string16 version; |
702 RegKey key; | 708 RegKey key; |
703 | 709 |
704 if (key.Open(root_key, | 710 if (key.Open(root_key, |
705 google_update::kRegPathGoogleUpdate, | 711 google_update::kRegPathGoogleUpdate, |
706 KEY_QUERY_VALUE) == ERROR_SUCCESS && | 712 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS && |
707 key.ReadValue(google_update::kRegGoogleUpdateVersion, | 713 key.ReadValue(google_update::kRegGoogleUpdateVersion, |
708 &version) == ERROR_SUCCESS) { | 714 &version) == ERROR_SUCCESS) { |
709 return Version(base::UTF16ToUTF8(version)); | 715 return Version(base::UTF16ToUTF8(version)); |
710 } | 716 } |
711 | 717 |
712 return Version(); | 718 return Version(); |
713 } | 719 } |
714 | 720 |
715 base::Time GoogleUpdateSettings::GetGoogleUpdateLastStartedAU( | 721 base::Time GoogleUpdateSettings::GetGoogleUpdateLastStartedAU( |
716 bool system_install) { | 722 bool system_install) { |
717 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 723 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
718 RegKey update_key; | 724 RegKey update_key; |
719 | 725 |
720 if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate, | 726 if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate, |
721 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 727 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { |
722 DWORD last_start; | 728 DWORD last_start; |
723 if (update_key.ReadValueDW(google_update::kRegLastStartedAUField, | 729 if (update_key.ReadValueDW(google_update::kRegLastStartedAUField, |
724 &last_start) == ERROR_SUCCESS) { | 730 &last_start) == ERROR_SUCCESS) { |
725 return base::Time::FromTimeT(last_start); | 731 return base::Time::FromTimeT(last_start); |
726 } | 732 } |
727 } | 733 } |
728 | 734 |
729 return base::Time(); | 735 return base::Time(); |
730 } | 736 } |
731 | 737 |
732 base::Time GoogleUpdateSettings::GetGoogleUpdateLastChecked( | 738 base::Time GoogleUpdateSettings::GetGoogleUpdateLastChecked( |
733 bool system_install) { | 739 bool system_install) { |
734 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 740 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
735 RegKey update_key; | 741 RegKey update_key; |
736 | 742 |
737 if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate, | 743 if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate, |
738 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 744 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { |
739 DWORD last_check; | 745 DWORD last_check; |
740 if (update_key.ReadValueDW(google_update::kRegLastCheckedField, | 746 if (update_key.ReadValueDW(google_update::kRegLastCheckedField, |
741 &last_check) == ERROR_SUCCESS) { | 747 &last_check) == ERROR_SUCCESS) { |
742 return base::Time::FromTimeT(last_check); | 748 return base::Time::FromTimeT(last_check); |
743 } | 749 } |
744 } | 750 } |
745 | 751 |
746 return base::Time(); | 752 return base::Time(); |
747 } | 753 } |
748 | 754 |
749 bool GoogleUpdateSettings::GetUpdateDetailForApp(bool system_install, | 755 bool GoogleUpdateSettings::GetUpdateDetailForApp(bool system_install, |
750 const wchar_t* app_guid, | 756 const wchar_t* app_guid, |
751 ProductData* data) { | 757 ProductData* data) { |
752 DCHECK(app_guid); | 758 DCHECK(app_guid); |
753 DCHECK(data); | 759 DCHECK(data); |
754 | 760 |
755 bool product_found = false; | 761 bool product_found = false; |
756 | 762 |
757 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 763 const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
758 base::string16 clientstate_reg_path(google_update::kRegPathClientState); | 764 base::string16 clientstate_reg_path(google_update::kRegPathClientState); |
759 clientstate_reg_path.append(L"\\"); | 765 clientstate_reg_path.append(L"\\"); |
760 clientstate_reg_path.append(app_guid); | 766 clientstate_reg_path.append(app_guid); |
761 | 767 |
762 RegKey clientstate; | 768 RegKey clientstate; |
763 if (clientstate.Open(root_key, clientstate_reg_path.c_str(), | 769 if (clientstate.Open(root_key, clientstate_reg_path.c_str(), |
764 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 770 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { |
765 base::string16 version; | 771 base::string16 version; |
766 DWORD dword_value; | 772 DWORD dword_value; |
767 if ((clientstate.ReadValueDW(google_update::kRegLastCheckSuccessField, | 773 if ((clientstate.ReadValueDW(google_update::kRegLastCheckSuccessField, |
768 &dword_value) == ERROR_SUCCESS) && | 774 &dword_value) == ERROR_SUCCESS) && |
769 (clientstate.ReadValue(google_update::kRegVersionField, | 775 (clientstate.ReadValue(google_update::kRegVersionField, |
770 &version) == ERROR_SUCCESS)) { | 776 &version) == ERROR_SUCCESS)) { |
771 product_found = true; | 777 product_found = true; |
772 data->version = base::UTF16ToASCII(version); | 778 data->version = base::UTF16ToASCII(version); |
773 data->last_success = base::Time::FromTimeT(dword_value); | 779 data->last_success = base::Time::FromTimeT(dword_value); |
774 data->last_result = 0; | 780 data->last_result = 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 823 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
818 | 824 |
819 // Use the browser distribution and install level to write to the correct | 825 // Use the browser distribution and install level to write to the correct |
820 // client state/app guid key. | 826 // client state/app guid key. |
821 bool success = false; | 827 bool success = false; |
822 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 828 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
823 if (dist->ShouldSetExperimentLabels()) { | 829 if (dist->ShouldSetExperimentLabels()) { |
824 base::string16 client_state_path( | 830 base::string16 client_state_path( |
825 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); | 831 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); |
826 RegKey client_state( | 832 RegKey client_state( |
827 reg_root, client_state_path.c_str(), KEY_SET_VALUE); | 833 reg_root, client_state_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); |
828 if (experiment_labels.empty()) { | 834 if (experiment_labels.empty()) { |
829 success = client_state.DeleteValue(google_update::kExperimentLabels) | 835 success = client_state.DeleteValue(google_update::kExperimentLabels) |
830 == ERROR_SUCCESS; | 836 == ERROR_SUCCESS; |
831 } else { | 837 } else { |
832 success = client_state.WriteValue(google_update::kExperimentLabels, | 838 success = client_state.WriteValue(google_update::kExperimentLabels, |
833 experiment_labels.c_str()) == ERROR_SUCCESS; | 839 experiment_labels.c_str()) == ERROR_SUCCESS; |
834 } | 840 } |
835 } | 841 } |
836 | 842 |
837 return success; | 843 return success; |
838 } | 844 } |
839 | 845 |
840 bool GoogleUpdateSettings::ReadExperimentLabels( | 846 bool GoogleUpdateSettings::ReadExperimentLabels( |
841 bool system_install, | 847 bool system_install, |
842 base::string16* experiment_labels) { | 848 base::string16* experiment_labels) { |
843 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 849 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
844 | 850 |
845 // If this distribution does not set the experiment labels, don't bother | 851 // If this distribution does not set the experiment labels, don't bother |
846 // reading. | 852 // reading. |
847 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 853 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
848 if (!dist->ShouldSetExperimentLabels()) | 854 if (!dist->ShouldSetExperimentLabels()) |
849 return false; | 855 return false; |
850 | 856 |
851 base::string16 client_state_path( | 857 base::string16 client_state_path( |
852 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); | 858 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); |
853 | 859 |
854 RegKey client_state; | 860 RegKey client_state; |
855 LONG result = | 861 LONG result = client_state.Open(reg_root, client_state_path.c_str(), |
856 client_state.Open(reg_root, client_state_path.c_str(), KEY_QUERY_VALUE); | 862 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
857 if (result == ERROR_SUCCESS) { | 863 if (result == ERROR_SUCCESS) { |
858 result = client_state.ReadValue(google_update::kExperimentLabels, | 864 result = client_state.ReadValue(google_update::kExperimentLabels, |
859 experiment_labels); | 865 experiment_labels); |
860 } | 866 } |
861 | 867 |
862 // If the key or value was not present, return the empty string. | 868 // If the key or value was not present, return the empty string. |
863 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 869 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
864 experiment_labels->clear(); | 870 experiment_labels->clear(); |
865 return true; | 871 return true; |
866 } | 872 } |
867 | 873 |
868 return result == ERROR_SUCCESS; | 874 return result == ERROR_SUCCESS; |
869 } | 875 } |
OLD | NEW |