Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: content/renderer/battery_status_dispatcher.cc

Issue 10024013: chromeos: Add support for the battery status API on chromeos. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/battery_status_dispatcher.h"
6
7 #include "base/pickle.h"
8 #include "content/common/battery_status_messages.h"
9 #include "content/renderer/render_view_impl.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBatteryStatus.h"
11
12 namespace content {
13
14 BatteryStatusDispatcher::BatteryStatusDispatcher(RenderViewImpl* render_view)
15 : RenderViewObserver(render_view),
16 started_(false) {
17 }
18
19 BatteryStatusDispatcher::~BatteryStatusDispatcher() {
20 if (started_)
21 stopUpdating();
22 }
23
24 bool BatteryStatusDispatcher::OnMessageReceived(const IPC::Message& msg) {
25 bool handled = true;
26 IPC_BEGIN_MESSAGE_MAP(BatteryStatusDispatcher, msg)
27 IPC_MESSAGE_HANDLER(BatteryStatusMsg_Updated, OnBatteryStatusUpdated)
28 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP()
30 return handled;
31 }
32
33 void BatteryStatusDispatcher::startUpdating() {
34 Send(new BatteryStatusHostMsg_StartUpdating(routing_id()));
35 started_ = true;
36 }
37
38 void BatteryStatusDispatcher::stopUpdating() {
39 Send(new BatteryStatusHostMsg_StopUpdating(routing_id()));
40 started_ = false;
41 }
42
43 void BatteryStatusDispatcher::OnBatteryStatusUpdated(
44 const WebKit::WebBatteryStatus& battery_status) {
45 render_view()->GetWebView()->updateBatteryStatus(battery_status);
46 }
47
48 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698