diff options
author | Steve Block <steveblock@google.com> | 2010-08-02 10:30:48 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-08-05 12:32:39 +0100 |
commit | 9e0be7261c268a89a8e318e9fc8534a8092d9e63 (patch) | |
tree | 0a4a4a3f2dc84a211a290a85ab6a782a51bfeb98 | |
parent | fe45d90a3acac116778548c44389e1110f5337ba (diff) | |
download | external_webkit-9e0be7261c268a89a8e318e9fc8534a8092d9e63.zip external_webkit-9e0be7261c268a89a8e318e9fc8534a8092d9e63.tar.gz external_webkit-9e0be7261c268a89a8e318e9fc8534a8092d9e63.tar.bz2 |
Implement DeviceOrientationClientAndroid
This class acts simply as a proxy to the real or mock client, which is owned by
the WebView. DEVICE_ORIENTATION is eabled on Android, so we must implement the
client before we pull in http://trac.webkit.org/changeset/64356, which calls
DeviceOrientationClient::setController() from the Page constructor.
Change-Id: Ie21957249e5bef7a58c51205732f4fb1b82fbbd3
-rw-r--r-- | WebKit/Android.mk | 1 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp | 76 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.h | 64 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 10 |
4 files changed, 149 insertions, 2 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk index ce72d65..3303370 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -19,6 +19,7 @@ LOCAL_SRC_FILES := \ android/WebCoreSupport/CachedFramePlatformDataAndroid.cpp \ android/WebCoreSupport/ChromeClientAndroid.cpp \ android/WebCoreSupport/ContextMenuClientAndroid.cpp \ + android/WebCoreSupport/DeviceOrientationClientAndroid.cpp \ android/WebCoreSupport/DragClientAndroid.cpp \ android/WebCoreSupport/EditorClientAndroid.cpp \ android/WebCoreSupport/FrameLoaderClientAndroid.cpp \ diff --git a/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp b/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp new file mode 100644 index 0000000..52923fd --- /dev/null +++ b/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DeviceOrientationClientAndroid.h" + +using namespace WebCore; + +namespace android { + +DeviceOrientationClientAndroid::DeviceOrientationClientAndroid() + : m_client(0) +{ +} + +void DeviceOrientationClientAndroid::setWebViewCore(WebViewCore* webViewCore) +{ + m_webViewCore = webViewCore; + ASSERT(m_webViewCore); +} + +void DeviceOrientationClientAndroid::setController(DeviceOrientationController* controller) +{ + // This will be called by the Page constructor before the WebViewCore + // has been configured regarding the mock. We cache the controller for + // later use. + m_controller = controller; + ASSERT(m_controller); +} + +void DeviceOrientationClientAndroid::startUpdating() +{ + client()->startUpdating(); +} + +void DeviceOrientationClientAndroid::stopUpdating() +{ + client()->stopUpdating(); +} + +DeviceOrientation* DeviceOrientationClientAndroid::lastOrientation() const +{ + return client()->lastOrientation(); +} + +DeviceOrientationClient* DeviceOrientationClientAndroid::client() const +{ + if (!m_client) { + // TODO: Get the client from the WebViewCore and set its controller. + } + return m_client; +} + +} // namespace android diff --git a/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.h b/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.h new file mode 100644 index 0000000..cc55cb8 --- /dev/null +++ b/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.h @@ -0,0 +1,64 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DeviceOrientationClientAndroid_h +#define DeviceOrientationClientAndroid_h + +#include <DeviceOrientationClient.h> + +namespace WebCore { +class DeviceOrientationController; +} + +namespace android { + +class WebViewCore; + +// The Android implementation of DeviceOrientationClient. Acts as a proxy to +// the real or mock impl, which is owned by the WebViewCore. +class DeviceOrientationClientAndroid : public WebCore::DeviceOrientationClient { +public: + DeviceOrientationClientAndroid(); + + void setWebViewCore(WebViewCore*); + + // DeviceOrientationClient methods + virtual void setController(WebCore::DeviceOrientationController*); + virtual void startUpdating(); + virtual void stopUpdating(); + virtual WebCore::DeviceOrientation* lastOrientation() const; + +private: + WebCore::DeviceOrientationClient* client() const; + + WebViewCore* m_webViewCore; + WebCore::DeviceOrientationController* m_controller; + // Lazily obtained cache of the client owned by the WebViewCore. + mutable WebCore::DeviceOrientationClient* m_client; +}; + +} // namespace android + +#endif // DeviceOrientationClientAndroid_h diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 254a516..c81bead 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -35,6 +35,7 @@ #include "Chrome.h" #include "ChromeClientAndroid.h" #include "ContextMenuClientAndroid.h" +#include "DeviceOrientationClientAndroid.h" #include "Document.h" #include "DocumentLoader.h" #include "DragClientAndroid.h" @@ -876,15 +877,19 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter); #endif // Create a new page - ChromeClientAndroid* chromeC = new ChromeClientAndroid; - EditorClientAndroid* editorC = new EditorClientAndroid; + ChromeClientAndroid* chromeC = new ChromeClientAndroid; + EditorClientAndroid* editorC = new EditorClientAndroid; + DeviceOrientationClientAndroid* deviceOrientationC = new DeviceOrientationClientAndroid; + WebCore::Page::PageClients pageClients; pageClients.chromeClient = chromeC; pageClients.contextMenuClient = new ContextMenuClientAndroid; pageClients.editorClient = editorC; pageClients.dragClient = new DragClientAndroid; pageClients.inspectorClient = new InspectorClientAndroid; + pageClients.deviceOrientationClient = deviceOrientationC; WebCore::Page* page = new WebCore::Page(pageClients); + // css files without explicit MIMETYPE is treated as generic text files in // the Java side. So we can't enforce CSS MIMETYPE. page->settings()->setEnforceCSSMIMETypeInStrictMode(false); @@ -921,6 +926,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Set the frame to active to turn on keyboard focus. frame->init(); frame->selection()->setFocused(true); + deviceOrientationC->setWebViewCore(webViewCore); // Allow local access to file:/// and substitute data WebCore::SecurityOrigin::setLocalLoadPolicy( |