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

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

Issue 2905003: Implement support for disabling sync through configuration management. (Closed)
Patch Set: Fix PrefsControllerTest on MAC. Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/configuration_policy_pref_store.h" 5 #include "chrome/browser/configuration_policy_pref_store.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/configuration_policy_provider.h" 10 #include "chrome/browser/configuration_policy_provider.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 << " system proxy settings should be used but also specifies" 217 << " system proxy settings should be used but also specifies"
218 << " an explicit proxy configuration."; 218 << " an explicit proxy configuration.";
219 } 219 }
220 220
221 // If the policy was a proxy policy, cleanup |value|. 221 // If the policy was a proxy policy, cleanup |value|.
222 if (result && value) 222 if (result && value)
223 delete value; 223 delete value;
224 return result; 224 return result;
225 } 225 }
226 226
227 bool ConfigurationPolicyPrefStore::ApplySyncPolicy(PolicyType policy,
228 Value* value) {
229 if (policy == ConfigurationPolicyStore::kPolicySyncDisabled) {
230 bool disable_sync;
231 if (value->GetAsBoolean(&disable_sync) && disable_sync)
232 prefs_->Set(prefs::kSyncManaged, value);
233 else
234 delete value;
235 return true;
236 }
237 return false;
238 }
239
227 bool ConfigurationPolicyPrefStore::ApplyPolicyFromMap(PolicyType policy, 240 bool ConfigurationPolicyPrefStore::ApplyPolicyFromMap(PolicyType policy,
228 Value* value, const PolicyToPreferenceMapEntry map[], int size) { 241 Value* value, const PolicyToPreferenceMapEntry map[], int size) {
229 const PolicyToPreferenceMapEntry* end = map + size; 242 const PolicyToPreferenceMapEntry* end = map + size;
230 for (const PolicyToPreferenceMapEntry* current = map; 243 for (const PolicyToPreferenceMapEntry* current = map;
231 current != end; ++current) { 244 current != end; ++current) {
232 if (current->policy_type == policy) { 245 if (current->policy_type == policy) {
233 DCHECK(current->value_type == value->GetType()); 246 DCHECK(current->value_type == value->GetType());
234 prefs_->Set(current->preference_path, value); 247 prefs_->Set(current->preference_path, value);
235 return true; 248 return true;
236 } 249 }
237 } 250 }
238 return false; 251 return false;
239 } 252 }
240 253
241 void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) { 254 void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) {
242 if (ApplyProxyPolicy(policy, value)) 255 if (ApplyProxyPolicy(policy, value))
243 return; 256 return;
244 257
258 if (ApplySyncPolicy(policy, value))
259 return;
260
245 if (ApplyPolicyFromMap(policy, value, simple_policy_map_, 261 if (ApplyPolicyFromMap(policy, value, simple_policy_map_,
246 arraysize(simple_policy_map_))) 262 arraysize(simple_policy_map_)))
247 return; 263 return;
248 264
249 // Other policy implementations go here. 265 // Other policy implementations go here.
250 NOTIMPLEMENTED(); 266 NOTIMPLEMENTED();
251 } 267 }
252
OLDNEW
« no previous file with comments | « chrome/browser/configuration_policy_pref_store.h ('k') | chrome/browser/configuration_policy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698