| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/online_attempt.h" | 5 #include "chrome/browser/chromeos/login/online_attempt.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/login/auth_attempt_state.h" | 12 #include "chrome/browser/chromeos/login/auth_attempt_state.h" |
| 13 #include "chrome/browser/chromeos/login/auth_attempt_state_resolver.h" | 13 #include "chrome/browser/chromeos/login/auth_attempt_state_resolver.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 16 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 17 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 17 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 18 #include "chrome/common/net/gaia/gaia_constants.h" | 18 #include "chrome/common/net/gaia/gaia_constants.h" |
| 19 #include "content/browser/browser_thread.h" | 19 #include "content/browser/browser_thread.h" |
| 20 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 22 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
| 23 #include "third_party/libjingle/source/talk/base/urlencode.h" | 23 #include "third_party/libjingle/source/talk/base/urlencode.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // The service scope of the OAuth v2 token that ChromeOS login will be | 27 // The service scope of the OAuth v2 token that ChromeOS login will be |
| 28 // requesting. | 28 // requesting. |
| 29 const char kServiceScopeChromeOS[] = | 29 const char* kServiceScopeChromeOS = GaiaConstants::kSyncServiceOAuth; |
| 30 "https://www.googleapis.com/auth/chromesync"; | |
| 31 | 30 |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace chromeos { | 33 namespace chromeos { |
| 35 | 34 |
| 36 // static | 35 // static |
| 37 const int OnlineAttempt::kClientLoginTimeoutMs = 10000; | 36 const int OnlineAttempt::kClientLoginTimeoutMs = 10000; |
| 38 | 37 |
| 39 OnlineAttempt::OnlineAttempt(bool using_oauth, | 38 OnlineAttempt::OnlineAttempt(bool using_oauth, |
| 40 AuthAttemptState* current_attempt, | 39 AuthAttemptState* current_attempt, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 oauth_fetcher_->CancelRequest(); | 55 oauth_fetcher_->CancelRequest(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void OnlineAttempt::Initiate(Profile* auth_profile) { | 58 void OnlineAttempt::Initiate(Profile* auth_profile) { |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 61 if (using_oauth_) { | 60 if (using_oauth_) { |
| 62 oauth_fetcher_.reset( | 61 oauth_fetcher_.reset( |
| 63 new GaiaOAuthFetcher(this, | 62 new GaiaOAuthFetcher(this, |
| 64 auth_profile->GetRequestContext(), | 63 auth_profile->GetRequestContext(), |
| 65 auth_profile, | 64 auth_profile, |
| 66 GaiaConstants::kSyncService, | |
| 67 kServiceScopeChromeOS)); | 65 kServiceScopeChromeOS)); |
| 68 } else { | 66 } else { |
| 69 client_fetcher_.reset( | 67 client_fetcher_.reset( |
| 70 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, | 68 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, |
| 71 auth_profile->GetRequestContext())); | 69 auth_profile->GetRequestContext())); |
| 72 } | 70 } |
| 73 BrowserThread::PostTask( | 71 BrowserThread::PostTask( |
| 74 BrowserThread::IO, FROM_HERE, | 72 BrowserThread::IO, FROM_HERE, |
| 75 NewRunnableMethod(this, &OnlineAttempt::TryClientLogin)); | 73 NewRunnableMethod(this, &OnlineAttempt::TryClientLogin)); |
| 76 } | 74 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void OnlineAttempt::TriggerResolve( | 213 void OnlineAttempt::TriggerResolve( |
| 216 const GaiaAuthConsumer::ClientLoginResult& credentials, | 214 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 217 const LoginFailure& outcome) { | 215 const LoginFailure& outcome) { |
| 218 attempt_->RecordOnlineLoginStatus(credentials, outcome); | 216 attempt_->RecordOnlineLoginStatus(credentials, outcome); |
| 219 client_fetcher_.reset(NULL); | 217 client_fetcher_.reset(NULL); |
| 220 oauth_fetcher_.reset(NULL); | 218 oauth_fetcher_.reset(NULL); |
| 221 resolver_->Resolve(); | 219 resolver_->Resolve(); |
| 222 } | 220 } |
| 223 | 221 |
| 224 } // namespace chromeos | 222 } // namespace chromeos |
| OLD | NEW |