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/extensions/api/storage/policy_value_store.h" | 5 #include "chrome/browser/extensions/api/storage/policy_value_store.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/values.h" | 10 #include "base/values.h" |
9 #include "components/policy/core/common/policy_map.h" | 11 #include "components/policy/core/common/policy_map.h" |
10 #include "components/policy/core/common/policy_types.h" | 12 #include "components/policy/core/common/policy_types.h" |
11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
12 #include "extensions/browser/api/storage/settings_namespace.h" | 14 #include "extensions/browser/api/storage/settings_namespace.h" |
13 #include "extensions/browser/value_store/value_store_change.h" | 15 #include "extensions/browser/value_store/value_store_change.h" |
14 | 16 |
15 using content::BrowserThread; | 17 using content::BrowserThread; |
16 | 18 |
17 namespace extensions { | 19 namespace extensions { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 ValueStore::Status ReadOnlyError() { | 23 ValueStore::Status ReadOnlyError() { |
22 return ValueStore::Status(ValueStore::READ_ONLY, | 24 return ValueStore::Status(ValueStore::READ_ONLY, |
23 "This is a read-only store."); | 25 "This is a read-only store."); |
24 } | 26 } |
25 | 27 |
26 } // namespace | 28 } // namespace |
27 | 29 |
28 PolicyValueStore::PolicyValueStore( | 30 PolicyValueStore::PolicyValueStore( |
29 const std::string& extension_id, | 31 const std::string& extension_id, |
30 const scoped_refptr<SettingsObserverList>& observers, | 32 const scoped_refptr<SettingsObserverList>& observers, |
31 scoped_ptr<ValueStore> delegate) | 33 scoped_ptr<ValueStore> delegate) |
32 : extension_id_(extension_id), | 34 : extension_id_(extension_id), |
33 observers_(observers), | 35 observers_(observers), |
34 delegate_(delegate.Pass()) {} | 36 delegate_(std::move(delegate)) {} |
35 | 37 |
36 PolicyValueStore::~PolicyValueStore() {} | 38 PolicyValueStore::~PolicyValueStore() {} |
37 | 39 |
38 void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) { | 40 void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) { |
39 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 41 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
40 // Convert |policy| to a dictionary value. Only include mandatory policies | 42 // Convert |policy| to a dictionary value. Only include mandatory policies |
41 // for now. | 43 // for now. |
42 base::DictionaryValue current_policy; | 44 base::DictionaryValue current_policy; |
43 for (policy::PolicyMap::const_iterator it = policy.begin(); | 45 for (policy::PolicyMap::const_iterator it = policy.begin(); |
44 it != policy.end(); ++it) { | 46 it != policy.end(); ++it) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 ValueStore::WriteResult PolicyValueStore::Remove( | 153 ValueStore::WriteResult PolicyValueStore::Remove( |
152 const std::vector<std::string>& keys) { | 154 const std::vector<std::string>& keys) { |
153 return MakeWriteResult(ReadOnlyError()); | 155 return MakeWriteResult(ReadOnlyError()); |
154 } | 156 } |
155 | 157 |
156 ValueStore::WriteResult PolicyValueStore::Clear() { | 158 ValueStore::WriteResult PolicyValueStore::Clear() { |
157 return MakeWriteResult(ReadOnlyError()); | 159 return MakeWriteResult(ReadOnlyError()); |
158 } | 160 } |
159 | 161 |
160 } // namespace extensions | 162 } // namespace extensions |
OLD | NEW |