Bumping manifests a=b2g-bump
[gecko.git] / widget / gonk / OrientationObserver.h
blob4467daf2e69c1be38773737a1fe463118dafa878
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et ft=cpp : */
3 /* Copyright 2012 Mozilla Foundation and Mozilla contributors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef OrientationObserver_h
19 #define OrientationObserver_h
21 #include "mozilla/Observer.h"
22 #include "mozilla/dom/ScreenOrientation.h"
23 #include "mozilla/UniquePtr.h"
25 namespace mozilla {
26 class ProcessOrientation;
27 namespace hal {
28 class SensorData;
29 typedef mozilla::Observer<SensorData> ISensorObserver;
30 } // namespace hal
31 } // namespace mozilla
33 using mozilla::hal::ISensorObserver;
34 using mozilla::hal::SensorData;
35 using mozilla::dom::ScreenOrientation;
37 class OrientationObserver : public ISensorObserver {
38 public:
39 OrientationObserver();
40 ~OrientationObserver();
42 // Call DisableAutoOrientation on the existing OrientatiOnobserver singleton,
43 // if it exists. If no OrientationObserver exists, do nothing.
44 static void ShutDown();
46 // Notification from sensor.
47 void Notify(const SensorData& aSensorData);
49 // Methods to enable/disable automatic orientation.
50 void EnableAutoOrientation();
51 void DisableAutoOrientation();
53 // Methods called by methods in hal_impl namespace.
54 bool LockScreenOrientation(ScreenOrientation aOrientation);
55 void UnlockScreenOrientation();
57 static OrientationObserver* GetInstance();
59 private:
60 bool mAutoOrientationEnabled;
61 uint32_t mAllowedOrientations;
62 mozilla::UniquePtr<mozilla::ProcessOrientation> mOrientation;
64 static const uint32_t sDefaultOrientations =
65 mozilla::dom::eScreenOrientation_PortraitPrimary |
66 mozilla::dom::eScreenOrientation_PortraitSecondary |
67 mozilla::dom::eScreenOrientation_LandscapePrimary |
68 mozilla::dom::eScreenOrientation_LandscapeSecondary;
71 #endif