Chromium Code Reviews| Index: ash/accelerometer/sensor_manager_delegate.cc |
| diff --git a/ash/accelerometer/sensor_manager_delegate.cc b/ash/accelerometer/sensor_manager_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8ec4ec910f6367d56f8b9af91cd7b2addd0e1bbc |
| --- /dev/null |
| +++ b/ash/accelerometer/sensor_manager_delegate.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/accelerometer/sensor_manager_delegate.h" |
| + |
| +#include "ash/accelerometer/accelerometer_controller.h" |
| +#include "ash/shell.h" |
| +#include "content/public/browser/sensor_manager.h" |
| +#include "ui/accelerometer/accelerometer_types.h" |
| +#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.
|
| + |
| +namespace ash { |
| + |
| +SensorManagerDelegate::SensorManagerDelegate() { |
| + Shell::GetInstance()->accelerometer_controller()->AddObserver(this); |
|
timvolodine
2014/11/07 03:27:39
related to comment in shell.cc:
unless I am missin
|
| +} |
| + |
| +SensorManagerDelegate::~SensorManagerDelegate() { |
| + Shell::GetInstance()->accelerometer_controller()->RemoveObserver(this); |
| +} |
| + |
| +void SensorManagerDelegate::OnAccelerometerUpdated( |
| + const ui::AccelerometerUpdate& update) { |
| + ui::AccelerometerSource source = ui::ACCELEROMETER_SOURCE_SCREEN; |
| + |
| + if (!update.has(source)) |
| + source = ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD; |
| + |
| + 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.
|
| + return; |
| + |
| + double x = update.get(source).x(); |
| + double y = update.get(source).y(); |
| + double z = update.get(source).z(); |
| + |
| + content::SensorManager::GetInstance()->OnAccelerationIncludingGravity(x, y, |
| + 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
|
| +} |
| + |
| +} // namespace ash |