Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2010 Apple Inc. All rights reserved. | 2 * Copyright 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above copyright | 10 * * Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef DeviceMotionController_h | 27 #ifndef DeviceMotionController_h |
| 28 #define DeviceMotionController_h | 28 #define DeviceMotionController_h |
| 29 | 29 |
| 30 #include "core/page/DeviceController.h" | 30 #include "core/dom/Event.h" |
| 31 #include "core/page/DOMWindow.h" | |
| 32 #include "core/platform/RefCountedSupplement.h" | |
| 33 #include "core/platform/Timer.h" | |
| 34 #include <wtf/HashCountedSet.h> | |
| 31 | 35 |
| 32 namespace WebCore { | 36 namespace WebCore { |
| 33 | 37 |
| 34 class DeviceMotionClient; | |
| 35 class DeviceMotionData; | 38 class DeviceMotionData; |
| 36 | 39 |
| 37 class DeviceMotionController : public DeviceController { | 40 // This class doesn't inherit from DeviceController anymore, which is a temporar y solution. |
| 41 // Once the device orientation switches to the client-less design, move some of the | |
| 42 // methods in this class to the DeviceController. | |
| 43 class DeviceMotionController : public RefCountedSupplement<Page, DeviceMotionCon troller> { | |
| 44 | |
| 38 public: | 45 public: |
| 39 ~DeviceMotionController() { }; | 46 virtual ~DeviceMotionController(); |
| 40 | 47 |
| 41 static PassOwnPtr<DeviceMotionController> create(DeviceMotionClient*); | 48 static PassRefPtr<DeviceMotionController> create(); |
| 42 | 49 |
| 43 void didChangeDeviceMotion(DeviceMotionData*); | 50 void didChangeDeviceMotion(DeviceMotionData*); |
| 44 DeviceMotionClient* deviceMotionClient(); | |
| 45 | 51 |
| 46 virtual bool hasLastData() OVERRIDE; | 52 virtual bool hasLastData(); |
| 47 virtual PassRefPtr<Event> getLastEvent() OVERRIDE; | 53 virtual PassRefPtr<Event> getLastEvent(); |
| 48 | 54 |
| 49 static const char* supplementName(); | 55 static const char* supplementName(); |
| 50 static DeviceMotionController* from(Page*); | 56 static DeviceMotionController* from(Page*); |
| 51 static bool isActiveAt(Page*); | 57 static bool isActiveAt(Page*); |
| 52 | 58 |
| 59 // FIXME move these methods to DeviceController | |
|
abarth-chromium
2013/05/06 17:04:17
FIXME -> FIXME:
timvolodine
2013/05/07 15:40:53
Done.
| |
| 60 void dispatchDeviceEvent(const PassRefPtr<Event>); | |
| 61 bool isActive() { return !m_listeners.isEmpty(); } | |
| 62 | |
| 63 void addDeviceEventListener(DOMWindow*); | |
| 64 void removeDeviceEventListener(DOMWindow*); | |
| 65 void removeAllDeviceEventListeners(DOMWindow*); | |
| 66 | |
| 53 private: | 67 private: |
| 54 explicit DeviceMotionController(DeviceMotionClient*); | 68 DeviceMotionController() : m_timer(this, &DeviceMotionController::fireDevice Event) { } |
| 69 | |
| 70 void startUpdating(); | |
| 71 void stopUpdating(); | |
| 72 void fireDeviceEvent(Timer<DeviceMotionController>*); | |
| 73 void dispatchEventToActiveDocuments(Vector<RefPtr<DOMWindow> >&, const PassR efPtr<Event>); | |
| 74 | |
| 75 HashCountedSet<RefPtr<DOMWindow> > m_listeners; | |
| 76 HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners; | |
| 77 Timer<DeviceMotionController> m_timer; | |
| 55 }; | 78 }; |
| 56 | 79 |
| 80 void provideDeviceMotionTo(Page*); | |
| 81 | |
| 57 } // namespace WebCore | 82 } // namespace WebCore |
| 58 | 83 |
| 59 #endif // DeviceMotionController_h | 84 #endif // DeviceMotionController_h |
| OLD | NEW |