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

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

Issue 11365112: Change PrefStore::ReadResult to a boolean. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 1 month 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) 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 "base/prefs/json_pref_store.h" 7 #include "base/prefs/json_pref_store.h"
8 #include "chrome/browser/policy/policy_bundle.h" 8 #include "chrome/browser/policy/policy_bundle.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void ManagedModePolicyProvider::OnPrefValueChanged(const std::string& key) {} 70 void ManagedModePolicyProvider::OnPrefValueChanged(const std::string& key) {}
71 71
72 void ManagedModePolicyProvider::OnInitializationCompleted(bool success) { 72 void ManagedModePolicyProvider::OnInitializationCompleted(bool success) {
73 DCHECK(success); 73 DCHECK(success);
74 UpdatePolicyFromCache(); 74 UpdatePolicyFromCache();
75 } 75 }
76 76
77 base::DictionaryValue* ManagedModePolicyProvider::GetCachedPolicy() const { 77 base::DictionaryValue* ManagedModePolicyProvider::GetCachedPolicy() const {
78 base::Value* value = NULL; 78 base::Value* value = NULL;
79 base::DictionaryValue* dict = NULL; 79 base::DictionaryValue* dict = NULL;
80 PrefStore::ReadResult result = store_->GetMutableValue(kPolicies, &value); 80 if (store_->GetMutableValue(kPolicies, &value)) {
81 switch (result) { 81 bool success = value->GetAsDictionary(&dict);
82 case PrefStore::READ_NO_VALUE: { 82 DCHECK(success);
83 dict = new base::DictionaryValue; 83 } else {
84 store_->SetValue(kPolicies, dict); 84 dict = new base::DictionaryValue;
85 break; 85 store_->SetValue(kPolicies, dict);
86 }
87 case PrefStore::READ_OK: {
88 bool success = value->GetAsDictionary(&dict);
89 DCHECK(success);
90 break;
91 }
92 default:
93 NOTREACHED();
94 } 86 }
95 87
96 return dict; 88 return dict;
97 } 89 }
98 90
99 void ManagedModePolicyProvider::UpdatePolicyFromCache() { 91 void ManagedModePolicyProvider::UpdatePolicyFromCache() {
100 scoped_ptr<PolicyBundle> policy_bundle(new PolicyBundle); 92 scoped_ptr<PolicyBundle> policy_bundle(new PolicyBundle);
101 PolicyMap* policy_map = 93 PolicyMap* policy_map =
102 &policy_bundle->Get(POLICY_DOMAIN_CHROME, std::string()); 94 &policy_bundle->Get(POLICY_DOMAIN_CHROME, std::string());
103 policy_map->LoadFrom(GetCachedPolicy(), 95 policy_map->LoadFrom(GetCachedPolicy(),
104 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); 96 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
105 UpdatePolicy(policy_bundle.Pass()); 97 UpdatePolicy(policy_bundle.Pass());
106 } 98 }
107 99
108 } // namespace policy 100 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698