Index: google_apis/gaia/account_tracker.h |
diff --git a/chrome/browser/extensions/api/identity/account_tracker.h b/google_apis/gaia/account_tracker.h |
similarity index 70% |
copy from chrome/browser/extensions/api/identity/account_tracker.h |
copy to google_apis/gaia/account_tracker.h |
index 3cd3a98aa80b21919f212ccb4c204c9ca2777f51..5fc5b4982a3ddce7c958a5642f7719e3b02d5556 100644 |
--- a/chrome/browser/extensions/api/identity/account_tracker.h |
+++ b/google_apis/gaia/account_tracker.h |
@@ -2,23 +2,26 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
-#define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
+#ifndef GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_ |
+#define GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_ |
#include <map> |
#include <string> |
#include <vector> |
+#include "base/memory/scoped_ptr.h" |
#include "base/observer_list.h" |
-#include "components/signin/core/browser/signin_error_controller.h" |
-#include "components/signin/core/browser/signin_manager_base.h" |
#include "google_apis/gaia/gaia_oauth_client.h" |
+#include "google_apis/gaia/identity_provider.h" |
#include "google_apis/gaia/oauth2_token_service.h" |
class GoogleServiceAuthError; |
-class Profile; |
-namespace extensions { |
+namespace net { |
+class URLRequestContextGetter; |
+} |
+ |
+namespace gaia { |
struct AccountIds { |
std::string account_key; // The account ID used by OAuth2TokenService. |
@@ -38,10 +41,10 @@ class AccountIdFetcher; |
// 3. SignIn follows Add, and there will be a SignOut between SignIn & Remove. |
// 4. If there is no primary account, there are no other accounts. |
class AccountTracker : public OAuth2TokenService::Observer, |
- public SigninErrorController::AuthStatusProvider, |
- public SigninManagerBase::Observer { |
+ public IdentityProvider::Observer { |
public: |
- explicit AccountTracker(Profile* profile); |
+ AccountTracker(IdentityProvider* identity_provider, |
+ net::URLRequestContextGetter* request_context_getter); |
virtual ~AccountTracker(); |
class Observer { |
@@ -54,9 +57,6 @@ class AccountTracker : public OAuth2TokenService::Observer, |
void Shutdown(); |
- void ReportAuthError(const std::string& account_key, |
- const GoogleServiceAuthError& error); |
- |
void AddObserver(Observer* observer); |
void RemoveObserver(Observer* observer); |
@@ -64,7 +64,7 @@ class AccountTracker : public OAuth2TokenService::Observer, |
// have been fetched. The primary account for the profile will be first |
// in the vector. Additional accounts will be in order of their gaia IDs. |
std::vector<AccountIds> GetAccounts() const; |
- std::string FindAccountKeyByGaiaId(const std::string& gaia_id); |
+ AccountIds FindAccountIdsByGaiaId(const std::string& gaia_id); |
// OAuth2TokenService::Observer implementation. |
virtual void OnRefreshTokenAvailable(const std::string& account_key) OVERRIDE; |
@@ -74,51 +74,46 @@ class AccountTracker : public OAuth2TokenService::Observer, |
const std::string& gaia_id); |
void OnUserInfoFetchFailure(AccountIdFetcher* fetcher); |
- // AuthStatusProvider implementation. |
- virtual std::string GetAccountId() const OVERRIDE; |
- virtual std::string GetUsername() const OVERRIDE; |
- virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; |
- |
- // SigninManagerBase::Observer implementation. |
- virtual void GoogleSigninSucceeded(const std::string& username, |
- const std::string& password) OVERRIDE; |
- virtual void GoogleSignedOut(const std::string& username) OVERRIDE; |
+ // IdentityProvider::Observer implementation. |
+ virtual void OnActiveAccountLogin() OVERRIDE; |
+ virtual void OnActiveAccountLogout() OVERRIDE; |
// Sets the state of an account. Does not fire notifications. |
void SetAccountStateForTest(AccountIds ids, bool is_signed_in); |
+ IdentityProvider* identity_provider() { return identity_provider_; } |
+ |
private: |
struct AccountState { |
AccountIds ids; |
bool is_signed_in; |
}; |
- const std::string signin_manager_account_id() const; |
- |
void NotifyAccountAdded(const AccountState& account); |
void NotifyAccountRemoved(const AccountState& account); |
void NotifySignInChanged(const AccountState& account); |
- void ClearAuthError(const std::string& account_key); |
- void UpdateSignInState(const std::string& account_key, bool is_signed_in); |
+ void UpdateSignInState(const std::string account_key, bool is_signed_in); |
- void StartTrackingAccount(const std::string& account_key); |
- void StopTrackingAccount(const std::string& account_key); |
+ void StartTrackingAccount(const std::string account_key); |
+ void StopTrackingAccount(const std::string account_key); |
void StopTrackingAllAccounts(); |
- void StartFetchingUserInfo(const std::string& account_key); |
+ void StartFetchingUserInfo(const std::string account_key); |
void DeleteFetcher(AccountIdFetcher* fetcher); |
- Profile* profile_; |
+ IdentityProvider* identity_provider_; // Not owned. |
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
std::map<std::string, AccountIdFetcher*> user_info_requests_; |
std::map<std::string, AccountState> accounts_; |
- std::map<std::string, GoogleServiceAuthError> account_errors_; |
ObserverList<Observer> observer_list_; |
+ bool shutdown_called_; |
}; |
class AccountIdFetcher : public OAuth2TokenService::Consumer, |
public gaia::GaiaOAuthClient::Delegate { |
public: |
- AccountIdFetcher(Profile* profile, |
+ AccountIdFetcher(OAuth2TokenService* token_service, |
+ net::URLRequestContextGetter* request_context_getter, |
AccountTracker* tracker, |
const std::string& account_key); |
virtual ~AccountIdFetcher(); |
@@ -140,7 +135,8 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer, |
virtual void OnNetworkError(int response_code) OVERRIDE; |
private: |
- Profile* profile_; |
+ OAuth2TokenService* token_service_; |
+ net::URLRequestContextGetter* request_context_getter_; |
AccountTracker* tracker_; |
const std::string account_key_; |
@@ -150,4 +146,4 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer, |
} // namespace extensions |
-#endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
+#endif // GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_ |