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