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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (policy_map) { | 201 if (policy_map) { |
202 policy::PolicyMap::const_iterator i; | 202 policy::PolicyMap::const_iterator i; |
203 for (i = policy_map->begin(); i != policy_map->end(); i++) | 203 for (i = policy_map->begin(); i != policy_map->end(); i++) |
204 dict->Set(policy::GetPolicyName(i->first), | 204 dict->Set(policy::GetPolicyName(i->first), |
205 i->second->DeepCopy()); | 205 i->second->DeepCopy()); |
206 } | 206 } |
207 } | 207 } |
208 return dict; | 208 return dict; |
209 } | 209 } |
210 | 210 |
| 211 // Last reported power status. |
| 212 chromeos::PowerSupplyStatus power_status; |
| 213 |
211 } // namespace | 214 } // namespace |
212 | 215 |
213 void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, | 216 void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, |
214 IPC::Message* reply_message) { | 217 IPC::Message* reply_message) { |
215 AutomationJSONReply reply(this, reply_message); | 218 AutomationJSONReply reply(this, reply_message); |
216 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 219 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
217 | 220 |
218 const UserManager* user_manager = UserManager::Get(); | 221 const UserManager* user_manager = UserManager::Get(); |
219 if (!user_manager) | 222 if (!user_manager) |
220 reply.SendError("No user manager!"); | 223 reply.SendError("No user manager!"); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // session manager then we'll die when the session is stopped. | 338 // session manager then we'll die when the session is stopped. |
336 reply.SendSuccess(NULL); | 339 reply.SendSuccess(NULL); |
337 screen_locker->Signout(); | 340 screen_locker->Signout(); |
338 } | 341 } |
339 | 342 |
340 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, | 343 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, |
341 IPC::Message* reply_message) { | 344 IPC::Message* reply_message) { |
342 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 345 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
343 return; | 346 return; |
344 | 347 |
345 chromeos::PowerLibrary* power_library = CrosLibrary::Get()->GetPowerLibrary(); | |
346 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 348 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
347 | 349 |
348 return_value->SetBoolean("battery_is_present", | 350 return_value->SetBoolean("battery_is_present", |
349 power_library->IsBatteryPresent()); | 351 power_status.battery_is_present); |
350 return_value->SetBoolean("line_power_on", power_library->IsLinePowerOn()); | 352 return_value->SetBoolean("line_power_on", power_status.line_power_on); |
351 if (power_library->IsBatteryPresent()) { | 353 if (power_status.battery_is_present) { |
352 return_value->SetBoolean("battery_fully_charged", | 354 return_value->SetBoolean("battery_fully_charged", |
353 power_library->IsBatteryFullyCharged()); | 355 power_status.battery_is_full); |
354 return_value->SetDouble("battery_percentage", | 356 return_value->SetDouble("battery_percentage", |
355 power_library->GetBatteryPercentage()); | 357 power_status.battery_percentage); |
356 if (power_library->IsLinePowerOn()) { | 358 if (power_status.line_power_on) { |
357 int time = power_library->GetBatteryTimeToFull().InSeconds(); | 359 int64 time = power_status.battery_seconds_to_full; |
358 if (time > 0 || power_library->IsBatteryFullyCharged()) | 360 if (time > 0 || power_status.battery_is_full) |
359 return_value->SetInteger("battery_time_to_full", time); | 361 return_value->SetInteger("battery_seconds_to_full", time); |
360 } else { | 362 } else { |
361 int time = power_library->GetBatteryTimeToEmpty().InSeconds(); | 363 int64 time = power_status.battery_seconds_to_empty; |
362 if (time > 0) | 364 if (time > 0) |
363 return_value->SetInteger("battery_time_to_empty", time); | 365 return_value->SetInteger("battery_seconds_to_empty", time); |
364 } | 366 } |
365 } | 367 } |
366 | 368 |
367 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 369 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
368 } | 370 } |
369 | 371 |
370 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, | 372 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, |
371 IPC::Message* reply_message) { | 373 IPC::Message* reply_message) { |
372 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 374 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
373 return; | 375 return; |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1196 |
1195 // Set up an observer (it will delete itself). | 1197 // Set up an observer (it will delete itself). |
1196 take_photo_dialog->AddObserver(new PhotoCaptureObserver( | 1198 take_photo_dialog->AddObserver(new PhotoCaptureObserver( |
1197 this, reply_message)); | 1199 this, reply_message)); |
1198 | 1200 |
1199 views::Widget* window = browser::CreateViewsWindow( | 1201 views::Widget* window = browser::CreateViewsWindow( |
1200 browser->window()->GetNativeHandle(), take_photo_dialog); | 1202 browser->window()->GetNativeHandle(), take_photo_dialog); |
1201 window->SetAlwaysOnTop(true); | 1203 window->SetAlwaysOnTop(true); |
1202 window->Show(); | 1204 window->Show(); |
1203 } | 1205 } |
| 1206 |
| 1207 void TestingAutomationProvider::PowerChanged( |
| 1208 const chromeos::PowerSupplyStatus& status) { |
| 1209 power_status = status; |
| 1210 } |
OLD | NEW |