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

Side by Side Diff: chrome/renderer/device_orientation_dispatcher.cc

Issue 2858049: Chromium plumbing for Device Orientation. (Closed)
Patch Set: Fixes after try bot runs Created 10 years, 4 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
« no previous file with comments | « chrome/renderer/device_orientation_dispatcher.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 "chrome/renderer/device_orientation_dispatcher.h"
6
7 #include "chrome/renderer/render_view.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientation.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientationControll er.h"
10
11 DeviceOrientationDispatcher::DeviceOrientationDispatcher(
12 RenderView* render_view)
13 : render_view_(render_view),
14 controller_(NULL),
15 started_(false) {
16 }
17
18 DeviceOrientationDispatcher::~DeviceOrientationDispatcher() {
19 if (started_)
20 stopUpdating();
21 }
22
23 bool DeviceOrientationDispatcher::OnMessageReceived(const IPC::Message& msg) {
24 bool handled = true;
25 IPC_BEGIN_MESSAGE_MAP(DeviceOrientationDispatcher, msg)
26 IPC_MESSAGE_HANDLER(ViewMsg_DeviceOrientationUpdated,
27 OnDeviceOrientationUpdated)
28 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP()
30 return handled;
31 }
32
33 void DeviceOrientationDispatcher::setController(
34 WebKit::WebDeviceOrientationController* controller) {
35 controller_.reset(controller);
36 }
37
38 void DeviceOrientationDispatcher::startUpdating() {
39 render_view_->Send(new ViewHostMsg_DeviceOrientation_StartUpdating(
40 render_view_->routing_id()));
41 started_ = true;
42 }
43
44 void DeviceOrientationDispatcher::stopUpdating() {
45 render_view_->Send(new ViewHostMsg_DeviceOrientation_StopUpdating(
46 render_view_->routing_id()));
47 started_ = false;
48 }
49
50 WebKit::WebDeviceOrientation DeviceOrientationDispatcher::lastOrientation()
51 const {
52 if (!last_update_.get())
53 return WebKit::WebDeviceOrientation::nullOrientation();
54
55 return WebKit::WebDeviceOrientation(last_update_->can_provide_alpha,
56 last_update_->alpha,
57 last_update_->can_provide_beta,
58 last_update_->beta,
59 last_update_->can_provide_gamma,
60 last_update_->gamma);
61 }
62
63 void DeviceOrientationDispatcher::OnDeviceOrientationUpdated(
64 const ViewMsg_DeviceOrientationUpdated_Params& p) {
65 last_update_.reset(new ViewMsg_DeviceOrientationUpdated_Params(p));
66
67 WebKit::WebDeviceOrientation orientation(p.can_provide_alpha, p.alpha,
68 p.can_provide_beta, p.beta,
69 p.can_provide_gamma, p.gamma);
70
71 controller_->didChangeDeviceOrientation(orientation);
72 }
OLDNEW
« no previous file with comments | « chrome/renderer/device_orientation_dispatcher.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698