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 12 class PrefService; 13 class SigninManagerBase; 14 class TokenWebData; 15 16 namespace net { 17 class CanonicalCookie; 18 class URLRequestContextGetter; 19 } 20 21 #if defined(OS_IOS) 22 namespace ios { 23 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the 24 // core SigninClient. 25 class ProfileOAuth2TokenServiceIOSProvider; 26 } 27 #endif 28 29 // An interface that needs to be supplied to the Signin component by its 30 // embedder. 31 class SigninClient : public KeyedService { 32 public: 33 typedef base::Callback<void(const net::CanonicalCookie* cookie)> 34 CookieChangedCallback; 35 ~SigninClient()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 the URL request context information associated with the client. 48 virtual net::URLRequestContextGetter* GetURLRequestContext() = 0; 49 50 // Returns whether the user's credentials should be merged into the cookie 51 // jar on signin completion. 52 virtual bool ShouldMergeSigninCredentialsIntoCookieJar() = 0; 53 54 // Returns a string containing the version info of the product in which the 55 // Signin component is being used. 56 virtual std::string GetProductVersion() = 0; 57 58 // Sets the callback that should be called when a cookie changes. The 59 // callback will be called only if it is not empty. 60 // TODO(blundell): Eliminate this interface in favor of having core signin 61 // code observe cookie changes once //chrome/browser/net has been 62 // componentized. 63 virtual void SetCookieChangedCallback( 64 const CookieChangedCallback& callback) = 0; 65 66 // Called when Google signin has succeeded. GoogleSigninSucceeded(const std::string & username,const std::string & password)67 virtual void GoogleSigninSucceeded(const std::string& username, 68 const std::string& password) {} 69 70 virtual void SetSigninProcess(int host_id) = 0; 71 virtual void ClearSigninProcess() = 0; 72 virtual bool IsSigninProcess(int host_id) const = 0; 73 virtual bool HasSigninProcess() const = 0; 74 75 76 #if defined(OS_IOS) 77 // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from 78 // the core SigninClient. 79 virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() = 0; 80 #endif 81 }; 82 83 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_ 84