OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/sync/engine/auth_watcher.h" | 5 #include "chrome/browser/sync/engine/auth_watcher.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/sync/engine/all_status.h" | 9 #include "chrome/browser/sync/engine/all_status.h" |
10 #include "chrome/browser/sync/engine/authenticator.h" | 10 #include "chrome/browser/sync/engine/authenticator.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 AuthWatcherEvent event = { AuthWatcherEvent::AUTHENTICATION_ATTEMPT_START }; | 210 AuthWatcherEvent event = { AuthWatcherEvent::AUTHENTICATION_ATTEMPT_START }; |
211 NotifyListeners(&event); | 211 NotifyListeners(&event); |
212 | 212 |
213 current_attempt_trigger_ = request.trigger; | 213 current_attempt_trigger_ = request.trigger; |
214 | 214 |
215 SaveCredentials save = request.persist_creds_to_disk ? | 215 SaveCredentials save = request.persist_creds_to_disk ? |
216 PERSIST_TO_DISK : SAVE_IN_MEMORY_ONLY; | 216 PERSIST_TO_DISK : SAVE_IN_MEMORY_ONLY; |
217 SignIn const signin = user_settings_-> | 217 SignIn const signin = user_settings_-> |
218 RecallSigninType(request.email, GMAIL_SIGNIN); | 218 RecallSigninType(request.email, GMAIL_SIGNIN); |
219 | 219 |
| 220 // We let the caller be lazy and try using the last captcha token seen by |
| 221 // the gaia authenticator if they haven't provided a token but have sent |
| 222 // a challenge response. Of course, if the captcha token is specified, |
| 223 // we use that one instead. |
| 224 std::string captcha_token(request.captcha_token); |
| 225 if (!request.captcha_value.empty() && captcha_token.empty()) |
| 226 captcha_token = gaia_->captcha_token(); |
| 227 |
220 if (!request.password.empty()) { | 228 if (!request.password.empty()) { |
221 bool authenticated = false; | 229 bool authenticated = false; |
222 if (!request.captcha_token.empty() && !request.captcha_value.empty()) { | 230 if (!captcha_token.empty()) { |
223 authenticated = gaia_->Authenticate(request.email, request.password, | 231 authenticated = gaia_->Authenticate(request.email, request.password, |
224 save, request.captcha_token, | 232 save, captcha_token, |
225 request.captcha_value, signin); | 233 request.captcha_value, signin); |
226 } else { | 234 } else { |
227 authenticated = gaia_->Authenticate(request.email, request.password, | 235 authenticated = gaia_->Authenticate(request.email, request.password, |
228 save, signin); | 236 save, signin); |
229 } | 237 } |
230 if (authenticated) { | 238 if (authenticated) { |
231 PersistCredentials(); | 239 PersistCredentials(); |
232 DoAuthenticateWithToken(gaia_->email(), gaia_->auth_token()); | 240 DoAuthenticateWithToken(gaia_->email(), gaia_->auth_token()); |
233 } else { | 241 } else { |
234 ProcessGaiaAuthFailure(); | 242 ProcessGaiaAuthFailure(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 string AuthWatcher::email() const { | 334 string AuthWatcher::email() const { |
327 return gaia_->email(); | 335 return gaia_->email(); |
328 } | 336 } |
329 | 337 |
330 void AuthWatcher::NotifyListeners(AuthWatcherEvent* event) { | 338 void AuthWatcher::NotifyListeners(AuthWatcherEvent* event) { |
331 event->trigger = current_attempt_trigger_; | 339 event->trigger = current_attempt_trigger_; |
332 channel_->NotifyListeners(*event); | 340 channel_->NotifyListeners(*event); |
333 } | 341 } |
334 | 342 |
335 } // namespace browser_sync | 343 } // namespace browser_sync |
OLD | NEW |