summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-08-05 04:34:24 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-08-05 04:34:24 -0700
commit03d64d185a49d165a316a45cd50ee8429c5c9ebc (patch)
tree99443539aedc99b633a25cf5d7c062533c2546eb
parentd90694237e0403668232924a79fabfb3d1214e6c (diff)
parent9e0be7261c268a89a8e318e9fc8534a8092d9e63 (diff)
downloadexternal_webkit-03d64d185a49d165a316a45cd50ee8429c5c9ebc.zip
external_webkit-03d64d185a49d165a316a45cd50ee8429c5c9ebc.tar.gz
external_webkit-03d64d185a49d165a316a45cd50ee8429c5c9ebc.tar.bz2
Merge "Implement DeviceOrientationClientAndroid"
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp76
-rw-r--r--WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.h64
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp10
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(