| 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/string_util.h" | 8 #include "base/string_util.h" |
| 8 #include "chrome/common/net/gaia/gaia_urls.h" | 9 #include "chrome/common/net/gaia/gaia_urls.h" |
| 9 #include "chrome/service/cloud_print/cloud_print_consts.h" | 10 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 10 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 11 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 11 #include "chrome/service/cloud_print/cloud_print_token_store.h" | 12 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
| 12 #include "chrome/service/gaia/service_gaia_authenticator.h" | 13 #include "chrome/service/gaia/service_gaia_authenticator.h" |
| 13 #include "chrome/service/net/service_url_request_context.h" | 14 #include "chrome/service/net/service_url_request_context.h" |
| 14 #include "chrome/service/service_process.h" | 15 #include "chrome/service/service_process.h" |
| 15 | 16 |
| 16 CloudPrintAuth::CloudPrintAuth( | 17 CloudPrintAuth::CloudPrintAuth( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 int expires_in_seconds) { | 133 int expires_in_seconds) { |
| 133 client_->OnAuthenticationComplete(access_token, refresh_token_, | 134 client_->OnAuthenticationComplete(access_token, refresh_token_, |
| 134 robot_email_, user_email_); | 135 robot_email_, user_email_); |
| 135 | 136 |
| 136 // 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 |
| 137 // expire. | 138 // expire. |
| 138 DCHECK(expires_in_seconds > kTokenRefreshGracePeriodSecs); | 139 DCHECK(expires_in_seconds > kTokenRefreshGracePeriodSecs); |
| 139 int64 refresh_delay = | 140 int64 refresh_delay = |
| 140 (expires_in_seconds - kTokenRefreshGracePeriodSecs)*1000; | 141 (expires_in_seconds - kTokenRefreshGracePeriodSecs)*1000; |
| 141 MessageLoop::current()->PostDelayedTask( | 142 MessageLoop::current()->PostDelayedTask( |
| 142 FROM_HERE, | 143 FROM_HERE, base::Bind(&CloudPrintAuth::RefreshAccessToken, this), |
| 143 NewRunnableMethod(this, &CloudPrintAuth::RefreshAccessToken), | |
| 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 |
| 152 void CloudPrintAuth::OnNetworkError(int response_code) { | 152 void CloudPrintAuth::OnNetworkError(int response_code) { |
| 153 // Since we specify infinite retries on network errors, this should never | 153 // Since we specify infinite retries on network errors, this should never |
| (...skipping 42 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 |