OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/policy/configuration_policy_pref_store.h" | 5 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/policy/browser_policy_connector.h" | 21 #include "chrome/browser/policy/browser_policy_connector.h" |
22 #include "chrome/browser/policy/configuration_policy_provider.h" | 22 #include "chrome/browser/policy/configuration_policy_provider.h" |
23 #include "chrome/browser/policy/policy_path_parser.h" | 23 #include "chrome/browser/policy/policy_path_parser.h" |
24 #include "chrome/browser/policy/profile_policy_connector.h" | |
25 #include "chrome/browser/policy/profile_policy_connector_factory.h" | |
26 #include "chrome/browser/prefs/pref_value_map.h" | 24 #include "chrome/browser/prefs/pref_value_map.h" |
27 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 25 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
28 #include "chrome/browser/profiles/profile.h" | |
29 #include "chrome/browser/search_engines/search_terms_data.h" | 26 #include "chrome/browser/search_engines/search_terms_data.h" |
30 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
31 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
32 #include "content/common/notification_service.h" | 29 #include "content/common/notification_service.h" |
33 #include "policy/policy_constants.h" | 30 #include "policy/policy_constants.h" |
34 | 31 |
35 namespace policy { | 32 namespace policy { |
36 | 33 |
37 // Accepts policy settings from a ConfigurationPolicyProvider, converts them | 34 // Accepts policy settings from a ConfigurationPolicyProvider, converts them |
38 // to preferences and caches the result. | 35 // to preferences and caches the result. |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 ConfigurationPolicyPrefStore* | 890 ConfigurationPolicyPrefStore* |
894 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() { | 891 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() { |
895 BrowserPolicyConnector* connector = | 892 BrowserPolicyConnector* connector = |
896 g_browser_process->browser_policy_connector(); | 893 g_browser_process->browser_policy_connector(); |
897 return new ConfigurationPolicyPrefStore( | 894 return new ConfigurationPolicyPrefStore( |
898 connector->GetManagedPlatformProvider()); | 895 connector->GetManagedPlatformProvider()); |
899 } | 896 } |
900 | 897 |
901 // static | 898 // static |
902 ConfigurationPolicyPrefStore* | 899 ConfigurationPolicyPrefStore* |
903 ConfigurationPolicyPrefStore::CreateManagedCloudPolicyPrefStore( | 900 ConfigurationPolicyPrefStore::CreateManagedCloudPolicyPrefStore() { |
904 Profile* profile) { | 901 return new ConfigurationPolicyPrefStore( |
905 ConfigurationPolicyProvider* provider = NULL; | 902 g_browser_process->browser_policy_connector()->GetManagedCloudProvider()); |
906 if (profile) { | |
907 // For user policy, return the profile's policy provider. | |
908 provider = policy::ProfilePolicyConnectorFactory::GetForProfile(profile)-> | |
909 GetManagedCloudProvider(); | |
910 } else { | |
911 // For device policy, return the provider of the browser process. | |
912 BrowserPolicyConnector* connector = | |
913 g_browser_process->browser_policy_connector(); | |
914 provider = connector->GetManagedCloudProvider(); | |
915 } | |
916 return new ConfigurationPolicyPrefStore(provider); | |
917 } | 903 } |
918 | 904 |
919 // static | 905 // static |
920 ConfigurationPolicyPrefStore* | 906 ConfigurationPolicyPrefStore* |
921 ConfigurationPolicyPrefStore::CreateRecommendedPlatformPolicyPrefStore() { | 907 ConfigurationPolicyPrefStore::CreateRecommendedPlatformPolicyPrefStore() { |
922 BrowserPolicyConnector* connector = | 908 BrowserPolicyConnector* connector = |
923 g_browser_process->browser_policy_connector(); | 909 g_browser_process->browser_policy_connector(); |
924 return new ConfigurationPolicyPrefStore( | 910 return new ConfigurationPolicyPrefStore( |
925 connector->GetRecommendedPlatformProvider()); | 911 connector->GetRecommendedPlatformProvider()); |
926 } | 912 } |
927 | 913 |
928 // static | 914 // static |
929 ConfigurationPolicyPrefStore* | 915 ConfigurationPolicyPrefStore* |
930 ConfigurationPolicyPrefStore::CreateRecommendedCloudPolicyPrefStore( | 916 ConfigurationPolicyPrefStore::CreateRecommendedCloudPolicyPrefStore() { |
931 Profile* profile) { | 917 return new ConfigurationPolicyPrefStore( |
932 ConfigurationPolicyProvider* provider = NULL; | 918 g_browser_process->browser_policy_connector()-> |
933 if (profile) { | 919 GetRecommendedCloudProvider()); |
934 // For user policy, return the profile's policy provider. | |
935 provider = policy::ProfilePolicyConnectorFactory::GetForProfile(profile)-> | |
936 GetRecommendedCloudProvider(); | |
937 } else { | |
938 // For device policy, return the provider of the browser process. | |
939 BrowserPolicyConnector* connector = | |
940 g_browser_process->browser_policy_connector(); | |
941 provider = connector->GetRecommendedCloudProvider(); | |
942 } | |
943 return new ConfigurationPolicyPrefStore(provider); | |
944 } | 920 } |
945 | 921 |
946 /* static */ | 922 /* static */ |
947 const ConfigurationPolicyProvider::PolicyDefinitionList* | 923 const ConfigurationPolicyProvider::PolicyDefinitionList* |
948 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { | 924 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { |
949 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { | 925 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { |
950 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation }, | 926 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation }, |
951 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, | 927 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, |
952 key::kHomepageIsNewTabPage }, | 928 key::kHomepageIsNewTabPage }, |
953 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, | 929 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 // Update the initialization flag. | 1119 // Update the initialization flag. |
1144 if (!initialization_complete_ && | 1120 if (!initialization_complete_ && |
1145 provider_->IsInitializationComplete()) { | 1121 provider_->IsInitializationComplete()) { |
1146 initialization_complete_ = true; | 1122 initialization_complete_ = true; |
1147 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1123 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
1148 OnInitializationCompleted(true)); | 1124 OnInitializationCompleted(true)); |
1149 } | 1125 } |
1150 } | 1126 } |
1151 | 1127 |
1152 } // namespace policy | 1128 } // namespace policy |
OLD | NEW |