signin_client.h revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
1// Copyright 2014 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 COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_
6#define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_
7
8#include "base/callback.h"
9#include "base/callback_list.h"
10#include "components/keyed_service/core/keyed_service.h"
11#include "components/signin/core/browser/webdata/token_web_data.h"
12
13class PrefService;
14class SigninManagerBase;
15class TokenWebData;
16
17namespace net {
18class CanonicalCookie;
19class URLRequestContextGetter;
20}
21
22#if defined(OS_IOS)
23namespace ios {
24// TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the
25// core SigninClient.
26class ProfileOAuth2TokenServiceIOSProvider;
27}
28#endif
29
30// An interface that needs to be supplied to the Signin component by its
31// embedder.
32class SigninClient : public KeyedService {
33 public:
34  typedef base::Callback<void(const net::CanonicalCookie* cookie)>
35      CookieChangedCallback;
36
37  typedef base::CallbackList<void(const net::CanonicalCookie* cookie)>
38      CookieChangedCallbackList;
39
40  virtual ~SigninClient() {}
41
42  // Gets the preferences associated with the client.
43  virtual PrefService* GetPrefs() = 0;
44
45  // Gets the TokenWebData instance associated with the client.
46  virtual scoped_refptr<TokenWebData> GetDatabase() = 0;
47
48  // Returns whether it is possible to revoke credentials.
49  virtual bool CanRevokeCredentials() = 0;
50
51  // Returns device id that is scoped to single signin. This device id will be
52  // regenerated if user signs out and signs back in.
53  // When refresh token is requested for this user it will be annotated with
54  // this device id.
55  virtual std::string GetSigninScopedDeviceId() = 0;
56
57  // Clears signin scoped device id. This happens when user signs out or about
58  // to sign in.
59  virtual void ClearSigninScopedDeviceId() = 0;
60
61  // Returns the URL request context information associated with the client.
62  virtual net::URLRequestContextGetter* GetURLRequestContext() = 0;
63
64  // Returns whether the user's credentials should be merged into the cookie
65  // jar on signin completion.
66  virtual bool ShouldMergeSigninCredentialsIntoCookieJar() = 0;
67
68  // Returns a string containing the version info of the product in which the
69  // Signin component is being used.
70  virtual std::string GetProductVersion() = 0;
71
72  // Adds or removes a callback that should be called when a cookie changes.
73  // TODO(blundell): Eliminate this interface in favor of having core signin
74  // code observe cookie changes once //chrome/browser/net has been
75  // componentized.
76  virtual scoped_ptr<CookieChangedCallbackList::Subscription>
77      AddCookieChangedCallback(const CookieChangedCallback& callback) = 0;
78
79  // Called when Google signin has succeeded.
80  virtual void GoogleSigninSucceeded(const std::string& username,
81                                     const std::string& password) {}
82
83  virtual void SetSigninProcess(int host_id) = 0;
84  virtual void ClearSigninProcess() = 0;
85  virtual bool IsSigninProcess(int host_id) const = 0;
86  virtual bool HasSigninProcess() const = 0;
87
88
89#if defined(OS_IOS)
90  // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from
91  // the core SigninClient.
92  virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() = 0;
93#endif
94};
95
96#endif  // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_
97