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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/service/cloud_print/cloud_print_consts.h" | 9 #include "chrome/common/cloud_print/cloud_print_constants.h" |
10 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 10 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
11 #include "chrome/service/cloud_print/cloud_print_token_store.h" | 11 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
12 #include "chrome/service/gaia/service_gaia_authenticator.h" | 12 #include "chrome/service/gaia/service_gaia_authenticator.h" |
13 #include "chrome/service/net/service_url_request_context.h" | 13 #include "chrome/service/net/service_url_request_context.h" |
14 #include "chrome/service/service_process.h" | 14 #include "chrome/service/service_process.h" |
15 #include "google_apis/gaia/gaia_urls.h" | 15 #include "google_apis/gaia/gaia_urls.h" |
16 | 16 |
| 17 namespace cloud_print { |
| 18 |
17 CloudPrintAuth::CloudPrintAuth( | 19 CloudPrintAuth::CloudPrintAuth( |
18 Client* client, | 20 Client* client, |
19 const GURL& cloud_print_server_url, | 21 const GURL& cloud_print_server_url, |
20 const gaia::OAuthClientInfo& oauth_client_info, | 22 const gaia::OAuthClientInfo& oauth_client_info, |
21 const std::string& proxy_id) | 23 const std::string& proxy_id) |
22 : client_(client), | 24 : client_(client), |
23 oauth_client_info_(oauth_client_info), | 25 oauth_client_info_(oauth_client_info), |
24 cloud_print_server_url_(cloud_print_server_url), | 26 cloud_print_server_url_(cloud_print_server_url), |
25 proxy_id_(proxy_id) { | 27 proxy_id_(proxy_id) { |
26 DCHECK(client); | 28 DCHECK(client); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 60 } |
59 } | 61 } |
60 | 62 |
61 void CloudPrintAuth::AuthenticateWithToken( | 63 void CloudPrintAuth::AuthenticateWithToken( |
62 const std::string& cloud_print_token) { | 64 const std::string& cloud_print_token) { |
63 VLOG(1) << "CP_AUTH: Authenticating with token"; | 65 VLOG(1) << "CP_AUTH: Authenticating with token"; |
64 | 66 |
65 client_login_token_ = cloud_print_token; | 67 client_login_token_ = cloud_print_token; |
66 | 68 |
67 // We need to get the credentials of the robot here. | 69 // We need to get the credentials of the robot here. |
68 GURL get_authcode_url = | 70 GURL get_authcode_url = GetUrlForGetAuthCode(cloud_print_server_url_, |
69 CloudPrintHelpers::GetUrlForGetAuthCode(cloud_print_server_url_, | 71 oauth_client_info_.client_id, |
70 oauth_client_info_.client_id, | 72 proxy_id_); |
71 proxy_id_); | |
72 request_ = new CloudPrintURLFetcher; | 73 request_ = new CloudPrintURLFetcher; |
73 request_->StartGetRequest(get_authcode_url, | 74 request_->StartGetRequest(get_authcode_url, |
74 this, | 75 this, |
75 kCloudPrintAuthMaxRetryCount, | 76 kCloudPrintAuthMaxRetryCount, |
76 std::string()); | 77 std::string()); |
77 } | 78 } |
78 | 79 |
79 void CloudPrintAuth::AuthenticateWithRobotToken( | 80 void CloudPrintAuth::AuthenticateWithRobotToken( |
80 const std::string& robot_oauth_refresh_token, | 81 const std::string& robot_oauth_refresh_token, |
81 const std::string& robot_email) { | 82 const std::string& robot_email) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 std::string CloudPrintAuth::GetAuthHeader() { | 191 std::string CloudPrintAuth::GetAuthHeader() { |
191 DCHECK(!client_login_token_.empty()); | 192 DCHECK(!client_login_token_.empty()); |
192 std::string header; | 193 std::string header; |
193 header = "Authorization: GoogleLogin auth="; | 194 header = "Authorization: GoogleLogin auth="; |
194 header += client_login_token_; | 195 header += client_login_token_; |
195 return header; | 196 return header; |
196 } | 197 } |
197 | 198 |
198 CloudPrintAuth::~CloudPrintAuth() {} | 199 CloudPrintAuth::~CloudPrintAuth() {} |
199 | 200 |
| 201 } // namespace cloud_print |
OLD | NEW |