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