| 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 Connect(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(PolicyDomain domain) 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. |success| is true if the fetch was | |
| 63 // successful. | |
| 64 void OnInitialPolicyFetchComplete(bool success); | |
| 65 | |
| 66 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. | |
| 67 scoped_ptr<CloudPolicyStore> store_; | |
| 68 | |
| 69 // Whether to wait for a policy fetch to complete before reporting | |
| 70 // IsInitializationComplete(). | |
| 71 bool wait_for_policy_fetch_; | |
| 72 | |
| 73 // The pref service to pass to the refresh scheduler on initialization. | |
| 74 PrefService* local_state_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); | |
| 77 }; | |
| 78 | |
| 79 } // namespace policy | |
| 80 | |
| 81 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | |
| OLD | NEW |