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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/configuration_policy_pref_store.cc
diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc
index 5a060b016cc7adbbfd3800710e0accc172e73386..abbf1ceddf0a149666b6175d247f542950669386 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store.cc
@@ -322,17 +322,23 @@ ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore(
proxy_disabled_(false),
proxy_configuration_specified_(false),
use_system_proxy_(false) {
+ if (!provider_->Provide(this))
+ LOG(WARNING) << "Failed to get policy from provider.";
+ FinalizeDefaultSearchPolicySettings();
}
-PrefStore::PrefReadError ConfigurationPolicyPrefStore::ReadPrefs() {
- proxy_disabled_ = false;
- proxy_configuration_specified_ = false;
- lower_priority_proxy_settings_overridden_ = false;
+PrefStore::ReadResult ConfigurationPolicyPrefStore::GetValue(
+ const std::string& key,
+ Value** value) const {
+ Value* configured_value = NULL;
+ if (!prefs_->Get(key, &configured_value) || !configured_value)
+ return READ_NO_VALUE;
- const bool success = (provider_ == NULL || provider_->Provide(this));
- FinalizeDefaultSearchPolicySettings();
- return success ? PrefStore::PREF_READ_ERROR_NONE :
- PrefStore::PREF_READ_ERROR_OTHER;
+ if (configured_value->IsType(Value::TYPE_NULL))
+ return READ_USE_DEFAULT;
+
+ *value = configured_value;
+ return READ_OK;
}
void ConfigurationPolicyPrefStore::Apply(ConfigurationPolicyType policy,
@@ -464,7 +470,7 @@ bool ConfigurationPolicyPrefStore::ApplyProxyPolicy(
GetProxyPreferenceSet(&proxy_preference_set);
for (ProxyPreferenceSet::const_iterator i = proxy_preference_set.begin();
i != proxy_preference_set.end(); ++i) {
- prefs_->Set(*i, PrefStore::CreateUseDefaultSentinelValue());
+ 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.
}
lower_priority_proxy_settings_overridden_ = true;
}

Powered by Google App Engine
This is Rietveld 408576698