| 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> |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 PrefStore::ReadResult | 354 PrefStore::ReadResult |
| 355 ConfigurationPolicyPrefKeeper::GetValue(const std::string& key, | 355 ConfigurationPolicyPrefKeeper::GetValue(const std::string& key, |
| 356 const Value** result) const { | 356 const Value** result) const { |
| 357 const Value* stored_value = NULL; | 357 const Value* stored_value = NULL; |
| 358 if (!prefs_.GetValue(key, &stored_value)) | 358 if (!prefs_.GetValue(key, &stored_value)) |
| 359 return PrefStore::READ_NO_VALUE; | 359 return PrefStore::READ_NO_VALUE; |
| 360 | 360 |
| 361 // Check whether there's a default value, which indicates READ_USE_DEFAULT | 361 // Check whether there's a default value, which indicates READ_USE_DEFAULT |
| 362 // should be returned. | 362 // should be returned. |
| 363 if (stored_value->IsType(Value::TYPE_NULL)) | 363 if (stored_value->IsNull()) |
| 364 return PrefStore::READ_USE_DEFAULT; | 364 return PrefStore::READ_USE_DEFAULT; |
| 365 | 365 |
| 366 if (result) | 366 if (result) |
| 367 *result = stored_value; | 367 *result = stored_value; |
| 368 return PrefStore::READ_OK; | 368 return PrefStore::READ_OK; |
| 369 } | 369 } |
| 370 | 370 |
| 371 void ConfigurationPolicyPrefKeeper::GetDifferingPrefPaths( | 371 void ConfigurationPolicyPrefKeeper::GetDifferingPrefPaths( |
| 372 const ConfigurationPolicyPrefKeeper* other, | 372 const ConfigurationPolicyPrefKeeper* other, |
| 373 std::vector<std::string>* differing_prefs) const { | 373 std::vector<std::string>* differing_prefs) const { |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 NOTREACHED(); | 918 NOTREACHED(); |
| 919 } | 919 } |
| 920 } | 920 } |
| 921 | 921 |
| 922 bool ConfigurationPolicyPrefKeeper::HasProxyPolicy( | 922 bool ConfigurationPolicyPrefKeeper::HasProxyPolicy( |
| 923 ConfigurationPolicyType policy) const { | 923 ConfigurationPolicyType policy) const { |
| 924 std::map<ConfigurationPolicyType, Value*>::const_iterator iter; | 924 std::map<ConfigurationPolicyType, Value*>::const_iterator iter; |
| 925 iter = proxy_policies_.find(policy); | 925 iter = proxy_policies_.find(policy); |
| 926 std::string tmp; | 926 std::string tmp; |
| 927 if (iter == proxy_policies_.end() || | 927 if (iter == proxy_policies_.end() || |
| 928 !iter->second || | 928 !iter->second || iter->second->IsNull() || |
| 929 iter->second->IsType(Value::TYPE_NULL) || | 929 (iter->second->IsString() && iter->second->GetAsString(&tmp) && |
| 930 (iter->second->IsType(Value::TYPE_STRING) && | |
| 931 iter->second->GetAsString(&tmp) && | |
| 932 tmp.empty())) { | 930 tmp.empty())) { |
| 933 return false; | 931 return false; |
| 934 } | 932 } |
| 935 return true; | 933 return true; |
| 936 } | 934 } |
| 937 | 935 |
| 938 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( | 936 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( |
| 939 ConfigurationPolicyProvider* provider) | 937 ConfigurationPolicyProvider* provider) |
| 940 : provider_(provider), | 938 : provider_(provider), |
| 941 initialization_complete_(false) { | 939 initialization_complete_(false) { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 // Update the initialization flag. | 1230 // Update the initialization flag. |
| 1233 if (!initialization_complete_ && | 1231 if (!initialization_complete_ && |
| 1234 provider_->IsInitializationComplete()) { | 1232 provider_->IsInitializationComplete()) { |
| 1235 initialization_complete_ = true; | 1233 initialization_complete_ = true; |
| 1236 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1234 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
| 1237 OnInitializationCompleted(true)); | 1235 OnInitializationCompleted(true)); |
| 1238 } | 1236 } |
| 1239 } | 1237 } |
| 1240 | 1238 |
| 1241 } // namespace policy | 1239 } // namespace policy |
| OLD | NEW |