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

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

Issue 2682473003: Add support for multiple allowed domains (Closed)
Patch Set: Rebase patch Created 3 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 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 if (!domain.empty()) {
252 auto list = base::MakeUnique<base::ListValue>();
253 list->AppendString(domain);
254 dict->Set(policy::key::kRemoteAccessHostDomainList, std::move(list));
255 }
256 }
257 dict->Remove(policy::key::kRemoteAccessHostDomain, nullptr);
258 }
259
260 // RemoteAccessHostClientDomain
261 if (dict->HasKey(policy::key::kRemoteAccessHostClientDomain)) {
262 if (!dict->HasKey(policy::key::kRemoteAccessHostClientDomainList)) {
263 std::string domain;
264 dict->GetString(policy::key::kRemoteAccessHostClientDomain, &domain);
265 if (!domain.empty()) {
266 auto list = base::MakeUnique<base::ListValue>();
267 list->AppendString(domain);
268 dict->Set(policy::key::kRemoteAccessHostClientDomainList,
269 std::move(list));
270 }
271 }
272 dict->Remove(policy::key::kRemoteAccessHostClientDomain, nullptr);
273 }
274 }
275
242 namespace { 276 namespace {
243 void CopyDictionaryValue(const base::DictionaryValue& from, 277 void CopyDictionaryValue(const base::DictionaryValue& from,
244 base::DictionaryValue& to, 278 base::DictionaryValue& to,
245 std::string key) { 279 std::string key) {
246 const base::Value* value; 280 const base::Value* value;
247 if (from.Get(key, &value)) { 281 if (from.Get(key, &value)) {
248 to.Set(key, value->CreateDeepCopy()); 282 to.Set(key, value->CreateDeepCopy());
249 } 283 }
250 } 284 }
251 } // namespace 285 } // namespace
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); 423 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader));
390 #endif // !(OS_CHROMEOS) 424 #endif // !(OS_CHROMEOS)
391 } 425 }
392 426
393 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting( 427 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting(
394 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) { 428 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) {
395 return CreateFromPolicyLoader(std::move(async_policy_loader)); 429 return CreateFromPolicyLoader(std::move(async_policy_loader));
396 } 430 }
397 431
398 } // namespace remoting 432 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698