| Index: remoting/host/policy_hack/policy_service_watcher.cc
|
| diff --git a/remoting/host/policy_hack/policy_service_watcher.cc b/remoting/host/policy_hack/policy_service_watcher.cc
|
| index 08cb78c5834bd530efd9c7a2e24b820669e40476..c97ba6846ace1cc0378a98da011eb8d45fc527b9 100644
|
| --- a/remoting/host/policy_hack/policy_service_watcher.cc
|
| +++ b/remoting/host/policy_hack/policy_service_watcher.cc
|
| @@ -2,17 +2,16 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "remoting/host/policy_hack/policy_service_watcher.h"
|
| +
|
| #include "base/files/file_path.h"
|
| -#include "base/single_thread_task_runner.h"
|
| #include "components/policy/core/common/async_policy_loader.h"
|
| #include "components/policy/core/common/async_policy_provider.h"
|
| #include "components/policy/core/common/policy_namespace.h"
|
| -#include "components/policy/core/common/policy_service.h"
|
| #include "components/policy/core/common/policy_service_impl.h"
|
| #include "components/policy/core/common/schema.h"
|
| #include "components/policy/core/common/schema_registry.h"
|
| #include "policy/policy_constants.h"
|
| -#include "remoting/host/policy_hack/policy_watcher.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -32,69 +31,12 @@ namespace policy_hack {
|
|
|
| namespace {
|
|
|
| -// TODO(lukasza): Merge PolicyServiceWatcher with PolicyWatcher class
|
| -// (after removing other classes derived from PolicyWatcher - i.e. after
|
| -// removing FakePolicyWatcher class and replacing it with mocks of classes
|
| -// from components/policy instead).
|
| -
|
| -// PolicyServiceWatcher is a concrete implementation of PolicyWatcher that wraps
|
| -// an instance of PolicyService.
|
| -class PolicyServiceWatcher : public PolicyWatcher,
|
| - public PolicyService::Observer {
|
| - public:
|
| - // Constructor for the case when |policy_service| is borrowed.
|
| - //
|
| - // |policy_service_task_runner| is the task runner where it is safe
|
| - // to call |policy_service| methods and where we expect to get callbacks
|
| - // from |policy_service|.
|
| - PolicyServiceWatcher(const scoped_refptr<base::SingleThreadTaskRunner>&
|
| - policy_service_task_runner,
|
| - PolicyService* policy_service);
|
| -
|
| - // Constructor for the case when |policy_service| is owned (and uses also
|
| - // owned |owned_policy_provider| and |owned_schema_registry|.
|
| - //
|
| - // |policy_service_task_runner| is the task runner where it is safe
|
| - // to call |policy_service| methods and where we expect to get callbacks
|
| - // from |policy_service|.
|
| - PolicyServiceWatcher(
|
| - const scoped_refptr<base::SingleThreadTaskRunner>&
|
| - policy_service_task_runner,
|
| - scoped_ptr<PolicyService> owned_policy_service,
|
| - scoped_ptr<ConfigurationPolicyProvider> owned_policy_provider,
|
| - scoped_ptr<SchemaRegistry> owned_schema_registry);
|
| -
|
| - ~PolicyServiceWatcher() override;
|
| -
|
| - // PolicyService::Observer interface.
|
| - void OnPolicyUpdated(const PolicyNamespace& ns,
|
| - const PolicyMap& previous,
|
| - const PolicyMap& current) override;
|
| - void OnPolicyServiceInitialized(PolicyDomain domain) override;
|
| -
|
| - protected:
|
| - // PolicyWatcher overrides.
|
| - void StartWatchingInternal() override;
|
| - void StopWatchingInternal() override;
|
| -
|
| - private:
|
| - PolicyService* policy_service_;
|
| -
|
| - // Order of fields below is important to ensure destruction takes object
|
| - // dependencies into account:
|
| - // - |owned_policy_service_| uses |owned_policy_provider_|
|
| - // - |owned_policy_provider_| uses |owned_schema_registry_|
|
| - scoped_ptr<SchemaRegistry> owned_schema_registry_;
|
| - scoped_ptr<ConfigurationPolicyProvider> owned_policy_provider_;
|
| - scoped_ptr<PolicyService> owned_policy_service_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(PolicyServiceWatcher);
|
| -};
|
| -
|
| PolicyNamespace GetPolicyNamespace() {
|
| return PolicyNamespace(POLICY_DOMAIN_CHROME, std::string());
|
| }
|
|
|
| +} // namespace
|
| +
|
| PolicyServiceWatcher::PolicyServiceWatcher(
|
| const scoped_refptr<base::SingleThreadTaskRunner>&
|
| policy_service_task_runner,
|
| @@ -154,14 +96,7 @@ void PolicyServiceWatcher::StopWatchingInternal() {
|
| policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, this);
|
| }
|
|
|
| -#if !defined(OS_CHROMEOS)
|
| -
|
| -// Creates PolicyServiceWatcher that wraps the owned |async_policy_loader|
|
| -// with an appropriate PolicySchema.
|
| -//
|
| -// |policy_service_task_runner| is passed through to the constructor
|
| -// of PolicyServiceWatcher.
|
| -scoped_ptr<PolicyServiceWatcher> CreateFromPolicyLoader(
|
| +scoped_ptr<PolicyServiceWatcher> PolicyServiceWatcher::CreateFromPolicyLoader(
|
| const scoped_refptr<base::SingleThreadTaskRunner>&
|
| policy_service_task_runner,
|
| scoped_ptr<AsyncPolicyLoader> async_policy_loader) {
|
| @@ -186,10 +121,6 @@ scoped_ptr<PolicyServiceWatcher> CreateFromPolicyLoader(
|
| schema_registry.Pass()));
|
| }
|
|
|
| -#endif
|
| -
|
| -} // anonymous namespace
|
| -
|
| scoped_ptr<PolicyWatcher> PolicyWatcher::Create(
|
| policy::PolicyService* policy_service,
|
| const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) {
|
| @@ -202,13 +133,13 @@ scoped_ptr<PolicyWatcher> PolicyWatcher::Create(
|
| #elif defined(OS_WIN)
|
| DCHECK(!policy_service);
|
| static const wchar_t kRegistryKey[] = L"SOFTWARE\\Policies\\Google\\Chrome";
|
| - return CreateFromPolicyLoader(
|
| + return PolicyServiceWatcher::CreateFromPolicyLoader(
|
| network_task_runner,
|
| PolicyLoaderWin::Create(network_task_runner, kRegistryKey));
|
| #elif defined(OS_MACOSX)
|
| CFStringRef bundle_id = CFSTR("com.google.Chrome");
|
| DCHECK(!policy_service);
|
| - return CreateFromPolicyLoader(
|
| + return PolicyServiceWatcher::CreateFromPolicyLoader(
|
| network_task_runner,
|
| make_scoped_ptr(new PolicyLoaderMac(
|
| network_task_runner,
|
| @@ -220,7 +151,7 @@ scoped_ptr<PolicyWatcher> PolicyWatcher::Create(
|
| // enforcement can't be bypassed by running Chromium.
|
| static const base::FilePath::CharType kPolicyDir[] =
|
| FILE_PATH_LITERAL("/etc/opt/chrome/policies");
|
| - return CreateFromPolicyLoader(
|
| + return PolicyServiceWatcher::CreateFromPolicyLoader(
|
| network_task_runner, make_scoped_ptr(new ConfigDirPolicyLoader(
|
| network_task_runner, base::FilePath(kPolicyDir),
|
| POLICY_SCOPE_MACHINE)));
|
|
|