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