| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/chromeos/login/auth_response_handler.h" | 13 #include "chrome/browser/chromeos/login/auth_response_handler.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 class URLRequestContextGetter; | 16 class URLRequestContextGetter; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace chromeos { | 19 namespace chromeos { |
| 19 | 20 |
| 20 // Handles responses to a fetch executed upon the Google Accounts IssueAuthToken | 21 // Handles responses to a fetch executed upon the Google Accounts IssueAuthToken |
| 21 // endpoint. The token that's sent back in the response body is used as an | 22 // endpoint. The token that's sent back in the response body is used as an |
| 22 // URL query parameter in a request that, ultimately, results in a full set | 23 // URL query parameter in a request that, ultimately, results in a full set |
| 23 // of authorization cookies for Google services being left in the cookie jar | 24 // of authorization cookies for Google services being left in the cookie jar |
| 24 // associated with |getter_|. | 25 // associated with |getter_|. |
| 25 class IssueResponseHandler : public AuthResponseHandler { | 26 class IssueResponseHandler : public AuthResponseHandler { |
| 26 public: | 27 public: |
| 27 explicit IssueResponseHandler(net::URLRequestContextGetter* getter) | 28 explicit IssueResponseHandler(net::URLRequestContextGetter* getter) |
| 28 : getter_(getter) {} | 29 : getter_(getter) {} |
| 29 virtual ~IssueResponseHandler() {} | 30 virtual ~IssueResponseHandler() {} |
| 30 | 31 |
| 31 // Overridden from AuthResponseHandler. | 32 // Overridden from AuthResponseHandler. |
| 32 virtual bool CanHandle(const GURL& url); | 33 virtual bool CanHandle(const GURL& url) OVERRIDE; |
| 33 | 34 |
| 34 // Overridden from AuthResponseHandler. | 35 // Overridden from AuthResponseHandler. |
| 35 // Takes in a response from IssueAuthToken, formats into an appropriate query | 36 // Takes in a response from IssueAuthToken, formats into an appropriate query |
| 36 // to sent to TokenAuth, and issues said query. |catcher| will receive | 37 // to sent to TokenAuth, and issues said query. |catcher| will receive |
| 37 // the response to the fetch. This fetch will follow redirects, which is | 38 // the response to the fetch. This fetch will follow redirects, which is |
| 38 // necesary to support GAFYD and corp accounts. | 39 // necesary to support GAFYD and corp accounts. |
| 39 virtual content::URLFetcher* Handle(const std::string& to_process, | 40 virtual content::URLFetcher* Handle( |
| 40 content::URLFetcherDelegate* catcher); | 41 const std::string& to_process, |
| 42 content::URLFetcherDelegate* catcher) OVERRIDE; |
| 41 | 43 |
| 42 // exposed for testing | 44 // exposed for testing |
| 43 std::string token_url() { return token_url_; } | 45 std::string token_url() { return token_url_; } |
| 44 | 46 |
| 45 // Builds a TokenAuth URL using the specified authorization token. | 47 // Builds a TokenAuth URL using the specified authorization token. |
| 46 static std::string BuildTokenAuthUrlWithToken(const std::string& token); | 48 static std::string BuildTokenAuthUrlWithToken(const std::string& token); |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 std::string token_url_; | 51 std::string token_url_; |
| 50 net::URLRequestContextGetter* getter_; | 52 net::URLRequestContextGetter* getter_; |
| 51 DISALLOW_COPY_AND_ASSIGN(IssueResponseHandler); | 53 DISALLOW_COPY_AND_ASSIGN(IssueResponseHandler); |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 } // namespace chromeos | 56 } // namespace chromeos |
| 55 | 57 |
| 56 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_ | 58 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_ |
| OLD | NEW |