Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/policy/device_cloud_policy_manager_chromeos.h

Issue 10928036: Implement Chrome OS device enrollment on the new cloud policy stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CloudPolicyClient error handling. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_
7 7
8 #include <bitset>
8 #include <string> 9 #include <string>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h"
11 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/policy/cloud_policy_manager.h" 15 #include "chrome/browser/policy/cloud_policy_manager.h"
14 #include "chrome/browser/policy/cloud_policy_store.h" 16 #include "chrome/browser/policy/cloud_policy_store.h"
17 #include "chrome/browser/policy/enrollment_status_chromeos.h"
15 18
16 class PrefService; 19 class PrefService;
17 20
18 namespace policy { 21 namespace policy {
19 22
20 class CloudPolicyClient; 23 class CloudPolicyClient;
21 class DeviceCloudPolicyStoreChromeOS; 24 class DeviceCloudPolicyStoreChromeOS;
22 class DeviceManagementService; 25 class DeviceManagementService;
26 class EnrollmentHandlerChromeOS;
23 class EnterpriseInstallAttributes; 27 class EnterpriseInstallAttributes;
24 28
25 // CloudPolicyManager specialization for device policy on Chrome OS. 29 // CloudPolicyManager specialization for device policy on Chrome OS. The most
30 // significant addition is support for device enrollment.
26 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager { 31 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager {
27 public: 32 public:
33 typedef std::bitset<32> AllowedDeviceModes;
34 typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback;
35
28 DeviceCloudPolicyManagerChromeOS( 36 DeviceCloudPolicyManagerChromeOS(
29 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, 37 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store,
30 EnterpriseInstallAttributes* install_attributes); 38 EnterpriseInstallAttributes* install_attributes);
31 virtual ~DeviceCloudPolicyManagerChromeOS(); 39 virtual ~DeviceCloudPolicyManagerChromeOS();
32 40
33 // Establishes the connection to the cloud, updating policy as necessary. 41 // Establishes the connection to the cloud, updating policy as necessary.
34 void Connect(PrefService* local_state, 42 void Connect(PrefService* local_state,
35 DeviceManagementService* device_management_service); 43 DeviceManagementService* device_management_service);
36 44
45 // Starts enrollment or re-enrollment. Once the enrollment process completes,
46 // |callback| is invoked and gets passed the status of the operation.
47 // |allowed_modes| specifies acceptable DEVICE_MODE_* constants for
48 // enrollment.
49 void StartEnrollment(const std::string& auth_token,
50 const AllowedDeviceModes& allowed_modes,
51 const EnrollmentCallback& callback);
52
53 // Cancels a pending enrollment operation, if any.
54 void CancelEnrollment();
55
37 // CloudPolicyStore::Observer: 56 // CloudPolicyStore::Observer:
38 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 57 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
39 58
40 // Returns the device serial number, or an empty string if not available. 59 // Returns the device serial number, or an empty string if not available.
41 static std::string GetMachineID(); 60 static std::string GetMachineID();
42 61
43 // Returns the machine model, or an empty string if not available. 62 // Returns the machine model, or an empty string if not available.
44 static std::string GetMachineModel(); 63 static std::string GetMachineModel();
45 64
46 private: 65 private:
47 // Creates a new CloudPolicyClient. 66 // Creates a new CloudPolicyClient.
48 scoped_ptr<CloudPolicyClient> CreateClient(); 67 scoped_ptr<CloudPolicyClient> CreateClient();
49 68
50 // Starts policy refreshes if |store_| indicates a managed device and the 69 // Starts policy refreshes if |store_| indicates a managed device and the
51 // necessary dependencies have been provided via Initialize(). 70 // necessary dependencies have been provided via Initialize().
52 void StartIfManaged(); 71 void StartIfManaged();
53 72
73 // Handles completion signaled by |enrollment_handler_|.
74 void EnrollmentCompleted(const EnrollmentCallback& callback,
75 EnrollmentStatus status);
76
54 // Points to the same object as the base CloudPolicyManager::store(), but with 77 // Points to the same object as the base CloudPolicyManager::store(), but with
55 // actual device policy specific type. 78 // actual device policy specific type.
56 DeviceCloudPolicyStoreChromeOS* device_store_; 79 DeviceCloudPolicyStoreChromeOS* device_store_;
57 EnterpriseInstallAttributes* install_attributes_; 80 EnterpriseInstallAttributes* install_attributes_;
58 81
59 DeviceManagementService* device_management_service_; 82 DeviceManagementService* device_management_service_;
60 83
61 // PrefService instance to read the policy refresh rate from. 84 // PrefService instance to read the policy refresh rate from.
62 PrefService* local_state_; 85 PrefService* local_state_;
63 86
87 // Non-null if there is an enrollment operation pending.
88 scoped_ptr<EnrollmentHandlerChromeOS> enrollment_handler_;
89
64 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS); 90 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS);
65 }; 91 };
66 92
67 } // namespace policy 93 } // namespace policy
68 94
69 #endif // CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 95 #endif // CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_client.cc ('k') | chrome/browser/policy/device_cloud_policy_manager_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698