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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/automation/automation_provider_json.h" | 8 #include "chrome/browser/automation/automation_provider_json.h" |
9 #include "chrome/browser/automation/automation_provider_observers.h" | 9 #include "chrome/browser/automation/automation_provider_observers.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
11 #include "chrome/browser/chromeos/cros/network_library.h" | 11 #include "chrome/browser/chromeos/cros/network_library.h" |
12 #include "chrome/browser/chromeos/cros/power_library.h" | |
12 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | 13 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
13 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 14 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
14 #include "chrome/browser/chromeos/login/screen_locker.h" | 15 #include "chrome/browser/chromeos/login/screen_locker.h" |
15 | 16 |
16 using chromeos::CrosLibrary; | 17 using chromeos::CrosLibrary; |
17 using chromeos::NetworkLibrary; | 18 using chromeos::NetworkLibrary; |
18 using chromeos::UserManager; | 19 using chromeos::UserManager; |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 "No default screen locker. Are you sure the screen is locked?"); | 117 "No default screen locker. Are you sure the screen is locked?"); |
117 return; | 118 return; |
118 } | 119 } |
119 | 120 |
120 // Send success before stopping session because if we're a child of | 121 // Send success before stopping session because if we're a child of |
121 // session manager then we'll die when the session is stopped. | 122 // session manager then we'll die when the session is stopped. |
122 reply.SendSuccess(NULL); | 123 reply.SendSuccess(NULL); |
123 screen_locker->Signout(); | 124 screen_locker->Signout(); |
124 } | 125 } |
125 | 126 |
127 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, | |
128 IPC::Message* reply_message) { | |
129 AutomationJSONReply reply(this, reply_message); | |
130 | |
131 if (!CrosLibrary::Get()->EnsureLoaded()) { | |
132 reply.SendError("Could not load cros library."); | |
133 return; | |
134 } | |
135 | |
136 chromeos::PowerLibrary* power_library = CrosLibrary::Get()->GetPowerLibrary(); | |
137 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | |
138 | |
139 return_value->SetBoolean("battery", power_library->battery_is_present()); | |
Nirnimesh
2011/03/29 01:29:39
Match the key string with the function name as muc
dtu
2011/03/29 02:21:22
Done.
| |
140 return_value->SetBoolean("line_power", power_library->line_power_on()); | |
141 return_value->SetBoolean("charged", power_library->battery_fully_charged()); | |
142 return_value->SetDouble("percentage", power_library->battery_percentage()); | |
143 return_value->SetInteger("time_left", | |
144 power_library->line_power_on() ? | |
145 power_library->battery_time_to_full().InSeconds() : | |
146 power_library->battery_time_to_empty().InSeconds()); | |
147 | |
148 reply.SendSuccess(return_value.get()); | |
149 } | |
150 | |
126 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, | 151 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, |
127 IPC::Message* reply_message) { | 152 IPC::Message* reply_message) { |
128 AutomationJSONReply reply(this, reply_message); | 153 AutomationJSONReply reply(this, reply_message); |
129 | 154 |
130 if (!CrosLibrary::Get()->EnsureLoaded()) { | 155 if (!CrosLibrary::Get()->EnsureLoaded()) { |
131 reply.SendError("Could not load cros library."); | 156 reply.SendError("Could not load cros library."); |
132 return; | 157 return; |
133 } | 158 } |
134 | 159 |
135 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 160 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 chromeos::WifiNetwork* wifi = | 293 chromeos::WifiNetwork* wifi = |
269 network_library->FindWifiNetworkByPath(service_path); | 294 network_library->FindWifiNetworkByPath(service_path); |
270 if (!wifi) { | 295 if (!wifi) { |
271 reply.SendError("No network found with specified service path."); | 296 reply.SendError("No network found with specified service path."); |
272 return; | 297 return; |
273 } | 298 } |
274 | 299 |
275 network_library->DisconnectFromWirelessNetwork(wifi); | 300 network_library->DisconnectFromWirelessNetwork(wifi); |
276 reply.SendSuccess(NULL); | 301 reply.SendSuccess(NULL); |
277 } | 302 } |
OLD | NEW |