| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/managed_mode_policy_provider.h" | 5 #include "chrome/browser/policy/managed_mode_policy_provider.h" |
| 6 | 6 |
| 7 #include "chrome/browser/policy/policy_bundle.h" | 7 #include "chrome/browser/policy/policy_bundle.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/json_pref_store.h" | 9 #include "chrome/common/json_pref_store.h" |
| 10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 ManagedModePolicyProvider::~ManagedModePolicyProvider() { | 38 ManagedModePolicyProvider::~ManagedModePolicyProvider() { |
| 39 store_->RemoveObserver(this); | 39 store_->RemoveObserver(this); |
| 40 } | 40 } |
| 41 | 41 |
| 42 const base::Value* ManagedModePolicyProvider::GetPolicy( | 42 const base::Value* ManagedModePolicyProvider::GetPolicy( |
| 43 const std::string& key) const { | 43 const std::string& key) const { |
| 44 base::DictionaryValue* dict = GetCachedPolicy(); | 44 base::DictionaryValue* dict = GetCachedPolicy(); |
| 45 base::Value* value = NULL; | 45 base::Value* value = NULL; |
| 46 |
| 47 // Returns NULL if the key doesn't exist. |
| 46 dict->GetWithoutPathExpansion(key, &value); | 48 dict->GetWithoutPathExpansion(key, &value); |
| 47 return value; | 49 return value; |
| 48 } | 50 } |
| 49 | 51 |
| 50 void ManagedModePolicyProvider::SetPolicy(const std::string& key, | 52 void ManagedModePolicyProvider::SetPolicy(const std::string& key, |
| 51 const base::Value* value) { | 53 const base::Value* value) { |
| 52 base::DictionaryValue* dict = GetCachedPolicy(); | 54 base::DictionaryValue* dict = GetCachedPolicy(); |
| 53 dict->SetWithoutPathExpansion(key, value->DeepCopy()); | 55 dict->SetWithoutPathExpansion(key, value->DeepCopy()); |
| 54 store_->ReportValueChanged(kPolicies); | 56 store_->ReportValueChanged(kPolicies); |
| 55 UpdatePolicyFromCache(); | 57 UpdatePolicyFromCache(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void ManagedModePolicyProvider::UpdatePolicyFromCache() { | 97 void ManagedModePolicyProvider::UpdatePolicyFromCache() { |
| 96 scoped_ptr<PolicyBundle> policy_bundle(new PolicyBundle); | 98 scoped_ptr<PolicyBundle> policy_bundle(new PolicyBundle); |
| 97 PolicyMap* policy_map = | 99 PolicyMap* policy_map = |
| 98 &policy_bundle->Get(POLICY_DOMAIN_CHROME, std::string()); | 100 &policy_bundle->Get(POLICY_DOMAIN_CHROME, std::string()); |
| 99 policy_map->LoadFrom(GetCachedPolicy(), | 101 policy_map->LoadFrom(GetCachedPolicy(), |
| 100 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); | 102 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); |
| 101 UpdatePolicy(policy_bundle.Pass()); | 103 UpdatePolicy(policy_bundle.Pass()); |
| 102 } | 104 } |
| 103 | 105 |
| 104 } // namespace policy | 106 } // namespace policy |
| OLD | NEW |