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

Side by Side Diff: chrome/browser/policy/device_token_fetcher.cc

Issue 6821045: Connect enrollment screen to cloud policy subsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests... Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/policy/cloud_policy_cache_base.h" 10 #include "chrome/browser/policy/cloud_policy_cache_base.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 DeviceTokenFetcher::~DeviceTokenFetcher() { 59 DeviceTokenFetcher::~DeviceTokenFetcher() {
60 CancelRetryTask(); 60 CancelRetryTask();
61 } 61 }
62 62
63 void DeviceTokenFetcher::FetchToken( 63 void DeviceTokenFetcher::FetchToken(
64 const std::string& auth_token, 64 const std::string& auth_token,
65 const std::string& device_id, 65 const std::string& device_id,
66 em::DeviceRegisterRequest_Type policy_type, 66 em::DeviceRegisterRequest_Type policy_type,
67 const std::string& machine_id) { 67 const std::string& machine_id,
68 const std::string& machine_model) {
68 SetState(STATE_INACTIVE); 69 SetState(STATE_INACTIVE);
69 auth_token_ = auth_token; 70 auth_token_ = auth_token;
70 device_id_ = device_id; 71 device_id_ = device_id;
71 policy_type_ = policy_type; 72 policy_type_ = policy_type;
72 machine_id_ = machine_id; 73 machine_id_ = machine_id;
74 machine_model_ = machine_model;
73 FetchTokenInternal(); 75 FetchTokenInternal();
74 } 76 }
75 77
76 void DeviceTokenFetcher::FetchTokenInternal() { 78 void DeviceTokenFetcher::FetchTokenInternal() {
77 DCHECK(state_ != STATE_TOKEN_AVAILABLE); 79 DCHECK(state_ != STATE_TOKEN_AVAILABLE);
78 if (auth_token_.empty() || device_id_.empty()) { 80 if (auth_token_.empty() || device_id_.empty()) {
79 // Maybe this device is unmanaged, just exit. The CloudPolicyController 81 // Maybe this device is unmanaged, just exit. The CloudPolicyController
80 // will call FetchToken() again if something changes. 82 // will call FetchToken() again if something changes.
81 return; 83 return;
82 } 84 }
83 // Construct a new backend, which will discard any previous requests. 85 // Construct a new backend, which will discard any previous requests.
84 backend_.reset(service_->CreateBackend()); 86 backend_.reset(service_->CreateBackend());
85 em::DeviceRegisterRequest request; 87 em::DeviceRegisterRequest request;
86 request.set_type(policy_type_); 88 request.set_type(policy_type_);
87 if (!machine_id_.empty()) 89 if (!machine_id_.empty())
88 request.set_machine_id(machine_id_); 90 request.set_machine_id(machine_id_);
89 request.set_machine_model(kRegisterRequestMachineModel); 91 if (!machine_model_.empty())
92 request.set_machine_model(machine_model_);
90 backend_->ProcessRegisterRequest(auth_token_, device_id_, request, this); 93 backend_->ProcessRegisterRequest(auth_token_, device_id_, request, this);
91 } 94 }
92 95
93 void DeviceTokenFetcher::SetUnmanagedState() { 96 void DeviceTokenFetcher::SetUnmanagedState() {
94 // The call to |cache_->SetUnmanaged()| has to happen first because it sets 97 // The call to |cache_->SetUnmanaged()| has to happen first because it sets
95 // the timestamp that |SetState()| needs to determine the correct refresh 98 // the timestamp that |SetState()| needs to determine the correct refresh
96 // time. 99 // time.
97 cache_->SetUnmanaged(); 100 cache_->SetUnmanaged();
98 SetState(STATE_UNMANAGED); 101 SetState(STATE_UNMANAGED);
99 } 102 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 259 }
257 260
258 void DeviceTokenFetcher::CancelRetryTask() { 261 void DeviceTokenFetcher::CancelRetryTask() {
259 if (retry_task_) { 262 if (retry_task_) {
260 retry_task_->Cancel(); 263 retry_task_->Cancel();
261 retry_task_ = NULL; 264 retry_task_ = NULL;
262 } 265 }
263 } 266 }
264 267
265 } // namespace policy 268 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.h ('k') | chrome/browser/policy/device_token_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698