Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / signin / core / browser / signin_client.h
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 "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"
14 #include "url/gurl.h"
15
16 class PrefService;
17 class SigninManagerBase;
18 class TokenWebData;
19
20 namespace net {
21 class URLRequestContextGetter;
22 }
23
24 #if defined(OS_IOS)
25 namespace ios {
26 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the
27 // core SigninClient.
28 class ProfileOAuth2TokenServiceIOSProvider;
29 }
30 #endif
31
32 // An interface that needs to be supplied to the Signin component by its
33 // embedder.
34 class SigninClient : public KeyedService {
35  public:
36   // The subcription for cookie changed notifications.
37   class CookieChangedSubscription {
38    public:
39     virtual ~CookieChangedSubscription() {};
40   };
41
42   ~SigninClient() override {}
43
44   // Gets the preferences associated with the client.
45   virtual PrefService* GetPrefs() = 0;
46
47   // Gets the TokenWebData instance associated with the client.
48   virtual scoped_refptr<TokenWebData> GetDatabase() = 0;
49
50   // Returns whether it is possible to revoke credentials.
51   virtual bool CanRevokeCredentials() = 0;
52
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
56   // this device id.
57   virtual std::string GetSigninScopedDeviceId() = 0;
58
59   // Perform Chrome-specific sign out. This happens when user signs out or about
60   // to sign in.
61   virtual void OnSignedOut() = 0;
62
63   // Returns the URL request context information associated with the client.
64   virtual net::URLRequestContextGetter* GetURLRequestContext() = 0;
65
66   // Returns whether the user's credentials should be merged into the cookie
67   // jar on signin completion.
68   virtual bool ShouldMergeSigninCredentialsIntoCookieJar() = 0;
69
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;
73
74   // Adds a callback to be called each time a cookie for |url| with name |name|
75   // changes.
76   // Note that |callback| will always be called on the thread that
77   // |AddCookieChangedCallback| was called on.
78   virtual scoped_ptr<CookieChangedSubscription> AddCookieChangedCallback(
79       const GURL& url,
80       const std::string& name,
81       const net::CookieStore::CookieChangedCallback& callback) = 0;
82
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) {}
87
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;
92
93   virtual bool IsFirstRun() const = 0;
94   virtual base::Time GetInstallDate() = 0;
95
96 #if defined(OS_IOS)
97   // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from
98   // the core SigninClient.
99   virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() = 0;
100 #endif
101 };
102
103 #endif  // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_