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 "google_apis/gaia/gaia_oauth_client.h" | 5 #include "google_apis/gaia/gaia_oauth_client.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 Delegate* delegate); | 55 Delegate* delegate); |
56 void GetUserId(const std::string& oauth_access_token, | 56 void GetUserId(const std::string& oauth_access_token, |
57 int max_retries, | 57 int max_retries, |
58 Delegate* delegate); | 58 Delegate* delegate); |
59 void GetUserInfo(const std::string& oauth_access_token, | 59 void GetUserInfo(const std::string& oauth_access_token, |
60 int max_retries, | 60 int max_retries, |
61 Delegate* delegate); | 61 Delegate* delegate); |
62 void GetTokenInfo(const std::string& oauth_access_token, | 62 void GetTokenInfo(const std::string& oauth_access_token, |
63 int max_retries, | 63 int max_retries, |
64 Delegate* delegate); | 64 Delegate* delegate); |
65 void GetTokenHandleInfo(const std::string& token_handle, | |
66 int max_retries, | |
67 Delegate* delegate); | |
65 | 68 |
66 // net::URLFetcherDelegate implementation. | 69 // net::URLFetcherDelegate implementation. |
67 void OnURLFetchComplete(const net::URLFetcher* source) override; | 70 void OnURLFetchComplete(const net::URLFetcher* source) override; |
68 | 71 |
69 private: | 72 private: |
70 friend class base::RefCountedThreadSafe<Core>; | 73 friend class base::RefCountedThreadSafe<Core>; |
71 | 74 |
72 enum RequestType { | 75 enum RequestType { |
73 NO_PENDING_REQUEST, | 76 NO_PENDING_REQUEST, |
74 TOKENS_FROM_AUTH_CODE, | 77 TOKENS_FROM_AUTH_CODE, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 DCHECK(!request_.get()); | 199 DCHECK(!request_.get()); |
197 request_type_ = TOKEN_INFO; | 200 request_type_ = TOKEN_INFO; |
198 std::string post_body = | 201 std::string post_body = |
199 "access_token=" + net::EscapeUrlEncodedData(oauth_access_token, true); | 202 "access_token=" + net::EscapeUrlEncodedData(oauth_access_token, true); |
200 MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()), | 203 MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()), |
201 post_body, | 204 post_body, |
202 max_retries, | 205 max_retries, |
203 delegate); | 206 delegate); |
204 } | 207 } |
205 | 208 |
209 void GaiaOAuthClient::Core::GetTokenHandleInfo(const std::string& token_handle, | |
210 int max_retries, | |
211 Delegate* delegate) { | |
212 DCHECK_EQ(request_type_, NO_PENDING_REQUEST); | |
213 DCHECK(!request_.get()); | |
214 request_type_ = TOKEN_INFO; | |
215 std::string post_body = | |
216 "token_handle=" + net::EscapeUrlEncodedData(token_handle, true); | |
217 MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()), | |
218 post_body, max_retries, delegate); | |
219 } | |
Roger Tawa OOO till Jul 10th
2015/03/11 18:23:52
Since Core is an internal only class, and since th
Denis Kuznetsov (DE-MUC)
2015/03/11 19:04:19
Done.
| |
220 | |
206 void GaiaOAuthClient::Core::MakeGaiaRequest( | 221 void GaiaOAuthClient::Core::MakeGaiaRequest( |
207 const GURL& url, | 222 const GURL& url, |
208 const std::string& post_body, | 223 const std::string& post_body, |
209 int max_retries, | 224 int max_retries, |
210 GaiaOAuthClient::Delegate* delegate) { | 225 GaiaOAuthClient::Delegate* delegate) { |
211 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; | 226 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; |
212 delegate_ = delegate; | 227 delegate_ = delegate; |
213 num_retries_ = 0; | 228 num_retries_ = 0; |
214 request_.reset(net::URLFetcher::Create( | 229 request_.reset(net::URLFetcher::Create( |
215 kUrlFetcherId, url, net::URLFetcher::POST, this)); | 230 kUrlFetcherId, url, net::URLFetcher::POST, this)); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 Delegate* delegate) { | 407 Delegate* delegate) { |
393 return core_->GetUserInfo(access_token, max_retries, delegate); | 408 return core_->GetUserInfo(access_token, max_retries, delegate); |
394 } | 409 } |
395 | 410 |
396 void GaiaOAuthClient::GetTokenInfo(const std::string& access_token, | 411 void GaiaOAuthClient::GetTokenInfo(const std::string& access_token, |
397 int max_retries, | 412 int max_retries, |
398 Delegate* delegate) { | 413 Delegate* delegate) { |
399 return core_->GetTokenInfo(access_token, max_retries, delegate); | 414 return core_->GetTokenInfo(access_token, max_retries, delegate); |
400 } | 415 } |
401 | 416 |
417 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle, | |
418 int max_retries, | |
419 Delegate* delegate) { | |
420 return core_->GetTokenInfo(token_handle, max_retries, delegate); | |
421 } | |
422 | |
402 } // namespace gaia | 423 } // namespace gaia |
OLD | NEW |