| 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/policy/configuration_policy_provider.h" | 5 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/policy/policy_map.h" | 9 #include "chrome/browser/policy/policy_map.h" |
| 10 #include "policy/policy_constants.h" | 10 #include "policy/policy_constants.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 proxy_settings->Clear(); | 90 proxy_settings->Clear(); |
| 91 current_priority = *entry; | 91 current_priority = *entry; |
| 92 } | 92 } |
| 93 if (!entry->has_higher_priority_than(current_priority) && | 93 if (!entry->has_higher_priority_than(current_priority) && |
| 94 !current_priority.has_higher_priority_than(*entry)) { | 94 !current_priority.has_higher_priority_than(*entry)) { |
| 95 proxy_settings->Set(kProxyPolicies[i], entry->value->DeepCopy()); | 95 proxy_settings->Set(kProxyPolicies[i], entry->value->DeepCopy()); |
| 96 } | 96 } |
| 97 policies->Erase(kProxyPolicies[i]); | 97 policies->Erase(kProxyPolicies[i]); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 if (!proxy_settings->empty() && !policies->Get(key::kProxySettings)) { | 100 // Sets the new |proxy_settings| if kProxySettings isn't set yet, or if the |
| 101 // new priority is higher. |
| 102 const PolicyMap::Entry* existing = policies->Get(key::kProxySettings); |
| 103 if (!proxy_settings->empty() && |
| 104 (!existing || current_priority.has_higher_priority_than(*existing))) { |
| 101 policies->Set(key::kProxySettings, | 105 policies->Set(key::kProxySettings, |
| 102 current_priority.level, | 106 current_priority.level, |
| 103 current_priority.scope, | 107 current_priority.scope, |
| 104 proxy_settings.release()); | 108 proxy_settings.release()); |
| 105 } | 109 } |
| 106 } | 110 } |
| 107 | 111 |
| 108 void ConfigurationPolicyProvider::NotifyPolicyUpdated() { | 112 void ConfigurationPolicyProvider::NotifyPolicyUpdated() { |
| 109 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, | 113 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
| 110 observer_list_, | 114 observer_list_, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 ConfigurationPolicyProvider* provider) { | 150 ConfigurationPolicyProvider* provider) { |
| 147 DCHECK_EQ(provider_, provider); | 151 DCHECK_EQ(provider_, provider); |
| 148 // The |observer_| might delete |this| during this callback. Don't touch any | 152 // The |observer_| might delete |this| during this callback. Don't touch any |
| 149 // of |this| field's after it returns. | 153 // of |this| field's after it returns. |
| 150 provider_->RemoveObserver(this); | 154 provider_->RemoveObserver(this); |
| 151 provider_ = NULL; | 155 provider_ = NULL; |
| 152 observer_->OnProviderGoingAway(provider); | 156 observer_->OnProviderGoingAway(provider); |
| 153 } | 157 } |
| 154 | 158 |
| 155 } // namespace policy | 159 } // namespace policy |
| OLD | NEW |