account_reconcilor.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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) 49f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Signal that the status of the new_profile_management flag has changed. 50f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Pass the new status as an explicit parameter since disabling the flag 51f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // doesn't remove it from the CommandLine::ForCurrentProcess(). 52f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void OnNewProfileManagementFlagChanged(bool new_flag_status); 53f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // KeyedService implementation. 558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Shutdown() OVERRIDE; 568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Add or remove observers for the merge session notification. 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void AddMergeSessionObserver(MergeSessionHelper::Observer* observer); 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void RemoveMergeSessionObserver(MergeSessionHelper::Observer* observer); 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 61c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ProfileOAuth2TokenService* token_service() { return token_service_; } 62c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninClient* client() { return client_; } 638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // An std::set<> for use with email addresses that uses 66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // gaia::CanonicalizeEmail() during comparisons. 67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // TODO(rogerta): this is a workaround for the fact that SigninManager and 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // SigninOAuthHelper use the gaia "email" property when adding accounts to 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the token service, whereas gaia::ParseListAccountsData() returns email 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // addresses that have been passed through gaia::CanonicalizeEmail(). These 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // two types of email addresses are not directly comparable. 72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) class EmailLessFunc : public std::less<std::string> { 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool operator()(const std::string& s1, const std::string& s2) const; 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) }; 76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) typedef std::set<std::string, EmailLessFunc> EmailSet; 77a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) class RefreshTokenFetcher; 79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) class UserIdFetcher; 80a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool IsRegisteredWithTokenService() const { 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return registered_with_token_service_; 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool AreGaiaAccountsSet() const { return are_gaia_accounts_set_; } 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool AreAllRefreshTokensChecked() const; 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 89c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const std::vector<std::pair<std::string, bool> >& GetGaiaAccountsForTesting() 90c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const { 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return gaia_accounts_; 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const EmailSet& GetValidChromeAccountsForTesting() const { 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return valid_chrome_accounts_; 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const EmailSet& GetInvalidChromeAccountsForTesting() const { 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return invalid_chrome_accounts_; 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used during GetAccountsFromCookie. 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Stores a callback for the next action to perform. 104c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch typedef base::Callback< 105c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void(const GoogleServiceAuthError& error, 106c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const std::vector<std::pair<std::string, bool> >&)> 107c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch GetAccountsFromCookieCallback; 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) friend class AccountReconcilorTest; 110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, SigninManagerRegistration); 111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, Reauth); 112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ProfileAlreadyConnected); 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieSuccess); 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieFailure); 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ValidateAccountsFromTokens); 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ValidateAccountsFromTokensFailedUserInfo); 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ValidateAccountsFromTokensFailedTokenRequest); 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoop); 121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopWithDots); 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopMultiple); 1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToCookie); 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToChrome); 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileBadPrimary); 1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileOnlyOnce); 127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, 128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) StartReconcileWithSessionInfoExpiredDefault); 129f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Register and unregister with dependent services. 131e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void RegisterForCookieChanges(); 132e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void UnregisterForCookieChanges(); 1331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void RegisterWithSigninManager(); 1341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void UnregisterWithSigninManager(); 1351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void RegisterWithTokenService(); 1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void UnregisterWithTokenService(); 1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 138f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool IsProfileConnected(); 139f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void DeleteFetchers(); 141f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // All actions with side effects. Virtual so that they can be overridden 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // in tests. 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PerformMergeAction(const std::string& account_id); 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PerformAddToChromeAction(const std::string& account_id, 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int session_index); 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PerformLogoutAllAccountsAction(); 148cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PerformAddAccountToTokenService( 149cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& account_id, 150cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& refresh_token); 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used to remove an account from chrome and the cookie jar. 153cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PerformStartRemoveAction(const std::string& account_id); 154cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PerformFinishRemoveAction( 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& account_id, 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const GoogleServiceAuthError& error, 157a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::vector<std::pair<std::string, bool> >& accounts); 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used during periodic reconciliation. 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void StartReconcile(); 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void FinishReconcile(); 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void AbortReconcile(); 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CalculateIfReconcileIsDone(); 164a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void ScheduleStartReconcileIfChromeAccountsChanged(); 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleSuccessfulAccountIdCheck(const std::string& account_id); 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleFailedAccountIdCheck(const std::string& account_id); 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleRefreshTokenFetched(const std::string& account_id, 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& refresh_token); 1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void GetAccountsFromCookie(GetAccountsFromCookieCallback callback); 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void ContinueReconcileActionAfterGetGaiaAccounts( 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const GoogleServiceAuthError& error, 173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::vector<std::pair<std::string, bool> >& accounts); 174f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) void ValidateAccountsFromTokenService(); 175f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 176e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void OnCookieChanged(const net::CanonicalCookie* cookie); 1771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from GaiaAuthConsumer. 1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE; 180c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void OnListAccountsFailure(const GoogleServiceAuthError& error) 181c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch OVERRIDE; 1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from MergeSessionHelper::Observer. 184c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void MergeSessionCompleted(const std::string& account_id, 185c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const GoogleServiceAuthError& error) 186c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch OVERRIDE; 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from OAuth2TokenService::Consumer. 189f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 190f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const std::string& access_token, 191f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const base::Time& expiration_time) OVERRIDE; 192f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 193f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const GoogleServiceAuthError& error) OVERRIDE; 1941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from OAuth2TokenService::Observer. 1961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 1971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 1981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void OnRefreshTokensLoaded() OVERRIDE; 1998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overriden from SigninManagerBase::Observer. 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void GoogleSigninSucceeded(const std::string& username, 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& password) OVERRIDE; 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void GoogleSignedOut(const std::string& username) OVERRIDE; 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void MayBeDoNextListAccounts(); 206f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 207c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // The ProfileOAuth2TokenService associated with this reconcilor. 208c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ProfileOAuth2TokenService* token_service_; 209c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 210c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // The SigninManager associated with this reconcilor. 211c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninManagerBase* signin_manager_; 212e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 213e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // The SigninClient associated with this reconcilor. 214e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch SigninClient* client_; 215e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MergeSessionHelper merge_session_helper_; 2175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool registered_with_token_service_; 2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // True while the reconcilor is busy checking or managing the accounts in 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // this profile. 2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool is_reconcile_started_; 223f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 224cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // True iff this is the first time the reconcilor is executing. 225cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool first_execution_; 226cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 227f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Used during reconcile action. 228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // These members are used used to validate the gaia cookie. |gaia_accounts_| 229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // holds the state of google accounts in the gaia cookie. Each element is 230a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // a pair that holds the email address of the account and a boolean that 231a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // indicates whether the account is valid or not. The accounts in the vector 232a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // are ordered the in same way as the gaia cookie. 233f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool are_gaia_accounts_set_; 234a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::vector<std::pair<std::string, bool> > gaia_accounts_; 235f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 236f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Used during reconcile action. 237f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // These members are used to validate the tokens in OAuth2TokenService. 238f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::string primary_account_; 239f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::vector<std::string> chrome_accounts_; 240f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<OAuth2TokenService::Request>* requests_; 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScopedVector<UserIdFetcher> user_id_fetchers_; 242a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ScopedVector<SigninOAuthHelper> refresh_token_fetchers_; 243a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EmailSet valid_chrome_accounts_; 244a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EmailSet invalid_chrome_accounts_; 2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::vector<std::string> add_to_cookie_; 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::vector<std::pair<std::string, int> > add_to_chrome_; 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::deque<GetAccountsFromCookieCallback> get_gaia_accounts_callbacks_; 249f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 2508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); 2518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 2528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 253c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_ 254