| 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_POLICY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_MANAGER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/policy/cloud_policy_store.h" |
| 14 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 15 |
| 16 class PrefService; |
| 17 |
| 18 namespace policy { |
| 19 |
| 20 class CloudPolicyClient; |
| 21 class CloudPolicyRefreshScheduler; |
| 22 class CloudPolicyService; |
| 23 |
| 24 // CloudPolicyManager is the main switching central between cloud policy and the |
| 25 // upper layers of the policy stack. It owns CloudPolicyStore, |
| 26 // CloudPolicyClient, and CloudPolicyService, is responsible for receiving and |
| 27 // keeping policy from the cloud and exposes the decoded policy via the |
| 28 // ConfigurationPolicyProvider interface. |
| 29 // |
| 30 // This class contains the base functionality, there are subclasses that add |
| 31 // functionality specific to user-level and device-level cloud policy, such as |
| 32 // blocking on initial user policy fetch or device enrollment. |
| 33 class CloudPolicyManager : public ConfigurationPolicyProvider, |
| 34 public CloudPolicyStore::Observer { |
| 35 public: |
| 36 explicit CloudPolicyManager(scoped_ptr<CloudPolicyStore> store); |
| 37 virtual ~CloudPolicyManager(); |
| 38 |
| 39 CloudPolicyClient* cloud_policy_client() { return client_.get(); } |
| 40 const CloudPolicyClient* cloud_policy_client() const { return client_.get(); } |
| 41 |
| 42 CloudPolicyStore* cloud_policy_store() { return store_.get(); } |
| 43 const CloudPolicyStore* cloud_policy_store() const { return store_.get(); } |
| 44 |
| 45 CloudPolicyService* cloud_policy_service() { return service_.get(); } |
| 46 const CloudPolicyService* cloud_policy_service() const { |
| 47 return service_.get(); |
| 48 } |
| 49 |
| 50 // ConfigurationPolicyProvider: |
| 51 virtual bool IsInitializationComplete() const OVERRIDE; |
| 52 virtual void RefreshPolicies() OVERRIDE; |
| 53 |
| 54 // CloudPolicyStore::Observer: |
| 55 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
| 56 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
| 57 |
| 58 protected: |
| 59 // Initializes the cloud connection. |
| 60 void InitializeService(scoped_ptr<CloudPolicyClient> client); |
| 61 |
| 62 // Shuts down the cloud connection. |
| 63 void ShutdownService(); |
| 64 |
| 65 // Starts a refresh scheduler in case none is running yet. |local_state| must |
| 66 // stay valid until ShutdownService() gets called. |
| 67 void StartRefreshScheduler(PrefService* local_state, |
| 68 const std::string& refresh_rate_pref); |
| 69 |
| 70 // Check whether fully initialized and if so, publish policy by calling |
| 71 // ConfigurationPolicyStore::UpdatePolicy(). |
| 72 void CheckAndPublishPolicy(); |
| 73 |
| 74 private: |
| 75 // Completion handler for policy refresh operations. |
| 76 void OnRefreshComplete(); |
| 77 |
| 78 scoped_ptr<CloudPolicyStore> store_; |
| 79 scoped_ptr<CloudPolicyClient> client_; |
| 80 scoped_ptr<CloudPolicyService> service_; |
| 81 scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_; |
| 82 |
| 83 // Whether there's a policy refresh operation pending, in which case all |
| 84 // policy update notifications are deferred until after it completes. |
| 85 bool waiting_for_policy_refresh_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); |
| 88 }; |
| 89 |
| 90 } // namespace policy |
| 91 |
| 92 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_MANAGER_H_ |
| OLD | NEW |