Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: chrome/browser/policy/configuration_policy_pref_store.cc

Issue 7147015: Move user cloud policy to BrowserProcess (was 6979011) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit_test include breakage Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 394 }
398 return false; 395 return false;
399 } 396 }
400 397
401 bool ConfigurationPolicyPrefKeeper::ApplyProxyPolicy( 398 bool ConfigurationPolicyPrefKeeper::ApplyProxyPolicy(
402 ConfigurationPolicyType policy, 399 ConfigurationPolicyType policy,
403 Value* value) { 400 Value* value) {
404 // We only collect the values until we have sufficient information when 401 // We only collect the values until we have sufficient information when
405 // FinalizeProxyPolicySettings() is called to determine whether the presented 402 // FinalizeProxyPolicySettings() is called to determine whether the presented
406 // values were correct and apply them in that case. 403 // values were correct and apply them in that case.
407 if (policy == kPolicyProxyMode || 404 if (ConfigurationPolicyPrefStore::IsProxyPolicy(policy)) {
408 policy == kPolicyProxyServerMode ||
409 policy == kPolicyProxyServer ||
410 policy == kPolicyProxyPacUrl ||
411 policy == kPolicyProxyBypassList) {
412 delete proxy_policies_[policy]; 405 delete proxy_policies_[policy];
413 proxy_policies_[policy] = value; 406 proxy_policies_[policy] = value;
414 return true; 407 return true;
415 } 408 }
416 // We are not interested in this policy. 409 // We are not interested in this policy.
417 return false; 410 return false;
418 } 411 }
419 412
420 bool ConfigurationPolicyPrefKeeper::ApplySyncPolicy( 413 bool ConfigurationPolicyPrefKeeper::ApplySyncPolicy(
421 ConfigurationPolicyType policy, Value* value) { 414 ConfigurationPolicyType policy, Value* value) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 ConfigurationPolicyPrefStore* 886 ConfigurationPolicyPrefStore*
894 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() { 887 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore() {
895 BrowserPolicyConnector* connector = 888 BrowserPolicyConnector* connector =
896 g_browser_process->browser_policy_connector(); 889 g_browser_process->browser_policy_connector();
897 return new ConfigurationPolicyPrefStore( 890 return new ConfigurationPolicyPrefStore(
898 connector->GetManagedPlatformProvider()); 891 connector->GetManagedPlatformProvider());
899 } 892 }
900 893
901 // static 894 // static
902 ConfigurationPolicyPrefStore* 895 ConfigurationPolicyPrefStore*
903 ConfigurationPolicyPrefStore::CreateManagedCloudPolicyPrefStore( 896 ConfigurationPolicyPrefStore::CreateManagedCloudPolicyPrefStore() {
904 Profile* profile) { 897 return new ConfigurationPolicyPrefStore(
905 ConfigurationPolicyProvider* provider = NULL; 898 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 } 899 }
918 900
919 // static 901 // static
920 ConfigurationPolicyPrefStore* 902 ConfigurationPolicyPrefStore*
921 ConfigurationPolicyPrefStore::CreateRecommendedPlatformPolicyPrefStore() { 903 ConfigurationPolicyPrefStore::CreateRecommendedPlatformPolicyPrefStore() {
922 BrowserPolicyConnector* connector = 904 BrowserPolicyConnector* connector =
923 g_browser_process->browser_policy_connector(); 905 g_browser_process->browser_policy_connector();
924 return new ConfigurationPolicyPrefStore( 906 return new ConfigurationPolicyPrefStore(
925 connector->GetRecommendedPlatformProvider()); 907 connector->GetRecommendedPlatformProvider());
926 } 908 }
927 909
928 // static 910 // static
929 ConfigurationPolicyPrefStore* 911 ConfigurationPolicyPrefStore*
930 ConfigurationPolicyPrefStore::CreateRecommendedCloudPolicyPrefStore( 912 ConfigurationPolicyPrefStore::CreateRecommendedCloudPolicyPrefStore() {
931 Profile* profile) { 913 return new ConfigurationPolicyPrefStore(
932 ConfigurationPolicyProvider* provider = NULL; 914 g_browser_process->browser_policy_connector()->
933 if (profile) { 915 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 } 916 }
945 917
946 /* static */ 918 /* static */
947 const ConfigurationPolicyProvider::PolicyDefinitionList* 919 const ConfigurationPolicyProvider::PolicyDefinitionList*
948 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { 920 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() {
949 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { 921 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = {
950 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation }, 922 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation },
951 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, 923 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN,
952 key::kHomepageIsNewTabPage }, 924 key::kHomepageIsNewTabPage },
953 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, 925 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup },
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 #endif 1072 #endif
1101 }; 1073 };
1102 1074
1103 static ConfigurationPolicyProvider::PolicyDefinitionList policy_list = { 1075 static ConfigurationPolicyProvider::PolicyDefinitionList policy_list = {
1104 entries, 1076 entries,
1105 entries + arraysize(entries), 1077 entries + arraysize(entries),
1106 }; 1078 };
1107 return &policy_list; 1079 return &policy_list;
1108 } 1080 }
1109 1081
1082 bool
1083 ConfigurationPolicyPrefStore::IsProxyPolicy(ConfigurationPolicyType policy) {
1084 return policy == kPolicyProxyMode ||
1085 policy == kPolicyProxyServerMode ||
1086 policy == kPolicyProxyServer ||
1087 policy == kPolicyProxyPacUrl ||
1088 policy == kPolicyProxyBypassList;
1089 }
1090
1110 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( 1091 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore(
1111 ConfigurationPolicyProvider* provider) 1092 ConfigurationPolicyProvider* provider)
1112 : provider_(provider), 1093 : provider_(provider),
1113 initialization_complete_(false) { 1094 initialization_complete_(false) {
1114 if (provider_) { 1095 if (provider_) {
1115 // Read initial policy. 1096 // Read initial policy.
1116 policy_keeper_.reset(new ConfigurationPolicyPrefKeeper(provider)); 1097 policy_keeper_.reset(new ConfigurationPolicyPrefKeeper(provider));
1117 registrar_.Init(provider_, this); 1098 registrar_.Init(provider_, this);
1118 initialization_complete_ = provider->IsInitializationComplete(); 1099 initialization_complete_ = provider->IsInitializationComplete();
1119 } else { 1100 } else {
(...skipping 23 matching lines...) Expand all
1143 // Update the initialization flag. 1124 // Update the initialization flag.
1144 if (!initialization_complete_ && 1125 if (!initialization_complete_ &&
1145 provider_->IsInitializationComplete()) { 1126 provider_->IsInitializationComplete()) {
1146 initialization_complete_ = true; 1127 initialization_complete_ = true;
1147 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 1128 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
1148 OnInitializationCompleted(true)); 1129 OnInitializationCompleted(true));
1149 } 1130 }
1150 } 1131 }
1151 1132
1152 } // namespace policy 1133 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store.h ('k') | chrome/browser/policy/configuration_policy_store_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698