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"
13 #include "net/cookies/cookie_store.h"
17 class SigninManagerBase
;
21 class URLRequestContextGetter
;
26 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the
28 class ProfileOAuth2TokenServiceIOSProvider
;
32 // An interface that needs to be supplied to the Signin component by its
34 class SigninClient
: public KeyedService
{
36 // The subcription for cookie changed notifications.
37 class CookieChangedSubscription
{
39 virtual ~CookieChangedSubscription() {};
42 ~SigninClient() override
{}
44 // Gets the preferences associated with the client.
45 virtual PrefService
* GetPrefs() = 0;
47 // Gets the TokenWebData instance associated with the client.
48 virtual scoped_refptr
<TokenWebData
> GetDatabase() = 0;
50 // Returns whether it is possible to revoke credentials.
51 virtual bool CanRevokeCredentials() = 0;
53 // Returns device id that is scoped to single signin. This device id will be
54 // regenerated if user signs out and signs back in.
55 // When refresh token is requested for this user it will be annotated with
57 virtual std::string
GetSigninScopedDeviceId() = 0;
59 // Perform Chrome-specific sign out. This happens when user signs out or about
61 virtual void OnSignedOut() = 0;
63 // Returns the URL request context information associated with the client.
64 virtual net::URLRequestContextGetter
* GetURLRequestContext() = 0;
66 // Returns whether the user's credentials should be merged into the cookie
67 // jar on signin completion.
68 virtual bool ShouldMergeSigninCredentialsIntoCookieJar() = 0;
70 // Returns a string containing the version info of the product in which the
71 // Signin component is being used.
72 virtual std::string
GetProductVersion() = 0;
74 // Adds a callback to be called each time a cookie for |url| with name |name|
76 // Note that |callback| will always be called on the thread that
77 // |AddCookieChangedCallback| was called on.
78 virtual scoped_ptr
<CookieChangedSubscription
> AddCookieChangedCallback(
80 const std::string
& name
,
81 const net::CookieStore::CookieChangedCallback
& callback
) = 0;
83 // Called when Google signin has succeeded.
84 virtual void GoogleSigninSucceeded(const std::string
& account_id
,
85 const std::string
& username
,
86 const std::string
& password
) {}
88 virtual void SetSigninProcess(int host_id
) = 0;
89 virtual void ClearSigninProcess() = 0;
90 virtual bool IsSigninProcess(int host_id
) const = 0;
91 virtual bool HasSigninProcess() const = 0;
93 virtual bool IsFirstRun() const = 0;
94 virtual base::Time
GetInstallDate() = 0;
97 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from
98 // the core SigninClient.
99 virtual ios::ProfileOAuth2TokenServiceIOSProvider
* GetIOSProvider() = 0;
103 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_