OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ |
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 AccountInfo(); | 51 AccountInfo(); |
52 ~AccountInfo(); | 52 ~AccountInfo(); |
53 | 53 |
54 std::string account_id; // The account ID used by OAuth2TokenService. | 54 std::string account_id; // The account ID used by OAuth2TokenService. |
55 std::string gaia; | 55 std::string gaia; |
56 std::string email; | 56 std::string email; |
57 std::string full_name; | 57 std::string full_name; |
58 std::string given_name; | 58 std::string given_name; |
59 std::string hosted_domain; | 59 std::string hosted_domain; |
60 std::string locale; | 60 std::string locale; |
| 61 std::vector<std::string> service_flags; |
61 // TODO(rogerta): eventually this structure will include other information | 62 // TODO(rogerta): eventually this structure will include other information |
62 // about the account, like full name, profile picture URL, etc. | 63 // about the account, like full name, profile picture URL, etc. |
63 | 64 |
64 bool IsValid(); | 65 bool IsValid(); |
65 }; | 66 }; |
66 | 67 |
67 // Clients of AccountTrackerService can implement this interface and register | 68 // Clients of AccountTrackerService can implement this interface and register |
68 // with AddObserver() to learn about account information changes. | 69 // with AddObserver() to learn about account information changes. |
69 class Observer { | 70 class Observer { |
70 public: | 71 public: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // with its corresponding gaia id and email address. Returns the same | 124 // with its corresponding gaia id and email address. Returns the same |
124 // value PickAccountIdForAccount() when given the same arguments. | 125 // value PickAccountIdForAccount() when given the same arguments. |
125 std::string SeedAccountInfo(const std::string& gaia, | 126 std::string SeedAccountInfo(const std::string& gaia, |
126 const std::string& email); | 127 const std::string& email); |
127 | 128 |
128 AccountIdMigrationState GetMigrationState(); | 129 AccountIdMigrationState GetMigrationState(); |
129 static AccountIdMigrationState GetMigrationState(PrefService* pref_service); | 130 static AccountIdMigrationState GetMigrationState(PrefService* pref_service); |
130 | 131 |
131 protected: | 132 protected: |
132 // Available to be called in tests. | 133 // Available to be called in tests. |
133 void SetAccountStateFromUserInfo(const std::string& account_id, | 134 void SetAccountStateFromUserInfo( |
134 const base::DictionaryValue* user_info); | 135 const std::string& account_id, |
| 136 const base::DictionaryValue* user_info, |
| 137 const std::vector<std::string>* service_flags); |
135 | 138 |
136 private: | 139 private: |
137 friend class AccountInfoFetcher; | 140 friend class AccountInfoFetcher; |
138 | 141 |
139 // These methods are called by fetchers. | 142 // These methods are called by fetchers. |
140 void OnUserInfoFetchSuccess(AccountInfoFetcher* fetcher, | 143 void OnUserInfoFetchSuccess(AccountInfoFetcher* fetcher, |
141 const base::DictionaryValue* user_info); | 144 const base::DictionaryValue* user_info, |
| 145 const std::vector<std::string>* service_flags); |
142 void OnUserInfoFetchFailure(AccountInfoFetcher* fetcher); | 146 void OnUserInfoFetchFailure(AccountInfoFetcher* fetcher); |
143 | 147 |
144 // Refreshes the AccountInfo associated with |account_id| if it's invalid or | 148 // Refreshes the AccountInfo associated with |account_id| if it's invalid or |
145 // if |force_remote_fetch| is true. | 149 // if |force_remote_fetch| is true. |
146 void RefreshAccountInfo( | 150 void RefreshAccountInfo( |
147 const std::string& account_id, bool force_remote_fetch); | 151 const std::string& account_id, bool force_remote_fetch); |
148 | 152 |
149 // OAuth2TokenService::Observer implementation. | 153 // OAuth2TokenService::Observer implementation. |
150 void OnRefreshTokenAvailable(const std::string& account_id) override; | 154 void OnRefreshTokenAvailable(const std::string& account_id) override; |
151 void OnRefreshTokenRevoked(const std::string& account_id) override; | 155 void OnRefreshTokenRevoked(const std::string& account_id) override; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 base::OneShotTimer<AccountTrackerService> timer_; | 196 base::OneShotTimer<AccountTrackerService> timer_; |
193 | 197 |
194 // Holds references to refresh token annotation requests keyed by account_id. | 198 // Holds references to refresh token annotation requests keyed by account_id. |
195 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> | 199 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> |
196 refresh_token_annotation_requests_; | 200 refresh_token_annotation_requests_; |
197 | 201 |
198 DISALLOW_COPY_AND_ASSIGN(AccountTrackerService); | 202 DISALLOW_COPY_AND_ASSIGN(AccountTrackerService); |
199 }; | 203 }; |
200 | 204 |
201 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ | 205 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ |
OLD | NEW |