Chromium Code Reviews| Index: chrome/browser/policy/configuration_policy_provider.cc |
| diff --git a/chrome/browser/policy/configuration_policy_provider.cc b/chrome/browser/policy/configuration_policy_provider.cc |
| index bef2da7b9630c61b6ed8a70f807b71e4d330fe62..4393322c6d349feb828ab655ff40bbacfb2267d0 100644 |
| --- a/chrome/browser/policy/configuration_policy_provider.cc |
| +++ b/chrome/browser/policy/configuration_policy_provider.cc |
| @@ -4,6 +4,8 @@ |
| #include "chrome/browser/policy/configuration_policy_provider.h" |
| +#include <algorithm> |
| + |
| #include "chrome/browser/policy/policy_map.h" |
| #include "policy/policy_constants.h" |
| @@ -11,12 +13,12 @@ namespace policy { |
| namespace { |
| -ConfigurationPolicyType kProxyPolicies[] = { |
| - kPolicyProxyMode, |
| - kPolicyProxyServerMode, |
| - kPolicyProxyServer, |
| - kPolicyProxyPacUrl, |
| - kPolicyProxyBypassList, |
| +const char* kProxyPolicies[] = { |
| + key::kProxyMode, |
| + key::kProxyServerMode, |
| + key::kProxyServer, |
| + key::kProxyPacUrl, |
| + key::kProxyBypassList, |
| }; |
| } // namespace |
| @@ -82,16 +84,31 @@ void ConfigurationPolicyProvider::FixDeprecatedPolicies(PolicyMap* policies) { |
| // single Dictionary policy when all providers have support for that. For |
| // now, the individual policies are mapped here to a single Dictionary policy |
| // that the rest of the policy machinery uses. |
| + |
| + // 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. |
| scoped_ptr<DictionaryValue> proxy_settings(new DictionaryValue); |
| for (size_t i = 0; i < arraysize(kProxyPolicies); ++i) { |
| - const Value* value = policies->Get(kProxyPolicies[i]); |
| - if (value) { |
| - proxy_settings->Set(GetPolicyName(kProxyPolicies[i]), value->DeepCopy()); |
| - policies->Erase(kProxyPolicies[i]); |
| + const PolicyMap::Entry* entry = policies->Get(kProxyPolicies[i]); |
| + if (entry) { |
| + if (entry->has_higher_priority_than(current_priority)) { |
| + proxy_settings->Clear(); |
| + current_priority = *entry; |
| + } |
| + if (!entry->has_higher_priority_than(current_priority) && |
| + !current_priority.has_higher_priority_than(*entry)) |
|
Mattias Nissler (ping if slow)
2012/01/19 12:58:36
need curlies.
Joao da Silva
2012/01/19 16:21:41
Done.
|
| + proxy_settings->Set(kProxyPolicies[i], entry->value->DeepCopy()); |
| } |
| } |
| - if (!proxy_settings->empty() && !policies->Get(kPolicyProxySettings)) |
| - policies->Set(kPolicyProxySettings, proxy_settings.release()); |
| + if (!proxy_settings->empty() && !policies->Get(key::kProxySettings)) { |
| + policies->Set(key::kProxySettings, |
| + current_priority.level, |
| + current_priority.scope, |
| + proxy_settings.release()); |
| + for (size_t i = 0; i < arraysize(kProxyPolicies); ++i) |
| + policies->Erase(kProxyPolicies[i]); |
|
Mattias Nissler (ping if slow)
2012/01/19 12:58:36
Shouldn't we be doing this unconditionally?
Joao da Silva
2012/01/19 16:21:41
Yes. The only case where it matters is when there
|
| + } |
| } |
| void ConfigurationPolicyProvider::AddObserver(Observer* observer) { |