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 // Most of this code is copied from: | 5 // Most of this code is copied from: |
6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} | 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} |
7 | 7 |
8 #include "remoting/host/policy_hack/policy_watcher.h" | 8 #include "remoting/host/policy_hack/policy_watcher.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 const char PolicyWatcher::kHostTokenValidationCertIssuerPolicyName[] = | 101 const char PolicyWatcher::kHostTokenValidationCertIssuerPolicyName[] = |
102 "RemoteAccessHostTokenValidationCertificateIssuer"; | 102 "RemoteAccessHostTokenValidationCertificateIssuer"; |
103 | 103 |
104 const char PolicyWatcher::kHostAllowClientPairing[] = | 104 const char PolicyWatcher::kHostAllowClientPairing[] = |
105 "RemoteAccessHostAllowClientPairing"; | 105 "RemoteAccessHostAllowClientPairing"; |
106 | 106 |
107 const char PolicyWatcher::kHostAllowGnubbyAuthPolicyName[] = | 107 const char PolicyWatcher::kHostAllowGnubbyAuthPolicyName[] = |
108 "RemoteAccessHostAllowGnubbyAuth"; | 108 "RemoteAccessHostAllowGnubbyAuth"; |
109 | 109 |
| 110 const char PolicyWatcher::kRelayPolicyName[] = |
| 111 "RemoteAccessHostAllowRelayedConnection"; |
| 112 |
| 113 const char PolicyWatcher::kUdpPortRangePolicyName[] = |
| 114 "RemoteAccessHostUdpPortRange"; |
| 115 |
110 const char PolicyWatcher::kHostDebugOverridePoliciesName[] = | 116 const char PolicyWatcher::kHostDebugOverridePoliciesName[] = |
111 "RemoteAccessHostDebugOverridePolicies"; | 117 "RemoteAccessHostDebugOverridePolicies"; |
112 | 118 |
113 PolicyWatcher::PolicyWatcher( | 119 PolicyWatcher::PolicyWatcher( |
114 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 120 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
115 : task_runner_(task_runner), | 121 : task_runner_(task_runner), |
116 old_policies_(new base::DictionaryValue()), | 122 old_policies_(new base::DictionaryValue()), |
117 default_values_(new base::DictionaryValue()), | 123 default_values_(new base::DictionaryValue()), |
118 weak_factory_(this) { | 124 weak_factory_(this) { |
119 // Initialize the default values for each policy. | 125 // Initialize the default values for each policy. |
120 default_values_->SetBoolean(kNatPolicyName, true); | 126 default_values_->SetBoolean(kNatPolicyName, true); |
121 default_values_->SetBoolean(kHostRequireTwoFactorPolicyName, false); | 127 default_values_->SetBoolean(kHostRequireTwoFactorPolicyName, false); |
122 default_values_->SetBoolean(kHostRequireCurtainPolicyName, false); | 128 default_values_->SetBoolean(kHostRequireCurtainPolicyName, false); |
123 default_values_->SetBoolean(kHostMatchUsernamePolicyName, false); | 129 default_values_->SetBoolean(kHostMatchUsernamePolicyName, false); |
124 default_values_->SetString(kHostDomainPolicyName, std::string()); | 130 default_values_->SetString(kHostDomainPolicyName, std::string()); |
125 default_values_->SetString(kHostTalkGadgetPrefixPolicyName, | 131 default_values_->SetString(kHostTalkGadgetPrefixPolicyName, |
126 kDefaultHostTalkGadgetPrefix); | 132 kDefaultHostTalkGadgetPrefix); |
127 default_values_->SetString(kHostTokenUrlPolicyName, std::string()); | 133 default_values_->SetString(kHostTokenUrlPolicyName, std::string()); |
128 default_values_->SetString(kHostTokenValidationUrlPolicyName, std::string()); | 134 default_values_->SetString(kHostTokenValidationUrlPolicyName, std::string()); |
129 default_values_->SetString(kHostTokenValidationCertIssuerPolicyName, | 135 default_values_->SetString(kHostTokenValidationCertIssuerPolicyName, |
130 std::string()); | 136 std::string()); |
131 default_values_->SetBoolean(kHostAllowClientPairing, true); | 137 default_values_->SetBoolean(kHostAllowClientPairing, true); |
132 default_values_->SetBoolean(kHostAllowGnubbyAuthPolicyName, true); | 138 default_values_->SetBoolean(kHostAllowGnubbyAuthPolicyName, true); |
| 139 default_values_->SetBoolean(kRelayPolicyName, true); |
| 140 default_values_->SetString(kUdpPortRangePolicyName, ""); |
133 #if !defined(NDEBUG) | 141 #if !defined(NDEBUG) |
134 default_values_->SetString(kHostDebugOverridePoliciesName, std::string()); | 142 default_values_->SetString(kHostDebugOverridePoliciesName, std::string()); |
135 #endif | 143 #endif |
136 | 144 |
137 // Initialize the fall-back values to use for unreadable policies. | 145 // Initialize the fall-back values to use for unreadable policies. |
138 // For most policies these match the defaults. | 146 // For most policies these match the defaults. |
139 bad_type_values_.reset(default_values_->DeepCopy()); | 147 bad_type_values_.reset(default_values_->DeepCopy()); |
140 bad_type_values_->SetBoolean(kNatPolicyName, false); | 148 bad_type_values_->SetBoolean(kNatPolicyName, false); |
| 149 bad_type_values_->SetBoolean(kRelayPolicyName, false); |
141 } | 150 } |
142 | 151 |
143 PolicyWatcher::~PolicyWatcher() { | 152 PolicyWatcher::~PolicyWatcher() { |
144 } | 153 } |
145 | 154 |
146 void PolicyWatcher::StartWatching(const PolicyCallback& policy_callback) { | 155 void PolicyWatcher::StartWatching(const PolicyCallback& policy_callback) { |
147 if (!OnPolicyWatcherThread()) { | 156 if (!OnPolicyWatcherThread()) { |
148 task_runner_->PostTask(FROM_HERE, | 157 task_runner_->PostTask(FROM_HERE, |
149 base::Bind(&PolicyWatcher::StartWatching, | 158 base::Bind(&PolicyWatcher::StartWatching, |
150 base::Unretained(this), | 159 base::Unretained(this), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 old_policies_.swap(new_policies); | 228 old_policies_.swap(new_policies); |
220 | 229 |
221 // Notify our client of the changed policies. | 230 // Notify our client of the changed policies. |
222 if (!changed_policies->empty()) { | 231 if (!changed_policies->empty()) { |
223 policy_callback_.Run(changed_policies.Pass()); | 232 policy_callback_.Run(changed_policies.Pass()); |
224 } | 233 } |
225 } | 234 } |
226 | 235 |
227 } // namespace policy_hack | 236 } // namespace policy_hack |
228 } // namespace remoting | 237 } // namespace remoting |
OLD | NEW |