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
;
20 namespace content_settings
{
25 class URLRequestContextGetter
;
30 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the
32 class ProfileOAuth2TokenServiceIOSProvider
;
36 // An interface that needs to be supplied to the Signin component by its
38 class SigninClient
: public KeyedService
{
40 // The subcription for cookie changed notifications.
41 class CookieChangedSubscription
{
43 virtual ~CookieChangedSubscription() {};
46 ~SigninClient() override
{}
48 // Gets the preferences associated with the client.
49 virtual PrefService
* GetPrefs() = 0;
51 // Gets the TokenWebData instance associated with the client.
52 virtual scoped_refptr
<TokenWebData
> GetDatabase() = 0;
54 // Returns whether it is possible to revoke credentials.
55 virtual bool CanRevokeCredentials() = 0;
57 // Returns device id that is scoped to single signin. This device id will be
58 // regenerated if user signs out and signs back in.
59 // When refresh token is requested for this user it will be annotated with
61 virtual std::string
GetSigninScopedDeviceId() = 0;
63 // Perform Chrome-specific sign out. This happens when user signs out or about
65 virtual void OnSignedOut() = 0;
67 // Returns the URL request context information associated with the client.
68 virtual net::URLRequestContextGetter
* GetURLRequestContext() = 0;
70 // Returns whether the user's credentials should be merged into the cookie
71 // jar on signin completion.
72 virtual bool ShouldMergeSigninCredentialsIntoCookieJar() = 0;
74 // Returns a string containing the version info of the product in which the
75 // Signin component is being used.
76 virtual std::string
GetProductVersion() = 0;
78 // Adds a callback to be called each time a cookie for |url| with name |name|
80 // Note that |callback| will always be called on the thread that
81 // |AddCookieChangedCallback| was called on.
82 virtual scoped_ptr
<CookieChangedSubscription
> AddCookieChangedCallback(
84 const std::string
& name
,
85 const net::CookieStore::CookieChangedCallback
& callback
) = 0;
87 // Called after Google signin has succeeded.
88 virtual void OnSignedIn(const std::string
& account_id
,
89 const std::string
& username
,
90 const std::string
& password
) {}
92 // Called after Google signin has succeeded and GetUserInfo has returned.
93 virtual void PostSignedIn(const std::string
& account_id
,
94 const std::string
& username
,
95 const std::string
& password
) {}
97 virtual bool IsFirstRun() const = 0;
98 virtual base::Time
GetInstallDate() = 0;
100 // Returns true if GAIA cookies are allowed in the content area.
101 virtual bool AreSigninCookiesAllowed() = 0;
103 // Adds an observer to listen for changes to the state of sign in cookie
105 virtual void AddContentSettingsObserver(
106 content_settings::Observer
* observer
) = 0;
107 virtual void RemoveContentSettingsObserver(
108 content_settings::Observer
* observer
) = 0;
111 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from
112 // the core SigninClient.
113 virtual ios::ProfileOAuth2TokenServiceIOSProvider
* GetIOSProvider() = 0;
117 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_