Index: components/policy/core/common/policy_service_impl.cc |
diff --git a/components/policy/core/common/policy_service_impl.cc b/components/policy/core/common/policy_service_impl.cc |
index c6116c7119edc3b53d89c7f245b06fbef5b87552..8b1a7c625c6e42f87d98c5ce497012008fb070eb 100644 |
--- a/components/policy/core/common/policy_service_impl.cc |
+++ b/components/policy/core/common/policy_service_impl.cc |
@@ -7,6 +7,7 @@ |
#include <stddef.h> |
#include <algorithm> |
+#include <utility> |
#include "base/bind.h" |
#include "base/location.h" |
@@ -44,22 +45,23 @@ void FixDeprecatedPolicies(PolicyMap* policies) { |
// The highest (level, scope) pair for an existing proxy policy is determined |
// first, and then only policies with those exact attributes are merged. |
- PolicyMap::Entry current_priority; // Defaults to the lowest priority. |
+ PolicyMap::Entry default_priority; // Defaults to the lowest priority. |
+ const PolicyMap::Entry* current_priority = &default_priority; |
PolicySource inherited_source = POLICY_SOURCE_ENTERPRISE_DEFAULT; |
std::unique_ptr<base::DictionaryValue> proxy_settings( |
new base::DictionaryValue); |
for (size_t i = 0; i < arraysize(kProxyPolicies); ++i) { |
const PolicyMap::Entry* entry = policies->Get(kProxyPolicies[i]); |
if (entry) { |
- if (entry->has_higher_priority_than(current_priority)) { |
+ if (entry->has_higher_priority_than(*current_priority)) { |
proxy_settings->Clear(); |
- current_priority = *entry; |
+ current_priority = entry; |
if (entry->source > inherited_source) // Higher priority? |
inherited_source = entry->source; |
} |
- if (!entry->has_higher_priority_than(current_priority) && |
- !current_priority.has_higher_priority_than(*entry)) { |
- proxy_settings->Set(kProxyPolicies[i], entry->value->DeepCopy()); |
+ if (!entry->has_higher_priority_than(*current_priority) && |
+ !current_priority->has_higher_priority_than(*entry)) { |
+ proxy_settings->Set(kProxyPolicies[i], entry->value->CreateDeepCopy()); |
} |
policies->Erase(kProxyPolicies[i]); |
} |
@@ -68,13 +70,10 @@ void FixDeprecatedPolicies(PolicyMap* policies) { |
// new priority is higher. |
const PolicyMap::Entry* existing = policies->Get(key::kProxySettings); |
if (!proxy_settings->empty() && |
- (!existing || current_priority.has_higher_priority_than(*existing))) { |
- policies->Set(key::kProxySettings, |
- current_priority.level, |
- current_priority.scope, |
- inherited_source, |
- proxy_settings.release(), |
- NULL); |
+ (!existing || current_priority->has_higher_priority_than(*existing))) { |
+ policies->Set(key::kProxySettings, current_priority->level, |
+ current_priority->scope, inherited_source, |
+ std::move(proxy_settings), nullptr); |
} |
} |