| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/prefs/pref_member.h" | |
| 15 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | |
| 16 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | |
| 17 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | |
| 18 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h" | |
| 19 #include "components/policy/core/common/configuration_policy_provider.h" | |
| 20 | |
| 21 namespace base { | |
| 22 class FilePath; | |
| 23 class SequencedTaskRunner; | |
| 24 } | |
| 25 | |
| 26 namespace net { | |
| 27 class URLRequestContextGetter; | |
| 28 } | |
| 29 | |
| 30 namespace policy { | |
| 31 | |
| 32 // CloudPolicyManager is the main switching central between cloud policy and the | |
| 33 // upper layers of the policy stack. It wires up a CloudPolicyCore to the | |
| 34 // ConfigurationPolicyProvider interface. | |
| 35 // | |
| 36 // This class contains the base functionality, there are subclasses that add | |
| 37 // functionality specific to user-level and device-level cloud policy, such as | |
| 38 // blocking on initial user policy fetch or device enrollment. | |
| 39 class CloudPolicyManager : public ConfigurationPolicyProvider, | |
| 40 public CloudPolicyStore::Observer, | |
| 41 public ComponentCloudPolicyService::Delegate { | |
| 42 public: | |
| 43 // |task_runner| is the runner for policy refresh tasks. | |
| 44 // |file_task_runner| is used for file operations. Currently this must be the | |
| 45 // FILE BrowserThread. | |
| 46 // |io_task_runner| is used for network IO. Currently this must be the IO | |
| 47 // BrowserThread. | |
| 48 CloudPolicyManager( | |
| 49 const PolicyNamespaceKey& policy_ns_key, | |
| 50 CloudPolicyStore* cloud_policy_store, | |
| 51 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | |
| 52 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, | |
| 53 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | |
| 54 virtual ~CloudPolicyManager(); | |
| 55 | |
| 56 CloudPolicyCore* core() { return &core_; } | |
| 57 const CloudPolicyCore* core() const { return &core_; } | |
| 58 | |
| 59 // ConfigurationPolicyProvider: | |
| 60 virtual void Shutdown() OVERRIDE; | |
| 61 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; | |
| 62 virtual void RefreshPolicies() OVERRIDE; | |
| 63 | |
| 64 // CloudPolicyStore::Observer: | |
| 65 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; | |
| 66 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; | |
| 67 | |
| 68 // ComponentCloudPolicyService::Delegate: | |
| 69 virtual void OnComponentCloudPolicyUpdated() OVERRIDE; | |
| 70 | |
| 71 protected: | |
| 72 // Check whether fully initialized and if so, publish policy by calling | |
| 73 // ConfigurationPolicyStore::UpdatePolicy(). | |
| 74 void CheckAndPublishPolicy(); | |
| 75 | |
| 76 void CreateComponentCloudPolicyService( | |
| 77 const base::FilePath& policy_cache_path, | |
| 78 const scoped_refptr<net::URLRequestContextGetter>& request_context); | |
| 79 | |
| 80 void ClearAndDestroyComponentCloudPolicyService(); | |
| 81 | |
| 82 // Convenience accessors to core() components. | |
| 83 CloudPolicyClient* client() { return core_.client(); } | |
| 84 const CloudPolicyClient* client() const { return core_.client(); } | |
| 85 CloudPolicyStore* store() { return core_.store(); } | |
| 86 const CloudPolicyStore* store() const { return core_.store(); } | |
| 87 CloudPolicyService* service() { return core_.service(); } | |
| 88 const CloudPolicyService* service() const { return core_.service(); } | |
| 89 ComponentCloudPolicyService* component_policy_service() const { | |
| 90 return component_policy_service_.get(); | |
| 91 } | |
| 92 | |
| 93 private: | |
| 94 // Completion handler for policy refresh operations. | |
| 95 void OnRefreshComplete(bool success); | |
| 96 | |
| 97 CloudPolicyCore core_; | |
| 98 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; | |
| 99 | |
| 100 // Whether there's a policy refresh operation pending, in which case all | |
| 101 // policy update notifications are deferred until after it completes. | |
| 102 bool waiting_for_policy_refresh_; | |
| 103 | |
| 104 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | |
| 105 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); | |
| 108 }; | |
| 109 | |
| 110 } // namespace policy | |
| 111 | |
| 112 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ | |
| OLD | NEW |