| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/policy/core/common/cloud/cloud_policy_client_registration_h
elper.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_client_registration_h
elper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 login_token_helper_.reset( | 196 login_token_helper_.reset( |
| 197 new CloudPolicyClientRegistrationHelper::LoginTokenHelper()); | 197 new CloudPolicyClientRegistrationHelper::LoginTokenHelper()); |
| 198 login_token_helper_->FetchAccessToken( | 198 login_token_helper_->FetchAccessToken( |
| 199 login_refresh_token, | 199 login_refresh_token, |
| 200 context_.get(), | 200 context_.get(), |
| 201 base::Bind(&CloudPolicyClientRegistrationHelper::OnTokenFetched, | 201 base::Bind(&CloudPolicyClientRegistrationHelper::OnTokenFetched, |
| 202 base::Unretained(this))); | 202 base::Unretained(this))); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void CloudPolicyClientRegistrationHelper::StartRegistrationWithAccessToken( | |
| 206 const std::string& access_token, | |
| 207 const base::Closure& callback) { | |
| 208 DCHECK(!client_->is_registered()); | |
| 209 callback_ = callback; | |
| 210 client_->AddObserver(this); | |
| 211 OnTokenFetched(access_token); | |
| 212 } | |
| 213 | |
| 214 // static | 205 // static |
| 215 std::vector<std::string> | 206 std::vector<std::string> |
| 216 CloudPolicyClientRegistrationHelper::GetScopes() { | 207 CloudPolicyClientRegistrationHelper::GetScopes() { |
| 217 std::vector<std::string> scopes; | 208 std::vector<std::string> scopes; |
| 218 scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth); | 209 scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth); |
| 219 scopes.push_back(GaiaConstants::kOAuthWrapBridgeUserInfoScope); | 210 scopes.push_back(GaiaConstants::kOAuthWrapBridgeUserInfoScope); |
| 220 return scopes; | 211 return scopes; |
| 221 } | 212 } |
| 222 #endif | 213 #endif |
| 223 | 214 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 void CloudPolicyClientRegistrationHelper::RequestCompleted() { | 291 void CloudPolicyClientRegistrationHelper::RequestCompleted() { |
| 301 if (client_) { | 292 if (client_) { |
| 302 client_->RemoveObserver(this); | 293 client_->RemoveObserver(this); |
| 303 // |client_| may be freed by the callback so clear it now. | 294 // |client_| may be freed by the callback so clear it now. |
| 304 client_ = NULL; | 295 client_ = NULL; |
| 305 callback_.Run(); | 296 callback_.Run(); |
| 306 } | 297 } |
| 307 } | 298 } |
| 308 | 299 |
| 309 } // namespace policy | 300 } // namespace policy |
| OLD | NEW |