diff options
author | mlerman@chromium.org <mlerman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-09 20:47:33 +0000 |
---|---|---|
committer | mlerman@chromium.org <mlerman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-09 20:47:33 +0000 |
commit | f19bac7e5c51b02a050d0319c8d6c61f309c1c40 (patch) | |
tree | 0c744f6e0e44ba686678838279ee37159f0d38d6 /chrome/browser/signin | |
parent | a2d38f0cc91bb499a37f994196f4cc85d4c12b69 (diff) | |
download | chromium_src-f19bac7e5c51b02a050d0319c8d6c61f309c1c40.zip chromium_src-f19bac7e5c51b02a050d0319c8d6c61f309c1c40.tar.gz chromium_src-f19bac7e5c51b02a050d0319c8d6c61f309c1c40.tar.bz2 |
Create a FakeAccountReconcilor that doesn't perform network requests
BUG=381866
Review URL: https://codereview.chromium.org/369353002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282116 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/signin')
-rw-r--r-- | chrome/browser/signin/fake_account_reconcilor.cc | 34 | ||||
-rw-r--r-- | chrome/browser/signin/fake_account_reconcilor.h | 31 |
2 files changed, 65 insertions, 0 deletions
diff --git a/chrome/browser/signin/fake_account_reconcilor.cc b/chrome/browser/signin/fake_account_reconcilor.cc new file mode 100644 index 0000000..e264f5b --- /dev/null +++ b/chrome/browser/signin/fake_account_reconcilor.cc @@ -0,0 +1,34 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/signin/fake_account_reconcilor.h" + +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/signin/chrome_signin_client_factory.h" +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_manager_factory.h" + +FakeAccountReconcilor::FakeAccountReconcilor( + ProfileOAuth2TokenService* token_service, + SigninManagerBase* signin_manager, + SigninClient* client) : + AccountReconcilor(token_service, signin_manager, client) {} + + +// static +KeyedService* FakeAccountReconcilor::Build(content::BrowserContext* context) { + Profile* profile = Profile::FromBrowserContext(context); + AccountReconcilor* reconcilor = new FakeAccountReconcilor( + ProfileOAuth2TokenServiceFactory::GetForProfile(profile), + SigninManagerFactory::GetForProfile(profile), + ChromeSigninClientFactory::GetForProfile(profile)); + reconcilor->Initialize(true /* start_reconcile_if_tokens_available */); + return reconcilor; +} + +void FakeAccountReconcilor::GetAccountsFromCookie( + GetAccountsFromCookieCallback callback) { + std::vector<std::pair<std::string, bool> > gaia_accounts; + callback.Run(GoogleServiceAuthError::AuthErrorNone(), gaia_accounts); +} diff --git a/chrome/browser/signin/fake_account_reconcilor.h b/chrome/browser/signin/fake_account_reconcilor.h new file mode 100644 index 0000000..49e81dc --- /dev/null +++ b/chrome/browser/signin/fake_account_reconcilor.h @@ -0,0 +1,31 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef CHROME_BROWSER_SIGNIN_FAKE_ACCOUNT_RECONCILOR_H_ +#define CHROME_BROWSER_SIGNIN_FAKE_ACCOUNT_RECONCILOR_H_ + +#include "components/signin/core/browser/account_reconcilor.h" + +namespace content { +class BrowserContext; +} + +class FakeAccountReconcilor : public AccountReconcilor { + public: + FakeAccountReconcilor(ProfileOAuth2TokenService* token_service, + SigninManagerBase* signin_manager, + SigninClient* client); + + // Helper function to be used with KeyedService::SetTestingFactory(). + static KeyedService* Build(content::BrowserContext* context); + + protected: + // Override this method to perform no network call, instead the callback + // is called immediately + virtual void GetAccountsFromCookie(GetAccountsFromCookieCallback callback) + OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(FakeAccountReconcilor); +}; + +#endif // CHROME_BROWSER_SIGNIN_FAKE_ACCOUNT_RECONCILOR_H_ |