| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ONLINE_ATTEMPT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" |
| 15 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 16 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
| 16 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" | 17 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" |
| 17 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | 18 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" |
| 19 #include "chrome/browser/signin/signin_internals_util.h" |
| 18 #include "google_apis/gaia/gaia_auth_consumer.h" | 20 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 19 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
| 20 | 22 |
| 21 class GaiaAuthFetcher; | 23 class GaiaAuthFetcher; |
| 22 class Profile; | 24 class Profile; |
| 23 | 25 |
| 24 namespace chromeos { | 26 namespace chromeos { |
| 25 class AuthAttemptState; | 27 class AuthAttemptState; |
| 26 class AuthAttemptStateResolver; | 28 class AuthAttemptStateResolver; |
| 27 | 29 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 virtual void OnClientLoginSuccess( | 48 virtual void OnClientLoginSuccess( |
| 47 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; | 49 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; |
| 48 | 50 |
| 49 // GaiaOAuthConsumer overrides. Callbacks from GaiaOAuthFetcher. | 51 // GaiaOAuthConsumer overrides. Callbacks from GaiaOAuthFetcher. |
| 50 virtual void OnOAuthLoginSuccess(const std::string& sid, | 52 virtual void OnOAuthLoginSuccess(const std::string& sid, |
| 51 const std::string& lsid, | 53 const std::string& lsid, |
| 52 const std::string& auth) OVERRIDE; | 54 const std::string& auth) OVERRIDE; |
| 53 virtual void OnOAuthLoginFailure( | 55 virtual void OnOAuthLoginFailure( |
| 54 const GoogleServiceAuthError& error) OVERRIDE; | 56 const GoogleServiceAuthError& error) OVERRIDE; |
| 55 | 57 |
| 58 // Methods to register (and remove) observers interested in signin |
| 59 // diagnostics related information updates. |
| 60 void AddSigninDiagnosticsObserver( |
| 61 signin_internals_util::SigninDiagnosticsObserver* observer); |
| 62 void RemoveSigninDiagnosticsObserver( |
| 63 signin_internals_util::SigninDiagnosticsObserver* observer); |
| 64 |
| 56 private: | 65 private: |
| 57 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, LoginSuccess); | 66 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, LoginSuccess); |
| 58 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, TwoFactorSuccess); | 67 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, TwoFactorSuccess); |
| 59 | 68 |
| 60 // Milliseconds until we timeout our attempt to hit ClientLogin. | 69 // Milliseconds until we timeout our attempt to hit ClientLogin. |
| 61 static const int kClientLoginTimeoutMs; | 70 static const int kClientLoginTimeoutMs; |
| 62 | 71 |
| 63 void TryClientLogin(); | 72 void TryClientLogin(); |
| 64 void CancelClientLogin(); | 73 void CancelClientLogin(); |
| 65 | 74 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 scoped_ptr<GaiaAuthFetcher> client_fetcher_; | 87 scoped_ptr<GaiaAuthFetcher> client_fetcher_; |
| 79 // Handles OAuthLogin communications with Gaia. | 88 // Handles OAuthLogin communications with Gaia. |
| 80 scoped_ptr<GaiaOAuthFetcher> oauth_fetcher_; | 89 scoped_ptr<GaiaOAuthFetcher> oauth_fetcher_; |
| 81 | 90 |
| 82 // Used to cancel the CancelClientLogin closure. | 91 // Used to cancel the CancelClientLogin closure. |
| 83 base::WeakPtrFactory<OnlineAttempt> weak_factory_; | 92 base::WeakPtrFactory<OnlineAttempt> weak_factory_; |
| 84 | 93 |
| 85 // Whether we're willing to re-try the ClientLogin attempt. | 94 // Whether we're willing to re-try the ClientLogin attempt. |
| 86 bool try_again_; | 95 bool try_again_; |
| 87 | 96 |
| 97 // A list of interested observers. |
| 98 ObserverList<signin_internals_util::SigninDiagnosticsObserver> |
| 99 signin_diagnostics_observers_; |
| 100 |
| 88 friend class OnlineAttemptTest; | 101 friend class OnlineAttemptTest; |
| 89 DISALLOW_COPY_AND_ASSIGN(OnlineAttempt); | 102 DISALLOW_COPY_AND_ASSIGN(OnlineAttempt); |
| 90 }; | 103 }; |
| 91 | 104 |
| 92 } // namespace chromeos | 105 } // namespace chromeos |
| 93 | 106 |
| 94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_H_ | 107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ONLINE_ATTEMPT_H_ |
| OLD | NEW |