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/browser/chromeos/login/client_login_response_handler.h" | 5 #include "chrome/browser/chromeos/login/client_login_response_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/chromeos/login/google_authenticator.h" | 10 #include "chrome/browser/chromeos/login/google_authenticator.h" |
11 #include "chrome/browser/net/chrome_url_request_context.h" | 11 #include "chrome/browser/net/chrome_url_request_context.h" |
12 #include "chrome/common/net/gaia/gaia_urls.h" | 12 #include "chrome/common/net/gaia/gaia_urls.h" |
13 #include "content/common/net/url_fetcher.h" | 13 #include "content/common/net/url_fetcher.h" |
14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 // By setting "service=gaia", we get an uber-auth-token back. | 18 // By setting "service=gaia", we get an uber-auth-token back. |
19 const char ClientLoginResponseHandler::kService[] = "service=gaia"; | 19 const char ClientLoginResponseHandler::kService[] = "service=gaia"; |
20 | 20 |
21 // Overridden from AuthResponseHandler. | 21 // Overridden from AuthResponseHandler. |
22 bool ClientLoginResponseHandler::CanHandle(const GURL& url) { | 22 bool ClientLoginResponseHandler::CanHandle(const GURL& url) { |
23 return (url.spec().find(GaiaUrls::GetInstance()->client_login_url()) != | 23 return (url.spec().find(GaiaUrls::GetInstance()->client_login_url()) != |
24 std::string::npos); | 24 std::string::npos); |
25 } | 25 } |
26 | 26 |
27 // Overridden from AuthResponseHandler. | 27 // Overridden from AuthResponseHandler. |
28 URLFetcher* ClientLoginResponseHandler::Handle( | 28 URLFetcher* ClientLoginResponseHandler::Handle( |
29 const std::string& to_process, | 29 const std::string& to_process, |
30 URLFetcher::Delegate* catcher) { | 30 content::URLFetcherDelegate* catcher) { |
31 VLOG(1) << "Handling ClientLogin response!"; | 31 VLOG(1) << "Handling ClientLogin response!"; |
32 payload_.assign(to_process); | 32 payload_.assign(to_process); |
33 std::replace(payload_.begin(), payload_.end(), '\n', '&'); | 33 std::replace(payload_.begin(), payload_.end(), '\n', '&'); |
34 payload_.append(kService); | 34 payload_.append(kService); |
35 | 35 |
36 URLFetcher* fetcher = | 36 URLFetcher* fetcher = |
37 new URLFetcher(GURL(GaiaUrls::GetInstance()->issue_auth_token_url()), | 37 new URLFetcher(GURL(GaiaUrls::GetInstance()->issue_auth_token_url()), |
38 URLFetcher::POST, | 38 URLFetcher::POST, |
39 catcher); | 39 catcher); |
40 fetcher->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES); | 40 fetcher->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES); |
41 fetcher->set_upload_data("application/x-www-form-urlencoded", payload_); | 41 fetcher->set_upload_data("application/x-www-form-urlencoded", payload_); |
42 if (getter_) { | 42 if (getter_) { |
43 VLOG(1) << "Fetching " << GaiaUrls::GetInstance()->issue_auth_token_url(); | 43 VLOG(1) << "Fetching " << GaiaUrls::GetInstance()->issue_auth_token_url(); |
44 fetcher->set_request_context(getter_); | 44 fetcher->set_request_context(getter_); |
45 fetcher->Start(); | 45 fetcher->Start(); |
46 } | 46 } |
47 return fetcher; | 47 return fetcher; |
48 } | 48 } |
49 | 49 |
50 } // namespace chromeos | 50 } // namespace chromeos |
OLD | NEW |