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; | 10 using chromeos::ExistingUserController; |
11 | 11 |
12 LoginEventObserver::LoginEventObserver( | 12 LoginEventObserver::LoginEventObserver( |
13 AutomationEventQueue* event_queue, | 13 AutomationEventQueue* event_queue, |
14 AutomationProvider* automation) | 14 AutomationProvider* automation) |
15 : AutomationEventObserver(event_queue, false), | 15 : AutomationEventObserver(event_queue, false), |
16 automation_(automation->AsWeakPtr()) { | 16 automation_(automation->AsWeakPtr()) { |
17 ExistingUserController* controller = | 17 ExistingUserController* controller = |
18 ExistingUserController::current_controller(); | 18 ExistingUserController::current_controller(); |
19 DCHECK(controller); | 19 DCHECK(controller); |
20 controller->set_login_status_consumer(this); | 20 controller->set_login_status_consumer(this); |
21 } | 21 } |
22 | 22 |
23 LoginEventObserver::~LoginEventObserver() {} | 23 LoginEventObserver::~LoginEventObserver() {} |
24 | 24 |
25 void LoginEventObserver::OnLoginFailure(const chromeos::LoginFailure& error) { | 25 void LoginEventObserver::OnLoginFailure(const chromeos::LoginFailure& error) { |
26 _NotifyLoginEvent(error.GetErrorString()); | 26 _NotifyLoginEvent(error.GetErrorString()); |
27 } | 27 } |
28 | 28 |
29 void LoginEventObserver::OnLoginSuccess(const std::string& username, | 29 void LoginEventObserver::OnLoginSuccess( |
30 const std::string& password, | 30 const chromeos::UserCredentials& credentials, |
31 bool pending_requests, | 31 bool pending_requests, |
32 bool using_oauth) { | 32 bool using_oauth) { |
33 // Profile changes after login. Ensure AutomationProvider refers to | 33 // Profile changes after login. Ensure AutomationProvider refers to |
34 // the correct one. | 34 // the correct one. |
35 if (automation_) { | 35 if (automation_) { |
36 automation_->set_profile( | 36 automation_->set_profile( |
37 g_browser_process->profile_manager()->GetLastUsedProfile()); | 37 g_browser_process->profile_manager()->GetLastUsedProfile()); |
38 } | 38 } |
39 VLOG(1) << "Successfully logged in. Waiting for a page to load"; | 39 VLOG(1) << "Successfully logged in. Waiting for a page to load"; |
40 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 40 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
41 content::NotificationService::AllBrowserContextsAndSources()); | 41 content::NotificationService::AllBrowserContextsAndSources()); |
42 } | 42 } |
(...skipping 13 matching lines...) Expand all Loading... |
56 dict->SetString("type", "login_event"); | 56 dict->SetString("type", "login_event"); |
57 if (error_string.length()) | 57 if (error_string.length()) |
58 dict->SetString("error_string", error_string); | 58 dict->SetString("error_string", error_string); |
59 NotifyEvent(dict); | 59 NotifyEvent(dict); |
60 ExistingUserController* controller = | 60 ExistingUserController* controller = |
61 ExistingUserController::current_controller(); | 61 ExistingUserController::current_controller(); |
62 if (controller) | 62 if (controller) |
63 controller->set_login_status_consumer(NULL); | 63 controller->set_login_status_consumer(NULL); |
64 RemoveIfDone(); | 64 RemoveIfDone(); |
65 } | 65 } |
OLD | NEW |