Chromium Code Reviews| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 bool AuthWatcher::AuthenticateLocally(string email, const string& password) { | 208 bool AuthWatcher::AuthenticateLocally(string email, const string& password) { |
| 209 DCHECK_EQ(MessageLoop::current(), message_loop()); | 209 DCHECK_EQ(MessageLoop::current(), message_loop()); |
| 210 user_settings_->GetEmailForSignin(&email); | 210 user_settings_->GetEmailForSignin(&email); |
| 211 return user_settings_->VerifyAgainstStoredHash(email, password) | 211 return user_settings_->VerifyAgainstStoredHash(email, password) |
| 212 && AuthenticateLocally(email); | 212 && AuthenticateLocally(email); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void AuthWatcher::ProcessGaiaAuthFailure() { | 215 void AuthWatcher::ProcessGaiaAuthFailure() { |
| 216 DCHECK_EQ(MessageLoop::current(), message_loop()); | 216 DCHECK_EQ(MessageLoop::current(), message_loop()); |
| 217 gaia::GaiaAuthenticator::AuthResults results = gaia_->results(); | 217 gaia::GaiaAuthenticator::AuthResults results = gaia_->results(); |
| 218 if (LOCALLY_AUTHENTICATED == status_) { | 218 if (LOCALLY_AUTHENTICATED != status_ && |
| 219 return; // nothing todo | 219 AuthenticateLocally(results.email, results.password)) { |
|
chron_chromium.org
2010/07/13 00:32:53
This seems fine as long as we test the conditions
| |
| 220 } else if (AuthenticateLocally(results.email, results.password)) { | |
| 221 // TODO(chron): Do we really want a bogus token? | 220 // TODO(chron): Do we really want a bogus token? |
| 222 const string auth_token("bogus"); | 221 const string auth_token("bogus"); |
| 223 user_settings_->SetAuthTokenForService(results.email, | 222 user_settings_->SetAuthTokenForService(results.email, |
| 224 SYNC_SERVICE_NAME, | 223 SYNC_SERVICE_NAME, |
| 225 auth_token); | 224 auth_token); |
| 226 const bool unavailable = | |
| 227 gaia::ConnectionUnavailable == results.auth_error || | |
| 228 gaia::Unknown == results.auth_error || | |
| 229 gaia::ServiceUnavailable == results.auth_error; | |
| 230 if (unavailable) | |
| 231 return; | |
| 232 } | 225 } |
| 233 AuthWatcherEvent myevent = { AuthWatcherEvent::GAIA_AUTH_FAILED, &results }; | 226 AuthWatcherEvent myevent = { AuthWatcherEvent::GAIA_AUTH_FAILED, &results }; |
| 234 NotifyListeners(&myevent); | 227 NotifyListeners(&myevent); |
| 235 } | 228 } |
| 236 | 229 |
| 237 void AuthWatcher::DoAuthenticate(const AuthRequest& request) { | 230 void AuthWatcher::DoAuthenticate(const AuthRequest& request) { |
| 238 DCHECK_EQ(MessageLoop::current(), message_loop()); | 231 DCHECK_EQ(MessageLoop::current(), message_loop()); |
| 239 | 232 |
| 240 AuthWatcherEvent event = { AuthWatcherEvent::AUTHENTICATION_ATTEMPT_START }; | 233 AuthWatcherEvent event = { AuthWatcherEvent::AUTHENTICATION_ATTEMPT_START }; |
| 241 NotifyListeners(&event); | 234 NotifyListeners(&event); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 string AuthWatcher::email() const { | 342 string AuthWatcher::email() const { |
| 350 return gaia_->email(); | 343 return gaia_->email(); |
| 351 } | 344 } |
| 352 | 345 |
| 353 void AuthWatcher::NotifyListeners(AuthWatcherEvent* event) { | 346 void AuthWatcher::NotifyListeners(AuthWatcherEvent* event) { |
| 354 event->trigger = current_attempt_trigger_; | 347 event->trigger = current_attempt_trigger_; |
| 355 channel_->NotifyListeners(*event); | 348 channel_->NotifyListeners(*event); |
| 356 } | 349 } |
| 357 | 350 |
| 358 } // namespace browser_sync | 351 } // namespace browser_sync |
| OLD | NEW |