Index: content/browser/power_monitor_message_broadcaster.cc |
diff --git a/content/browser/power_monitor_message_broadcaster.cc b/content/browser/power_monitor_message_broadcaster.cc |
index 23de161b05c7225af72b1efb3dcd45c8545c879f..e862abbfe74be316fddce4b8adcfc0761d24b422 100644 |
--- a/content/browser/power_monitor_message_broadcaster.cc |
+++ b/content/browser/power_monitor_message_broadcaster.cc |
@@ -24,6 +24,13 @@ PowerMonitorMessageBroadcaster::~PowerMonitorMessageBroadcaster() { |
power_monitor->RemoveObserver(this); |
} |
+void PowerMonitorMessageBroadcaster::Init() { |
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
+ // Unit tests does not initialize the PowerMonitor. |
+ if (power_monitor) |
+ OnPowerStateChange(power_monitor->IsOnBatteryPower()); |
+} |
+ |
void PowerMonitorMessageBroadcaster::OnPowerStateChange(bool on_battery_power) { |
sender_->Send(new PowerMonitorMsg_PowerStateChange(on_battery_power)); |
} |