| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 AUTH_EVENT_NET_ERROR, | 36 AUTH_EVENT_NET_ERROR, |
| 37 AUTH_EVENT_MAX | 37 AUTH_EVENT_MAX |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 CloudPrintAuth::CloudPrintAuth( | 42 CloudPrintAuth::CloudPrintAuth( |
| 43 Client* client, | 43 Client* client, |
| 44 const GURL& cloud_print_server_url, | 44 const GURL& cloud_print_server_url, |
| 45 const gaia::OAuthClientInfo& oauth_client_info, | 45 const gaia::OAuthClientInfo& oauth_client_info, |
| 46 const std::string& proxy_id) | 46 const std::string& proxy_id, |
| 47 : client_(client), | 47 const net::PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) |
| 48 oauth_client_info_(oauth_client_info), | 48 : client_(client), |
| 49 cloud_print_server_url_(cloud_print_server_url), | 49 oauth_client_info_(oauth_client_info), |
| 50 proxy_id_(proxy_id) { | 50 cloud_print_server_url_(cloud_print_server_url), |
| 51 proxy_id_(proxy_id), |
| 52 partial_traffic_annotation_(partial_traffic_annotation) { |
| 51 DCHECK(client); | 53 DCHECK(client); |
| 52 } | 54 } |
| 53 | 55 |
| 54 void CloudPrintAuth::AuthenticateWithToken( | 56 void CloudPrintAuth::AuthenticateWithToken( |
| 55 const std::string& cloud_print_token) { | 57 const std::string& cloud_print_token) { |
| 56 VLOG(1) << "CP_AUTH: Authenticating with token"; | 58 VLOG(1) << "CP_AUTH: Authenticating with token"; |
| 57 | 59 |
| 58 UMA_HISTOGRAM_ENUMERATION("CloudPrint.AuthEvent", AUTH_EVENT_ROBO_CREATE, | 60 UMA_HISTOGRAM_ENUMERATION("CloudPrint.AuthEvent", AUTH_EVENT_ROBO_CREATE, |
| 59 AUTH_EVENT_MAX); | 61 AUTH_EVENT_MAX); |
| 60 | 62 |
| 61 client_login_token_ = cloud_print_token; | 63 client_login_token_ = cloud_print_token; |
| 62 | 64 |
| 63 // We need to get the credentials of the robot here. | 65 // We need to get the credentials of the robot here. |
| 64 GURL get_authcode_url = GetUrlForGetAuthCode(cloud_print_server_url_, | 66 GURL get_authcode_url = GetUrlForGetAuthCode(cloud_print_server_url_, |
| 65 oauth_client_info_.client_id, | 67 oauth_client_info_.client_id, |
| 66 proxy_id_); | 68 proxy_id_); |
| 67 request_ = CloudPrintURLFetcher::Create(); | 69 request_ = CloudPrintURLFetcher::Create(partial_traffic_annotation_); |
| 68 request_->StartGetRequest(CloudPrintURLFetcher::REQUEST_AUTH_CODE, | 70 request_->StartGetRequest(CloudPrintURLFetcher::REQUEST_AUTH_CODE, |
| 69 get_authcode_url, this, | 71 get_authcode_url, this, |
| 70 kCloudPrintAuthMaxRetryCount, std::string()); | 72 kCloudPrintAuthMaxRetryCount, std::string()); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void CloudPrintAuth::AuthenticateWithRobotToken( | 75 void CloudPrintAuth::AuthenticateWithRobotToken( |
| 74 const std::string& robot_oauth_refresh_token, | 76 const std::string& robot_oauth_refresh_token, |
| 75 const std::string& robot_email) { | 77 const std::string& robot_email) { |
| 76 VLOG(1) << "CP_AUTH: Authenticating with robot token"; | 78 VLOG(1) << "CP_AUTH: Authenticating with robot token"; |
| 77 | 79 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 DCHECK(!client_login_token_.empty()); | 217 DCHECK(!client_login_token_.empty()); |
| 216 std::string header; | 218 std::string header; |
| 217 header = "Authorization: GoogleLogin auth="; | 219 header = "Authorization: GoogleLogin auth="; |
| 218 header += client_login_token_; | 220 header += client_login_token_; |
| 219 return header; | 221 return header; |
| 220 } | 222 } |
| 221 | 223 |
| 222 CloudPrintAuth::~CloudPrintAuth() {} | 224 CloudPrintAuth::~CloudPrintAuth() {} |
| 223 | 225 |
| 224 } // namespace cloud_print | 226 } // namespace cloud_print |
| OLD | NEW |