1559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block/* 2559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * Copyright 2010, The Android Open Source Project 3559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * 4559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * Redistribution and use in source and binary forms, with or without 5559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * modification, are permitted provided that the following conditions 6559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * are met: 7559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * * Redistributions of source code must retain the above copyright 8559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * notice, this list of conditions and the following disclaimer. 9559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * * Redistributions in binary form must reproduce the above copyright 10559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * notice, this list of conditions and the following disclaimer in the 11559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * documentation and/or other materials provided with the distribution. 12559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * 13559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 14559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 17559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block */ 25559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 26ce9059cc142923289338127a469177d2eb57579fSteve Block#ifndef DeviceMotionAndOrientationManager_h 27ce9059cc142923289338127a469177d2eb57579fSteve Block#define DeviceMotionAndOrientationManager_h 28559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 2943cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block#include <DeviceMotionData.h> 3043cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block#include <DeviceMotionClient.h> 31a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Block#include <DeviceOrientation.h> 32559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block#include <DeviceOrientationClient.h> 33559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block#include <OwnPtr.h> 34a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Block#include <PassRefPtr.h> 35a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Block#include <RefPtr.h> 36559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 37559136b02c843ca1b495c43291f2e38b991a7e5eSteve Blocknamespace android { 38559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 39a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Blockclass WebViewCore; 40a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Block 4143cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block// This class takes care of the fact that the clients used for DeviceMotion and 4243cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block// DeviceOrientation may be either the real implementations or mocks. It also 4343cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block// handles setting the data on both the real and mock clients. This class is 4443cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block// owned by WebViewCore and exists to keep cruft out of that class. 45ce9059cc142923289338127a469177d2eb57579fSteve Blockclass DeviceMotionAndOrientationManager { 46559136b02c843ca1b495c43291f2e38b991a7e5eSteve Blockpublic: 47ce9059cc142923289338127a469177d2eb57579fSteve Block DeviceMotionAndOrientationManager(WebViewCore*); 48559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 49f6e5bbe8804f63dfb72c5dce1e225a13b85177a7Steve Block void setUseMock(); 5043cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block void setMockMotion(PassRefPtr<WebCore::DeviceMotionData>); 5143cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block void onMotionChange(PassRefPtr<WebCore::DeviceMotionData>); 52559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block void setMockOrientation(PassRefPtr<WebCore::DeviceOrientation>); 53a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Block void onOrientationChange(PassRefPtr<WebCore::DeviceOrientation>); 5443cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block void maybeSuspendClients(); 5543cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block void maybeResumeClients(); 5643cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block WebCore::DeviceMotionClient* motionClient(); 5743cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block WebCore::DeviceOrientationClient* orientationClient(); 58559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 59559136b02c843ca1b495c43291f2e38b991a7e5eSteve Blockprivate: 60559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block bool m_useMock; 61a49e216a2b9e2243bdeb847a5ebb66a0a291b902Steve Block WebViewCore* m_webViewCore; 6243cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block OwnPtr<WebCore::DeviceMotionClient> m_motionClient; 6343cbb6a517664df15ba6cfa5ed9c612ffe92f646Steve Block OwnPtr<WebCore::DeviceOrientationClient> m_orientationClient; 64559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block}; 65559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 66559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block} // namespace android 67559136b02c843ca1b495c43291f2e38b991a7e5eSteve Block 68ce9059cc142923289338127a469177d2eb57579fSteve Block#endif // DeviceMotionAndOrientationManager_h 69