1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_RESPONSE_HANDLER_H_
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_RESPONSE_HANDLER_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string>
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/common/net/url_fetcher.h"
12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass GURL;
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace chromeos {
16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// The success code specified by the HTTP spec.
18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochextern const int kHttpSuccess;
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass AuthResponseHandler {
21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  AuthResponseHandler() {}
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ~AuthResponseHandler() {}
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // True if this object can handle responses from |url|, false otherwise.
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual bool CanHandle(const GURL& url) = 0;
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Caller takes ownership of return value.
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Takes in |to_process|, creates an appropriate URLFetcher to handle
30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // the next step, sets |catcher| to get called back when that fetcher is done.
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Starts the fetch and returns the fetcher, so the the caller can handle
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // the object lifetime.
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual URLFetcher* Handle(const std::string& to_process,
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                             URLFetcher::Delegate* catcher) = 0;
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The URLs for different calls in the Google Accounts programmatic login API.
37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const char kClientLoginUrl[];
38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const char kIssueAuthTokenUrl[];
39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const char kTokenAuthUrl[];
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}  // namespace chromeos
43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_RESPONSE_HANDLER_H_
45