OLD | NEW |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // Listen for future policy changes. | 152 // Listen for future policy changes. |
153 policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this); | 153 policy_service_->AddObserver(policy::POLICY_DOMAIN_CHROME, this); |
154 | 154 |
155 // Process current policy state. | 155 // Process current policy state. |
156 if (policy_service_->IsInitializationComplete(policy::POLICY_DOMAIN_CHROME)) { | 156 if (policy_service_->IsInitializationComplete(policy::POLICY_DOMAIN_CHROME)) { |
157 OnPolicyServiceInitialized(policy::POLICY_DOMAIN_CHROME); | 157 OnPolicyServiceInitialized(policy::POLICY_DOMAIN_CHROME); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 std::unique_ptr<base::DictionaryValue> PolicyWatcher::GetCurrentPolicies() { | 161 std::unique_ptr<base::DictionaryValue> PolicyWatcher::GetCurrentPolicies() { |
162 // If |old_policies_| is empty, then the PolicyService has not yet provided | 162 return old_policies_->CreateDeepCopy(); |
163 // policies, so just return the default values. Otherwise, |old_policies_| | |
164 // already contains all the supported policies, defaults and overrides. | |
165 return old_policies_->size() == 0 ? GetDefaultPolicies() | |
166 : old_policies_->CreateDeepCopy(); | |
167 } | 163 } |
168 | 164 |
169 std::unique_ptr<base::DictionaryValue> PolicyWatcher::GetDefaultPolicies() { | 165 std::unique_ptr<base::DictionaryValue> PolicyWatcher::GetDefaultPolicies() { |
170 auto result = base::MakeUnique<base::DictionaryValue>(); | 166 auto result = base::MakeUnique<base::DictionaryValue>(); |
171 result->SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); | 167 result->SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); |
172 result->SetBoolean(key::kRemoteAccessHostRequireCurtain, false); | 168 result->SetBoolean(key::kRemoteAccessHostRequireCurtain, false); |
173 result->SetBoolean(key::kRemoteAccessHostMatchUsername, false); | 169 result->SetBoolean(key::kRemoteAccessHostMatchUsername, false); |
174 result->Set(key::kRemoteAccessHostClientDomainList, | 170 result->Set(key::kRemoteAccessHostClientDomainList, |
175 base::MakeUnique<base::ListValue>()); | 171 base::MakeUnique<base::ListValue>()); |
176 result->Set(key::kRemoteAccessHostDomainList, | 172 result->Set(key::kRemoteAccessHostDomainList, |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); | 428 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); |
433 #endif // !(OS_CHROMEOS) | 429 #endif // !(OS_CHROMEOS) |
434 } | 430 } |
435 | 431 |
436 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting( | 432 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting( |
437 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) { | 433 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) { |
438 return CreateFromPolicyLoader(std::move(async_policy_loader)); | 434 return CreateFromPolicyLoader(std::move(async_policy_loader)); |
439 } | 435 } |
440 | 436 |
441 } // namespace remoting | 437 } // namespace remoting |
OLD | NEW |