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/configuration_policy_provider.h" | 22 #include "chrome/browser/policy/configuration_policy_provider.h" |
22 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" | 23 #include "chrome/browser/policy/profile_policy_connector.h" |
23 #include "chrome/browser/policy/device_management_policy_provider.h" | |
24 #include "chrome/browser/policy/profile_policy_context.h" | |
25 #include "chrome/browser/prefs/pref_value_map.h" | 24 #include "chrome/browser/prefs/pref_value_map.h" |
26 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 25 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
27 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/search_engines/search_terms_data.h" | 27 #include "chrome/browser/search_engines/search_terms_data.h" |
29 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
30 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
31 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
32 #include "policy/policy_constants.h" | 31 #include "policy/policy_constants.h" |
33 | 32 |
34 namespace policy { | 33 namespace policy { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 prefs::kEnableAuthNegotiatePort }, | 220 prefs::kEnableAuthNegotiatePort }, |
222 { Value::TYPE_STRING, kPolicyAuthServerWhitelist, | 221 { Value::TYPE_STRING, kPolicyAuthServerWhitelist, |
223 prefs::kAuthServerWhitelist }, | 222 prefs::kAuthServerWhitelist }, |
224 { Value::TYPE_STRING, kPolicyAuthNegotiateDelegateWhitelist, | 223 { Value::TYPE_STRING, kPolicyAuthNegotiateDelegateWhitelist, |
225 prefs::kAuthNegotiateDelegateWhitelist }, | 224 prefs::kAuthNegotiateDelegateWhitelist }, |
226 { Value::TYPE_STRING, kPolicyGSSAPILibraryName, | 225 { Value::TYPE_STRING, kPolicyGSSAPILibraryName, |
227 prefs::kGSSAPILibraryName }, | 226 prefs::kGSSAPILibraryName }, |
228 { Value::TYPE_BOOLEAN, kPolicyDisable3DAPIs, | 227 { Value::TYPE_BOOLEAN, kPolicyDisable3DAPIs, |
229 prefs::kDisable3DAPIs }, | 228 prefs::kDisable3DAPIs }, |
230 { Value::TYPE_INTEGER, kPolicyPolicyRefreshRate, | 229 { Value::TYPE_INTEGER, kPolicyPolicyRefreshRate, |
231 prefs::kPolicyRefreshRate }, | 230 prefs::kPolicyUserPolicyRefreshRate }, |
232 { Value::TYPE_BOOLEAN, kPolicyInstantEnabled, prefs::kInstantEnabled }, | 231 { Value::TYPE_BOOLEAN, kPolicyInstantEnabled, prefs::kInstantEnabled }, |
233 { Value::TYPE_BOOLEAN, kPolicyDefaultBrowserSettingEnabled, | 232 { Value::TYPE_BOOLEAN, kPolicyDefaultBrowserSettingEnabled, |
234 prefs::kDefaultBrowserSettingEnabled }, | 233 prefs::kDefaultBrowserSettingEnabled }, |
235 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, | 234 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, |
236 prefs::kCloudPrintProxyEnabled }, | 235 prefs::kCloudPrintProxyEnabled }, |
237 { Value::TYPE_STRING, kPolicyDownloadDirectory, | 236 { Value::TYPE_STRING, kPolicyDownloadDirectory, |
238 prefs::kDownloadDefaultDirectory }, | 237 prefs::kDownloadDefaultDirectory }, |
239 | 238 |
240 #if defined(OS_CHROMEOS) | 239 #if defined(OS_CHROMEOS) |
241 { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, | 240 { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 Refresh(); | 730 Refresh(); |
732 } | 731 } |
733 | 732 |
734 void ConfigurationPolicyPrefStore::OnProviderGoingAway() { | 733 void ConfigurationPolicyPrefStore::OnProviderGoingAway() { |
735 provider_ = NULL; | 734 provider_ = NULL; |
736 } | 735 } |
737 | 736 |
738 // static | 737 // static |
739 ConfigurationPolicyPrefStore* | 738 ConfigurationPolicyPrefStore* |
740 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() { | 739 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() { |
741 ConfigurationPolicyProviderKeeper* keeper = | 740 BrowserPolicyConnector* connector = |
742 g_browser_process->configuration_policy_provider_keeper(); | 741 g_browser_process->browser_policy_connector(); |
743 return new ConfigurationPolicyPrefStore(keeper->managed_platform_provider()); | 742 return new ConfigurationPolicyPrefStore( |
| 743 connector->GetManagedPlatformProvider()); |
744 } | 744 } |
745 | 745 |
746 // static | 746 // static |
747 ConfigurationPolicyPrefStore* | 747 ConfigurationPolicyPrefStore* |
748 ConfigurationPolicyPrefStore::CreateManagedCloudPolicyPrefStore( | 748 ConfigurationPolicyPrefStore::CreateManagedCloudPolicyPrefStore( |
749 Profile* profile) { | 749 Profile* profile) { |
| 750 ConfigurationPolicyProvider* provider = NULL; |
750 if (profile) { | 751 if (profile) { |
751 return new ConfigurationPolicyPrefStore( | 752 // For user policy, return the profile's policy provider. |
752 profile->GetPolicyContext()->GetDeviceManagementPolicyProvider()); | 753 provider = profile->GetPolicyConnector()->GetManagedCloudProvider(); |
| 754 } else { |
| 755 // For device policy, return the provider of the browser process. |
| 756 BrowserPolicyConnector* connector = |
| 757 g_browser_process->browser_policy_connector(); |
| 758 provider = connector->GetManagedCloudProvider(); |
753 } | 759 } |
754 return new ConfigurationPolicyPrefStore(NULL); | 760 return new ConfigurationPolicyPrefStore(provider); |
755 } | 761 } |
756 | 762 |
757 // static | 763 // static |
758 ConfigurationPolicyPrefStore* | 764 ConfigurationPolicyPrefStore* |
759 ConfigurationPolicyPrefStore::CreateRecommendedPlatformPolicyPrefStore() { | 765 ConfigurationPolicyPrefStore::CreateRecommendedPlatformPolicyPrefStore() { |
760 ConfigurationPolicyProviderKeeper* keeper = | 766 BrowserPolicyConnector* connector = |
761 g_browser_process->configuration_policy_provider_keeper(); | 767 g_browser_process->browser_policy_connector(); |
762 return new ConfigurationPolicyPrefStore(keeper->recommended_provider()); | 768 return new ConfigurationPolicyPrefStore( |
| 769 connector->GetRecommendedPlatformProvider()); |
763 } | 770 } |
764 | 771 |
765 // static | 772 // static |
766 ConfigurationPolicyPrefStore* | 773 ConfigurationPolicyPrefStore* |
767 ConfigurationPolicyPrefStore::CreateRecommendedCloudPolicyPrefStore( | 774 ConfigurationPolicyPrefStore::CreateRecommendedCloudPolicyPrefStore( |
768 Profile* profile) { | 775 Profile* profile) { |
769 return new ConfigurationPolicyPrefStore(NULL); | 776 ConfigurationPolicyProvider* provider = NULL; |
| 777 if (profile) { |
| 778 // For user policy, return the profile's policy provider. |
| 779 provider = profile->GetPolicyConnector()->GetRecommendedCloudProvider(); |
| 780 } else { |
| 781 // For device policy, return the provider of the browser process. |
| 782 BrowserPolicyConnector* connector = |
| 783 g_browser_process->browser_policy_connector(); |
| 784 provider = connector->GetRecommendedCloudProvider(); |
| 785 } |
| 786 return new ConfigurationPolicyPrefStore(provider); |
770 } | 787 } |
771 | 788 |
772 /* static */ | 789 /* static */ |
773 const ConfigurationPolicyProvider::PolicyDefinitionList* | 790 const ConfigurationPolicyProvider::PolicyDefinitionList* |
774 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { | 791 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { |
775 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { | 792 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { |
776 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation }, | 793 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation }, |
777 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, | 794 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, |
778 key::kHomepageIsNewTabPage }, | 795 key::kHomepageIsNewTabPage }, |
779 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, | 796 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 // Update the initialization flag. | 927 // Update the initialization flag. |
911 if (!initialization_complete_ && | 928 if (!initialization_complete_ && |
912 provider_->IsInitializationComplete()) { | 929 provider_->IsInitializationComplete()) { |
913 initialization_complete_ = true; | 930 initialization_complete_ = true; |
914 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 931 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
915 OnInitializationCompleted()); | 932 OnInitializationCompleted()); |
916 } | 933 } |
917 } | 934 } |
918 | 935 |
919 } // namespace policy | 936 } // namespace policy |
OLD | NEW |