Chromium Code Reviews| 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 "content/public/browser/notification_service.h" | |
|
jam
2012/09/11 00:34:43
nit: order
| |
| 5 #include "chrome/browser/automation/automation_event_observers.h" | 6 #include "chrome/browser/automation/automation_event_observers.h" |
| 6 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 8 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 8 | 9 |
| 9 LoginEventObserver::LoginEventObserver( | 10 LoginEventObserver::LoginEventObserver( |
| 10 AutomationEventQueue* event_queue, | 11 AutomationEventQueue* event_queue, |
| 11 chromeos::ExistingUserController* controller, | 12 chromeos::ExistingUserController* controller, |
| 12 AutomationProvider* automation) | 13 AutomationProvider* automation) |
| 13 : AutomationEventObserver(event_queue, false), | 14 : AutomationEventObserver(event_queue, false), |
| 14 controller_(controller), | 15 controller_(controller), |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 25 void LoginEventObserver::OnLoginSuccess(const std::string& username, | 26 void LoginEventObserver::OnLoginSuccess(const std::string& username, |
| 26 const std::string& password, | 27 const std::string& password, |
| 27 bool pending_requests, | 28 bool pending_requests, |
| 28 bool using_oauth) { | 29 bool using_oauth) { |
| 29 // Profile changes after login. Ensure AutomationProvider refers to | 30 // Profile changes after login. Ensure AutomationProvider refers to |
| 30 // the correct one. | 31 // the correct one. |
| 31 if (automation_) { | 32 if (automation_) { |
| 32 automation_->set_profile( | 33 automation_->set_profile( |
| 33 g_browser_process->profile_manager()->GetLastUsedProfile()); | 34 g_browser_process->profile_manager()->GetLastUsedProfile()); |
| 34 } | 35 } |
| 35 _NotifyLoginEvent(std::string()); | 36 VLOG(1) << "Successfully logged in. Waiting for a page to load"; |
| 37 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | |
| 38 content::NotificationService::AllBrowserContextsAndSources()); | |
| 36 } | 39 } |
| 37 | 40 |
| 41 void LoginEventObserver::Observe( | |
| 42 int type, | |
| 43 const content::NotificationSource& source, | |
| 44 const content::NotificationDetails& details) { | |
| 45 if (type == content::NOTIFICATION_LOAD_STOP) { | |
| 46 VLOG(1) << "Page load done."; | |
| 47 _NotifyLoginEvent(std::string()); | |
| 48 } | |
| 49 } | |
| 50 | |
|
jam
2012/09/11 00:34:43
nit: extra blank line
| |
| 51 | |
| 38 void LoginEventObserver::_NotifyLoginEvent(const std::string& error_string) { | 52 void LoginEventObserver::_NotifyLoginEvent(const std::string& error_string) { |
| 39 DictionaryValue* dict = new DictionaryValue; | 53 DictionaryValue* dict = new DictionaryValue; |
| 40 dict->SetString("type", "login_event"); | 54 dict->SetString("type", "login_event"); |
| 41 if (error_string.length()) | 55 if (error_string.length()) |
| 42 dict->SetString("error_string", error_string); | 56 dict->SetString("error_string", error_string); |
| 43 NotifyEvent(dict); | 57 NotifyEvent(dict); |
| 44 controller_->set_login_status_consumer(NULL); | 58 controller_->set_login_status_consumer(NULL); |
| 45 RemoveIfDone(); | 59 RemoveIfDone(); |
| 46 } | 60 } |
| OLD | NEW |