| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 delegate_(std::move(delegate)) {} | 36 delegate_(std::move(delegate)) {} |
| 37 | 37 |
| 38 PolicyValueStore::~PolicyValueStore() {} | 38 PolicyValueStore::~PolicyValueStore() {} |
| 39 | 39 |
| 40 void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) { | 40 void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) { |
| 41 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 41 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 42 // Convert |policy| to a dictionary value. Only include mandatory policies | 42 // Convert |policy| to a dictionary value. Only include mandatory policies |
| 43 // for now. | 43 // for now. |
| 44 base::DictionaryValue current_policy; | 44 base::DictionaryValue current_policy; |
| 45 for (policy::PolicyMap::const_iterator it = policy.begin(); | 45 for (policy::PolicyMap::const_iterator it = policy.begin(); |
| 46 it != policy.end(); ++it) { | 46 it != policy.end(); policy.next_dominant(&it)) { |
| 47 if (it->second.level == policy::POLICY_LEVEL_MANDATORY) { | 47 if (it->first.level == policy::POLICY_LEVEL_MANDATORY) { |
| 48 current_policy.SetWithoutPathExpansion( | 48 current_policy.SetWithoutPathExpansion( |
| 49 it->first, it->second.value->DeepCopy()); | 49 it->first.name, it->second.value->DeepCopy()); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Get the previous policies stored in the database. | 53 // Get the previous policies stored in the database. |
| 54 // TODO(joaodasilva): it'd be better to have a less expensive way of | 54 // TODO(joaodasilva): it'd be better to have a less expensive way of |
| 55 // determining which keys are currently stored, or of determining which keys | 55 // determining which keys are currently stored, or of determining which keys |
| 56 // must be removed. | 56 // must be removed. |
| 57 base::DictionaryValue previous_policy; | 57 base::DictionaryValue previous_policy; |
| 58 ValueStore::ReadResult read_result = delegate_->Get(); | 58 ValueStore::ReadResult read_result = delegate_->Get(); |
| 59 | 59 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 ValueStore::WriteResult PolicyValueStore::Remove( | 153 ValueStore::WriteResult PolicyValueStore::Remove( |
| 154 const std::vector<std::string>& keys) { | 154 const std::vector<std::string>& keys) { |
| 155 return MakeWriteResult(ReadOnlyError()); | 155 return MakeWriteResult(ReadOnlyError()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 ValueStore::WriteResult PolicyValueStore::Clear() { | 158 ValueStore::WriteResult PolicyValueStore::Clear() { |
| 159 return MakeWriteResult(ReadOnlyError()); | 159 return MakeWriteResult(ReadOnlyError()); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |