| 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 #include "chrome/browser/chromeos/login/auth/online_attempt.h" | 5 #include "chrome/browser/chromeos/login/auth/online_attempt.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/chromeos/login/auth/auth_attempt_state.h" | 13 #include "chrome/browser/chromeos/login/auth/auth_attempt_state.h" |
| 14 #include "chrome/browser/chromeos/login/auth/auth_attempt_state_resolver.h" | 14 #include "chrome/browser/chromeos/login/auth/auth_attempt_state_resolver.h" |
| 15 #include "chrome/browser/chromeos/login/users/user.h" | 15 #include "chrome/browser/chromeos/login/users/user.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | |
| 18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 19 #include "google_apis/gaia/gaia_auth_consumer.h" | 18 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 20 #include "google_apis/gaia/gaia_auth_fetcher.h" | 19 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 21 #include "google_apis/gaia/gaia_constants.h" | 20 #include "google_apis/gaia/gaia_constants.h" |
| 22 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
| 23 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 24 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
| 25 | 24 |
| 26 using content::BrowserThread; | 25 using content::BrowserThread; |
| 27 | 26 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 try_again_(true) { | 37 try_again_(true) { |
| 39 DCHECK(attempt_->user_type == User::USER_TYPE_REGULAR); | 38 DCHECK(attempt_->user_type == User::USER_TYPE_REGULAR); |
| 40 } | 39 } |
| 41 | 40 |
| 42 OnlineAttempt::~OnlineAttempt() { | 41 OnlineAttempt::~OnlineAttempt() { |
| 43 // Just to be sure. | 42 // Just to be sure. |
| 44 if (client_fetcher_.get()) | 43 if (client_fetcher_.get()) |
| 45 client_fetcher_->CancelRequest(); | 44 client_fetcher_->CancelRequest(); |
| 46 } | 45 } |
| 47 | 46 |
| 48 void OnlineAttempt::Initiate(Profile* auth_profile) { | 47 void OnlineAttempt::Initiate(content::BrowserContext* auth_context) { |
| 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 50 client_fetcher_.reset( | 49 client_fetcher_.reset( |
| 51 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, | 50 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, |
| 52 auth_profile->GetRequestContext())); | 51 auth_context->GetRequestContext())); |
| 53 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 54 BrowserThread::UI, FROM_HERE, | 53 BrowserThread::UI, FROM_HERE, |
| 55 base::Bind(&OnlineAttempt::TryClientLogin, weak_factory_.GetWeakPtr())); | 54 base::Bind(&OnlineAttempt::TryClientLogin, weak_factory_.GetWeakPtr())); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void OnlineAttempt::OnClientLoginSuccess( | 57 void OnlineAttempt::OnClientLoginSuccess( |
| 59 const GaiaAuthConsumer::ClientLoginResult& unused) { | 58 const GaiaAuthConsumer::ClientLoginResult& unused) { |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 61 VLOG(1) << "Online login successful!"; | 60 VLOG(1) << "Online login successful!"; |
| 62 | 61 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 153 } |
| 155 | 154 |
| 156 void OnlineAttempt::TriggerResolve( | 155 void OnlineAttempt::TriggerResolve( |
| 157 const LoginFailure& outcome) { | 156 const LoginFailure& outcome) { |
| 158 attempt_->RecordOnlineLoginStatus(outcome); | 157 attempt_->RecordOnlineLoginStatus(outcome); |
| 159 client_fetcher_.reset(NULL); | 158 client_fetcher_.reset(NULL); |
| 160 resolver_->Resolve(); | 159 resolver_->Resolve(); |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace chromeos | 162 } // namespace chromeos |
| OLD | NEW |