OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/automation/automation_provider.h" | 8 #include "chrome/browser/automation/automation_provider.h" |
9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
10 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 10 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 LoginObserver::LoginObserver(chromeos::ExistingUserController* controller, | 45 LoginObserver::LoginObserver(chromeos::ExistingUserController* controller, |
46 AutomationProvider* automation, | 46 AutomationProvider* automation, |
47 IPC::Message* reply_message) | 47 IPC::Message* reply_message) |
48 : controller_(controller), | 48 : controller_(controller), |
49 automation_(automation->AsWeakPtr()), | 49 automation_(automation->AsWeakPtr()), |
50 reply_message_(reply_message) { | 50 reply_message_(reply_message) { |
51 controller_->set_login_status_consumer(this); | 51 controller_->set_login_status_consumer(this); |
52 registrar_.Add(this, NotificationType::LOAD_STOP, | 52 registrar_.Add(this, chrome::LOAD_STOP, |
53 NotificationService::AllSources()); | 53 NotificationService::AllSources()); |
54 } | 54 } |
55 | 55 |
56 LoginObserver::~LoginObserver() { | 56 LoginObserver::~LoginObserver() { |
57 controller_->set_login_status_consumer(NULL); | 57 controller_->set_login_status_consumer(NULL); |
58 } | 58 } |
59 | 59 |
60 void LoginObserver::OnLoginFailure(const chromeos::LoginFailure& error) { | 60 void LoginObserver::OnLoginFailure(const chromeos::LoginFailure& error) { |
61 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 61 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
62 return_value->SetString("error_string", error.GetErrorString()); | 62 return_value->SetString("error_string", error.GetErrorString()); |
63 AutomationJSONReply(automation_, reply_message_.release()) | 63 AutomationJSONReply(automation_, reply_message_.release()) |
64 .SendSuccess(return_value.get()); | 64 .SendSuccess(return_value.get()); |
65 delete this; | 65 delete this; |
66 } | 66 } |
67 | 67 |
68 void LoginObserver::OnLoginSuccess( | 68 void LoginObserver::OnLoginSuccess( |
69 const std::string& username, | 69 const std::string& username, |
70 const std::string& password, | 70 const std::string& password, |
71 const GaiaAuthConsumer::ClientLoginResult& credentials, | 71 const GaiaAuthConsumer::ClientLoginResult& credentials, |
72 bool pending_requests) { | 72 bool pending_requests) { |
73 controller_->set_login_status_consumer(NULL); | 73 controller_->set_login_status_consumer(NULL); |
74 } | 74 } |
75 | 75 |
76 void LoginObserver::Observe(NotificationType type, | 76 void LoginObserver::Observe(int type, |
77 const NotificationSource& source, | 77 const NotificationSource& source, |
78 const NotificationDetails& details) { | 78 const NotificationDetails& details) { |
79 AutomationJSONReply(automation_, reply_message_.release()).SendSuccess(NULL); | 79 AutomationJSONReply(automation_, reply_message_.release()).SendSuccess(NULL); |
80 delete this; | 80 delete this; |
81 } | 81 } |
82 | 82 |
83 ScreenLockUnlockObserver::ScreenLockUnlockObserver( | 83 ScreenLockUnlockObserver::ScreenLockUnlockObserver( |
84 AutomationProvider* automation, | 84 AutomationProvider* automation, |
85 IPC::Message* reply_message, | 85 IPC::Message* reply_message, |
86 bool lock_screen) | 86 bool lock_screen) |
87 : automation_(automation->AsWeakPtr()), | 87 : automation_(automation->AsWeakPtr()), |
88 reply_message_(reply_message), | 88 reply_message_(reply_message), |
89 lock_screen_(lock_screen) { | 89 lock_screen_(lock_screen) { |
90 registrar_.Add(this, NotificationType::SCREEN_LOCK_STATE_CHANGED, | 90 registrar_.Add(this, chrome::SCREEN_LOCK_STATE_CHANGED, |
91 NotificationService::AllSources()); | 91 NotificationService::AllSources()); |
92 } | 92 } |
93 | 93 |
94 ScreenLockUnlockObserver::~ScreenLockUnlockObserver() {} | 94 ScreenLockUnlockObserver::~ScreenLockUnlockObserver() {} |
95 | 95 |
96 void ScreenLockUnlockObserver::Observe(NotificationType type, | 96 void ScreenLockUnlockObserver::Observe(int type, |
97 const NotificationSource& source, | 97 const NotificationSource& source, |
98 const NotificationDetails& details) { | 98 const NotificationDetails& details) { |
99 DCHECK(type == NotificationType::SCREEN_LOCK_STATE_CHANGED); | 99 DCHECK(type == chrome::SCREEN_LOCK_STATE_CHANGED); |
100 if (automation_) { | 100 if (automation_) { |
101 AutomationJSONReply reply(automation_, reply_message_.release()); | 101 AutomationJSONReply reply(automation_, reply_message_.release()); |
102 bool is_screen_locked = *Details<bool>(details).ptr(); | 102 bool is_screen_locked = *Details<bool>(details).ptr(); |
103 if (lock_screen_ == is_screen_locked) | 103 if (lock_screen_ == is_screen_locked) |
104 reply.SendSuccess(NULL); | 104 reply.SendSuccess(NULL); |
105 else | 105 else |
106 reply.SendError("Screen lock failure."); | 106 reply.SendError("Screen lock failure."); |
107 } | 107 } |
108 delete this; | 108 delete this; |
109 } | 109 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 const chromeos::WifiNetworkVector& wifi_networks = | 279 const chromeos::WifiNetworkVector& wifi_networks = |
280 network_library->wifi_networks(); | 280 network_library->wifi_networks(); |
281 for (chromeos::WifiNetworkVector::const_iterator iter = wifi_networks.begin(); | 281 for (chromeos::WifiNetworkVector::const_iterator iter = wifi_networks.begin(); |
282 iter != wifi_networks.end(); ++iter) { | 282 iter != wifi_networks.end(); ++iter) { |
283 const chromeos::WifiNetwork* wifi = *iter; | 283 const chromeos::WifiNetwork* wifi = *iter; |
284 if (wifi->name() == ssid_) | 284 if (wifi->name() == ssid_) |
285 return wifi; | 285 return wifi; |
286 } | 286 } |
287 return NULL; | 287 return NULL; |
288 } | 288 } |
OLD | NEW |