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