Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |