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