| 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 CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_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 "chrome/browser/chromeos/login/auth/login_status_consumer.h" | 15 #include "chrome/browser/chromeos/login/auth/login_status_consumer.h" |
| 16 #include "google_apis/gaia/gaia_auth_consumer.h" | 16 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 17 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
| 18 | 18 |
| 19 class GaiaAuthFetcher; | 19 class GaiaAuthFetcher; |
| 20 class Profile; | 20 |
| 21 namespace content { |
| 22 class BrowserContext; |
| 23 } |
| 21 | 24 |
| 22 namespace chromeos { | 25 namespace chromeos { |
| 23 class AuthAttemptState; | 26 class AuthAttemptState; |
| 24 class AuthAttemptStateResolver; | 27 class AuthAttemptStateResolver; |
| 25 | 28 |
| 26 class OnlineAttempt | 29 class OnlineAttempt |
| 27 : public GaiaAuthConsumer { | 30 : public GaiaAuthConsumer { |
| 28 public: | 31 public: |
| 29 OnlineAttempt(AuthAttemptState* current_attempt, | 32 OnlineAttempt(AuthAttemptState* current_attempt, |
| 30 AuthAttemptStateResolver* callback); | 33 AuthAttemptStateResolver* callback); |
| 31 virtual ~OnlineAttempt(); | 34 virtual ~OnlineAttempt(); |
| 32 | 35 |
| 33 // Initiate the online login attempt either through client or auth login. | 36 // Initiate the online login attempt either through client or auth login. |
| 34 // Status will be recorded in |current_attempt|, and resolver_->Resolve() will | 37 // Status will be recorded in |current_attempt|, and resolver_->Resolve() will |
| 35 // be called on the IO thread when useful state is available. | 38 // be called on the IO thread when useful state is available. |
| 36 // Must be called on the UI thread. | 39 // Must be called on the UI thread. |
| 37 void Initiate(Profile* auth_profile); | 40 void Initiate(content::BrowserContext* auth_context); |
| 38 | 41 |
| 39 // GaiaAuthConsumer overrides. Callbacks from GaiaAuthFetcher | 42 // GaiaAuthConsumer overrides. Callbacks from GaiaAuthFetcher |
| 40 virtual void OnClientLoginFailure( | 43 virtual void OnClientLoginFailure( |
| 41 const GoogleServiceAuthError& error) OVERRIDE; | 44 const GoogleServiceAuthError& error) OVERRIDE; |
| 42 virtual void OnClientLoginSuccess( | 45 virtual void OnClientLoginSuccess( |
| 43 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; | 46 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, LoginSuccess); | 49 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, LoginSuccess); |
| 47 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, TwoFactorSuccess); | 50 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, TwoFactorSuccess); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 // Whether we're willing to re-try the ClientLogin attempt. | 72 // Whether we're willing to re-try the ClientLogin attempt. |
| 70 bool try_again_; | 73 bool try_again_; |
| 71 | 74 |
| 72 friend class OnlineAttemptTest; | 75 friend class OnlineAttemptTest; |
| 73 DISALLOW_COPY_AND_ASSIGN(OnlineAttempt); | 76 DISALLOW_COPY_AND_ASSIGN(OnlineAttempt); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 } // namespace chromeos | 79 } // namespace chromeos |
| 77 | 80 |
| 78 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_ |
| OLD | NEW |