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

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

Powered by Google App Engine
This is Rietveld 408576698