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 71% |
copy from chrome/browser/extensions/api/identity/account_tracker.h |
copy to google_apis/gaia/account_tracker.h |
index 3cd3a98aa80b21919f212ccb4c204c9ca2777f51..a919e2c3a9a4a644358a690df1968d22b6db20de 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. |
fgorski
2014/06/17 04:14:00
Did you consider the following:
* calling it accou
Michael Courage
2014/06/18 23:13:17
Considered, but this seemed more straightforward t
|
@@ -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(scoped_ptr<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); |
@@ -74,51 +74,47 @@ 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; |
fgorski
2014/06/17 04:14:00
Is active account a new name for primary account?
Roger Tawa OOO till Jul 10th
2014/06/17 15:28:20
No. IdentityProvider has its own concept of one a
fgorski
2014/06/19 13:48:14
Thanks for the explanation... Now I feel like I've
|
+ 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_.get(); } |
+ |
private: |
struct AccountState { |
AccountIds ids; |
bool is_signed_in; |
}; |
- const std::string signin_manager_account_id() const; |
+ const std::string active_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_; |
+ scoped_ptr<IdentityProvider> identity_provider_; |
fgorski
2014/06/17 04:14:00
Why is AccountTracker taking the ownership of Iden
Michael Courage
2014/06/18 23:13:15
That seemed to match existing IdentityProvider usa
|
+ 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_; |
}; |
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 +136,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 +147,4 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer, |
} // namespace extensions |
-#endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
+#endif // GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_ |