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