Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/policy/cloud_policy_client.h" | 10 #include "chrome/browser/policy/cloud_policy_client.h" |
| 11 #include "chrome/browser/policy/cloud_policy_constants.h" | 11 #include "chrome/browser/policy/cloud_policy_constants.h" |
| 12 #include "chrome/browser/policy/cloud_policy_store.h" | 12 #include "chrome/browser/policy/cloud_policy_store.h" |
| 13 #include "chrome/browser/policy/configuration_policy_provider.h" | 13 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 14 | 14 |
| 15 class PrefService; | 15 class PrefService; |
| 16 class Profile; | |
| 16 | 17 |
| 17 namespace policy { | 18 namespace policy { |
| 18 | 19 |
| 19 class CloudPolicyRefreshScheduler; | 20 class CloudPolicyRefreshScheduler; |
| 20 class CloudPolicyService; | 21 class CloudPolicyService; |
| 21 class DeviceManagementService; | 22 class DeviceManagementService; |
| 22 | 23 |
| 23 // UserCloudPolicyManager keeps track of all things user policy, drives the | 24 // UserCloudPolicyManager keeps track of all things user policy, drives the |
| 24 // corresponding cloud policy service and publishes policy through the | 25 // corresponding cloud policy service and publishes policy through the |
| 25 // ConfigurationPolicyProvider interface. | 26 // ConfigurationPolicyProvider interface. |
| 26 class UserCloudPolicyManager : public ConfigurationPolicyProvider, | 27 class UserCloudPolicyManager : public ConfigurationPolicyProvider, |
| 27 public CloudPolicyClient::Observer, | 28 public CloudPolicyClient::Observer, |
| 28 public CloudPolicyStore::Observer { | 29 public CloudPolicyStore::Observer { |
| 29 public: | 30 public: |
| 30 // If |wait_for_policy| fetch is true, IsInitializationComplete() will return | 31 // If |wait_for_policy| fetch is true, IsInitializationComplete() will return |
| 31 // false as long as there hasn't been a successful policy fetch. | 32 // false as long as there hasn't been a successful policy fetch. |
| 32 UserCloudPolicyManager(scoped_ptr<CloudPolicyStore> store, | 33 UserCloudPolicyManager(scoped_ptr<CloudPolicyStore> store, |
| 33 bool wait_for_policy_fetch); | 34 bool wait_for_policy_fetch); |
| 34 virtual ~UserCloudPolicyManager(); | 35 virtual ~UserCloudPolicyManager(); |
| 35 | 36 |
| 36 #if defined(OS_CHROMEOS) | 37 // Creates a UserCloudPolicyService instance associated with the passed |
| 37 // Creates a UserCloudPolicyService instance for the Chrome OS platform. | 38 // |profile|. |
| 38 static scoped_ptr<UserCloudPolicyManager> Create(bool wait_for_policy_fetch); | 39 static scoped_ptr<UserCloudPolicyManager> Create(Profile* profile, |
| 39 #endif | 40 bool wait_for_policy_fetch); |
| 40 | 41 |
| 41 // Initializes the cloud connection. |prefs| and |service| must stay valid | 42 // Initializes the cloud connection. |local_prefs| and |service| must stay |
| 42 // until Shutdown() gets called. | 43 // valid until Shutdown() gets called. Virtual for mocking. |
| 43 void Initialize(PrefService* prefs, | 44 virtual void Initialize(PrefService* local_prefs, |
|
Mattias Nissler (ping if slow)
2012/08/03 12:19:08
Wait, are you passing g_browser_process->local_sta
Andrew T Wilson (Slow)
2012/08/04 00:54:41
As far as I can tell, the only thing local_state i
Mattias Nissler (ping if slow)
2012/08/06 08:33:52
Ah, correct, I was mistaken. FWIW, in the future w
Andrew T Wilson (Slow)
2012/08/06 20:30:23
Hmmm. Good point (or we could ignore policy pollin
| |
| 44 DeviceManagementService* service, | 45 DeviceManagementService* service, |
| 45 UserAffiliation user_affiliation); | 46 UserAffiliation user_affiliation); |
| 46 void Shutdown(); | 47 |
| 48 // Virtual for mocks. | |
| 49 virtual void Shutdown(); | |
| 47 | 50 |
| 48 // Cancels waiting for the policy fetch and flags the | 51 // Cancels waiting for the policy fetch and flags the |
| 49 // ConfigurationPolicyProvider ready (assuming all other initialization tasks | 52 // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
| 50 // have completed). | 53 // have completed). |
| 51 void CancelWaitForPolicyFetch(); | 54 void CancelWaitForPolicyFetch(); |
| 52 | 55 |
| 56 // Returns true if the underlying CloudPolicyClient is already registered. | |
| 57 // Virtual for mocking. | |
| 58 virtual bool IsClientRegistered() const; | |
| 59 | |
| 60 // Register the CloudPolicyClient using the passed OAuth token. | |
| 61 void RegisterClient(const std::string& access_token); | |
| 62 | |
| 53 CloudPolicyService* cloud_policy_service() { return service_.get(); } | 63 CloudPolicyService* cloud_policy_service() { return service_.get(); } |
| 54 | 64 |
| 55 // ConfigurationPolicyProvider: | 65 // ConfigurationPolicyProvider: |
| 56 virtual bool IsInitializationComplete() const OVERRIDE; | 66 virtual bool IsInitializationComplete() const OVERRIDE; |
| 57 virtual void RefreshPolicies() OVERRIDE; | 67 virtual void RefreshPolicies() OVERRIDE; |
| 58 | 68 |
| 59 // CloudPolicyClient::Observer: | 69 // CloudPolicyClient::Observer: |
| 60 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; | 70 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
| 61 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; | 71 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; |
| 62 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; | 72 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 91 | 101 |
| 92 // The pref service to pass to the refresh scheduler on initialization. | 102 // The pref service to pass to the refresh scheduler on initialization. |
| 93 PrefService* prefs_; | 103 PrefService* prefs_; |
| 94 | 104 |
| 95 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); | 105 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); |
| 96 }; | 106 }; |
| 97 | 107 |
| 98 } // namespace policy | 108 } // namespace policy |
| 99 | 109 |
| 100 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 110 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
| OLD | NEW |