| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/automation/automation_event_observers.h" | 5 #include "chrome/browser/automation/automation_event_observers.h" |
| 6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 7 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 8 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
| 9 | 9 |
| 10 using chromeos::ExistingUserController; |
| 11 |
| 10 LoginEventObserver::LoginEventObserver( | 12 LoginEventObserver::LoginEventObserver( |
| 11 AutomationEventQueue* event_queue, | 13 AutomationEventQueue* event_queue, |
| 12 chromeos::ExistingUserController* controller, | |
| 13 AutomationProvider* automation) | 14 AutomationProvider* automation) |
| 14 : AutomationEventObserver(event_queue, false), | 15 : AutomationEventObserver(event_queue, false), |
| 15 controller_(controller), | |
| 16 automation_(automation->AsWeakPtr()) { | 16 automation_(automation->AsWeakPtr()) { |
| 17 controller_->set_login_status_consumer(this); | 17 ExistingUserController* controller = |
| 18 ExistingUserController::current_controller(); |
| 19 DCHECK(controller); |
| 20 controller->set_login_status_consumer(this); |
| 18 } | 21 } |
| 19 | 22 |
| 20 LoginEventObserver::~LoginEventObserver() {} | 23 LoginEventObserver::~LoginEventObserver() {} |
| 21 | 24 |
| 22 void LoginEventObserver::OnLoginFailure(const chromeos::LoginFailure& error) { | 25 void LoginEventObserver::OnLoginFailure(const chromeos::LoginFailure& error) { |
| 23 _NotifyLoginEvent(error.GetErrorString()); | 26 _NotifyLoginEvent(error.GetErrorString()); |
| 24 } | 27 } |
| 25 | 28 |
| 26 void LoginEventObserver::OnLoginSuccess(const std::string& username, | 29 void LoginEventObserver::OnLoginSuccess(const std::string& username, |
| 27 const std::string& password, | 30 const std::string& password, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 _NotifyLoginEvent(std::string()); | 50 _NotifyLoginEvent(std::string()); |
| 48 } | 51 } |
| 49 } | 52 } |
| 50 | 53 |
| 51 void LoginEventObserver::_NotifyLoginEvent(const std::string& error_string) { | 54 void LoginEventObserver::_NotifyLoginEvent(const std::string& error_string) { |
| 52 DictionaryValue* dict = new DictionaryValue; | 55 DictionaryValue* dict = new DictionaryValue; |
| 53 dict->SetString("type", "login_event"); | 56 dict->SetString("type", "login_event"); |
| 54 if (error_string.length()) | 57 if (error_string.length()) |
| 55 dict->SetString("error_string", error_string); | 58 dict->SetString("error_string", error_string); |
| 56 NotifyEvent(dict); | 59 NotifyEvent(dict); |
| 57 controller_->set_login_status_consumer(NULL); | 60 ExistingUserController* controller = |
| 61 ExistingUserController::current_controller(); |
| 62 if (controller) |
| 63 controller->set_login_status_consumer(NULL); |
| 58 RemoveIfDone(); | 64 RemoveIfDone(); |
| 59 } | 65 } |
| OLD | NEW |