| 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_NOT_NEEDED = 6, |
| 129 SESSION_RESTORE_COUNT = 7, |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 // Outcomes of post-merge session verification. | 132 // Outcomes of post-merge session verification. |
| 131 // This enum is used for an UMA histogram, and hence new items should only be | 133 // This enum is used for an UMA histogram, and hence new items should only be |
| 132 // appended at the end. | 134 // appended at the end. |
| 133 enum PostMergeVerificationOutcome { | 135 enum MergeVerificationOutcome { |
| 134 POST_MERGE_UNDEFINED = 0, | 136 POST_MERGE_UNDEFINED = 0, |
| 135 POST_MERGE_SUCCESS = 1, | 137 POST_MERGE_SUCCESS = 1, |
| 136 POST_MERGE_NO_ACCOUNTS = 2, | 138 POST_MERGE_NO_ACCOUNTS = 2, |
| 137 POST_MERGE_MISSING_PRIMARY_ACCOUNT = 3, | 139 POST_MERGE_MISSING_PRIMARY_ACCOUNT = 3, |
| 138 POST_MERGE_PRIMARY_NOT_FIRST_ACCOUNT = 4, | 140 POST_MERGE_PRIMARY_NOT_FIRST_ACCOUNT = 4, |
| 139 POST_MERGE_VERIFICATION_FAILED = 5, | 141 POST_MERGE_VERIFICATION_FAILED = 5, |
| 140 POST_MERGE_CONNECTION_FAILED = 6, | 142 POST_MERGE_CONNECTION_FAILED = 6, |
| 141 POST_MERGE_COUNT = 7, | 143 POST_MERGE_COUNT = 7, |
| 142 }; | 144 }; |
| 143 | 145 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Get the account id corresponding to the specified refresh token. | 183 // Get the account id corresponding to the specified refresh token. |
| 182 void GetAccountIdOfRefreshToken(const std::string& refresh_token); | 184 void GetAccountIdOfRefreshToken(const std::string& refresh_token); |
| 183 | 185 |
| 184 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from | 186 // Attempts to fetch OAuth2 tokens by using pre-authenticated cookie jar from |
| 185 // provided |auth_profile|. | 187 // provided |auth_profile|. |
| 186 void FetchOAuth2Tokens(); | 188 void FetchOAuth2Tokens(); |
| 187 | 189 |
| 188 // Reports when all tokens are loaded. | 190 // Reports when all tokens are loaded. |
| 189 void ReportOAuth2TokensLoaded(); | 191 void ReportOAuth2TokensLoaded(); |
| 190 | 192 |
| 193 // Checks if primary account sessions cookies are stale and restores them |
| 194 // if needed. |
| 195 void VerifySessionCookies(); |
| 196 |
| 191 // Issue GAIA cookie recovery (MergeSession) from |refresh_token_|. | 197 // Issue GAIA cookie recovery (MergeSession) from |refresh_token_|. |
| 192 void RestoreSessionCookies(); | 198 void RestoreSessionCookies(); |
| 193 | 199 |
| 194 // Checks GAIA error and figures out whether the request should be | 200 // Checks GAIA error and figures out whether the request should be |
| 195 // re-attempted. | 201 // re-attempted. |
| 196 bool RetryOnError(const GoogleServiceAuthError& error); | 202 bool RetryOnError(const GoogleServiceAuthError& error); |
| 197 | 203 |
| 198 // Changes |state_|, if needed fires observers (OnSessionRestoreStateChanged). | 204 // Changes |state_|, if needed fires observers (OnSessionRestoreStateChanged). |
| 199 void SetSessionRestoreState(SessionRestoreState state); | 205 void SetSessionRestoreState(SessionRestoreState state); |
| 200 | 206 |
| 201 // Testing helper. | 207 // Testing helper. |
| 202 void SetSessionRestoreStartForTesting(const base::Time& time); | 208 void SetSessionRestoreStartForTesting(const base::Time& time); |
| 203 | 209 |
| 204 // Records |outcome| of post merge verification check. | 210 // Records |outcome| of merge verification check. |is_pre_merge| specifies |
| 205 static void RecordPostMergeOutcome(PostMergeVerificationOutcome outcome); | 211 // if this is pre or post merge session verification. |
| 212 static void RecordCookiesCheckOutcome( |
| 213 bool is_pre_merge, |
| 214 MergeVerificationOutcome outcome); |
| 215 |
| 216 // Records successful |outcome| of merge session process. |
| 217 void RecordSessionRestoreOutcome(SessionRestoreOutcome outcome); |
| 206 | 218 |
| 207 // Keeps the track if we have already reported OAuth2 token being loaded | 219 // Keeps the track if we have already reported OAuth2 token being loaded |
| 208 // by OAuth2TokenService. | 220 // by OAuth2TokenService. |
| 209 Profile* user_profile_; | 221 Profile* user_profile_; |
| 210 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; | 222 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; |
| 211 SessionRestoreStrategy restore_strategy_; | 223 SessionRestoreStrategy restore_strategy_; |
| 212 SessionRestoreState state_; | 224 SessionRestoreState state_; |
| 213 | 225 |
| 214 scoped_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; | 226 scoped_ptr<OAuth2TokenFetcher> oauth2_token_fetcher_; |
| 215 scoped_ptr<OAuth2LoginVerifier> login_verifier_; | 227 scoped_ptr<OAuth2LoginVerifier> login_verifier_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 232 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we | 244 // TODO(zelidrag|gspencer): Figure out how to get rid of ProfileHelper so we |
| 233 // can change the line below to ObserverList<Observer, true>. | 245 // can change the line below to ObserverList<Observer, true>. |
| 234 ObserverList<Observer, false> observer_list_; | 246 ObserverList<Observer, false> observer_list_; |
| 235 | 247 |
| 236 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); | 248 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); |
| 237 }; | 249 }; |
| 238 | 250 |
| 239 } // namespace chromeos | 251 } // namespace chromeos |
| 240 | 252 |
| 241 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 253 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| OLD | NEW |