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

Side by Side Diff: remoting/host/policy_watcher.cc

Issue 2682473003: Add support for multiple allowed domains (Closed)
Patch Set: Rework to follow a deprecation approach Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_watcher.h" 8 #include "remoting/host/policy_watcher.h"
9 9
10 #include <utility> 10 #include <utility>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 owned_schema_registry_(std::move(owned_schema_registry)), 174 owned_schema_registry_(std::move(owned_schema_registry)),
175 owned_policy_provider_(std::move(owned_policy_provider)), 175 owned_policy_provider_(std::move(owned_policy_provider)),
176 owned_policy_service_(std::move(owned_policy_service)) { 176 owned_policy_service_(std::move(owned_policy_service)) {
177 DCHECK(policy_service_); 177 DCHECK(policy_service_);
178 DCHECK(owned_schema_registry_); 178 DCHECK(owned_schema_registry_);
179 179
180 // Initialize the default values for each policy. 180 // Initialize the default values for each policy.
181 default_values_->SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); 181 default_values_->SetBoolean(key::kRemoteAccessHostFirewallTraversal, true);
182 default_values_->SetBoolean(key::kRemoteAccessHostRequireCurtain, false); 182 default_values_->SetBoolean(key::kRemoteAccessHostRequireCurtain, false);
183 default_values_->SetBoolean(key::kRemoteAccessHostMatchUsername, false); 183 default_values_->SetBoolean(key::kRemoteAccessHostMatchUsername, false);
184 default_values_->SetString(key::kRemoteAccessHostClientDomain, std::string()); 184 default_values_->Set(key::kRemoteAccessHostClientDomainList,
185 default_values_->SetString(key::kRemoteAccessHostDomain, std::string()); 185 base::MakeUnique<base::ListValue>());
186 default_values_->Set(key::kRemoteAccessHostDomainList,
187 base::MakeUnique<base::ListValue>());
186 default_values_->SetString(key::kRemoteAccessHostTalkGadgetPrefix, 188 default_values_->SetString(key::kRemoteAccessHostTalkGadgetPrefix,
187 kDefaultHostTalkGadgetPrefix); 189 kDefaultHostTalkGadgetPrefix);
188 default_values_->SetString(key::kRemoteAccessHostTokenUrl, std::string()); 190 default_values_->SetString(key::kRemoteAccessHostTokenUrl, std::string());
189 default_values_->SetString(key::kRemoteAccessHostTokenValidationUrl, 191 default_values_->SetString(key::kRemoteAccessHostTokenValidationUrl,
190 std::string()); 192 std::string());
191 default_values_->SetString( 193 default_values_->SetString(
192 key::kRemoteAccessHostTokenValidationCertificateIssuer, std::string()); 194 key::kRemoteAccessHostTokenValidationCertificateIssuer, std::string());
193 default_values_->SetBoolean(key::kRemoteAccessHostAllowClientPairing, true); 195 default_values_->SetBoolean(key::kRemoteAccessHostAllowClientPairing, true);
194 default_values_->SetBoolean(key::kRemoteAccessHostAllowGnubbyAuth, true); 196 default_values_->SetBoolean(key::kRemoteAccessHostAllowGnubbyAuth, true);
195 default_values_->SetBoolean(key::kRemoteAccessHostAllowRelayedConnection, 197 default_values_->SetBoolean(key::kRemoteAccessHostAllowRelayedConnection,
(...skipping 29 matching lines...) Expand all
225 227
226 std::string path; 228 std::string path;
227 std::string error; 229 std::string error;
228 bool changed = false; 230 bool changed = false;
229 const policy::Schema* schema = GetPolicySchema(); 231 const policy::Schema* schema = GetPolicySchema();
230 if (schema->Normalize(policy_dict, strategy, &path, &error, &changed)) { 232 if (schema->Normalize(policy_dict, strategy, &path, &error, &changed)) {
231 if (changed) { 233 if (changed) {
232 LOG(WARNING) << "Unknown (unrecognized or unsupported) policy: " << path 234 LOG(WARNING) << "Unknown (unrecognized or unsupported) policy: " << path
233 << ": " << error; 235 << ": " << error;
234 } 236 }
237 HandleDeprecatedPolicies(policy_dict);
235 return true; 238 return true;
236 } else { 239 } else {
237 LOG(ERROR) << "Invalid policy contents: " << path << ": " << error; 240 LOG(ERROR) << "Invalid policy contents: " << path << ": " << error;
238 return false; 241 return false;
239 } 242 }
240 } 243 }
241 244
245 void PolicyWatcher::HandleDeprecatedPolicies(base::DictionaryValue* dict) {
246 // RemoteAccessHostDomain
247 if (dict->HasKey(policy::key::kRemoteAccessHostDomain)) {
248 if (!dict->HasKey(policy::key::kRemoteAccessHostDomainList)) {
249 std::string domain;
250 dict->GetString(policy::key::kRemoteAccessHostDomain, &domain);
251 auto list = base::MakeUnique<base::ListValue>();
252 list->AppendString(domain);
253 dict->Set(policy::key::kRemoteAccessHostDomainList, std::move(list));
254 }
255 dict->Remove(policy::key::kRemoteAccessHostDomain, nullptr);
256 }
257
258 // RemoteAccessHostClientDomain
259 if (dict->HasKey(policy::key::kRemoteAccessHostClientDomain)) {
260 if (!dict->HasKey(policy::key::kRemoteAccessHostClientDomainList)) {
261 std::string domain;
262 dict->GetString(policy::key::kRemoteAccessHostClientDomain, &domain);
263 auto list = base::MakeUnique<base::ListValue>();
264 list->AppendString(domain);
265 dict->Set(policy::key::kRemoteAccessHostClientDomainList,
266 std::move(list));
267 }
268 dict->Remove(policy::key::kRemoteAccessHostClientDomain, nullptr);
269 }
270 }
Jamie 2017/04/19 00:29:02 Does the existing PolicyWatcher test code cover th
rkjnsn 2017/04/19 16:45:26 It's getting exercised by the It2MeHost tests, but
271
242 namespace { 272 namespace {
243 void CopyDictionaryValue(const base::DictionaryValue& from, 273 void CopyDictionaryValue(const base::DictionaryValue& from,
244 base::DictionaryValue& to, 274 base::DictionaryValue& to,
245 std::string key) { 275 std::string key) {
246 const base::Value* value; 276 const base::Value* value;
247 if (from.Get(key, &value)) { 277 if (from.Get(key, &value)) {
248 to.Set(key, value->CreateDeepCopy()); 278 to.Set(key, value->CreateDeepCopy());
249 } 279 }
250 } 280 }
251 } // namespace 281 } // namespace
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); 419 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader));
390 #endif // !(OS_CHROMEOS) 420 #endif // !(OS_CHROMEOS)
391 } 421 }
392 422
393 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting( 423 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting(
394 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) { 424 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) {
395 return CreateFromPolicyLoader(std::move(async_policy_loader)); 425 return CreateFromPolicyLoader(std::move(async_policy_loader));
396 } 426 }
397 427
398 } // namespace remoting 428 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698