| 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 "components/policy/core/common/policy_service_impl.h" | 5 #include "components/policy/core/common/policy_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // together, and maps of policies had to take this into account when merging | 39 // together, and maps of policies had to take this into account when merging |
| 40 // policy sources. The proxy settings will eventually be configured by a | 40 // policy sources. The proxy settings will eventually be configured by a |
| 41 // single Dictionary policy when all providers have support for that. For | 41 // single Dictionary policy when all providers have support for that. For |
| 42 // now, the individual policies are mapped here to a single Dictionary policy | 42 // now, the individual policies are mapped here to a single Dictionary policy |
| 43 // that the rest of the policy machinery uses. | 43 // that the rest of the policy machinery uses. |
| 44 | 44 |
| 45 // The highest (level, scope) pair for an existing proxy policy is determined | 45 // The highest (level, scope) pair for an existing proxy policy is determined |
| 46 // first, and then only policies with those exact attributes are merged. | 46 // first, and then only policies with those exact attributes are merged. |
| 47 PolicyMap::Entry current_priority; // Defaults to the lowest priority. | 47 PolicyMap::Entry current_priority; // Defaults to the lowest priority. |
| 48 PolicySource inherited_source = POLICY_SOURCE_ENTERPRISE_DEFAULT; | 48 PolicySource inherited_source = POLICY_SOURCE_ENTERPRISE_DEFAULT; |
| 49 scoped_ptr<base::DictionaryValue> proxy_settings(new base::DictionaryValue); | 49 std::unique_ptr<base::DictionaryValue> proxy_settings( |
| 50 new base::DictionaryValue); |
| 50 for (size_t i = 0; i < arraysize(kProxyPolicies); ++i) { | 51 for (size_t i = 0; i < arraysize(kProxyPolicies); ++i) { |
| 51 const PolicyMap::Entry* entry = policies->Get(kProxyPolicies[i]); | 52 const PolicyMap::Entry* entry = policies->Get(kProxyPolicies[i]); |
| 52 if (entry) { | 53 if (entry) { |
| 53 if (entry->has_higher_priority_than(current_priority)) { | 54 if (entry->has_higher_priority_than(current_priority)) { |
| 54 proxy_settings->Clear(); | 55 proxy_settings->Clear(); |
| 55 current_priority = *entry; | 56 current_priority = *entry; |
| 56 if (entry->source > inherited_source) // Higher priority? | 57 if (entry->source > inherited_source) // Higher priority? |
| 57 inherited_source = entry->source; | 58 inherited_source = entry->source; |
| 58 } | 59 } |
| 59 if (!entry->has_higher_priority_than(current_priority) && | 60 if (!entry->has_higher_priority_than(current_priority) && |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) { | 282 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) { |
| 282 std::vector<base::Closure> callbacks; | 283 std::vector<base::Closure> callbacks; |
| 283 callbacks.swap(refresh_callbacks_); | 284 callbacks.swap(refresh_callbacks_); |
| 284 std::vector<base::Closure>::iterator it; | 285 std::vector<base::Closure>::iterator it; |
| 285 for (it = callbacks.begin(); it != callbacks.end(); ++it) | 286 for (it = callbacks.begin(); it != callbacks.end(); ++it) |
| 286 it->Run(); | 287 it->Run(); |
| 287 } | 288 } |
| 288 } | 289 } |
| 289 | 290 |
| 290 } // namespace policy | 291 } // namespace policy |
| OLD | NEW |