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_ISSUE_RESPONSE_HANDLER_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_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
14namespace net {
15class URLRequestContextGetter;
16}
17
18namespace chromeos {
19
20// 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// 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// associated with |getter_|.
25class IssueResponseHandler : public AuthResponseHandler {
26 public:
27  explicit IssueResponseHandler(net::URLRequestContextGetter* getter)
28      : getter_(getter) {}
29  virtual ~IssueResponseHandler() {}
30
31  // Overridden from AuthResponseHandler.
32  virtual bool CanHandle(const GURL& url);
33
34  // Overridden from AuthResponseHandler.
35  // Takes in a response from IssueAuthToken, formats into an appropriate query
36  // 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  // necesary to support GAFYD and corp accounts.
39  virtual URLFetcher* Handle(const std::string& to_process,
40                             URLFetcher::Delegate* catcher);
41
42  // exposed for testing
43  std::string token_url() { return token_url_; }
44
45 private:
46  std::string token_url_;
47  net::URLRequestContextGetter* getter_;
48  DISALLOW_COPY_AND_ASSIGN(IssueResponseHandler);
49};
50
51}  // namespace chromeos
52
53#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_ISSUE_RESPONSE_HANDLER_H_
54