| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 SessionRestoreState state() { return state_; } | 108 SessionRestoreState state() { return state_; } |
| 109 | 109 |
| 110 const base::Time& session_restore_start() { return session_restore_start_; } | 110 const base::Time& session_restore_start() { return session_restore_start_; } |
| 111 | 111 |
| 112 // Returns true if the tab loading should block until session restore | 112 // Returns true if the tab loading should block until session restore |
| 113 // finishes. | 113 // finishes. |
| 114 bool ShouldBlockTabLoading(); | 114 bool ShouldBlockTabLoading(); |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 friend class MergeSessionLoadPageTest; | 117 friend class MergeSessionLoadPageTest; |
| 118 friend class OAuth2Test; |
| 118 | 119 |
| 119 // Session restore outcomes (for UMA). | 120 // Session restore outcomes (for UMA). |
| 120 enum { | 121 enum SessionRestoreOutcome { |
| 121 SESSION_RESTORE_UNDEFINED = 0, | 122 SESSION_RESTORE_UNDEFINED = 0, |
| 122 SESSION_RESTORE_SUCCESS = 1, | 123 SESSION_RESTORE_SUCCESS = 1, |
| 123 SESSION_RESTORE_TOKEN_FETCH_FAILED = 2, | 124 SESSION_RESTORE_TOKEN_FETCH_FAILED = 2, |
| 124 SESSION_RESTORE_NO_REFRESH_TOKEN_FAILED = 3, | 125 SESSION_RESTORE_NO_REFRESH_TOKEN_FAILED = 3, |
| 125 SESSION_RESTORE_OAUTHLOGIN_FAILED = 4, | 126 SESSION_RESTORE_OAUTHLOGIN_FAILED = 4, |
| 126 SESSION_RESTORE_MERGE_SESSION_FAILED = 5, | 127 SESSION_RESTORE_MERGE_SESSION_FAILED = 5, |
| 127 SESSION_RESTORE_COUNT = SESSION_RESTORE_MERGE_SESSION_FAILED, | 128 SESSION_RESTORE_LISTACCOUNTS_FAILED = 6, |
| 129 SESSION_RESTORE_NOT_NEEDED = 7, |
| 130 SESSION_RESTORE_COUNT = 8, |
| 128 }; | 131 }; |
| 129 | 132 |
| 130 // Outcomes of post-merge session verification. | 133 // Outcomes of post-merge session verification. |
| 131 // This enum is used for an UMA histogram, and hence new items should only be | 134 // This enum is used for an UMA histogram, and hence new items should only be |
| 132 // appended at the end. | 135 // appended at the end. |
| 133 enum PostMergeVerificationOutcome { | 136 enum MergeVerificationOutcome { |
| 134 POST_MERGE_UNDEFINED = 0, | 137 POST_MERGE_UNDEFINED = 0, |
| 135 POST_MERGE_SUCCESS = 1, | 138 POST_MERGE_SUCCESS = 1, |
| 136 POST_MERGE_NO_ACCOUNTS = 2, | 139 POST_MERGE_NO_ACCOUNTS = 2, |
| 137 POST_MERGE_MISSING_PRIMARY_ACCOUNT = 3, | 140 POST_MERGE_MISSING_PRIMARY_ACCOUNT = 3, |
| 138 POST_MERGE_PRIMARY_NOT_FIRST_ACCOUNT = 4, | 141 POST_MERGE_PRIMARY_NOT_FIRST_ACCOUNT = 4, |
| 139 POST_MERGE_VERIFICATION_FAILED = 5, | 142 POST_MERGE_VERIFICATION_FAILED = 5, |
| 140 POST_MERGE_CONNECTION_FAILED = 6, | 143 POST_MERGE_CONNECTION_FAILED = 6, |
| 141 POST_MERGE_COUNT = 7, | 144 POST_MERGE_COUNT = 7, |
| 142 }; | 145 }; |
| 143 | 146 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // Get the account id corresponding to the specified refresh token. | 187 // Get the account id corresponding to the specified refresh token. |
| 185 void GetAccountIdOfRefreshToken(const std::string& refresh_token); | 188 void GetAccountIdOfRefreshToken(const std::string& refresh_token); |
| 186 | 189 |
| 187 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from | 190 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from |
| 188 // provided |auth_profile|. | 191 // provided |auth_profile|. |
| 189 void FetchOAuth2Tokens(); | 192 void FetchOAuth2Tokens(); |
| 190 | 193 |
| 191 // Reports when all tokens are loaded. | 194 // Reports when all tokens are loaded. |
| 192 void ReportOAuth2TokensLoaded(); | 195 void ReportOAuth2TokensLoaded(); |
| 193 | 196 |
| 197 // Checks if primary account sessions cookies are stale and restores them |
| 198 // if needed. |
| 199 void VerifySessionCookies(); |
| 200 |
| 194 // Issue GAIA cookie recovery (MergeSession) from |refresh_token_|. | 201 // Issue GAIA cookie recovery (MergeSession) from |refresh_token_|. |
| 195 void RestoreSessionCookies(); | 202 void RestoreSessionCookies(); |
| 196 | 203 |
| 197 // Checks GAIA error and figures out whether the request should be | 204 // Checks GAIA error and figures out whether the request should be |
| 198 // re-attempted. | 205 // re-attempted. |
| 199 bool RetryOnError(const GoogleServiceAuthError& error); | 206 bool RetryOnError(const GoogleServiceAuthError& error); |
| 200 | 207 |
| 201 // Changes |state_|, if needed fires observers (OnSessionRestoreStateChanged). | 208 // Changes |state_|, if needed fires observers (OnSessionRestoreStateChanged). |
| 202 void SetSessionRestoreState(SessionRestoreState state); | 209 void SetSessionRestoreState(SessionRestoreState state); |
| 203 | 210 |
| 204 // Testing helper. | 211 // Testing helper. |
| 205 void SetSessionRestoreStartForTesting(const base::Time& time); | 212 void SetSessionRestoreStartForTesting(const base::Time& time); |
| 206 | 213 |
| 207 // Records |outcome| of post merge verification check. | 214 // Records |outcome| of session restore process and sets new |state|. |
| 208 static void RecordPostMergeOutcome(PostMergeVerificationOutcome outcome); | 215 void RecordSessionRestoreOutcome(SessionRestoreOutcome outcome, |
| 216 SessionRestoreState state); |
| 217 |
| 218 // Records |outcome| of merge verification check. |is_pre_merge| specifies |
| 219 // if this is pre or post merge session verification. |
| 220 static void RecordCookiesCheckOutcome( |
| 221 bool is_pre_merge, |
| 222 MergeVerificationOutcome outcome); |
| 209 | 223 |
| 210 // Keeps the track if we have already reported OAuth2 token being loaded | 224 // Keeps the track if we have already reported OAuth2 token being loaded |
| 211 // by OAuth2TokenService. | 225 // by OAuth2TokenService. |
| 212 Profile* user_profile_; | 226 Profile* user_profile_; |
| 213 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; | 227 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; |
| 214 SessionRestoreStrategy restore_strategy_; | 228 SessionRestoreStrategy restore_strategy_; |
| 215 SessionRestoreState state_; | 229 SessionRestoreState state_; |
| 216 | 230 |
| 217 scoped_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; | 231 scoped_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; |
| 218 scoped_ptr<OAuth2LoginVerifier> login_verifier_; | 232 scoped_ptr<OAuth2LoginVerifier> login_verifier_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 235 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we | 249 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we |
| 236 // can change the line below to ObserverList<Observer, true>. | 250 // can change the line below to ObserverList<Observer, true>. |
| 237 ObserverList<Observer, false> observer_list_; | 251 ObserverList<Observer, false> observer_list_; |
| 238 | 252 |
| 239 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); | 253 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); |
| 240 }; | 254 }; |
| 241 | 255 |
| 242 } // namespace chromeos | 256 } // namespace chromeos |
| 243 | 257 |
| 244 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 258 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| OLD | NEW |