Index: chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc |
diff --git a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc |
index ce7f8bb1fd5e57fc242523856eb5898ab248d1ba..0b65a89e6d8c45965e6a3a503b77cec50f3ee28a 100644 |
--- a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc |
+++ b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc |
@@ -21,6 +21,7 @@ const char kRequestPowerInfo[] = "requestPowerInfo"; |
// Define update functions that will update the power properties to the |
// variables defined in the web UI. |
const char kUpdateBatteryPercent[] = "updateBatteryPercent"; |
+const char kUpdateBatteryState[] = "updateBatteryState"; |
const char kUpdateExternalPower[] = "updateExternalPower"; |
const char kUpdateTimeToEmpty[] = "updateTimeToEmpty"; |
const char kUpdateTimeToFull[] = "updateTimeToFull"; |
@@ -62,6 +63,19 @@ void DeviceEmulatorMessageHandler::UpdateBatteryPercent( |
fake_power_manager_client_->UpdatePowerProperties(props); |
} |
+void DeviceEmulatorMessageHandler::UpdateBatteryState( |
+ const base::ListValue* args) { |
+ int battery_state; |
+ args->GetInteger(0, &battery_state); |
+ |
+ power_manager::PowerSupplyProperties props = |
+ fake_power_manager_client_->props(); |
+ props.set_battery_state( |
+ static_cast<power_manager::PowerSupplyProperties_BatteryState>( |
+ battery_state)); |
+ fake_power_manager_client_->UpdatePowerProperties(props); |
+} |
+ |
void DeviceEmulatorMessageHandler::UpdateExternalPower( |
const base::ListValue* args) { |
int power_source; |
@@ -102,11 +116,12 @@ void DeviceEmulatorMessageHandler::PowerChanged( |
web_ui()->CallJavascriptFunction( |
kUpdatePowerPropertiesJSCallback, |
base::FundamentalValue(proto.battery_percent()), |
+ base::FundamentalValue(proto.battery_state())), |
base::FundamentalValue(proto.external_power()), |
base::FundamentalValue( |
static_cast<int>(proto.battery_time_to_empty_sec())), |
base::FundamentalValue( |
- static_cast<int>(proto.battery_time_to_full_sec()))); |
+ static_cast<int>(proto.battery_time_to_full_sec())); |
} |
void DeviceEmulatorMessageHandler::RegisterMessages() { |
@@ -119,6 +134,10 @@ void DeviceEmulatorMessageHandler::RegisterMessages() { |
base::Bind(&DeviceEmulatorMessageHandler::UpdateBatteryPercent, |
base::Unretained(this))); |
web_ui()->RegisterMessageCallback( |
+ kUpdateBatteryState, |
+ base::Bind(&DeviceEmulatorMessageHandler::UpdateBatteryState, |
+ base::Unretained(this))); |
+ web_ui()->RegisterMessageCallback( |
kUpdateExternalPower, |
base::Bind(&DeviceEmulatorMessageHandler::UpdateExternalPower, |
base::Unretained(this))); |