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" |
| 12 |
| 13 namespace ash { |
| 14 |
| 15 SensorManagerDelegate::SensorManagerDelegate() { |
| 16 Shell::GetInstance()->accelerometer_controller()->AddObserver(this); |
| 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)) |
| 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); |
| 39 } |
| 40 |
| 41 } // namespace ash |
OLD | NEW |