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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 } | 844 } |
845 | 845 |
846 bool GoogleUpdateSettings::GetUpdateDetail(ProductData* data) { | 846 bool GoogleUpdateSettings::GetUpdateDetail(ProductData* data) { |
847 return GetUpdateDetailForApp(!InstallUtil::IsPerUserInstall(), | 847 return GetUpdateDetailForApp(!InstallUtil::IsPerUserInstall(), |
848 install_static::GetAppGuid(), data); | 848 install_static::GetAppGuid(), data); |
849 } | 849 } |
850 | 850 |
851 bool GoogleUpdateSettings::SetExperimentLabels( | 851 bool GoogleUpdateSettings::SetExperimentLabels( |
852 bool system_install, | 852 bool system_install, |
853 const base::string16& experiment_labels) { | 853 const base::string16& experiment_labels) { |
854 // There is nothing to do if this brand does not support integration with | |
grt (UTC plus 2)
2017/05/31 12:24:10
please update GoogleUpdateSettingsTest so that it
nikunjb
2017/06/02 05:11:24
Done. (New CL for this https://codereview.chromium
| |
855 // Google Update. | |
856 if (!install_static::kUseGoogleUpdateIntegration) | |
857 return false; | |
858 | |
859 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 854 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
860 | 855 |
861 // Use the browser distribution and install level to write to the correct | 856 // Use the browser distribution and install level to write to the correct |
862 // client state/app guid key. | 857 // client state/app guid key. |
863 bool success = false; | 858 bool success = false; |
864 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 859 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
865 base::string16 client_state_path(system_install ? dist->GetStateMediumKey() | 860 base::string16 client_state_path(system_install ? dist->GetStateMediumKey() |
866 : dist->GetStateKey()); | 861 : dist->GetStateKey()); |
867 RegKey client_state(reg_root, client_state_path.c_str(), | 862 RegKey client_state(reg_root, client_state_path.c_str(), |
868 KEY_SET_VALUE | KEY_WOW64_32KEY); | 863 KEY_SET_VALUE | KEY_WOW64_32KEY); |
869 // It is possible that the registry keys do not yet exist or have not yet | 864 // It is possible that the registry keys do not yet exist or have not yet |
870 // been ACLed by Google Update to be user writable. | 865 // been ACLed by Google Update to be user writable. |
871 if (!client_state.Valid()) | 866 if (!client_state.Valid()) |
872 return false; | 867 return false; |
873 if (experiment_labels.empty()) { | 868 if (experiment_labels.empty()) { |
874 success = client_state.DeleteValue(google_update::kExperimentLabels) == | 869 success = client_state.DeleteValue(google_update::kExperimentLabels) == |
875 ERROR_SUCCESS; | 870 ERROR_SUCCESS; |
876 } else { | 871 } else { |
877 success = | 872 success = |
878 client_state.WriteValue(google_update::kExperimentLabels, | 873 client_state.WriteValue(google_update::kExperimentLabels, |
879 experiment_labels.c_str()) == ERROR_SUCCESS; | 874 experiment_labels.c_str()) == ERROR_SUCCESS; |
880 } | 875 } |
881 | 876 |
882 return success; | 877 return success; |
883 } | 878 } |
884 | 879 |
885 bool GoogleUpdateSettings::ReadExperimentLabels( | 880 bool GoogleUpdateSettings::ReadExperimentLabels( |
886 bool system_install, | 881 bool system_install, |
887 base::string16* experiment_labels) { | 882 base::string16* experiment_labels) { |
888 // There is nothing to do if this brand does not support integration with | |
889 // Google Update. | |
890 if (!install_static::kUseGoogleUpdateIntegration) | |
891 return false; | |
892 | |
893 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 883 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
894 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 884 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
895 base::string16 client_state_path( | 885 base::string16 client_state_path( |
896 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); | 886 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); |
897 | 887 |
898 RegKey client_state; | 888 RegKey client_state; |
899 LONG result = client_state.Open( | 889 LONG result = client_state.Open( |
900 reg_root, client_state_path.c_str(), KEY_QUERY_VALUE | KEY_WOW64_32KEY); | 890 reg_root, client_state_path.c_str(), KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
901 if (result == ERROR_SUCCESS) { | 891 if (result == ERROR_SUCCESS) { |
902 result = client_state.ReadValue(google_update::kExperimentLabels, | 892 result = client_state.ReadValue(google_update::kExperimentLabels, |
903 experiment_labels); | 893 experiment_labels); |
904 } | 894 } |
905 | 895 |
906 // If the key or value was not present, return the empty string. | 896 // If the key or value was not present, return the empty string. |
907 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 897 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
908 experiment_labels->clear(); | 898 experiment_labels->clear(); |
909 return true; | 899 return true; |
910 } | 900 } |
911 | 901 |
912 return result == ERROR_SUCCESS; | 902 return result == ERROR_SUCCESS; |
913 } | 903 } |
OLD | NEW |