widget/gonk/OrientationObserver.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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
     4  *
     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
     8  *
     9  *     http://www.apache.org/licenses/LICENSE-2.0
    10  *
    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.
    16  */
    18 #ifndef OrientationObserver_h
    19 #define OrientationObserver_h
    21 #include "mozilla/Observer.h"
    22 #include "mozilla/dom/ScreenOrientation.h"
    23 #include "mozilla/Scoped.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::ScopedDeletePtr<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;
    69 };
    71 #endif

mercurial