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

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

Issue 12189011: Split up chrome/browser/policy subdirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, add chrome/browser/chromeos/policy/OWNERS Created 7 years, 9 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
(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_ENROLLMENT_HANDLER_CHROMEOS_H_
6 #define CHROME_BROWSER_POLICY_ENROLLMENT_HANDLER_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 "base/memory/weak_ptr.h"
14 #include "chrome/browser/policy/cloud_policy_client.h"
15 #include "chrome/browser/policy/cloud_policy_store.h"
16 #include "chrome/browser/policy/cloud_policy_validator.h"
17 #include "chrome/browser/policy/device_cloud_policy_manager_chromeos.h"
18
19 namespace enterprise_management {
20 class PolicyFetchResponse;
21 }
22
23 namespace policy {
24
25 class EnterpriseInstallAttributes;
26
27 // Implements the logic that establishes enterprise enrollment for Chromium OS
28 // devices. The process is as follows:
29 // 1. Given an auth token, register with the policy service.
30 // 2. Download the initial policy blob from the service.
31 // 3. Verify the policy blob. Everything up to this point doesn't touch device
32 // state.
33 // 4. Establish the device lock in installation-time attributes.
34 // 5. Store the policy blob.
35 class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer,
36 public CloudPolicyStore::Observer {
37 public:
38 typedef DeviceCloudPolicyManagerChromeOS::AllowedDeviceModes
39 AllowedDeviceModes;
40 typedef DeviceCloudPolicyManagerChromeOS::EnrollmentCallback
41 EnrollmentCallback;
42
43 // |store| and |install_attributes| must remain valid for the life time of the
44 // enrollment handler. |allowed_device_modes| determines what device modes
45 // are acceptable. If the mode specified by the server is not acceptable,
46 // enrollment will fail with an EnrollmentStatus indicating
47 // STATUS_REGISTRATION_BAD_MODE.
48 EnrollmentHandlerChromeOS(DeviceCloudPolicyStoreChromeOS* store,
49 EnterpriseInstallAttributes* install_attributes,
50 scoped_ptr<CloudPolicyClient> client,
51 const std::string& auth_token,
52 const std::string& client_id,
53 bool is_auto_enrollment,
54 const AllowedDeviceModes& allowed_device_modes,
55 const EnrollmentCallback& completion_callback);
56 virtual ~EnrollmentHandlerChromeOS();
57
58 // Starts the enrollment process and reports the result to
59 // |completion_callback_|.
60 void StartEnrollment();
61
62 // Releases the client.
63 scoped_ptr<CloudPolicyClient> ReleaseClient();
64
65 // CloudPolicyClient::Observer:
66 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
67 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
68 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
69
70 // CloudPolicyStore::Observer:
71 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
72 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
73
74 private:
75 // Indicates what step of the process is currently pending. These steps need
76 // to be listed in the order they are traversed in.
77 enum EnrollmentStep {
78 STEP_PENDING, // Not started yet.
79 STEP_LOADING_STORE, // Waiting for |store_| to initialize.
80 STEP_REGISTRATION, // Currently registering the client.
81 STEP_POLICY_FETCH, // Fetching policy.
82 STEP_VALIDATION, // Policy validation.
83 STEP_LOCK_DEVICE, // Writing installation-time attributes.
84 STEP_STORE_POLICY, // Storing policy.
85 STEP_FINISHED, // Enrollment process finished, no further action.
86 };
87
88 // Starts registration if the store is initialized.
89 void AttemptRegistration();
90
91 // Handles the policy validation result, proceeding with installation-time
92 // attributes locking if successful.
93 void PolicyValidated(DeviceCloudPolicyValidator* validator);
94
95 // Writes install attributes and proceeds to policy installation. If
96 // unsuccessful, reports the result.
97 void WriteInstallAttributes(const std::string& user,
98 DeviceMode device_mode,
99 const std::string& device_id);
100
101 // Drops any ongoing actions.
102 void Stop();
103
104 // Reports the result of the enrollment process to the initiator.
105 void ReportResult(EnrollmentStatus status);
106
107 DeviceCloudPolicyStoreChromeOS* store_;
108 EnterpriseInstallAttributes* install_attributes_;
109 scoped_ptr<CloudPolicyClient> client_;
110
111 std::string auth_token_;
112 std::string client_id_;
113 bool is_auto_enrollment_;
114 AllowedDeviceModes allowed_device_modes_;
115 EnrollmentCallback completion_callback_;
116
117 // The device mode as received in the registration request.
118 DeviceMode device_mode_;
119
120 // The validated policy response to be installed in the store.
121 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_;
122
123 // Current enrollment step.
124 EnrollmentStep enrollment_step_;
125
126 // Total amount of time in milliseconds spent waiting for lockbox
127 // initialization.
128 int lockbox_init_duration_;
129
130 base::WeakPtrFactory<EnrollmentHandlerChromeOS> weak_factory_;
131
132 DISALLOW_COPY_AND_ASSIGN(EnrollmentHandlerChromeOS);
133 };
134
135 } // namespace policy
136
137 #endif // CHROME_BROWSER_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_status_collector_browsertest.cc ('k') | chrome/browser/policy/enrollment_handler_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698