account_reconcilor.h revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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"
206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "components/signin/core/browser/signin_client.h"
21e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "components/signin/core/browser/signin_manager.h"
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "google_apis/gaia/gaia_auth_consumer.h"
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "google_apis/gaia/google_service_auth_error.h"
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "google_apis/gaia/merge_session_helper.h"
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "google_apis/gaia/oauth2_token_service.h"
268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class GaiaAuthFetcher;
28c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass ProfileOAuth2TokenService;
29e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass SigninClient;
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::Observer,
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                          public SigninManagerBase::Observer {
408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public:
41c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  AccountReconcilor(ProfileOAuth2TokenService* token_service,
42c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                    SigninManagerBase* signin_manager,
43c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                    SigninClient* client);
448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual ~AccountReconcilor();
458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void Initialize(bool start_reconcile_if_tokens_available);
47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
48f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // Signal that the status of the new_profile_management flag has changed.
49f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // Pass the new status as an explicit parameter since disabling the flag
50f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // doesn't remove it from the CommandLine::ForCurrentProcess().
51f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  void OnNewProfileManagementFlagChanged(bool new_flag_status);
52f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // KeyedService implementation.
548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void Shutdown() OVERRIDE;
558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Add or remove observers for the merge session notification.
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void AddMergeSessionObserver(MergeSessionHelper::Observer* observer);
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void RemoveMergeSessionObserver(MergeSessionHelper::Observer* observer);
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
60c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  ProfileOAuth2TokenService* token_service() { return token_service_; }
61c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  SigninClient* client() { return client_; }
628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch protected:
64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Used during GetAccountsFromCookie.
65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Stores a callback for the next action to perform.
66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  typedef base::Callback<
67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      void(const GoogleServiceAuthError& error,
68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch           const std::vector<std::pair<std::string, bool> >&)>
69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      GetAccountsFromCookieCallback;
70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void GetAccountsFromCookie(GetAccountsFromCookieCallback callback);
72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private:
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool IsRegisteredWithTokenService() const {
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return registered_with_token_service_;
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool AreGaiaAccountsSet() const { return are_gaia_accounts_set_; }
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
80c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  const std::vector<std::pair<std::string, bool> >& GetGaiaAccountsForTesting()
81c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      const {
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return gaia_accounts_;
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Virtual so that it can be overridden in tests.
866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void StartFetchingExternalCcResult();
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  friend class AccountReconcilorTest;
89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, SigninManagerRegistration);
90a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, Reauth);
91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ProfileAlreadyConnected);
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieSuccess);
935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, GetAccountsFromCookieFailure);
945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoop);
95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopWithDots);
965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopMultiple);
975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToCookie);
986d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                           StartReconcileRemoveFromCookie);
1001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
1016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)                           StartReconcileAddToCookieTwice);
1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileBadPrimary);
1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileOnlyOnce);
104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                           StartReconcileWithSessionInfoExpiredDefault);
106116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
107116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                           MergeSessionCompletedWithBogusAccount);
108f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
1091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Register and unregister with dependent services.
110e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  void RegisterForCookieChanges();
111e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  void UnregisterForCookieChanges();
1121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void RegisterWithSigninManager();
1131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void UnregisterWithSigninManager();
1141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void RegisterWithTokenService();
1151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void UnregisterWithTokenService();
1161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
117f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  bool IsProfileConnected();
118f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // All actions with side effects.  Virtual so that they can be overridden
1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // in tests.
1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void PerformMergeAction(const std::string& account_id);
1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void PerformLogoutAllAccountsAction();
1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Used during periodic reconciliation.
1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void StartReconcile();
1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void FinishReconcile();
1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void AbortReconcile();
1285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void CalculateIfReconcileIsDone();
129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void ScheduleStartReconcileIfChromeAccountsChanged();
1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void ContinueReconcileActionAfterGetGaiaAccounts(
1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const GoogleServiceAuthError& error,
133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const std::vector<std::pair<std::string, bool> >& accounts);
134f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void ValidateAccountsFromTokenService();
1356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  // Note internally that this |account_id| is added to the cookie jar.
136116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool MarkAccountAsAddedToCookie(const std::string& account_id);
137f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
138e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  void OnCookieChanged(const net::CanonicalCookie* cookie);
1391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Overriden from GaiaAuthConsumer.
1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE;
142c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void OnListAccountsFailure(const GoogleServiceAuthError& error)
143c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      OVERRIDE;
1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Overriden from MergeSessionHelper::Observer.
146c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void MergeSessionCompleted(const std::string& account_id,
147c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                     const GoogleServiceAuthError& error)
148c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      OVERRIDE;
1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Overriden from OAuth2TokenService::Observer.
151116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  virtual void OnEndBatchChanges() OVERRIDE;
1528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Overriden from SigninManagerBase::Observer.
1541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void GoogleSigninSucceeded(const std::string& account_id,
1551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                     const std::string& username,
1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                     const std::string& password) OVERRIDE;
1571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void GoogleSignedOut(const std::string& account_id,
1581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                               const std::string& username) OVERRIDE;
1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void MayBeDoNextListAccounts();
161f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
162c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  // The ProfileOAuth2TokenService associated with this reconcilor.
163c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  ProfileOAuth2TokenService* token_service_;
164c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
165c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  // The SigninManager associated with this reconcilor.
166c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  SigninManagerBase* signin_manager_;
167e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
168e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  // The SigninClient associated with this reconcilor.
169e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  SigninClient* client_;
170e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  MergeSessionHelper merge_session_helper_;
1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<GaiaAuthFetcher> gaia_fetcher_;
1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool registered_with_token_service_;
1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // True while the reconcilor is busy checking or managing the accounts in
1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // this profile.
1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool is_reconcile_started_;
178f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
179cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // True iff this is the first time the reconcilor is executing.
180cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  bool first_execution_;
181cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
182f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Used during reconcile action.
1831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // These members are used to validate the gaia cookie.  |gaia_accounts_|
184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // holds the state of google accounts in the gaia cookie.  Each element is
185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // a pair that holds the email address of the account and a boolean that
186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // indicates whether the account is valid or not.  The accounts in the vector
187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // are ordered the in same way as the gaia cookie.
188f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  bool are_gaia_accounts_set_;
189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  std::vector<std::pair<std::string, bool> > gaia_accounts_;
190f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
191f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Used during reconcile action.
192f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // These members are used to validate the tokens in OAuth2TokenService.
193f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  std::string primary_account_;
194f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  std::vector<std::string> chrome_accounts_;
1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::vector<std::string> add_to_cookie_;
1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::deque<GetAccountsFromCookieCallback> get_gaia_accounts_callbacks_;
198f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
1996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription>
2006e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      cookie_changed_subscription_;
2016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
2028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(AccountReconcilor);
2038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)};
2048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
205c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#endif  // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_RECONCILOR_H_
206