1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_ 6effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_ 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 8e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "base/callback.h" 96e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/callback_list.h" 1003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "base/time/time.h" 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/keyed_service/core/keyed_service.h" 12effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "components/signin/core/browser/webdata/token_web_data.h" 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass PrefService; 15effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass SigninManagerBase; 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class TokenWebData; 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace net { 19e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass CanonicalCookie; 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class URLRequestContextGetter; 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 23a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#if defined(OS_IOS) 24a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochnamespace ios { 25a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the 26a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// core SigninClient. 27a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochclass ProfileOAuth2TokenServiceIOSProvider; 28a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch} 29a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#endif 30a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// An interface that needs to be supplied to the Signin component by its 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// embedder. 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class SigninClient : public KeyedService { 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 35e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch typedef base::Callback<void(const net::CanonicalCookie* cookie)> 36e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch CookieChangedCallback; 37e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) typedef base::CallbackList<void(const net::CanonicalCookie* cookie)> 396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) CookieChangedCallbackList; 406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual ~SigninClient() {} 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 43effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Gets the preferences associated with the client. 44effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual PrefService* GetPrefs() = 0; 45effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Gets the TokenWebData instance associated with the client. 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual scoped_refptr<TokenWebData> GetDatabase() = 0; 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns whether it is possible to revoke credentials. 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual bool CanRevokeCredentials() = 0; 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 52116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Returns device id that is scoped to single signin. This device id will be 53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // regenerated if user signs out and signs back in. 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // When refresh token is requested for this user it will be annotated with 55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // this device id. 56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual std::string GetSigninScopedDeviceId() = 0; 57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Clears signin scoped device id. This happens when user signs out or about 59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // to sign in. 60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void ClearSigninScopedDeviceId() = 0; 61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the URL request context information associated with the client. 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual net::URLRequestContextGetter* GetURLRequestContext() = 0; 64effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 65e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // Returns whether the user's credentials should be merged into the cookie 66e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // jar on signin completion. 67e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch virtual bool ShouldMergeSigninCredentialsIntoCookieJar() = 0; 68e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 69e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // Returns a string containing the version info of the product in which the 70e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // Signin component is being used. 71e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch virtual std::string GetProductVersion() = 0; 72e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Adds or removes a callback that should be called when a cookie changes. 74e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // TODO(blundell): Eliminate this interface in favor of having core signin 75e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // code observe cookie changes once //chrome/browser/net has been 76e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // componentized. 776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual scoped_ptr<CookieChangedCallbackList::Subscription> 786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) AddCookieChangedCallback(const CookieChangedCallback& callback) = 0; 79e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 80effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Called when Google signin has succeeded. 811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void GoogleSigninSucceeded(const std::string& account_id, 821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const std::string& username, 83effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch const std::string& password) {} 84a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 85cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void SetSigninProcess(int host_id) = 0; 86cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ClearSigninProcess() = 0; 87cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool IsSigninProcess(int host_id) const = 0; 88cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool HasSigninProcess() const = 0; 89cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 9003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual bool IsFirstRun() const = 0; 9103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual base::Time GetInstallDate() = 0; 92cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 93a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#if defined(OS_IOS) 94a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from 95a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // the core SigninClient. 96a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() = 0; 97a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#endif 98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 100effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_CLIENT_H_ 101