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

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

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Add dep. 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
« no previous file with comments | « remoting/host/policy_watcher.h ('k') | remoting/host/policy_watcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
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() {
162 // If |old_policies_| is empty, then the PolicyService has not yet provided
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 }
168
169 std::unique_ptr<base::DictionaryValue> PolicyWatcher::GetDefaultPolicies() {
170 auto result = base::MakeUnique<base::DictionaryValue>();
171 result->SetBoolean(key::kRemoteAccessHostFirewallTraversal, true);
172 result->SetBoolean(key::kRemoteAccessHostRequireCurtain, false);
173 result->SetBoolean(key::kRemoteAccessHostMatchUsername, false);
174 result->Set(key::kRemoteAccessHostClientDomainList,
175 base::MakeUnique<base::ListValue>());
176 result->Set(key::kRemoteAccessHostDomainList,
177 base::MakeUnique<base::ListValue>());
178 result->SetString(key::kRemoteAccessHostTalkGadgetPrefix,
179 kDefaultHostTalkGadgetPrefix);
180 result->SetString(key::kRemoteAccessHostTokenUrl, std::string());
181 result->SetString(key::kRemoteAccessHostTokenValidationUrl, std::string());
182 result->SetString(key::kRemoteAccessHostTokenValidationCertificateIssuer,
183 std::string());
184 result->SetBoolean(key::kRemoteAccessHostAllowClientPairing, true);
185 result->SetBoolean(key::kRemoteAccessHostAllowGnubbyAuth, true);
186 result->SetBoolean(key::kRemoteAccessHostAllowRelayedConnection, true);
187 result->SetString(key::kRemoteAccessHostUdpPortRange, "");
188 result->SetBoolean(key::kRemoteAccessHostAllowUiAccessForRemoteAssistance,
189 false);
190 return result;
191 }
192
161 void PolicyWatcher::SignalPolicyError() { 193 void PolicyWatcher::SignalPolicyError() {
162 old_policies_->Clear(); 194 old_policies_->Clear();
163 policy_error_callback_.Run(); 195 policy_error_callback_.Run();
164 } 196 }
165 197
166 PolicyWatcher::PolicyWatcher( 198 PolicyWatcher::PolicyWatcher(
167 policy::PolicyService* policy_service, 199 policy::PolicyService* policy_service,
168 std::unique_ptr<policy::PolicyService> owned_policy_service, 200 std::unique_ptr<policy::PolicyService> owned_policy_service,
169 std::unique_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider, 201 std::unique_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider,
170 std::unique_ptr<policy::SchemaRegistry> owned_schema_registry) 202 std::unique_ptr<policy::SchemaRegistry> owned_schema_registry)
171 : old_policies_(new base::DictionaryValue()), 203 : old_policies_(new base::DictionaryValue()),
172 default_values_(new base::DictionaryValue()), 204 default_values_(GetDefaultPolicies()),
173 policy_service_(policy_service), 205 policy_service_(policy_service),
174 owned_schema_registry_(std::move(owned_schema_registry)), 206 owned_schema_registry_(std::move(owned_schema_registry)),
175 owned_policy_provider_(std::move(owned_policy_provider)), 207 owned_policy_provider_(std::move(owned_policy_provider)),
176 owned_policy_service_(std::move(owned_policy_service)) { 208 owned_policy_service_(std::move(owned_policy_service)) {
177 DCHECK(policy_service_); 209 DCHECK(policy_service_);
178 DCHECK(owned_schema_registry_); 210 DCHECK(owned_schema_registry_);
179
180 // Initialize the default values for each policy.
181 default_values_->SetBoolean(key::kRemoteAccessHostFirewallTraversal, true);
182 default_values_->SetBoolean(key::kRemoteAccessHostRequireCurtain, false);
183 default_values_->SetBoolean(key::kRemoteAccessHostMatchUsername, false);
184 default_values_->Set(key::kRemoteAccessHostClientDomainList,
185 base::MakeUnique<base::ListValue>());
186 default_values_->Set(key::kRemoteAccessHostDomainList,
187 base::MakeUnique<base::ListValue>());
188 default_values_->SetString(key::kRemoteAccessHostTalkGadgetPrefix,
189 kDefaultHostTalkGadgetPrefix);
190 default_values_->SetString(key::kRemoteAccessHostTokenUrl, std::string());
191 default_values_->SetString(key::kRemoteAccessHostTokenValidationUrl,
192 std::string());
193 default_values_->SetString(
194 key::kRemoteAccessHostTokenValidationCertificateIssuer, std::string());
195 default_values_->SetBoolean(key::kRemoteAccessHostAllowClientPairing, true);
196 default_values_->SetBoolean(key::kRemoteAccessHostAllowGnubbyAuth, true);
197 default_values_->SetBoolean(key::kRemoteAccessHostAllowRelayedConnection,
198 true);
199 default_values_->SetString(key::kRemoteAccessHostUdpPortRange, "");
200 default_values_->SetBoolean(
201 key::kRemoteAccessHostAllowUiAccessForRemoteAssistance, false);
202 } 211 }
203 212
204 PolicyWatcher::~PolicyWatcher() { 213 PolicyWatcher::~PolicyWatcher() {
205 // Stop observing |policy_service_| if StartWatching() has been called. 214 // Stop observing |policy_service_| if StartWatching() has been called.
206 if (!policy_updated_callback_.is_null()) { 215 if (!policy_updated_callback_.is_null()) {
207 policy_service_->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this); 216 policy_service_->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
208 } 217 }
209 218
210 if (owned_policy_provider_) { 219 if (owned_policy_provider_) {
211 owned_policy_provider_->Shutdown(); 220 owned_policy_provider_->Shutdown();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); 432 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader));
424 #endif // !(OS_CHROMEOS) 433 #endif // !(OS_CHROMEOS)
425 } 434 }
426 435
427 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting( 436 std::unique_ptr<PolicyWatcher> PolicyWatcher::CreateFromPolicyLoaderForTesting(
428 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) { 437 std::unique_ptr<policy::AsyncPolicyLoader> async_policy_loader) {
429 return CreateFromPolicyLoader(std::move(async_policy_loader)); 438 return CreateFromPolicyLoader(std::move(async_policy_loader));
430 } 439 }
431 440
432 } // namespace remoting 441 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/policy_watcher.h ('k') | remoting/host/policy_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698