login_utils.h revision c407dc5cd9bdc5668497f21b26b09d988ab439de
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_
7
8#include <string>
9#include <vector>
10
11#include "chrome/common/net/gaia/gaia_auth_consumer.h"
12
13class Profile;
14
15namespace chromeos {
16
17class Authenticator;
18class LoginStatusConsumer;
19
20class LoginUtils {
21 public:
22  // Get LoginUtils singleton object. If it was not set before, new default
23  // instance will be created.
24  static LoginUtils* Get();
25
26  // Set LoginUtils singleton object for test purpose only!
27  static void Set(LoginUtils* ptr);
28
29  // Thin wrapper around BrowserInit::LaunchBrowser().  Meant to be used in a
30  // Task posted to the UI thread.
31  static void DoBrowserLaunch(Profile* profile);
32
33  // Extracts specified param from given ClientLogin response.
34  // Returns the param value if found, empty string otherwise.
35  // Ex. prefix: "Auth=", suffix: "\n"
36  static std::string ExtractClientLoginParam(const std::string& credentials,
37                                             const std::string& param_prefix,
38                                             const std::string& param_suffix);
39
40  virtual ~LoginUtils() {}
41
42  // Invoked after the user has successfully logged in. This launches a browser
43  // and does other bookkeeping after logging in.
44  virtual void CompleteLogin(const std::string& username,
45      const GaiaAuthConsumer::ClientLoginResult& credentials) = 0;
46
47  // Invoked after the tmpfs is successfully mounted.
48  // Launches a browser in the off the record (incognito) mode.
49  virtual void CompleteOffTheRecordLogin() = 0;
50
51  // Creates and returns the authenticator to use. The caller owns the returned
52  // Authenticator and must delete it when done.
53  virtual Authenticator* CreateAuthenticator(LoginStatusConsumer* consumer) = 0;
54
55  // Used to postpone browser launch via DoBrowserLaunch() if some post
56  // login screen is to be shown.
57  virtual void EnableBrowserLaunch(bool enable) = 0;
58
59  // Returns if browser launch enabled now or not.
60  virtual bool IsBrowserLaunchEnabled() const = 0;
61
62  // Returns auth token for 'cp' Contacts service.
63  virtual const std::string& GetAuthToken() const = 0;
64};
65
66}  // namespace chromeos
67
68#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_
69