account_reconcilor.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 4c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 5c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <deque> 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <functional> 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <set> 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <string> 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <utility> 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <vector> 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/basictypes.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/callback_forward.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/compiler_specific.h" 17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_vector.h" 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/core/keyed_service.h" 20e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "components/signin/core/browser/signin_manager.h" 21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "google_apis/gaia/gaia_auth_consumer.h" 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "google_apis/gaia/google_service_auth_error.h" 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "google_apis/gaia/merge_session_helper.h" 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "google_apis/gaia/oauth2_token_service.h" 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class GaiaAuthFetcher; 27c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass ProfileOAuth2TokenService; 28e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass SigninClient; 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class SigninOAuthHelper; 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 31e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochnamespace net { 32e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass CanonicalCookie; 33e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch} 34e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class AccountReconcilor : public KeyedService, 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public GaiaAuthConsumer, 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public MergeSessionHelper::Observer, 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public OAuth2TokenService::Consumer, 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public OAuth2TokenService::Observer, 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public SigninManagerBase::Observer { 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 42c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch AccountReconcilor(ProfileOAuth2TokenService* token_service, 43c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninManagerBase* signin_manager, 44c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninClient* client); 458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~AccountReconcilor(); 468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void Initialize(bool start_reconcile_if_tokens_available); 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // KeyedService implementation. 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Shutdown() OVERRIDE; 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Add or remove observers for the merge session notification. 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void AddMergeSessionObserver(MergeSessionHelper::Observer* observer); 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void RemoveMergeSessionObserver(MergeSessionHelper::Observer* observer); 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 56c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ProfileOAuth2TokenService* token_service() { return token_service_; } 57c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninClient* client() { return client_; } 588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // An std::set<> for use with email addresses that uses 61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // gaia::CanonicalizeEmail() during comparisons. 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // TODO(rogerta): this is a workaround for the fact that SigninManager and 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // SigninOAuthHelper use the gaia "email" property when adding accounts to 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the token service, whereas gaia::ParseListAccountsData() returns email 65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // addresses that have been passed through gaia::CanonicalizeEmail(). These 66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // two types of email addresses are not directly comparable. 67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) class EmailLessFunc : public std::less<std::string> { 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool operator()(const std::string& s1, const std::string& s2) const; 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) }; 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) typedef std::set<std::string, EmailLessFunc> EmailSet; 72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) class RefreshTokenFetcher; 74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) class UserIdFetcher; 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool IsRegisteredWithTokenService() const { 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return registered_with_token_service_; 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool AreGaiaAccountsSet() const { return are_gaia_accounts_set_; } 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool AreAllRefreshTokensChecked() const; 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 84c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const std::vector<std::pair<std::string, bool> >& GetGaiaAccountsForTesting() 85c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const { 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return gaia_accounts_; 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const EmailSet& GetValidChromeAccountsForTesting() const { 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return valid_chrome_accounts_; 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const EmailSet& GetInvalidChromeAccountsForTesting() const { 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return invalid_chrome_accounts_; 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used during GetAccountsFromCookie. 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Stores a callback for the next action to perform. 99c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch typedef base::Callback< 100c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void(const GoogleServiceAuthError& error, 101c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const std::vector<std::pair<std::string, bool> >&)> 102c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch GetAccountsFromCookieCallback; 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) friend class AccountReconcilorTest; 105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, SigninManagerRegistration); 106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, Reauth); 107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ProfileAlreadyConnected); 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieSuccess); 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieFailure); 1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ValidateAccountsFromTokens); 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ValidateAccountsFromTokensFailedUserInfo); 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ValidateAccountsFromTokensFailedTokenRequest); 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoop); 116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopWithDots); 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopMultiple); 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToCookie); 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToChrome); 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileBadPrimary); 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileOnlyOnce); 122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) StartReconcileWithSessionInfoExpiredDefault); 124f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Register and unregister with dependent services. 126e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void RegisterForCookieChanges(); 127e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void UnregisterForCookieChanges(); 1281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void RegisterWithSigninManager(); 1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void UnregisterWithSigninManager(); 1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void RegisterWithTokenService(); 1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void UnregisterWithTokenService(); 1321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 133f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool IsProfileConnected(); 134f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void DeleteFetchers(); 136f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // All actions with side effects. Virtual so that they can be overridden 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // in tests. 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PerformMergeAction(const std::string& account_id); 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PerformAddToChromeAction(const std::string& account_id, 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int session_index); 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PerformLogoutAllAccountsAction(); 143cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PerformAddAccountToTokenService( 144cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& account_id, 145cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& refresh_token); 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used to remove an account from chrome and the cookie jar. 148cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PerformStartRemoveAction(const std::string& account_id); 149cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PerformFinishRemoveAction( 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& account_id, 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const GoogleServiceAuthError& error, 152a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::vector<std::pair<std::string, bool> >& accounts); 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used during periodic reconciliation. 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void StartReconcile(); 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void FinishReconcile(); 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void AbortReconcile(); 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CalculateIfReconcileIsDone(); 159a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void ScheduleStartReconcileIfChromeAccountsChanged(); 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleSuccessfulAccountIdCheck(const std::string& account_id); 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleFailedAccountIdCheck(const std::string& account_id); 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleRefreshTokenFetched(const std::string& account_id, 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& refresh_token); 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void GetAccountsFromCookie(GetAccountsFromCookieCallback callback); 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void ContinueReconcileActionAfterGetGaiaAccounts( 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const GoogleServiceAuthError& error, 168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::vector<std::pair<std::string, bool> >& accounts); 169f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) void ValidateAccountsFromTokenService(); 170f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 171e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void OnCookieChanged(const net::CanonicalCookie* cookie); 1721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from GaiaAuthConsumer. 1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE; 175c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void OnListAccountsFailure(const GoogleServiceAuthError& error) 176c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch OVERRIDE; 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from MergeSessionHelper::Observer. 179c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void MergeSessionCompleted(const std::string& account_id, 180c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const GoogleServiceAuthError& error) 181c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch OVERRIDE; 1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from OAuth2TokenService::Consumer. 184f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 185f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const std::string& access_token, 186f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const base::Time& expiration_time) OVERRIDE; 187f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 188f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const GoogleServiceAuthError& error) OVERRIDE; 1891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from OAuth2TokenService::Observer. 1911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 1921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 1931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void OnRefreshTokensLoaded() OVERRIDE; 1948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from SigninManagerBase::Observer. 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void GoogleSigninSucceeded(const std::string& username, 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& password) OVERRIDE; 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void GoogleSignedOut(const std::string& username) OVERRIDE; 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void MayBeDoNextListAccounts(); 201f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 202c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // The ProfileOAuth2TokenService associated with this reconcilor. 203c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ProfileOAuth2TokenService* token_service_; 204c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 205c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // The SigninManager associated with this reconcilor. 206c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninManagerBase* signin_manager_; 207e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 208e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // The SigninClient associated with this reconcilor. 209e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch SigninClient* client_; 210e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MergeSessionHelper merge_session_helper_; 2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; 2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool registered_with_token_service_; 2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // True while the reconcilor is busy checking or managing the accounts in 2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // this profile. 2175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool is_reconcile_started_; 218f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 219cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // True iff this is the first time the reconcilor is executing. 220cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool first_execution_; 221cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 222f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Used during reconcile action. 223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // These members are used used to validate the gaia cookie. |gaia_accounts_| 224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // holds the state of google accounts in the gaia cookie. Each element is 225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // a pair that holds the email address of the account and a boolean that 226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // indicates whether the account is valid or not. The accounts in the vector 227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // are ordered the in same way as the gaia cookie. 228f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool are_gaia_accounts_set_; 229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::vector<std::pair<std::string, bool> > gaia_accounts_; 230f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 231f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Used during reconcile action. 232f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // These members are used to validate the tokens in OAuth2TokenService. 233f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::string primary_account_; 234f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::vector<std::string> chrome_accounts_; 235f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<OAuth2TokenService::Request>* requests_; 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScopedVector<UserIdFetcher> user_id_fetchers_; 237a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ScopedVector<SigninOAuthHelper> refresh_token_fetchers_; 238a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EmailSet valid_chrome_accounts_; 239a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EmailSet invalid_chrome_accounts_; 2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::vector<std::string> add_to_cookie_; 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::vector<std::pair<std::string, int> > add_to_chrome_; 2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::deque<GetAccountsFromCookieCallback> get_gaia_accounts_callbacks_; 244f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 2458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); 2468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 2478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 248c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 249