OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
12 #include "components/signin/core/browser/signin_error_controller.h" | 13 #include "components/signin/core/browser/signin_error_controller.h" |
13 #include "components/signin/core/browser/signin_manager_base.h" | 14 #include "components/signin/core/browser/signin_manager_base.h" |
14 #include "google_apis/gaia/gaia_oauth_client.h" | 15 #include "google_apis/gaia/gaia_oauth_client.h" |
15 #include "google_apis/gaia/oauth2_token_service.h" | 16 #include "google_apis/gaia/oauth2_token_service.h" |
16 | 17 |
17 class GoogleServiceAuthError; | 18 class GoogleServiceAuthError; |
18 class Profile; | 19 class Profile; |
19 | 20 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 }; | 53 }; |
53 | 54 |
54 void Shutdown(); | 55 void Shutdown(); |
55 | 56 |
56 void ReportAuthError(const std::string& account_key, | 57 void ReportAuthError(const std::string& account_key, |
57 const GoogleServiceAuthError& error); | 58 const GoogleServiceAuthError& error); |
58 | 59 |
59 void AddObserver(Observer* observer); | 60 void AddObserver(Observer* observer); |
60 void RemoveObserver(Observer* observer); | 61 void RemoveObserver(Observer* observer); |
61 | 62 |
| 63 // Returns the list of accounts that are signed in, and for which gaia IDs |
| 64 // have been fetched. The primary account for the profile will be first |
| 65 // in the vector. Additional accounts will be in order of their gaia IDs. |
| 66 std::vector<AccountIds> GetAccounts() const; |
| 67 |
62 // OAuth2TokenService::Observer implementation. | 68 // OAuth2TokenService::Observer implementation. |
63 virtual void OnRefreshTokenAvailable(const std::string& account_key) OVERRIDE; | 69 virtual void OnRefreshTokenAvailable(const std::string& account_key) OVERRIDE; |
64 virtual void OnRefreshTokenRevoked(const std::string& account_key) OVERRIDE; | 70 virtual void OnRefreshTokenRevoked(const std::string& account_key) OVERRIDE; |
65 | 71 |
66 void OnUserInfoFetchSuccess(AccountIdFetcher* fetcher, | 72 void OnUserInfoFetchSuccess(AccountIdFetcher* fetcher, |
67 const std::string& gaia_id); | 73 const std::string& gaia_id); |
68 void OnUserInfoFetchFailure(AccountIdFetcher* fetcher); | 74 void OnUserInfoFetchFailure(AccountIdFetcher* fetcher); |
69 | 75 |
70 // AuthStatusProvider implementation. | 76 // AuthStatusProvider implementation. |
71 virtual std::string GetAccountId() const OVERRIDE; | 77 virtual std::string GetAccountId() const OVERRIDE; |
72 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; | 78 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; |
73 | 79 |
74 // SigninManagerBase::Observer implementation. | 80 // SigninManagerBase::Observer implementation. |
75 virtual void GoogleSigninSucceeded(const std::string& username, | 81 virtual void GoogleSigninSucceeded(const std::string& username, |
76 const std::string& password) OVERRIDE; | 82 const std::string& password) OVERRIDE; |
77 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; | 83 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; |
78 | 84 |
| 85 // Sets the state of an account. Does not fire notifications. |
| 86 void SetAccountStateForTest(AccountIds ids, bool is_signed_in); |
| 87 |
79 private: | 88 private: |
80 struct AccountState { | 89 struct AccountState { |
81 AccountIds ids; | 90 AccountIds ids; |
82 bool is_signed_in; | 91 bool is_signed_in; |
83 }; | 92 }; |
84 | 93 |
85 const std::string signin_manager_account_id(); | 94 const std::string signin_manager_account_id() const; |
86 | 95 |
87 void NotifyAccountAdded(const AccountState& account); | 96 void NotifyAccountAdded(const AccountState& account); |
88 void NotifyAccountRemoved(const AccountState& account); | 97 void NotifyAccountRemoved(const AccountState& account); |
89 void NotifySignInChanged(const AccountState& account); | 98 void NotifySignInChanged(const AccountState& account); |
90 | 99 |
91 void ClearAuthError(const std::string& account_key); | 100 void ClearAuthError(const std::string& account_key); |
92 void UpdateSignInState(const std::string& account_key, bool is_signed_in); | 101 void UpdateSignInState(const std::string& account_key, bool is_signed_in); |
93 | 102 |
94 void StartTrackingAccount(const std::string& account_key); | 103 void StartTrackingAccount(const std::string& account_key); |
95 void StopTrackingAccount(const std::string& account_key); | 104 void StopTrackingAccount(const std::string& account_key); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 AccountTracker* tracker_; | 142 AccountTracker* tracker_; |
134 const std::string account_key_; | 143 const std::string account_key_; |
135 | 144 |
136 scoped_ptr<OAuth2TokenService::Request> login_token_request_; | 145 scoped_ptr<OAuth2TokenService::Request> login_token_request_; |
137 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; | 146 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; |
138 }; | 147 }; |
139 | 148 |
140 } // namespace extensions | 149 } // namespace extensions |
141 | 150 |
142 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ | 151 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_ACCOUNT_TRACKER_H_ |
OLD | NEW |