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; |
61 // TODO(rogerta): eventually this structure will include other information | 64 std::string picture_url; |
62 // about the account, like full name, profile picture URL, etc. | 65 // TODO(anthonyvd): Eventually this structure should contain the account |
| 66 // service flags. |
63 | 67 |
64 bool IsValid(); | 68 bool IsValid() const; |
65 }; | 69 }; |
66 | 70 |
67 // Clients of AccountTrackerService can implement this interface and register | 71 // Clients of AccountTrackerService can implement this interface and register |
68 // with AddObserver() to learn about account information changes. | 72 // with AddObserver() to learn about account information changes. |
69 class Observer { | 73 class Observer { |
70 public: | 74 public: |
71 virtual ~Observer() {} | 75 virtual ~Observer() {} |
72 virtual void OnAccountUpdated(const AccountInfo& info) {} | 76 virtual void OnAccountUpdated(const AccountInfo& info) {} |
73 virtual void OnAccountUpdateFailed(const std::string& account_id) {} | 77 virtual void OnAccountUpdateFailed(const std::string& account_id) {} |
74 virtual void OnAccountRemoved(const AccountInfo& info) {} | 78 virtual void OnAccountRemoved(const AccountInfo& info) {} |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 const std::string& email); | 121 const std::string& email); |
118 static std::string PickAccountIdForAccount(PrefService* pref_service, | 122 static std::string PickAccountIdForAccount(PrefService* pref_service, |
119 const std::string& gaia, | 123 const std::string& gaia, |
120 const std::string& email); | 124 const std::string& email); |
121 | 125 |
122 // Seeds the account whose account_id is given by PickAccountIdForAccount() | 126 // Seeds the account whose account_id is given by PickAccountIdForAccount() |
123 // with its corresponding gaia id and email address. Returns the same | 127 // with its corresponding gaia id and email address. Returns the same |
124 // value PickAccountIdForAccount() when given the same arguments. | 128 // value PickAccountIdForAccount() when given the same arguments. |
125 std::string SeedAccountInfo(const std::string& gaia, | 129 std::string SeedAccountInfo(const std::string& gaia, |
126 const std::string& email); | 130 const std::string& email); |
| 131 void SeedAccountInfo(AccountInfo info); |
127 | 132 |
128 AccountIdMigrationState GetMigrationState(); | 133 AccountIdMigrationState GetMigrationState(); |
129 static AccountIdMigrationState GetMigrationState(PrefService* pref_service); | 134 static AccountIdMigrationState GetMigrationState(PrefService* pref_service); |
130 | 135 |
131 protected: | 136 protected: |
132 // Available to be called in tests. | 137 // Available to be called in tests. |
133 void SetAccountStateFromUserInfo(const std::string& account_id, | 138 void SetAccountStateFromUserInfo(const std::string& account_id, |
134 const base::DictionaryValue* user_info); | 139 const base::DictionaryValue* user_info); |
135 | 140 |
136 private: | 141 private: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 base::OneShotTimer<AccountTrackerService> timer_; | 197 base::OneShotTimer<AccountTrackerService> timer_; |
193 | 198 |
194 // Holds references to refresh token annotation requests keyed by account_id. | 199 // Holds references to refresh token annotation requests keyed by account_id. |
195 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> | 200 base::ScopedPtrHashMap<std::string, scoped_ptr<RefreshTokenAnnotationRequest>> |
196 refresh_token_annotation_requests_; | 201 refresh_token_annotation_requests_; |
197 | 202 |
198 DISALLOW_COPY_AND_ASSIGN(AccountTrackerService); | 203 DISALLOW_COPY_AND_ASSIGN(AccountTrackerService); |
199 }; | 204 }; |
200 | 205 |
201 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ | 206 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_TRACKER_SERVICE_H_ |
OLD | NEW |