| 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 "base/threading/sequenced_worker_pool.h" |
| 7 #include "chrome/browser/policy/policy_bundle.h" | 8 #include "chrome/browser/policy/policy_bundle.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/json_pref_store.h" | 10 #include "chrome/common/json_pref_store.h" |
| 10 #include "chrome/common/chrome_constants.h" | 11 #include "chrome/common/chrome_constants.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 #include "policy/policy_constants.h" | 13 #include "policy/policy_constants.h" |
| 13 | 14 |
| 14 using content::BrowserThread; | 15 using content::BrowserThread; |
| 15 | 16 |
| 16 namespace policy { | 17 namespace policy { |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 const char ManagedModePolicyProvider::kPolicies[] = "policies"; | 20 const char ManagedModePolicyProvider::kPolicies[] = "policies"; |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 ManagedModePolicyProvider* ManagedModePolicyProvider::Create(Profile* profile) { | 23 ManagedModePolicyProvider* ManagedModePolicyProvider::Create(Profile* profile) { |
| 24 FilePath path = profile->GetPath().Append(chrome::kManagedModePolicyFilename); |
| 23 JsonPrefStore* pref_store = | 25 JsonPrefStore* pref_store = |
| 24 new JsonPrefStore(profile->GetPath().Append( | 26 JsonPrefStore::Create(path, BrowserThread::GetBlockingPool()); |
| 25 chrome::kManagedModePolicyFilename), | |
| 26 BrowserThread::GetMessageLoopProxyForThread( | |
| 27 BrowserThread::FILE)); | |
| 28 return new ManagedModePolicyProvider(pref_store); | 27 return new ManagedModePolicyProvider(pref_store); |
| 29 } | 28 } |
| 30 | 29 |
| 31 ManagedModePolicyProvider::ManagedModePolicyProvider( | 30 ManagedModePolicyProvider::ManagedModePolicyProvider( |
| 32 PersistentPrefStore* pref_store) | 31 PersistentPrefStore* pref_store) |
| 33 : store_(pref_store) { | 32 : store_(pref_store) { |
| 34 store_->AddObserver(this); | 33 store_->AddObserver(this); |
| 35 store_->ReadPrefsAsync(NULL); | 34 store_->ReadPrefsAsync(NULL); |
| 36 } | 35 } |
| 37 | 36 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void ManagedModePolicyProvider::UpdatePolicyFromCache() { | 96 void ManagedModePolicyProvider::UpdatePolicyFromCache() { |
| 98 scoped_ptr<PolicyBundle> policy_bundle(new PolicyBundle); | 97 scoped_ptr<PolicyBundle> policy_bundle(new PolicyBundle); |
| 99 PolicyMap* policy_map = | 98 PolicyMap* policy_map = |
| 100 &policy_bundle->Get(POLICY_DOMAIN_CHROME, std::string()); | 99 &policy_bundle->Get(POLICY_DOMAIN_CHROME, std::string()); |
| 101 policy_map->LoadFrom(GetCachedPolicy(), | 100 policy_map->LoadFrom(GetCachedPolicy(), |
| 102 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); | 101 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); |
| 103 UpdatePolicy(policy_bundle.Pass()); | 102 UpdatePolicy(policy_bundle.Pass()); |
| 104 } | 103 } |
| 105 | 104 |
| 106 } // namespace policy | 105 } // namespace policy |
| OLD | NEW |