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

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

Issue 11434053: Add support for public account policy to CloudPolicyClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years 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_CLOUD_POLICY_CLIENT_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CLIENT_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CLIENT_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "chrome/browser/policy/cloud_policy_constants.h" 14 #include "chrome/browser/policy/cloud_policy_constants.h"
15 #include "chrome/browser/policy/policy_types.h" 15 #include "chrome/browser/policy/policy_types.h"
bartfab (slow) 2012/12/03 12:28:40 Nit: No longer needed.
16 16
17 namespace enterprise_management { 17 namespace enterprise_management {
18 class DeviceManagementResponse; 18 class DeviceManagementResponse;
19 class DeviceRegisterRequest; 19 class DeviceRegisterRequest;
20 class DeviceStatusReportRequest; 20 class DeviceStatusReportRequest;
21 class PolicyFetchRequest; 21 class PolicyFetchRequest;
22 class PolicyFetchResponse; 22 class PolicyFetchResponse;
23 class SessionStatusReportRequest; 23 class SessionStatusReportRequest;
24 } 24 }
25 25
26 namespace policy { 26 namespace policy {
27 27
28 class DeviceManagementRequestJob; 28 class DeviceManagementRequestJob;
29 class DeviceManagementService; 29 class DeviceManagementService;
30 30
31 // Implements the core logic required to talk to the device management service. 31 // Implements the core logic required to talk to the device management service.
32 // Also keeps track of the current state of the association with the service, 32 // Also keeps track of the current state of the association with the service,
33 // such as whether there is a valid registration (DMToken is present in that 33 // such as whether there is a valid registration (DMToken is present in that
34 // case) and whether and what errors occurred in the latest request. 34 // case) and whether and what errors occurred in the latest request.
35 // 35 //
36 // Note that CloudPolicyClient doesn't do any validation of policy responses 36 // Note that CloudPolicyClient doesn't do any validation of policy responses
37 // such as signature and time stamp checks. These happen once the policy gets 37 // such as signature and time stamp checks. These happen once the policy gets
38 // installed in the cloud policy cache. 38 // installed in the cloud policy cache.
39 class CloudPolicyClient { 39 class CloudPolicyClient {
40 public: 40 public:
41 // Indicates the type of policy the client should register for and fetch.
42 enum PolicyType {
43 POLICY_TYPE_DEVICE,
44 POLICY_TYPE_USER,
45 POLICY_TYPE_PUBLIC_ACCOUNT,
46 };
47
41 // Observer interface for state and policy changes. 48 // Observer interface for state and policy changes.
42 class Observer { 49 class Observer {
43 public: 50 public:
44 virtual ~Observer(); 51 virtual ~Observer();
45 52
46 // Called when a policy fetch completes successfully. If a policy fetch 53 // Called when a policy fetch completes successfully. If a policy fetch
47 // triggers an error, OnClientError() will fire. 54 // triggers an error, OnClientError() will fire.
48 virtual void OnPolicyFetched(CloudPolicyClient* client) = 0; 55 virtual void OnPolicyFetched(CloudPolicyClient* client) = 0;
49 56
50 // Called upon registration state changes. This callback is invoked for 57 // Called upon registration state changes. This callback is invoked for
(...skipping 20 matching lines...) Expand all
71 // Called after the status information has successfully been submitted to 78 // Called after the status information has successfully been submitted to
72 // the server. 79 // the server.
73 virtual void OnSubmittedSuccessfully() = 0; 80 virtual void OnSubmittedSuccessfully() = 0;
74 }; 81 };
75 82
76 // |provider| and |service| are weak pointers and it's the caller's 83 // |provider| and |service| are weak pointers and it's the caller's
77 // responsibility to keep them valid for the lifetime of CloudPolicyClient. 84 // responsibility to keep them valid for the lifetime of CloudPolicyClient.
78 CloudPolicyClient(const std::string& machine_id, 85 CloudPolicyClient(const std::string& machine_id,
79 const std::string& machine_model, 86 const std::string& machine_model,
80 UserAffiliation user_affiliation, 87 UserAffiliation user_affiliation,
81 PolicyScope scope, 88 PolicyType policy_type,
82 StatusProvider* provider, 89 StatusProvider* provider,
83 DeviceManagementService* service); 90 DeviceManagementService* service);
84 virtual ~CloudPolicyClient(); 91 virtual ~CloudPolicyClient();
85 92
86 // Sets the DMToken, thereby establishing a registration with the server. A 93 // Sets the DMToken, thereby establishing a registration with the server. A
87 // policy fetch is not automatically issued but can be requested by calling 94 // policy fetch is not automatically issued but can be requested by calling
88 // FetchPolicy(). 95 // FetchPolicy().
89 virtual void SetupRegistration(const std::string& dm_token, 96 virtual void SetupRegistration(const std::string& dm_token,
90 const std::string& client_id); 97 const std::string& client_id);
91 98
(...skipping 29 matching lines...) Expand all
121 128
122 void set_public_key_version(int public_key_version) { 129 void set_public_key_version(int public_key_version) {
123 public_key_version_ = public_key_version; 130 public_key_version_ = public_key_version;
124 public_key_version_valid_ = true; 131 public_key_version_valid_ = true;
125 } 132 }
126 133
127 void clear_public_key_version() { 134 void clear_public_key_version() {
128 public_key_version_valid_ = false; 135 public_key_version_valid_ = false;
129 } 136 }
130 137
138 void set_entity_id(const std::string& entity_id) {
139 entity_id_ = entity_id;
140 }
141
131 // Whether the client is registered with the device management service. 142 // Whether the client is registered with the device management service.
132 bool is_registered() const { return !dm_token_.empty(); } 143 bool is_registered() const { return !dm_token_.empty(); }
133 144
134 const std::string& dm_token() const { return dm_token_; } 145 const std::string& dm_token() const { return dm_token_; }
135 146
136 // The device mode as received in the registration request. 147 // The device mode as received in the registration request.
137 DeviceMode device_mode() const { return device_mode_; } 148 DeviceMode device_mode() const { return device_mode_; }
138 149
139 // The policy response as obtained by the last request to the cloud. This 150 // The policy response as obtained by the last request to the cloud. This
140 // policy blob hasn't gone through verification, so its contents cannot be 151 // policy blob hasn't gone through verification, so its contents cannot be
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 184
174 // Observer notification helpers. 185 // Observer notification helpers.
175 void NotifyPolicyFetched(); 186 void NotifyPolicyFetched();
176 void NotifyRegistrationStateChanged(); 187 void NotifyRegistrationStateChanged();
177 void NotifyClientError(); 188 void NotifyClientError();
178 189
179 // Data necessary for constructing policy requests. 190 // Data necessary for constructing policy requests.
180 const std::string machine_id_; 191 const std::string machine_id_;
181 const std::string machine_model_; 192 const std::string machine_model_;
182 const UserAffiliation user_affiliation_; 193 const UserAffiliation user_affiliation_;
183 const PolicyScope scope_; 194 const PolicyType type_;
184 195
185 std::string dm_token_; 196 std::string dm_token_;
186 DeviceMode device_mode_; 197 DeviceMode device_mode_;
187 std::string client_id_; 198 std::string client_id_;
188 bool submit_machine_id_; 199 bool submit_machine_id_;
189 base::Time last_policy_timestamp_; 200 base::Time last_policy_timestamp_;
190 int public_key_version_; 201 int public_key_version_;
191 bool public_key_version_valid_; 202 bool public_key_version_valid_;
203 std::string entity_id_;
192 204
193 // Used for issuing requests to the cloud. 205 // Used for issuing requests to the cloud.
194 DeviceManagementService* service_; 206 DeviceManagementService* service_;
195 scoped_ptr<DeviceManagementRequestJob> request_job_; 207 scoped_ptr<DeviceManagementRequestJob> request_job_;
196 208
197 // Status upload data is produced by |status_provider_|. 209 // Status upload data is produced by |status_provider_|.
198 StatusProvider* status_provider_; 210 StatusProvider* status_provider_;
199 211
200 // The policy blob returned by the last policy fetch operation. 212 // The policy blob returned by the last policy fetch operation.
201 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_; 213 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_;
202 DeviceManagementStatus status_; 214 DeviceManagementStatus status_;
203 215
204 ObserverList<Observer, true> observers_; 216 ObserverList<Observer, true> observers_;
205 217
206 private: 218 private:
207 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); 219 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient);
208 }; 220 };
209 221
210 } // namespace policy 222 } // namespace policy
211 223
212 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CLIENT_H_ 224 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698