Home | History | Annotate | Download | only in login
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_CLIENT_LOGIN_RESPONSE_HANDLER_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_CLIENT_LOGIN_RESPONSE_HANDLER_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "chrome/browser/chromeos/login/auth_response_handler.h"
     13 
     14 namespace net {
     15 class URLRequestContextGetter;
     16 }
     17 
     18 namespace chromeos {
     19 
     20 // Handles responses to a fetch executed upon the Google Accounts ClientLogin
     21 // endpoint.  The cookies that are sent back in the response body are
     22 // reformatted into a request for an time-limited authorization token, which
     23 // is then sent to the IssueAuthToken endpoint.
     24 class ClientLoginResponseHandler : public AuthResponseHandler {
     25  public:
     26   explicit ClientLoginResponseHandler(net::URLRequestContextGetter* getter)
     27       : getter_(getter) {}
     28   ~ClientLoginResponseHandler() {}
     29 
     30   // Overridden from AuthResponseHandler.
     31   virtual bool CanHandle(const GURL& url);
     32 
     33   // Overridden from AuthResponseHandler.
     34   // Takes in a response from ClientLogin, formats into an appropriate query
     35   // to sent to IssueAuthToken and issues said query.  |catcher| will receive
     36   // the response to the fetch.
     37   virtual URLFetcher* Handle(const std::string& to_process,
     38                              URLFetcher::Delegate* catcher);
     39 
     40   // exposed for tests.
     41   std::string payload() { return payload_; }
     42 
     43   // A string that tells the Accounts backend to which service we're trying to
     44   // authenticate.
     45   static const char kService[];
     46  private:
     47   std::string payload_;
     48   net::URLRequestContextGetter* getter_;
     49 
     50   DISALLOW_COPY_AND_ASSIGN(ClientLoginResponseHandler);
     51 };
     52 
     53 }  // namespace chromeos
     54 
     55 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_CLIENT_LOGIN_RESPONSE_HANDLER_H_
     56