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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } // namespace | 211 } // namespace |
212 | 212 |
| 213 void TestingAutomationProvider::PowerChanged( |
| 214 const chromeos::PowerSupplyStatus& status) { |
| 215 power_status_ = status; |
| 216 } |
| 217 |
213 void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, | 218 void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, |
214 IPC::Message* reply_message) { | 219 IPC::Message* reply_message) { |
215 AutomationJSONReply reply(this, reply_message); | 220 AutomationJSONReply reply(this, reply_message); |
216 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 221 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
217 | 222 |
218 const UserManager* user_manager = UserManager::Get(); | 223 const UserManager* user_manager = UserManager::Get(); |
219 if (!user_manager) | 224 if (!user_manager) |
220 reply.SendError("No user manager!"); | 225 reply.SendError("No user manager!"); |
221 const chromeos::ScreenLocker* screen_locker = | 226 const chromeos::ScreenLocker* screen_locker = |
222 chromeos::ScreenLocker::default_screen_locker(); | 227 chromeos::ScreenLocker::default_screen_locker(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // session manager then we'll die when the session is stopped. | 340 // session manager then we'll die when the session is stopped. |
336 reply.SendSuccess(NULL); | 341 reply.SendSuccess(NULL); |
337 screen_locker->Signout(); | 342 screen_locker->Signout(); |
338 } | 343 } |
339 | 344 |
340 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, | 345 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, |
341 IPC::Message* reply_message) { | 346 IPC::Message* reply_message) { |
342 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 347 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
343 return; | 348 return; |
344 | 349 |
345 chromeos::PowerLibrary* power_library = CrosLibrary::Get()->GetPowerLibrary(); | |
346 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 350 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
347 | 351 |
348 return_value->SetBoolean("battery_is_present", | 352 return_value->SetBoolean("battery_is_present", |
349 power_library->IsBatteryPresent()); | 353 power_status_.battery_is_present); |
350 return_value->SetBoolean("line_power_on", power_library->IsLinePowerOn()); | 354 return_value->SetBoolean("line_power_on", power_status_.line_power_on); |
351 if (power_library->IsBatteryPresent()) { | 355 if (power_status_.battery_is_present) { |
352 return_value->SetBoolean("battery_fully_charged", | 356 return_value->SetBoolean("battery_fully_charged", |
353 power_library->IsBatteryFullyCharged()); | 357 power_status_.battery_is_full); |
354 return_value->SetDouble("battery_percentage", | 358 return_value->SetDouble("battery_percentage", |
355 power_library->GetBatteryPercentage()); | 359 power_status_.battery_percentage); |
356 if (power_library->IsLinePowerOn()) { | 360 if (power_status_.line_power_on) { |
357 int time = power_library->GetBatteryTimeToFull().InSeconds(); | 361 int64 time = power_status_.battery_time_to_full; |
358 if (time > 0 || power_library->IsBatteryFullyCharged()) | 362 if (time > 0 || power_status_.battery_is_full) |
359 return_value->SetInteger("battery_time_to_full", time); | 363 return_value->SetInteger("battery_time_to_full", time); |
360 } else { | 364 } else { |
361 int time = power_library->GetBatteryTimeToEmpty().InSeconds(); | 365 int64 time = power_status_.battery_time_to_empty; |
362 if (time > 0) | 366 if (time > 0) |
363 return_value->SetInteger("battery_time_to_empty", time); | 367 return_value->SetInteger("battery_time_to_empty", time); |
364 } | 368 } |
365 } | 369 } |
366 | 370 |
367 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 371 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
368 } | 372 } |
369 | 373 |
370 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, | 374 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, |
371 IPC::Message* reply_message) { | 375 IPC::Message* reply_message) { |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1198 |
1195 // Set up an observer (it will delete itself). | 1199 // Set up an observer (it will delete itself). |
1196 take_photo_dialog->AddObserver(new PhotoCaptureObserver( | 1200 take_photo_dialog->AddObserver(new PhotoCaptureObserver( |
1197 this, reply_message)); | 1201 this, reply_message)); |
1198 | 1202 |
1199 views::Widget* window = browser::CreateViewsWindow( | 1203 views::Widget* window = browser::CreateViewsWindow( |
1200 browser->window()->GetNativeHandle(), take_photo_dialog); | 1204 browser->window()->GetNativeHandle(), take_photo_dialog); |
1201 window->SetAlwaysOnTop(true); | 1205 window->SetAlwaysOnTop(true); |
1202 window->Show(); | 1206 window->Show(); |
1203 } | 1207 } |
OLD | NEW |