OLD | NEW |
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 #include "chrome/browser/policy/cloud_policy_client.h" | 5 #include "chrome/browser/policy/cloud_policy_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/guid.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "chrome/browser/policy/device_management_service.h" | 10 #include "chrome/browser/policy/device_management_service.h" |
10 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 11 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
11 #include "chrome/common/guid.h" | |
12 | 12 |
13 namespace em = enterprise_management; | 13 namespace em = enterprise_management; |
14 | 14 |
15 namespace policy { | 15 namespace policy { |
16 | 16 |
17 CloudPolicyClient::Observer::~Observer() {} | 17 CloudPolicyClient::Observer::~Observer() {} |
18 | 18 |
19 CloudPolicyClient::StatusProvider::~StatusProvider() {} | 19 CloudPolicyClient::StatusProvider::~StatusProvider() {} |
20 | 20 |
21 CloudPolicyClient::CloudPolicyClient(const std::string& machine_id, | 21 CloudPolicyClient::CloudPolicyClient(const std::string& machine_id, |
(...skipping 29 matching lines...) Expand all Loading... |
51 NotifyRegistrationStateChanged(); | 51 NotifyRegistrationStateChanged(); |
52 } | 52 } |
53 | 53 |
54 void CloudPolicyClient::Register(const std::string& auth_token) { | 54 void CloudPolicyClient::Register(const std::string& auth_token) { |
55 DCHECK(!auth_token.empty()); | 55 DCHECK(!auth_token.empty()); |
56 DCHECK(!is_registered()); | 56 DCHECK(!is_registered()); |
57 | 57 |
58 // Generate a new client ID. This is intentionally done on each new | 58 // Generate a new client ID. This is intentionally done on each new |
59 // registration request in order to preserve privacy. Reusing IDs would mean | 59 // registration request in order to preserve privacy. Reusing IDs would mean |
60 // the server could track clients by their registration attempts. | 60 // the server could track clients by their registration attempts. |
61 client_id_ = guid::GenerateGUID(); | 61 client_id_ = base::GenerateGUID(); |
62 | 62 |
63 request_job_.reset( | 63 request_job_.reset( |
64 service_->CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION)); | 64 service_->CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION)); |
65 request_job_->SetOAuthToken(auth_token); | 65 request_job_->SetOAuthToken(auth_token); |
66 request_job_->SetClientID(client_id_); | 66 request_job_->SetClientID(client_id_); |
67 | 67 |
68 em::DeviceRegisterRequest* request = | 68 em::DeviceRegisterRequest* request = |
69 request_job_->GetRequest()->mutable_register_request(); | 69 request_job_->GetRequest()->mutable_register_request(); |
70 SetRegistrationType(request); | 70 SetRegistrationType(request); |
71 if (!machine_id_.empty()) | 71 if (!machine_id_.empty()) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 void CloudPolicyClient::NotifyRegistrationStateChanged() { | 230 void CloudPolicyClient::NotifyRegistrationStateChanged() { |
231 FOR_EACH_OBSERVER(Observer, observers_, OnRegistrationStateChanged(this)); | 231 FOR_EACH_OBSERVER(Observer, observers_, OnRegistrationStateChanged(this)); |
232 } | 232 } |
233 | 233 |
234 void CloudPolicyClient::NotifyClientError() { | 234 void CloudPolicyClient::NotifyClientError() { |
235 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); | 235 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); |
236 } | 236 } |
237 | 237 |
238 } // namespace policy | 238 } // namespace policy |
OLD | NEW |