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