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 | |
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 | |
861 // Use the browser distribution and install level to write to the correct | 855 // Use the browser distribution and install level to write to the correct |
862 // client state/app guid key. | 856 // client state/app guid key. |
863 bool success = false; | 857 bool success = false; |
864 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 858 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
865 base::string16 client_state_path(system_install ? dist->GetStateMediumKey() | 859 base::string16 client_state_path(system_install ? dist->GetStateMediumKey() |
866 : dist->GetStateKey()); | 860 : dist->GetStateKey()); |
867 RegKey client_state(reg_root, client_state_path.c_str(), | 861 RegKey client_state(reg_root, client_state_path.c_str(), |
868 KEY_SET_VALUE | KEY_WOW64_32KEY); | 862 KEY_SET_VALUE | KEY_WOW64_32KEY); |
869 // It is possible that the registry keys do not yet exist or have not yet | 863 // 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. | 864 // been ACLed by Google Update to be user writable. |
871 if (!client_state.Valid()) | 865 if (!client_state.Valid()) |
872 return false; | 866 return false; |
873 if (experiment_labels.empty()) { | 867 if (experiment_labels.empty()) { |
874 success = client_state.DeleteValue(google_update::kExperimentLabels) == | 868 success = client_state.DeleteValue(google_update::kExperimentLabels) == |
875 ERROR_SUCCESS; | 869 ERROR_SUCCESS; |
876 } else { | 870 } else { |
877 success = | 871 success = |
878 client_state.WriteValue(google_update::kExperimentLabels, | 872 client_state.WriteValue(google_update::kExperimentLabels, |
879 experiment_labels.c_str()) == ERROR_SUCCESS; | 873 experiment_labels.c_str()) == ERROR_SUCCESS; |
880 } | 874 } |
881 | 875 |
882 return success; | 876 return success; |
883 } | 877 } |
884 | 878 |
885 bool GoogleUpdateSettings::ReadExperimentLabels( | 879 bool GoogleUpdateSettings::ReadExperimentLabels( |
886 bool system_install, | 880 bool system_install, |
887 base::string16* experiment_labels) { | 881 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; | 882 HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
894 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 883 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
895 base::string16 client_state_path( | 884 base::string16 client_state_path( |
896 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); | 885 system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); |
897 | 886 |
898 RegKey client_state; | 887 RegKey client_state; |
899 LONG result = client_state.Open( | 888 LONG result = client_state.Open( |
900 reg_root, client_state_path.c_str(), KEY_QUERY_VALUE | KEY_WOW64_32KEY); | 889 reg_root, client_state_path.c_str(), KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
901 if (result == ERROR_SUCCESS) { | 890 if (result == ERROR_SUCCESS) { |
902 result = client_state.ReadValue(google_update::kExperimentLabels, | 891 result = client_state.ReadValue(google_update::kExperimentLabels, |
903 experiment_labels); | 892 experiment_labels); |
904 } | 893 } |
905 | 894 |
906 // If the key or value was not present, return the empty string. | 895 // If the key or value was not present, return the empty string. |
907 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 896 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
908 experiment_labels->clear(); | 897 experiment_labels->clear(); |
909 return true; | 898 return true; |
910 } | 899 } |
911 | 900 |
912 return result == ERROR_SUCCESS; | 901 return result == ERROR_SUCCESS; |
913 } | 902 } |
OLD | NEW |