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

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

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, fix up unit tests. Created 10 years 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) 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/policy/configuration_policy_pref_store.h" 5 #include "chrome/browser/policy/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/path_service.h" 9 #include "base/path_service.h"
10 #include "base/singleton.h" 10 #include "base/singleton.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 315 }
316 316
317 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( 317 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore(
318 ConfigurationPolicyProvider* provider) 318 ConfigurationPolicyProvider* provider)
319 : provider_(provider), 319 : provider_(provider),
320 prefs_(new DictionaryValue()), 320 prefs_(new DictionaryValue()),
321 lower_priority_proxy_settings_overridden_(false), 321 lower_priority_proxy_settings_overridden_(false),
322 proxy_disabled_(false), 322 proxy_disabled_(false),
323 proxy_configuration_specified_(false), 323 proxy_configuration_specified_(false),
324 use_system_proxy_(false) { 324 use_system_proxy_(false) {
325 if (!provider_->Provide(this))
326 LOG(WARNING) << "Failed to get policy from provider.";
327 FinalizeDefaultSearchPolicySettings();
325 } 328 }
326 329
327 PrefStore::PrefReadError ConfigurationPolicyPrefStore::ReadPrefs() { 330 PrefStore::ReadResult ConfigurationPolicyPrefStore::GetValue(
328 proxy_disabled_ = false; 331 const std::string& key,
329 proxy_configuration_specified_ = false; 332 Value** value) const {
330 lower_priority_proxy_settings_overridden_ = false; 333 Value* configured_value = NULL;
334 if (!prefs_->Get(key, &configured_value) || !configured_value)
335 return READ_NO_VALUE;
331 336
332 const bool success = (provider_ == NULL || provider_->Provide(this)); 337 if (configured_value->IsType(Value::TYPE_NULL))
333 FinalizeDefaultSearchPolicySettings(); 338 return READ_USE_DEFAULT;
334 return success ? PrefStore::PREF_READ_ERROR_NONE : 339
335 PrefStore::PREF_READ_ERROR_OTHER; 340 *value = configured_value;
341 return READ_OK;
336 } 342 }
337 343
338 void ConfigurationPolicyPrefStore::Apply(ConfigurationPolicyType policy, 344 void ConfigurationPolicyPrefStore::Apply(ConfigurationPolicyType policy,
339 Value* value) { 345 Value* value) {
340 if (ApplyProxyPolicy(policy, value)) 346 if (ApplyProxyPolicy(policy, value))
341 return; 347 return;
342 348
343 if (ApplySyncPolicy(policy, value)) 349 if (ApplySyncPolicy(policy, value))
344 return; 350 return;
345 351
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // proxy-related command-line switches or set proxy-related prefs in an 463 // proxy-related command-line switches or set proxy-related prefs in an
458 // extension that are related, but not identical, to the ones set through 464 // extension that are related, but not identical, to the ones set through
459 // policy. 465 // policy.
460 if (!lower_priority_proxy_settings_overridden_ && 466 if (!lower_priority_proxy_settings_overridden_ &&
461 (match_entry || 467 (match_entry ||
462 policy == kPolicyProxyServerMode)) { 468 policy == kPolicyProxyServerMode)) {
463 ProxyPreferenceSet proxy_preference_set; 469 ProxyPreferenceSet proxy_preference_set;
464 GetProxyPreferenceSet(&proxy_preference_set); 470 GetProxyPreferenceSet(&proxy_preference_set);
465 for (ProxyPreferenceSet::const_iterator i = proxy_preference_set.begin(); 471 for (ProxyPreferenceSet::const_iterator i = proxy_preference_set.begin();
466 i != proxy_preference_set.end(); ++i) { 472 i != proxy_preference_set.end(); ++i) {
467 prefs_->Set(*i, PrefStore::CreateUseDefaultSentinelValue()); 473 prefs_->Set(*i, Value::CreateNullValue());
danno 2010/12/08 13:08:45 Through comment or well named method it should be
Mattias Nissler (ping if slow) 2010/12/09 10:20:20 Done.
468 } 474 }
469 lower_priority_proxy_settings_overridden_ = true; 475 lower_priority_proxy_settings_overridden_ = true;
470 } 476 }
471 477
472 // Translate the proxy policy into preferences. 478 // Translate the proxy policy into preferences.
473 if (policy == kPolicyProxyServerMode) { 479 if (policy == kPolicyProxyServerMode) {
474 int int_value; 480 int int_value;
475 bool proxy_auto_detect = false; 481 bool proxy_auto_detect = false;
476 if (value->GetAsInteger(&int_value)) { 482 if (value->GetAsInteger(&int_value)) {
477 result = true; 483 result = true;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 std::string()); 649 std::string());
644 return; 650 return;
645 } 651 }
646 } 652 }
647 // Required entries are not there. Remove any related entries. 653 // Required entries are not there. Remove any related entries.
648 RemovePreferencesOfMap(kDefaultSearchPolicyMap, 654 RemovePreferencesOfMap(kDefaultSearchPolicyMap,
649 arraysize(kDefaultSearchPolicyMap)); 655 arraysize(kDefaultSearchPolicyMap));
650 } 656 }
651 657
652 } // namespace policy 658 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698