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

Side by Side Diff: ash/accelerometer/sensor_manager_delegate.cc

Issue 680383007: DeviceOrientation API on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Isolate Chrome OS changes Created 6 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2014 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 "ash/accelerometer/sensor_manager_delegate.h"
6
7 #include "ash/accelerometer/accelerometer_controller.h"
8 #include "ash/shell.h"
9 #include "content/public/browser/sensor_manager.h"
10 #include "ui/accelerometer/accelerometer_types.h"
11 #include "ui/gfx/geometry/vector3d_f.h"
timvolodine 2014/11/07 03:27:39 is this needed?
jonross 2014/11/07 19:59:37 Nope, will be removed in next patch.
12
13 namespace ash {
14
15 SensorManagerDelegate::SensorManagerDelegate() {
16 Shell::GetInstance()->accelerometer_controller()->AddObserver(this);
timvolodine 2014/11/07 03:27:39 related to comment in shell.cc: unless I am missin
17 }
18
19 SensorManagerDelegate::~SensorManagerDelegate() {
20 Shell::GetInstance()->accelerometer_controller()->RemoveObserver(this);
21 }
22
23 void SensorManagerDelegate::OnAccelerometerUpdated(
24 const ui::AccelerometerUpdate& update) {
25 ui::AccelerometerSource source = ui::ACCELEROMETER_SOURCE_SCREEN;
26
27 if (!update.has(source))
28 source = ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD;
29
30 if (!update.has(source))
flackr 2014/11/07 19:30:46 nit, I think this would be a bit cleaner as an if/
jonross 2014/11/10 22:39:09 Done.
31 return;
32
33 double x = update.get(source).x();
34 double y = update.get(source).y();
35 double z = update.get(source).z();
36
37 content::SensorManager::GetInstance()->OnAccelerationIncludingGravity(x, y,
38 z);
timvolodine 2014/11/07 03:27:39 I think a callback (or maybe shared memory) would
jonross 2014/11/10 22:39:09 Switched to using a callback
39 }
40
41 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698