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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // Name of the preference that tracks the int64 representation of the last | 40 // Name of the preference that tracks the int64 representation of the last |
41 // time the AccountTrackerService was updated. | 41 // time the AccountTrackerService was updated. |
42 static const char kAccountTrackerServiceLastUpdate[]; | 42 static const char kAccountTrackerServiceLastUpdate[]; |
43 | 43 |
44 // TODO(mlerman): Remove all references to Profile::kNoHostedDomainFound in | 44 // TODO(mlerman): Remove all references to Profile::kNoHostedDomainFound in |
45 // favour of this. | 45 // favour of this. |
46 // Value representing no hosted domain in the kProfileHostedDomain preference. | 46 // Value representing no hosted domain in the kProfileHostedDomain preference. |
47 static const char kNoHostedDomainFound[]; | 47 static const char kNoHostedDomainFound[]; |
48 | 48 |
| 49 // Value representing no picture URL associated with an account. |
| 50 static const char kNoPictureURLFound[]; |
| 51 |
49 // Information about a specific account. | 52 // Information about a specific account. |
50 struct AccountInfo { | 53 struct AccountInfo { |
51 AccountInfo(); | 54 AccountInfo(); |
52 ~AccountInfo(); | 55 ~AccountInfo(); |
53 | 56 |
54 std::string account_id; // The account ID used by OAuth2TokenService. | 57 std::string account_id; // The account ID used by OAuth2TokenService. |
55 std::string gaia; | 58 std::string gaia; |
56 std::string email; | 59 std::string email; |
57 std::string full_name; | 60 std::string full_name; |
58 std::string given_name; | 61 std::string given_name; |
59 std::string hosted_domain; | 62 std::string hosted_domain; |
60 std::string locale; | 63 std::string locale; |
| 64 std::string picture_url; |
61 std::vector<std::string> service_flags; | 65 std::vector<std::string> service_flags; |
62 // TODO(rogerta): eventually this structure will include other information | |
63 // about the account, like full name, profile picture URL, etc. | |
64 | 66 |
65 bool IsValid(); | 67 bool IsValid() const; |
66 }; | 68 }; |
67 | 69 |
68 // Clients of AccountTrackerService can implement this interface and register | 70 // Clients of AccountTrackerService can implement this interface and register |
69 // with AddObserver() to learn about account information changes. | 71 // with AddObserver() to learn about account information changes. |
70 class Observer { | 72 class Observer { |
71 public: | 73 public: |
72 virtual ~Observer() {} | 74 virtual ~Observer() {} |
73 virtual void OnAccountUpdated(const AccountInfo& info) {} | 75 virtual void OnAccountUpdated(const AccountInfo& info) {} |
74 virtual void OnAccountUpdateFailed(const std::string& account_id) {} | 76 virtual void OnAccountUpdateFailed(const std::string& account_id) {} |
75 virtual void OnAccountRemoved(const AccountInfo& info) {} | 77 virtual void OnAccountRemoved(const AccountInfo& info) {} |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const std::string& email); | 120 const std::string& email); |
119 static std::string PickAccountIdForAccount(PrefService* pref_service, | 121 static std::string PickAccountIdForAccount(PrefService* pref_service, |
120 const std::string& gaia, | 122 const std::string& gaia, |
121 const std::string& email); | 123 const std::string& email); |
122 | 124 |
123 // Seeds the account whose account_id is given by PickAccountIdForAccount() | 125 // Seeds the account whose account_id is given by PickAccountIdForAccount() |
124 // with its corresponding gaia id and email address. Returns the same | 126 // with its corresponding gaia id and email address. Returns the same |
125 // value PickAccountIdForAccount() when given the same arguments. | 127 // value PickAccountIdForAccount() when given the same arguments. |
126 std::string SeedAccountInfo(const std::string& gaia, | 128 std::string SeedAccountInfo(const std::string& gaia, |
127 const std::string& email); | 129 const std::string& email); |
| 130 void SeedAccountInfo(AccountInfo info); |
128 | 131 |
129 AccountIdMigrationState GetMigrationState(); | 132 AccountIdMigrationState GetMigrationState(); |
130 static AccountIdMigrationState GetMigrationState(PrefService* pref_service); | 133 static AccountIdMigrationState GetMigrationState(PrefService* pref_service); |
131 | 134 |
132 protected: | 135 protected: |
133 // Available to be called in tests. | 136 // Available to be called in tests. |
134 void SetAccountStateFromUserInfo( | 137 void SetAccountStateFromUserInfo( |
135 const std::string& account_id, | 138 const std::string& account_id, |
136 const base::DictionaryValue* user_info, | 139 const base::DictionaryValue* user_info, |
137 const std::vector<std::string>* service_flags); | 140 const std::vector<std::string>* service_flags); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 base::OneShotTimer<AccountTrackerService> timer_; | 199 base::OneShotTimer<AccountTrackerService> timer_; |
197 | 200 |
198 // Holds references to refresh token annotation requests keyed by account_id. | 201 // Holds references to refresh token annotation requests keyed by account_id. |
199 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> | 202 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> |
200 refresh_token_annotation_requests_; | 203 refresh_token_annotation_requests_; |
201 | 204 |
202 DISALLOW_COPY_AND_ASSIGN(AccountTrackerService); | 205 DISALLOW_COPY_AND_ASSIGN(AccountTrackerService); |
203 }; | 206 }; |
204 | 207 |
205 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ | 208 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ |
OLD | NEW |