OLD | NEW |
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/service/cloud_print/cloud_print_auth.h" | 5 #include "chrome/service/cloud_print/cloud_print_auth.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/net/gaia/gaia_urls.h" | 9 #include "chrome/common/net/gaia/gaia_urls.h" |
10 #include "chrome/service/cloud_print/cloud_print_consts.h" | 10 #include "chrome/service/cloud_print/cloud_print_consts.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 void CloudPrintAuth::OnRefreshTokenResponse(const std::string& access_token, | 132 void CloudPrintAuth::OnRefreshTokenResponse(const std::string& access_token, |
133 int expires_in_seconds) { | 133 int expires_in_seconds) { |
134 client_->OnAuthenticationComplete(access_token, refresh_token_, | 134 client_->OnAuthenticationComplete(access_token, refresh_token_, |
135 robot_email_, user_email_); | 135 robot_email_, user_email_); |
136 | 136 |
137 // Schedule a task to refresh the access token again when it is about to | 137 // Schedule a task to refresh the access token again when it is about to |
138 // expire. | 138 // expire. |
139 DCHECK(expires_in_seconds > kTokenRefreshGracePeriodSecs); | 139 DCHECK(expires_in_seconds > kTokenRefreshGracePeriodSecs); |
140 int64 refresh_delay = | 140 base::TimeDelta refresh_delay = base::TimeDelta::FromSeconds( |
141 (expires_in_seconds - kTokenRefreshGracePeriodSecs)*1000; | 141 expires_in_seconds - kTokenRefreshGracePeriodSecs); |
142 MessageLoop::current()->PostDelayedTask( | 142 MessageLoop::current()->PostDelayedTask( |
143 FROM_HERE, base::Bind(&CloudPrintAuth::RefreshAccessToken, this), | 143 FROM_HERE, base::Bind(&CloudPrintAuth::RefreshAccessToken, this), |
144 refresh_delay); | 144 refresh_delay); |
145 } | 145 } |
146 | 146 |
147 void CloudPrintAuth::OnOAuthError() { | 147 void CloudPrintAuth::OnOAuthError() { |
148 // Notify client about authentication error. | 148 // Notify client about authentication error. |
149 client_->OnInvalidCredentials(); | 149 client_->OnInvalidCredentials(); |
150 } | 150 } |
151 | 151 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 | 197 |
198 std::string CloudPrintAuth::GetAuthHeader() { | 198 std::string CloudPrintAuth::GetAuthHeader() { |
199 DCHECK(!client_login_token_.empty()); | 199 DCHECK(!client_login_token_.empty()); |
200 std::string header; | 200 std::string header; |
201 header = "Authorization: GoogleLogin auth="; | 201 header = "Authorization: GoogleLogin auth="; |
202 header += client_login_token_; | 202 header += client_login_token_; |
203 return header; | 203 return header; |
204 } | 204 } |
205 | 205 |
OLD | NEW |