#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "components/keyed_service/core/keyed_service.h"
+#include "components/signin/core/browser/signin_client.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/google_service_auth_error.h"
void Initialize(bool start_reconcile_if_tokens_available);
+ // Signal that the status of the new_profile_management flag has changed.
+ // Pass the new status as an explicit parameter since disabling the flag
+ // doesn't remove it from the CommandLine::ForCurrentProcess().
+ void OnNewProfileManagementFlagChanged(bool new_flag_status);
+
// KeyedService implementation.
virtual void Shutdown() OVERRIDE;
ProfileOAuth2TokenService* token_service() { return token_service_; }
SigninClient* client() { return client_; }
+ protected:
+ // Used during GetAccountsFromCookie.
+ // Stores a callback for the next action to perform.
+ typedef base::Callback<
+ void(const GoogleServiceAuthError& error,
+ const std::vector<std::pair<std::string, bool> >&)>
+ GetAccountsFromCookieCallback;
+
+ virtual void GetAccountsFromCookie(GetAccountsFromCookieCallback callback);
+
private:
// An std::set<> for use with email addresses that uses
// gaia::CanonicalizeEmail() during comparisons.
return invalid_chrome_accounts_;
}
- // Used during GetAccountsFromCookie.
- // Stores a callback for the next action to perform.
- typedef base::Callback<
- void(const GoogleServiceAuthError& error,
- const std::vector<std::pair<std::string, bool> >&)>
- GetAccountsFromCookieCallback;
+ // Virtual so that it can be overridden in tests.
+ virtual void StartFetchingExternalCcResult();
friend class AccountReconcilorTest;
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, SigninManagerRegistration);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopWithDots);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopMultiple);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToCookie);
+ FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
+ StartReconcileAddToCookieTwice);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToChrome);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileBadPrimary);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileOnlyOnce);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
StartReconcileWithSessionInfoExpiredDefault);
+ FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
+ MergeSessionCompletedWithBogusAccount);
// Register and unregister with dependent services.
void RegisterForCookieChanges();
// All actions with side effects. Virtual so that they can be overridden
// in tests.
virtual void PerformMergeAction(const std::string& account_id);
- virtual void PerformAddToChromeAction(const std::string& account_id,
- int session_index);
+ virtual void PerformAddToChromeAction(
+ const std::string& account_id,
+ int session_index,
+ const std::string& signin_scoped_device_id);
virtual void PerformLogoutAllAccountsAction();
+ virtual void PerformAddAccountToTokenService(
+ const std::string& account_id,
+ const std::string& refresh_token);
// Used to remove an account from chrome and the cookie jar.
- virtual void StartRemoveAction(const std::string& account_id);
- virtual void FinishRemoveAction(
+ virtual void PerformStartRemoveAction(const std::string& account_id);
+ virtual void PerformFinishRemoveAction(
const std::string& account_id,
const GoogleServiceAuthError& error,
const std::vector<std::pair<std::string, bool> >& accounts);
void HandleRefreshTokenFetched(const std::string& account_id,
const std::string& refresh_token);
- void GetAccountsFromCookie(GetAccountsFromCookieCallback callback);
void ContinueReconcileActionAfterGetGaiaAccounts(
const GoogleServiceAuthError& error,
const std::vector<std::pair<std::string, bool> >& accounts);
void ValidateAccountsFromTokenService();
+ // Note internally that this |account_id| is added to the cookie jar.
+ bool MarkAccountAsAddedToCookie(const std::string& account_id);
+ // Note internally that this |account_id| is added to the token service.
+ void MarkAccountAsAddedToChrome(const std::string& account_id);
void OnCookieChanged(const net::CanonicalCookie* cookie);
const GoogleServiceAuthError& error) OVERRIDE;
// Overriden from OAuth2TokenService::Observer.
- virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
- virtual void OnRefreshTokensLoaded() OVERRIDE;
+ virtual void OnEndBatchChanges() OVERRIDE;
// Overriden from SigninManagerBase::Observer.
virtual void GoogleSigninSucceeded(const std::string& username,
// this profile.
bool is_reconcile_started_;
+ // True iff this is the first time the reconcilor is executing.
+ bool first_execution_;
+
// Used during reconcile action.
// These members are used used to validate the gaia cookie. |gaia_accounts_|
// holds the state of google accounts in the gaia cookie. Each element is
std::deque<GetAccountsFromCookieCallback> get_gaia_accounts_callbacks_;
+ scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription>
+ cookie_changed_subscription_;
+
DISALLOW_COPY_AND_ASSIGN(AccountReconcilor);
};