Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/policy/configuration_policy_provider.cc

Issue 10384145: Removed ConfigurationPolicyProvider::Provide(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 7 #include <string>
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"
11 11
12 namespace policy { 12 namespace policy {
13 13
14 namespace { 14 namespace {
15 15
16 const char* kProxyPolicies[] = { 16 const char* kProxyPolicies[] = {
17 key::kProxyMode, 17 key::kProxyMode,
18 key::kProxyServerMode, 18 key::kProxyServerMode,
19 key::kProxyServer, 19 key::kProxyServer,
20 key::kProxyPacUrl, 20 key::kProxyPacUrl,
21 key::kProxyBypassList, 21 key::kProxyBypassList,
22 }; 22 };
23 23
24 } // namespace 24 // Helper that converts deprecated chrome policies into their corresponding
25 25 // actual policies.
26 ConfigurationPolicyProvider::Observer::~Observer() {} 26 void FixDeprecatedPolicies(PolicyMap* policies) {
27
28 void ConfigurationPolicyProvider::Observer::OnProviderGoingAway(
29 ConfigurationPolicyProvider* provider) {}
30
31 // Class ConfigurationPolicyProvider.
32
33 ConfigurationPolicyProvider::ConfigurationPolicyProvider(
34 const PolicyDefinitionList* policy_list)
35 : policy_definition_list_(policy_list) {
36 }
37
38 ConfigurationPolicyProvider::~ConfigurationPolicyProvider() {
39 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer,
40 observer_list_,
41 OnProviderGoingAway(this));
42 }
43
44 bool ConfigurationPolicyProvider::Provide(PolicyMap* result) {
45 result->CopyFrom(policy_bundle_.Get(POLICY_DOMAIN_CHROME, std::string()));
46 return true;
47 }
48
49 bool ConfigurationPolicyProvider::IsInitializationComplete() const {
50 return true;
51 }
52
53 // static
54 void ConfigurationPolicyProvider::FixDeprecatedPolicies(PolicyMap* policies) {
55 // Proxy settings have been configured by 5 policies that didn't mix well 27 // Proxy settings have been configured by 5 policies that didn't mix well
56 // together, and maps of policies had to take this into account when merging 28 // together, and maps of policies had to take this into account when merging
57 // policy sources. The proxy settings will eventually be configured by a 29 // policy sources. The proxy settings will eventually be configured by a
58 // single Dictionary policy when all providers have support for that. For 30 // single Dictionary policy when all providers have support for that. For
59 // now, the individual policies are mapped here to a single Dictionary policy 31 // now, the individual policies are mapped here to a single Dictionary policy
60 // that the rest of the policy machinery uses. 32 // that the rest of the policy machinery uses.
61 33
62 // The highest (level, scope) pair for an existing proxy policy is determined 34 // The highest (level, scope) pair for an existing proxy policy is determined
63 // first, and then only policies with those exact attributes are merged. 35 // first, and then only policies with those exact attributes are merged.
64 PolicyMap::Entry current_priority; // Defaults to the lowest priority. 36 PolicyMap::Entry current_priority; // Defaults to the lowest priority.
(...skipping 17 matching lines...) Expand all
82 const PolicyMap::Entry* existing = policies->Get(key::kProxySettings); 54 const PolicyMap::Entry* existing = policies->Get(key::kProxySettings);
83 if (!proxy_settings->empty() && 55 if (!proxy_settings->empty() &&
84 (!existing || current_priority.has_higher_priority_than(*existing))) { 56 (!existing || current_priority.has_higher_priority_than(*existing))) {
85 policies->Set(key::kProxySettings, 57 policies->Set(key::kProxySettings,
86 current_priority.level, 58 current_priority.level,
87 current_priority.scope, 59 current_priority.scope,
88 proxy_settings.release()); 60 proxy_settings.release());
89 } 61 }
90 } 62 }
91 63
64 } // namespace
65
66 ConfigurationPolicyProvider::Observer::~Observer() {}
67
68 void ConfigurationPolicyProvider::Observer::OnProviderGoingAway(
69 ConfigurationPolicyProvider* provider) {}
70
71 // Class ConfigurationPolicyProvider.
Mattias Nissler (ping if slow) 2012/05/14 16:55:59 If you add that here, you probably want another co
Joao da Silva 2012/05/15 13:07:05 I didn't even notice this :-) This was the origina
72
73 ConfigurationPolicyProvider::ConfigurationPolicyProvider(
74 const PolicyDefinitionList* policy_list)
75 : policy_definition_list_(policy_list) {
76 }
77
78 ConfigurationPolicyProvider::~ConfigurationPolicyProvider() {
79 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer,
80 observer_list_,
81 OnProviderGoingAway(this));
82 }
83
84 bool ConfigurationPolicyProvider::IsInitializationComplete() const {
85 return true;
86 }
87
92 void ConfigurationPolicyProvider::UpdatePolicy( 88 void ConfigurationPolicyProvider::UpdatePolicy(
93 scoped_ptr<PolicyBundle> bundle) { 89 scoped_ptr<PolicyBundle> bundle) {
94 policy_bundle_.Swap(bundle.get()); 90 if (bundle.get())
91 policy_bundle_.Swap(bundle.get());
92 else
93 policy_bundle_.Clear();
95 FixDeprecatedPolicies( 94 FixDeprecatedPolicies(
96 &policy_bundle_.Get(POLICY_DOMAIN_CHROME, std::string())); 95 &policy_bundle_.Get(POLICY_DOMAIN_CHROME, std::string()));
97 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, 96 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer,
98 observer_list_, 97 observer_list_,
99 OnUpdatePolicy(this)); 98 OnUpdatePolicy(this));
100 } 99 }
101 100
102 void ConfigurationPolicyProvider::AddObserver(Observer* observer) { 101 void ConfigurationPolicyProvider::AddObserver(Observer* observer) {
103 observer_list_.AddObserver(observer); 102 observer_list_.AddObserver(observer);
104 } 103 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // be set to NULL. So we set |observer_| to NULL instead to signal that 142 // be set to NULL. So we set |observer_| to NULL instead to signal that
144 // we're not observing the provider anymore. 143 // we're not observing the provider anymore.
145 ConfigurationPolicyProvider::Observer* observer = observer_; 144 ConfigurationPolicyProvider::Observer* observer = observer_;
146 observer_ = NULL; 145 observer_ = NULL;
147 provider_->RemoveObserver(this); 146 provider_->RemoveObserver(this);
148 147
149 observer->OnProviderGoingAway(provider); 148 observer->OnProviderGoingAway(provider);
150 } 149 }
151 150
152 } // namespace policy 151 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698