[WK2] Add Vibration API support for WebKit2
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2012 22:14:34 +0000 (22:14 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2012 22:14:34 +0000 (22:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90058

Patch by Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> on 2012-07-10
Reviewed by Anders Carlsson.

Add support for Vibration API to WebKit2.

* CMakeLists.txt:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Platform/CoreIPC/MessageID.h:
* Shared/API/c/WKBase.h:
* Shared/APIObject.h:
* Target.pri:
* UIProcess/API/C/WKAPICast.h:
(WebKit):
* UIProcess/API/C/WKVibration.cpp: Added.
(WKVibrationGetTypeID):
(WKVibrationSetProvider):
* UIProcess/API/C/WKVibration.h: Added.
* UIProcess/WebVibrationProvider.cpp: Added.
(WebKit):
(WebKit::WebVibrationProvider::vibrate):
(WebKit::WebVibrationProvider::cancelVibration):
* UIProcess/WebVibrationProvider.h: Added.
(WebKit):
(WebVibrationProvider):
* UIProcess/WebVibrationProxy.cpp: Added.
(WebKit):
(WebKit::WebVibrationProxy::create):
(WebKit::WebVibrationProxy::WebVibrationProxy):
(WebKit::WebVibrationProxy::~WebVibrationProxy):
(WebKit::WebVibrationProxy::invalidate):
(WebKit::WebVibrationProxy::initializeProvider):
(WebKit::WebVibrationProxy::didReceiveMessage):
(WebKit::WebVibrationProxy::vibrate):
(WebKit::WebVibrationProxy::cancelVibration):
* UIProcess/WebVibrationProxy.h: Added.
(CoreIPC):
(WebKit):
(WebVibrationProxy):
(WebKit::WebVibrationProxy::clearContext):
(WebKit::WebVibrationProxy::type):
* UIProcess/WebVibrationProxy.messages.in: Added.
* WebProcess/WebCoreSupport/WebVibrationClient.cpp: Added.
(WebKit):
(WebKit::WebVibrationClient::vibrate):
(WebKit::WebVibrationClient::cancelVibration):
(WebKit::WebVibrationClient::vibrationDestroyed):
* WebProcess/WebCoreSupport/WebVibrationClient.h: Added.
(WebKit):
(WebVibrationClient):
(WebKit::WebVibrationClient::WebVibrationClient):
(WebKit::WebVibrationClient::~WebVibrationClient):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122270 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.pri
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Platform/CoreIPC/MessageID.h
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/Shared/APIObject.h
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKVibration.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKVibration.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebVibrationProvider.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebVibrationProvider.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebVibrationProxy.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebVibrationProxy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebVibrationProxy.messages.in [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.h [new file with mode: 0644]

index 1d47088..03501bc 100644 (file)
@@ -266,6 +266,8 @@ SET(WebKit2_SOURCES
     UIProcess/WebTextChecker.cpp
     UIProcess/WebTextCheckerClient.cpp
     UIProcess/WebUIClient.cpp
+    UIProcess/WebVibrationProvider.cpp
+    UIProcess/WebVibrationProxy.cpp
 
     UIProcess/API/C/WKApplicationCacheManager.cpp
     UIProcess/API/C/WKAuthenticationChallenge.cpp
@@ -307,6 +309,7 @@ SET(WebKit2_SOURCES
     UIProcess/API/C/WKProtectionSpace.cpp
     UIProcess/API/C/WKResourceCacheManager.cpp
     UIProcess/API/C/WKTextChecker.cpp
+    UIProcess/API/C/WKVibration.cpp
 
     UIProcess/Authentication/AuthenticationChallengeProxy.cpp
     UIProcess/Authentication/AuthenticationDecisionListener.cpp
@@ -433,6 +436,7 @@ SET(WebKit2_SOURCES
     WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
     WebProcess/WebCoreSupport/WebPopupMenu.cpp
     WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
+    WebProcess/WebCoreSupport/WebVibrationClient.cpp
 
     WebProcess/WebPage/DecoderAdapter.cpp
     WebProcess/WebPage/DrawingArea.cpp
@@ -479,6 +483,7 @@ SET(WebKit2_MESSAGES_IN_FILES
     UIProcess/WebPageProxy.messages.in
     UIProcess/WebProcessProxy.messages.in
     UIProcess/WebResourceCacheManagerProxy.messages.in
+    UIProcess/WebVibrationProxy.messages.in
 
     UIProcess/Downloads/DownloadProxy.messages.in
 
index 6f33683..7c8e7b0 100644 (file)
@@ -1,3 +1,60 @@
+2012-07-10  Sudarsana Nagineni  <sudarsana.nagineni@linux.intel.com>
+
+        [WK2] Add Vibration API support for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=90058
+
+        Reviewed by Anders Carlsson.
+
+        Add support for Vibration API to WebKit2.
+
+        * CMakeLists.txt:
+        * DerivedSources.pri:
+        * GNUmakefile.list.am:
+        * Platform/CoreIPC/MessageID.h:
+        * Shared/API/c/WKBase.h:
+        * Shared/APIObject.h:
+        * Target.pri:
+        * UIProcess/API/C/WKAPICast.h:
+        (WebKit):
+        * UIProcess/API/C/WKVibration.cpp: Added.
+        (WKVibrationGetTypeID):
+        (WKVibrationSetProvider):
+        * UIProcess/API/C/WKVibration.h: Added.
+        * UIProcess/WebVibrationProvider.cpp: Added.
+        (WebKit):
+        (WebKit::WebVibrationProvider::vibrate):
+        (WebKit::WebVibrationProvider::cancelVibration):
+        * UIProcess/WebVibrationProvider.h: Added.
+        (WebKit):
+        (WebVibrationProvider):
+        * UIProcess/WebVibrationProxy.cpp: Added.
+        (WebKit):
+        (WebKit::WebVibrationProxy::create):
+        (WebKit::WebVibrationProxy::WebVibrationProxy):
+        (WebKit::WebVibrationProxy::~WebVibrationProxy):
+        (WebKit::WebVibrationProxy::invalidate):
+        (WebKit::WebVibrationProxy::initializeProvider):
+        (WebKit::WebVibrationProxy::didReceiveMessage):
+        (WebKit::WebVibrationProxy::vibrate):
+        (WebKit::WebVibrationProxy::cancelVibration):
+        * UIProcess/WebVibrationProxy.h: Added.
+        (CoreIPC):
+        (WebKit):
+        (WebVibrationProxy):
+        (WebKit::WebVibrationProxy::clearContext):
+        (WebKit::WebVibrationProxy::type):
+        * UIProcess/WebVibrationProxy.messages.in: Added.
+        * WebProcess/WebCoreSupport/WebVibrationClient.cpp: Added.
+        (WebKit):
+        (WebKit::WebVibrationClient::vibrate):
+        (WebKit::WebVibrationClient::cancelVibration):
+        (WebKit::WebVibrationClient::vibrationDestroyed):
+        * WebProcess/WebCoreSupport/WebVibrationClient.h: Added.
+        (WebKit):
+        (WebVibrationClient):
+        (WebKit::WebVibrationClient::WebVibrationClient):
+        (WebKit::WebVibrationClient::~WebVibrationClient):
+
 2012-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Add API to clear the cache to WebKit2 GTK+
index ce039f0..42fa665 100644 (file)
@@ -103,6 +103,7 @@ MESSAGE_RECEIVERS = \
     WebProcessProxy.messages.in \
     WebResourceCacheManager.messages.in \
     WebResourceCacheManagerProxy.messages.in \
+    WebVibrationProxy.messages.in \
     NPObjectMessageReceiver.messages.in
 
 SCRIPTS = \
index 6c06d5a..d420afa 100644 (file)
@@ -88,6 +88,7 @@ webkit2_h_api += \
        $(WebKit2)/UIProcess/API/C/WKProtectionSpaceTypes.h \
        $(WebKit2)/UIProcess/API/C/WKResourceCacheManager.h \
        $(WebKit2)/UIProcess/API/C/WKTextChecker.h \
+       $(WebKit2)/UIProcess/API/C/WKVibration.cpp \
        $(WebKit2)/UIProcess/API/cpp/WKRetainPtr.h
 
 webkit2gtk_h_api += \
@@ -218,7 +219,9 @@ webkit2_built_sources += \
        DerivedSources/WebKit2/WebSoupRequestManagerMessageReceiver.cpp \
        DerivedSources/WebKit2/WebSoupRequestManagerMessages.h \
        DerivedSources/WebKit2/WebSoupRequestManagerProxyMessageReceiver.cpp \
-       DerivedSources/WebKit2/WebSoupRequestManagerProxyMessages.h
+       DerivedSources/WebKit2/WebSoupRequestManagerProxyMessages.h \
+       DerivedSources/WebKit2/WebVibrationProxyMessageReceiver.cpp \
+       DerivedSources/WebKit2/WebVibrationProxyMessages.h
 
 webkit2gtk_built_sources += \
        DerivedSources/WebKit2/webkit2gtk/webkit2/WebKitEnumTypes.cpp \
@@ -596,6 +599,8 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp \
        Source/WebKit2/UIProcess/API/C/WKTextChecker.h \
        Source/WebKit2/UIProcess/API/C/WKTextChecker.cpp \
+       Source/WebKit2/UIProcess/API/C/WKVibration.cpp \
+       Source/WebKit2/UIProcess/API/C/WKVibration.h \
        Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h \
        Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h \
        Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp \
@@ -891,6 +896,10 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/WebTextCheckerClient.h \
        Source/WebKit2/UIProcess/WebUIClient.cpp \
        Source/WebKit2/UIProcess/WebUIClient.h \
+       Source/WebKit2/UIProcess/WebVibrationProvider.cpp \
+       Source/WebKit2/UIProcess/WebVibrationProvider.h \
+       Source/WebKit2/UIProcess/WebVibrationProxy.cpp \
+       Source/WebKit2/UIProcess/WebVibrationProxy.h \
        Source/WebKit2/WebKit2Prefix.h \
        Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.h \
        Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp \
@@ -1081,6 +1090,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h \
+       Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.cpp \
+       Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.h \
        Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp \
        Source/WebKit2/WebProcess/WebPage/DecoderAdapter.h \
        Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp \
index 401a666..22d306b 100644 (file)
@@ -83,6 +83,7 @@ enum MessageClass {
 #if USE(SOUP)
     MessageClassWebSoupRequestManagerProxy,
 #endif
+    MessageClassWebVibrationProxy,
 
     // Messages sent to a WebConnection
     MessageClassWebConnectionLegacy,
index 813f5bf..3f707ba 100644 (file)
@@ -123,6 +123,7 @@ typedef const struct OpaqueWKPluginSiteDataManager* WKPluginSiteDataManagerRef;
 typedef const struct OpaqueWKPreferences* WKPreferencesRef;
 typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef;
 typedef const struct OpaqueWKTextChecker* WKTextCheckerRef;
+typedef const struct OpaqueWKVibration* WKVibrationRef;
 
 /* WebKit2 Bundle types */
 
index 6db6779..6e9c1d6 100644 (file)
@@ -107,6 +107,7 @@ public:
         TypePluginSiteDataManager,
         TypePreferences,
         TypeTextChecker,
+        TypeVibration,
 
         // Bundle types
         TypeBundle,
index 2ca8c2e..25d894f 100644 (file)
@@ -180,6 +180,7 @@ HEADERS += \
     UIProcess/API/C/WKPreferencesPrivate.h \
     UIProcess/API/C/WKProtectionSpace.h \
     UIProcess/API/C/WKProtectionSpaceTypes.h \
+    UIProcess/API/C/WKVibration.h \
     UIProcess/API/C/WebKit2.h \
     UIProcess/API/C/qt/WKNativeEvent.h \
     UIProcess/API/cpp/WKRetainPtr.h \
@@ -280,6 +281,8 @@ HEADERS += \
     UIProcess/WebResourceCacheManagerProxy.h \
     UIProcess/WebResourceLoadClient.h \
     UIProcess/WebUIClient.h \
+    UIProcess/WebVibrationProvider.h \
+    UIProcess/WebVibrationProxy.h \
     UIProcess/qt/QtWebContext.h \
     UIProcess/qt/QtWebPageEventHandler.h \
     UIProcess/qt/QtGestureRecognizer.h \
@@ -372,6 +375,7 @@ HEADERS += \
     WebProcess/WebCoreSupport/WebPlatformStrategies.h \
     WebProcess/WebCoreSupport/WebPopupMenu.h \
     WebProcess/WebCoreSupport/WebSearchPopupMenu.h \
+    WebProcess/WebCoreSupport/WebVibrationClient.h \
     WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h \
     WebProcess/WebPage/DrawingArea.h \
     WebProcess/WebPage/DrawingAreaImpl.h \
@@ -550,6 +554,7 @@ SOURCES += \
     UIProcess/API/C/WKPreferences.cpp \
     UIProcess/API/C/WKProtectionSpace.cpp \
     UIProcess/API/C/WKResourceCacheManager.cpp \
+    UIProcess/API/C/WKVibration.cpp \
     UIProcess/API/cpp/qt/WKStringQt.cpp \
     UIProcess/API/cpp/qt/WKURLQt.cpp \
     UIProcess/API/qt/qwebdownloaditem.cpp \
@@ -645,6 +650,8 @@ SOURCES += \
     UIProcess/WebResourceCacheManagerProxy.cpp \
     UIProcess/WebResourceLoadClient.cpp \
     UIProcess/WebUIClient.cpp \
+    UIProcess/WebVibrationProvider.cpp \
+    UIProcess/WebVibrationProxy.cpp \
     UIProcess/qt/QtWebContext.cpp \
     UIProcess/qt/QtWebPageEventHandler.cpp \
     UIProcess/qt/QtGestureRecognizer.cpp \
@@ -754,6 +761,7 @@ SOURCES += \
     WebProcess/WebCoreSupport/WebPlatformStrategies.cpp \
     WebProcess/WebCoreSupport/WebPopupMenu.cpp \
     WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp \
+    WebProcess/WebCoreSupport/WebVibrationClient.cpp \
     WebProcess/WebCoreSupport/qt/WebContextMenuClientQt.cpp \
     WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp \
     WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp \
index 283fed1..bef294e 100644 (file)
@@ -92,6 +92,7 @@ class WebProtectionSpace;
 class WebRenderLayer;
 class WebRenderObject;
 class WebTextChecker;
+class WebVibrationProxy;
 
 WK_ADD_API_MAPPING(WKApplicationCacheManagerRef, WebApplicationCacheManagerProxy)
 WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
@@ -136,6 +137,7 @@ WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
 WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
+WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
 
 #if ENABLE(INSPECTOR)
 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
diff --git a/Source/WebKit2/UIProcess/API/C/WKVibration.cpp b/Source/WebKit2/UIProcess/API/C/WKVibration.cpp
new file mode 100644 (file)
index 0000000..e9d933c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 "WKVibration.h"
+
+#include "WKAPICast.h"
+
+#if ENABLE(VIBRATION)
+#include "WebVibrationProxy.h"
+#endif
+
+using namespace WebKit;
+
+WKTypeID WKVibrationGetTypeID()
+{
+#if ENABLE(VIBRATION)
+    return toAPI(WebVibrationProxy::APIType);
+#else
+    return 0;
+#endif
+}
+
+void WKVibrationSetProvider(WKVibrationRef vibrationRef, const WKVibrationProvider* wkProvider)
+{
+#if ENABLE(VIBRATION)
+    toImpl(vibrationRef)->initializeProvider(wkProvider);
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKVibration.h b/Source/WebKit2/UIProcess/API/C/WKVibration.h
new file mode 100644 (file)
index 0000000..f300b46
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 WKVibration_h
+#define WKVibration_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Provider.
+typedef void (*WKVibrationProviderVibrateCallback)(WKVibrationRef vibrationRef, uint64_t vibrationTime, const void* clientInfo);
+typedef void (*WKVibrationProviderCancelVibrationCallback)(WKVibrationRef vibrationRef, const void* clientInfo);
+
+struct WKVibrationProvider {
+    int                                                                 version;
+    const void *                                                        clientInfo;
+    WKVibrationProviderVibrateCallback                                  vibrate;
+    WKVibrationProviderCancelVibrationCallback                          cancelVibration;
+};
+typedef struct WKVibrationProvider WKVibrationProvider;
+
+enum { kWKVibrationProviderCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKVibrationGetTypeID();
+
+WK_EXPORT void WKVibrationSetProvider(WKVibrationRef vibrationRef, const WKVibrationProvider* provider);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKVibration_h
diff --git a/Source/WebKit2/UIProcess/WebVibrationProvider.cpp b/Source/WebKit2/UIProcess/WebVibrationProvider.cpp
new file mode 100644 (file)
index 0000000..095bd97
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 "WebVibrationProvider.h"
+
+#if ENABLE(VIBRATION)
+
+#include "WKAPICast.h"
+#include "WebVibrationProxy.h"
+
+namespace WebKit {
+
+void WebVibrationProvider::vibrate(WebVibrationProxy* vibration, uint64_t vibrationTime)
+{
+    if (!m_client.vibrate)
+        return;
+
+    m_client.vibrate(toAPI(vibration), vibrationTime, m_client.clientInfo);
+}
+
+void WebVibrationProvider::cancelVibration(WebVibrationProxy* vibration)
+{
+    if (!m_client.cancelVibration)
+        return;
+
+    m_client.cancelVibration(toAPI(vibration), m_client.clientInfo);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(VIBRATION)
diff --git a/Source/WebKit2/UIProcess/WebVibrationProvider.h b/Source/WebKit2/UIProcess/WebVibrationProvider.h
new file mode 100644 (file)
index 0000000..76d98a8
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 WebVibrationProvider_h
+#define WebVibrationProvider_h
+
+#if ENABLE(VIBRATION)
+
+#include "APIClient.h"
+#include "WKVibration.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebVibrationProxy;
+
+class WebVibrationProvider : public APIClient<WKVibrationProvider, kWKVibrationProviderCurrentVersion> {
+public:
+    void vibrate(WebVibrationProxy*, uint64_t vibrationTime);
+    void cancelVibration(WebVibrationProxy*);
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(VIBRATION)
+
+#endif // WebVibrationProvider_h
diff --git a/Source/WebKit2/UIProcess/WebVibrationProxy.cpp b/Source/WebKit2/UIProcess/WebVibrationProxy.cpp
new file mode 100644 (file)
index 0000000..9a5f7f2
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 "WebVibrationProxy.h"
+
+#if ENABLE(VIBRATION)
+
+#include "WebContext.h"
+
+namespace WebKit {
+
+PassRefPtr<WebVibrationProxy> WebVibrationProxy::create(WebContext* context)
+{
+    return adoptRef(new WebVibrationProxy(context));
+}
+
+WebVibrationProxy::WebVibrationProxy(WebContext* context)
+    : m_context(context)
+{
+}
+
+WebVibrationProxy::~WebVibrationProxy()
+{
+}
+
+void WebVibrationProxy::invalidate()
+{
+    cancelVibration();
+}
+
+void WebVibrationProxy::initializeProvider(const WKVibrationProvider* provider)
+{
+    m_provider.initialize(provider);
+}
+
+void WebVibrationProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+    didReceiveWebVibrationProxyMessage(connection, messageID, arguments);
+}
+
+void WebVibrationProxy::vibrate(uint64_t vibrationTime)
+{
+    m_provider.vibrate(this, vibrationTime);
+}
+
+void WebVibrationProxy::cancelVibration()
+{
+    m_provider.cancelVibration(this);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(VIBRATION)
diff --git a/Source/WebKit2/UIProcess/WebVibrationProxy.h b/Source/WebKit2/UIProcess/WebVibrationProxy.h
new file mode 100644 (file)
index 0000000..4e69e96
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 WebVibrationProxy_h
+#define WebVibrationProxy_h
+
+#if ENABLE(VIBRATION)
+
+#include "APIObject.h"
+#include "MessageID.h"
+#include "WebVibrationProvider.h"
+#include <wtf/Forward.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+}
+
+namespace WebKit {
+
+class WebContext;
+
+class WebVibrationProxy : public APIObject {
+public:
+    static const Type APIType = TypeVibration;
+
+    static PassRefPtr<WebVibrationProxy> create(WebContext*);
+    virtual ~WebVibrationProxy();
+
+    void invalidate();
+    void clearContext() { m_context = 0; }
+
+    void initializeProvider(const WKVibrationProvider*);
+
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+private:
+    explicit WebVibrationProxy(WebContext*);
+
+    virtual Type type() const { return APIType; }
+
+    // Implemented in generated WebVibrationProxyMessageReceiver.cpp
+    void didReceiveWebVibrationProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+    void vibrate(uint64_t vibrationTime);
+    void cancelVibration();
+
+    WebContext* m_context;
+    WebVibrationProvider m_provider;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(VIBRATION)
+
+#endif // WebVibrationProxy_h
diff --git a/Source/WebKit2/UIProcess/WebVibrationProxy.messages.in b/Source/WebKit2/UIProcess/WebVibrationProxy.messages.in
new file mode 100644 (file)
index 0000000..ff40b0d
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2012 Intel Corporation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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.
+
+#if ENABLE(VIBRATION)
+
+messages -> WebVibrationProxy {
+    Vibrate(uint64_t vibrationTime);
+    CancelVibration();
+}
+
+#endif
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.cpp
new file mode 100644 (file)
index 0000000..f635df4
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 "WebVibrationClient.h"
+
+#if ENABLE(VIBRATION)
+
+#include "WebPage.h"
+#include "WebProcess.h"
+#include "WebVibrationProxyMessages.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebVibrationClient::vibrate(const uint64_t& vibrationTime)
+{
+    WebProcess::shared().connection()->send(Messages::WebVibrationProxy::Vibrate(vibrationTime), m_page->pageID());
+}
+
+void WebVibrationClient::cancelVibration()
+{
+    WebProcess::shared().connection()->send(Messages::WebVibrationProxy::CancelVibration(), m_page->pageID());
+}
+
+void WebVibrationClient::vibrationDestroyed()
+{
+    delete this;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(VIBRATION)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebVibrationClient.h
new file mode 100644 (file)
index 0000000..e71db28
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 WebVibrationClient_h
+#define WebVibrationClient_h
+
+#if ENABLE(VIBRATION)
+
+#include <WebCore/VibrationClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebVibrationClient : public WebCore::VibrationClient {
+public:
+    WebVibrationClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+
+    virtual ~WebVibrationClient() { }
+
+private:
+    virtual void vibrate(const uint64_t& vibrationTime) OVERRIDE;
+    virtual void cancelVibration() OVERRIDE;
+    virtual void vibrationDestroyed() OVERRIDE;
+
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(VIBRATION)
+
+#endif // WebVibrationClient_h