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_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_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_client.h" |
| 14 #include "chrome/browser/policy/cloud_policy_constants.h" |
| 15 #include "chrome/browser/policy/cloud_policy_manager.h" |
| 16 |
| 17 class PrefService; |
| 18 |
| 19 namespace policy { |
| 20 |
| 21 class DeviceManagementService; |
| 22 |
| 23 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy |
| 24 // on Chrome OS. |
| 25 class UserCloudPolicyManagerChromeOS : public CloudPolicyManager, |
| 26 public CloudPolicyClient::Observer { |
| 27 public: |
| 28 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return |
| 29 // false as long as there hasn't been a successful policy fetch. |
| 30 UserCloudPolicyManagerChromeOS(scoped_ptr<CloudPolicyStore> store, |
| 31 bool wait_for_policy_fetch); |
| 32 virtual ~UserCloudPolicyManagerChromeOS(); |
| 33 |
| 34 // Initializes the cloud connection. |local_state| and |
| 35 // |device_management_service| must stay valid until this object is deleted. |
| 36 void Initialize(PrefService* local_state, |
| 37 DeviceManagementService* device_management_service, |
| 38 UserAffiliation user_affiliation); |
| 39 |
| 40 // Cancels waiting for the policy fetch and flags the |
| 41 // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
| 42 // have completed). |
| 43 void CancelWaitForPolicyFetch(); |
| 44 |
| 45 // Register the CloudPolicyClient using the passed OAuth token. |
| 46 void RegisterClient(const std::string& access_token); |
| 47 |
| 48 // Returns true if the underlying CloudPolicyClient is already registered. |
| 49 bool IsClientRegistered() const; |
| 50 |
| 51 // ConfigurationPolicyProvider: |
| 52 virtual void Shutdown() OVERRIDE; |
| 53 virtual bool IsInitializationComplete() const OVERRIDE; |
| 54 |
| 55 // CloudPolicyClient::Observer: |
| 56 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
| 57 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; |
| 58 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; |
| 59 |
| 60 private: |
| 61 // Completion handler for the explicit policy fetch triggered on startup in |
| 62 // case |wait_for_policy_fetch_| is true. |
| 63 void OnInitialPolicyFetchComplete(); |
| 64 |
| 65 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. |
| 66 scoped_ptr<CloudPolicyStore> store_; |
| 67 |
| 68 // Whether to wait for a policy fetch to complete before reporting |
| 69 // IsInitializationComplete(). |
| 70 bool wait_for_policy_fetch_; |
| 71 |
| 72 // The pref service to pass to the refresh scheduler on initialization. |
| 73 PrefService* local_state_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); |
| 76 }; |
| 77 |
| 78 } // namespace policy |
| 79 |
| 80 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
OLD | NEW |