Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2010, The Android Open Source Project | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | |
| 4 * | 3 * |
| 5 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions are |
| 7 * are met: | 6 * met: |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | 7 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 8 * * Redistributions of source code must retain the above copyright |
| 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 9 * notice, this list of conditions and the following disclaimer. |
| 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 10 * * Redistributions in binary form must reproduce the above |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 11 * copyright notice, this list of conditions and the following disclaimer |
| 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 12 * in the documentation and/or other materials provided with the |
| 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 13 * distribution. |
| 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 14 * * Neither the name of Google Inc. nor the names of its |
| 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 15 * contributors may be used to endorse or promote products derived from |
| 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 16 * this software without specific prior written permission. |
| 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 17 * |
| 24 * THE POSSIBILITY OF SUCH DAMAGE. | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 */ | 29 */ |
|
Peter Beverloo
2013/04/09 17:29:53
We can't just change the copyright header and this
timvolodine
2013/04/10 19:06:12
Done.
| |
| 26 | 30 |
| 27 #ifndef DeviceController_h | 31 #ifndef DeviceController_h |
| 28 #define DeviceController_h | 32 #define DeviceController_h |
| 29 | 33 |
| 30 #include "DOMWindow.h" | 34 #include "DOMWindow.h" |
| 31 #include "Event.h" | 35 #include "Event.h" |
| 32 #include "Supplementable.h" | 36 #include "Supplementable.h" |
| 33 #include "Timer.h" | 37 #include "Timer.h" |
| 34 #include <wtf/HashCountedSet.h> | 38 #include <wtf/HashCountedSet.h> |
| 35 | 39 |
| 36 namespace WebCore { | 40 namespace WebCore { |
| 37 | 41 |
| 38 class DeviceClient; | 42 class DeviceClient; |
| 39 class Page; | 43 class Page; |
| 40 | 44 |
| 41 class DeviceController : public Supplement<Page> { | 45 class DeviceController : public Supplement<Page> { |
| 42 public: | 46 public: |
| 47 // FIXME(timvolodine): remove this constructor and all references to DeviceC lient | |
|
Peter Beverloo
2013/04/09 17:29:53
nit: FIXMEs in WebKit code are unattributed.
timvolodine
2013/04/10 19:06:12
Done.
| |
| 48 // once the device orientation is switched to platform implementation. | |
| 43 explicit DeviceController(DeviceClient*); | 49 explicit DeviceController(DeviceClient*); |
| 44 ~DeviceController() { } | 50 ~DeviceController() { } |
| 45 | 51 |
| 46 void addDeviceEventListener(DOMWindow*); | 52 void addDeviceEventListener(DOMWindow*); |
| 47 void removeDeviceEventListener(DOMWindow*); | 53 void removeDeviceEventListener(DOMWindow*); |
| 48 void removeAllDeviceEventListeners(DOMWindow*); | 54 void removeAllDeviceEventListeners(DOMWindow*); |
| 49 | 55 |
| 50 void dispatchDeviceEvent(PassRefPtr<Event>); | 56 void dispatchDeviceEvent(PassRefPtr<Event>); |
| 51 bool isActive() { return !m_listeners.isEmpty(); } | 57 bool isActive() { return !m_listeners.isEmpty(); } |
| 52 DeviceClient* client() { return m_client; } | 58 DeviceClient* client() { return m_client; } |
| 53 | 59 |
| 54 virtual bool hasLastData() { return false; } | 60 virtual bool hasLastData() { return false; } |
| 55 virtual PassRefPtr<Event> getLastEvent() { return 0; } | 61 virtual PassRefPtr<Event> getLastEvent() { return 0; } |
| 56 | 62 |
| 57 protected: | 63 protected: |
| 64 DeviceController() : m_timer(this, &DeviceController::fireDeviceEvent) { } | |
|
Peter Beverloo
2013/04/09 17:29:53
Do we have any static analysis tools which may ass
timvolodine
2013/04/10 19:06:12
ok I've added init to null
| |
| 58 void fireDeviceEvent(Timer<DeviceController>*); | 65 void fireDeviceEvent(Timer<DeviceController>*); |
| 59 | 66 |
| 60 HashCountedSet<RefPtr<DOMWindow> > m_listeners; | 67 HashCountedSet<RefPtr<DOMWindow> > m_listeners; |
| 61 HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners; | 68 HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners; |
| 62 DeviceClient* m_client; | 69 DeviceClient* m_client; |
| 63 Timer<DeviceController> m_timer; | 70 Timer<DeviceController> m_timer; |
| 64 }; | 71 }; |
| 65 | 72 |
| 66 } // namespace WebCore | 73 } // namespace WebCore |
| 67 | 74 |
| 68 #endif // DeviceController_h | 75 #endif // DeviceController_h |
| OLD | NEW |