OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/policy/consumer_enrollment_handler.h" | 5 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> | 56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> |
57 RemoveObserver(this); | 57 RemoveObserver(this); |
58 OnOwnerRefreshTokenAvailable(); | 58 OnOwnerRefreshTokenAvailable(); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void ConsumerEnrollmentHandler::OnGetTokenSuccess( | 62 void ConsumerEnrollmentHandler::OnGetTokenSuccess( |
63 const OAuth2TokenService::Request* request, | 63 const OAuth2TokenService::Request* request, |
64 const std::string& access_token, | 64 const std::string& access_token, |
65 const base::Time& expiration_time) { | 65 const base::Time& expiration_time) { |
66 DCHECK_EQ(token_request_, request); | 66 DCHECK_EQ(token_request_.get(), request); |
67 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); | 67 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); |
68 | 68 |
69 OnOwnerAccessTokenAvailable(access_token); | 69 OnOwnerAccessTokenAvailable(access_token); |
70 } | 70 } |
71 | 71 |
72 void ConsumerEnrollmentHandler::OnGetTokenFailure( | 72 void ConsumerEnrollmentHandler::OnGetTokenFailure( |
73 const OAuth2TokenService::Request* request, | 73 const OAuth2TokenService::Request* request, |
74 const GoogleServiceAuthError& error) { | 74 const GoogleServiceAuthError& error) { |
75 DCHECK_EQ(token_request_, request); | 75 DCHECK_EQ(token_request_.get(), request); |
76 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); | 76 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); |
77 | 77 |
78 LOG(ERROR) << "Failed to get the access token: " << error.ToString(); | 78 LOG(ERROR) << "Failed to get the access token: " << error.ToString(); |
79 EndEnrollment(ConsumerManagementStage::EnrollmentGetTokenFailed()); | 79 EndEnrollment(ConsumerManagementStage::EnrollmentGetTokenFailed()); |
80 } | 80 } |
81 | 81 |
82 void ConsumerEnrollmentHandler::ContinueEnrollmentProcess() { | 82 void ConsumerEnrollmentHandler::ContinueEnrollmentProcess() { |
83 // First, we need to ensure that the refresh token is available. | 83 // First, we need to ensure that the refresh token is available. |
84 ProfileOAuth2TokenService* token_service = | 84 ProfileOAuth2TokenService* token_service = |
85 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 85 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 EndEnrollment(ConsumerManagementStage::EnrollmentSuccess()); | 138 EndEnrollment(ConsumerManagementStage::EnrollmentSuccess()); |
139 } | 139 } |
140 | 140 |
141 void ConsumerEnrollmentHandler::EndEnrollment( | 141 void ConsumerEnrollmentHandler::EndEnrollment( |
142 const ConsumerManagementStage& stage) { | 142 const ConsumerManagementStage& stage) { |
143 consumer_management_service_->SetStage(stage); | 143 consumer_management_service_->SetStage(stage); |
144 } | 144 } |
145 | 145 |
146 } // namespace policy | 146 } // namespace policy |
OLD | NEW |