[WK2] Add support for Web Intents MessagePorts
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2012 13:03:19 +0000 (13:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2012 13:03:19 +0000 (13:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89072

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-08-15
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

Add support for WebIntents MessagePorts in WebKit2.
MessagePorts can be passed with a Web Intent in
order to open a direct communication channel
between the Web application and the intent service.

This functionality is already supported by WebKit 1.

This patch introduces a new InjectedBundleIntent
class which wraps a WebCore::Intent. This way
information regarding the MessagePorts in a Web
Intent is kept when using an injected bundle.

For the UIProcess, WebIntentData now carries
identifiers for the MessagePorts which can go over
IPC. Those identifiers map to actual MessagePorts
stored in the Web process. This way, when the UI
delivers an intent to a frame, we can get back the
corresponding MessagePorts from the Web process
before delivering the intent to the DOMWindow.

This functionality is already tested by:

- webintents/web-intents-invoke-port.html
- webintents/web-intents-obj-constructor.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Shared/API/c/WKBase.h:
* Shared/APIObject.h:
* Shared/IntentData.cpp: Add MessagePort identifiers.
(WebKit::IntentData::IntentData):
(WebKit::IntentData::encode):
(WebKit::IntentData::decode):
* Shared/IntentData.h:
(IntentData):
* Target.pri:
* UIProcess/API/C/WKIntentData.cpp: Rename WKIntentDataCopyExtra() to
WKIntentDataCopyExtraValue() for clarity.
(WKIntentDataCopyExtraValue):
* UIProcess/API/C/WKIntentData.h: Remove WKIntentDataCreate() function now
that WTR uses WKBundleIntentCreate() instead.
* UIProcess/API/efl/ewk_intent.cpp:
(ewk_intent_extra_get): Use WKIntentDataCopyExtraValue() instead of
WKIntentDataCopyExtra() since it was renamed.
* UIProcess/WebIntentData.cpp:
(WebKit::WebIntentData::WebIntentData):
(WebKit::WebIntentData::~WebIntentData): Remove MessagePorts from WebProcess upon
WebIntentData destruction.
(WebKit):
(WebKit::WebIntentData::extras):
* UIProcess/WebIntentData.h:
(WebKit):
(WebKit::WebIntentData::create):
(WebIntentData):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveIntentForFrame):
* UIProcess/WebProcessProxy.cpp:
(WebKit):
(WebKit::WebProcessProxy::removeMessagePortChannel):
* UIProcess/WebProcessProxy.h:
(WebProcessProxy):
* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
(WebKit):
* WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp: Copied from Source/WebKit2/UIProcess/API/C/WKIntentData.cpp.
(WKBundleIntentGetTypeID):
(WKBundleIntentCreate):
(WKBundleIntentCopyAction):
(WKBundleIntentCopyType):
(WKBundleIntentCopyService):
(WKBundleIntentCopySuggestions):
(WKBundleIntentCopyExtraValue):
(WKBundleIntentCopyExtras):
(WKBundleIntentMessagePortCount):
* WebProcess/InjectedBundle/API/c/WKBundleIntent.h: Copied from Source/WebKit2/UIProcess/API/C/WKIntentData.h.
* WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp:
(WKBundleIntentRequestCopyIntent):
* WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageDeliverIntentToFrame):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundleIntent.cpp: Copied from Source/WebKit2/UIProcess/WebIntentData.cpp.
(WebKit):
(WebKit::InjectedBundleIntent::create):
(WebKit::InjectedBundleIntent::InjectedBundleIntent):
(WebKit::InjectedBundleIntent::action):
(WebKit::InjectedBundleIntent::payloadType):
(WebKit::InjectedBundleIntent::service):
(WebKit::InjectedBundleIntent::data):
(WebKit::InjectedBundleIntent::extra):
(WebKit::InjectedBundleIntent::extras):
(WebKit::InjectedBundleIntent::suggestions):
* WebProcess/InjectedBundle/InjectedBundleIntent.h: Copied from Source/WebKit2/UIProcess/WebIntentData.h.
(WebKit):
(InjectedBundleIntent):
(WebKit::InjectedBundleIntent::coreIntent):
(WebKit::InjectedBundleIntent::type):
* WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp:
(WebKit::InjectedBundleIntentRequest::intent):
* WebProcess/InjectedBundle/InjectedBundleIntentRequest.h:
(WebKit):
(InjectedBundleIntentRequest):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::deliverIntent):
(WebKit):
* WebProcess/WebPage/WebFrame.h:
(WebCore):
(WebFrame):
* WebProcess/WebPage/WebPage.cpp:
(WebKit):
(WebKit::WebPage::deliverCoreIntentToFrame):
* WebProcess/WebPage/WebPage.h:
(WebCore):
(WebPage):
* WebProcess/WebProcess.cpp: Store MessagePorts in WebProcess and keep mapping with
their identifiers.
(WebKit):
(WebKit::WebProcess::addMessagePortChannel):
(WebKit::WebProcess::messagePortChannel):
(WebKit::WebProcess::removeMessagePortChannel):
* WebProcess/WebProcess.h:
(WebCore):
(WebProcess):
* WebProcess/WebProcess.messages.in:

Tools:

Use WKBundleIntent instead of WebIntentData in
WebKitTestRunner. WTR now prints the number of
MessagePorts in received Web intents as
expected by the following layout tests:
webintents/web-intents-invoke-port.html
webintents/web-intents-obj-constructor.html

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::didReceiveIntentForFrame):
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::deliverWebIntent):

LayoutTests:

Unskip webintents/web-intents-invoke-port.html and
webintents/web-intents-obj-constructor.html for
WebKit2 EFL now that information about message ports
is correctly displayed by WebKitTestRunner.

* platform/efl-wk2/TestExpectations:

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

39 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/efl-wk2/TestExpectations
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/Shared/APIObject.h
Source/WebKit2/Shared/IntentData.cpp
Source/WebKit2/Shared/IntentData.h
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/C/WKIntentData.cpp
Source/WebKit2/UIProcess/API/C/WKIntentData.h
Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp
Source/WebKit2/UIProcess/WebIntentData.cpp
Source/WebKit2/UIProcess/WebIntentData.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp

index ffc2d65..9370c52 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-15  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2] Add support for Web Intents MessagePorts
+        https://bugs.webkit.org/show_bug.cgi?id=89072
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskip webintents/web-intents-invoke-port.html and
+        webintents/web-intents-obj-constructor.html for
+        WebKit2 EFL now that information about message ports
+        is correctly displayed by WebKitTestRunner.
+
+        * platform/efl-wk2/TestExpectations:
+
 2012-08-15  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
         [EFL] Remove image expectation added for a ref test
 2012-08-15  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
         [EFL] Remove image expectation added for a ref test
index 47d13dd..e9a62fd 100644 (file)
@@ -278,7 +278,3 @@ BUGWKEFL : inspector/extensions/extensions-panel.html = TEXT
 BUGWKEFL : inspector/extensions/extensions-sidebar.html = TEXT
 BUGWKEFL : jquery/attributes.html = TEXT
 
 BUGWKEFL : inspector/extensions/extensions-sidebar.html = TEXT
 BUGWKEFL : jquery/attributes.html = TEXT
 
-// WTR does not print information about Web Intents MessagePorts
-BUGWK89072 : webintents/web-intents-invoke-port.html = TEXT
-BUGWK89072 : webintents/web-intents-obj-constructor.html = TEXT
-
index a66a56c..c43dd4a 100644 (file)
@@ -56,6 +56,7 @@ SET(WebKit2_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/bridge/jsc"
     "${WEBCORE_DIR}/css"
     "${WEBCORE_DIR}/dom"
     "${WEBCORE_DIR}/bridge/jsc"
     "${WEBCORE_DIR}/css"
     "${WEBCORE_DIR}/dom"
+    "${WEBCORE_DIR}/dom/default"
     "${WEBCORE_DIR}/editing"
     "${WEBCORE_DIR}/history"
     "${WEBCORE_DIR}/html"
     "${WEBCORE_DIR}/editing"
     "${WEBCORE_DIR}/history"
     "${WEBCORE_DIR}/html"
@@ -380,6 +381,7 @@ SET(WebKit2_SOURCES
     WebProcess/InjectedBundle/InjectedBundleClient.cpp
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
     WebProcess/InjectedBundle/InjectedBundleClient.cpp
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
+    WebProcess/InjectedBundle/InjectedBundleIntent.cpp
     WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp
     WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp
     WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp
     WebProcess/InjectedBundle/InjectedBundlePageDiagnosticLoggingClient.cpp
@@ -400,6 +402,7 @@ SET(WebKit2_SOURCES
     WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
     WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
     WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
     WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
+    WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp
     WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp
     WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
     WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp
     WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
index 9a2df1d..ed579dd 100644 (file)
@@ -1,3 +1,134 @@
+2012-08-15  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2] Add support for Web Intents MessagePorts
+        https://bugs.webkit.org/show_bug.cgi?id=89072
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add support for WebIntents MessagePorts in WebKit2.
+        MessagePorts can be passed with a Web Intent in
+        order to open a direct communication channel
+        between the Web application and the intent service.
+
+        This functionality is already supported by WebKit 1.
+
+        This patch introduces a new InjectedBundleIntent
+        class which wraps a WebCore::Intent. This way
+        information regarding the MessagePorts in a Web
+        Intent is kept when using an injected bundle.
+
+        For the UIProcess, WebIntentData now carries
+        identifiers for the MessagePorts which can go over
+        IPC. Those identifiers map to actual MessagePorts
+        stored in the Web process. This way, when the UI
+        delivers an intent to a frame, we can get back the
+        corresponding MessagePorts from the Web process
+        before delivering the intent to the DOMWindow.
+
+        This functionality is already tested by:
+
+        - webintents/web-intents-invoke-port.html
+        - webintents/web-intents-obj-constructor.html
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Shared/API/c/WKBase.h:
+        * Shared/APIObject.h:
+        * Shared/IntentData.cpp: Add MessagePort identifiers.
+        (WebKit::IntentData::IntentData):
+        (WebKit::IntentData::encode):
+        (WebKit::IntentData::decode):
+        * Shared/IntentData.h:
+        (IntentData):
+        * Target.pri:
+        * UIProcess/API/C/WKIntentData.cpp: Rename WKIntentDataCopyExtra() to
+        WKIntentDataCopyExtraValue() for clarity.
+        (WKIntentDataCopyExtraValue): 
+        * UIProcess/API/C/WKIntentData.h: Remove WKIntentDataCreate() function now
+        that WTR uses WKBundleIntentCreate() instead.
+        * UIProcess/API/efl/ewk_intent.cpp:
+        (ewk_intent_extra_get): Use WKIntentDataCopyExtraValue() instead of
+        WKIntentDataCopyExtra() since it was renamed.
+        * UIProcess/WebIntentData.cpp:
+        (WebKit::WebIntentData::WebIntentData):
+        (WebKit::WebIntentData::~WebIntentData): Remove MessagePorts from WebProcess upon
+        WebIntentData destruction.
+        (WebKit):
+        (WebKit::WebIntentData::extras):
+        * UIProcess/WebIntentData.h:
+        (WebKit):
+        (WebKit::WebIntentData::create):
+        (WebIntentData):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didReceiveIntentForFrame):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit):
+        (WebKit::WebProcessProxy::removeMessagePortChannel):
+        * UIProcess/WebProcessProxy.h:
+        (WebProcessProxy):
+        * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
+        (WebKit):
+        * WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp: Copied from Source/WebKit2/UIProcess/API/C/WKIntentData.cpp.
+        (WKBundleIntentGetTypeID):
+        (WKBundleIntentCreate):
+        (WKBundleIntentCopyAction):
+        (WKBundleIntentCopyType):
+        (WKBundleIntentCopyService):
+        (WKBundleIntentCopySuggestions):
+        (WKBundleIntentCopyExtraValue):
+        (WKBundleIntentCopyExtras):
+        (WKBundleIntentMessagePortCount):
+        * WebProcess/InjectedBundle/API/c/WKBundleIntent.h: Copied from Source/WebKit2/UIProcess/API/C/WKIntentData.h.
+        * WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp:
+        (WKBundleIntentRequestCopyIntent):
+        * WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h:
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageDeliverIntentToFrame):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/InjectedBundle/InjectedBundleIntent.cpp: Copied from Source/WebKit2/UIProcess/WebIntentData.cpp.
+        (WebKit):
+        (WebKit::InjectedBundleIntent::create):
+        (WebKit::InjectedBundleIntent::InjectedBundleIntent):
+        (WebKit::InjectedBundleIntent::action):
+        (WebKit::InjectedBundleIntent::payloadType):
+        (WebKit::InjectedBundleIntent::service):
+        (WebKit::InjectedBundleIntent::data):
+        (WebKit::InjectedBundleIntent::extra):
+        (WebKit::InjectedBundleIntent::extras):
+        (WebKit::InjectedBundleIntent::suggestions):
+        * WebProcess/InjectedBundle/InjectedBundleIntent.h: Copied from Source/WebKit2/UIProcess/WebIntentData.h.
+        (WebKit):
+        (InjectedBundleIntent):
+        (WebKit::InjectedBundleIntent::coreIntent):
+        (WebKit::InjectedBundleIntent::type):
+        * WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp:
+        (WebKit::InjectedBundleIntentRequest::intent):
+        * WebProcess/InjectedBundle/InjectedBundleIntentRequest.h:
+        (WebKit):
+        (InjectedBundleIntentRequest):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::deliverIntent):
+        (WebKit):
+        * WebProcess/WebPage/WebFrame.h:
+        (WebCore):
+        (WebFrame):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit):
+        (WebKit::WebPage::deliverCoreIntentToFrame):
+        * WebProcess/WebPage/WebPage.h:
+        (WebCore):
+        (WebPage):
+        * WebProcess/WebProcess.cpp: Store MessagePorts in WebProcess and keep mapping with
+        their identifiers.
+        (WebKit):
+        (WebKit::WebProcess::addMessagePortChannel):
+        (WebKit::WebProcess::messagePortChannel):
+        (WebKit::WebProcess::removeMessagePortChannel):
+        * WebProcess/WebProcess.h:
+        (WebCore):
+        (WebProcess):
+        * WebProcess/WebProcess.messages.in:
+
 2012-08-14  Adam Barth  <abarth@webkit.org>
 
         Delete Frame::domWindow() and Frame::existingDOMWindow()
 2012-08-14  Adam Barth  <abarth@webkit.org>
 
         Delete Frame::domWindow() and Frame::existingDOMWindow()
index d737bc7..d417b5f 100644 (file)
@@ -961,6 +961,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp \
+       Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp \
@@ -995,6 +997,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \
+       Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp \
+       Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntentRequest.h \
        Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \
index 6854ecc..a6a8bd6 100644 (file)
@@ -135,6 +135,7 @@ typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensio
 typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
 typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
 typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
 typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
 typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
 typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
+typedef const struct OpaqueWKBundleIntent* WKBundleIntentRef;
 typedef const struct OpaqueWKBundleIntentRequest* WKBundleIntentRequestRef;
 typedef const struct OpaqueWKBundleNavigationAction* WKBundleNavigationActionRef;
 typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
 typedef const struct OpaqueWKBundleIntentRequest* WKBundleIntentRequestRef;
 typedef const struct OpaqueWKBundleNavigationAction* WKBundleNavigationActionRef;
 typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
index 8e4d293..708effe 100644 (file)
@@ -117,6 +117,7 @@ public:
         TypeBundleFrame,
         TypeBundleHitTestResult,
         TypeBundleInspector,
         TypeBundleFrame,
         TypeBundleHitTestResult,
         TypeBundleInspector,
+        TypeBundleIntent,
         TypeBundleIntentRequest,
         TypeBundleNavigationAction,
         TypeBundleNodeHandle,
         TypeBundleIntentRequest,
         TypeBundleNavigationAction,
         TypeBundleNodeHandle,
index 4995b2e..4107874 100644 (file)
 #include "APIObject.h"
 #include "DataReference.h"
 #include "WebCoreArgumentCoders.h"
 #include "APIObject.h"
 #include "DataReference.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebProcess.h"
 #include <WebCore/Intent.h>
 #include <WebCore/Intent.h>
+#include <WebCore/MessagePortChannel.h>
+#include <WebCore/PlatformMessagePortChannel.h>
 
 using namespace WebCore;
 
 
 using namespace WebCore;
 
@@ -45,6 +48,12 @@ IntentData::IntentData(Intent* coreIntent)
     , extras(coreIntent->extras())
     , suggestions(coreIntent->suggestions())
 {
     , extras(coreIntent->extras())
     , suggestions(coreIntent->suggestions())
 {
+    MessagePortChannelArray* coreMessagePorts = coreIntent->messagePorts();
+    if (coreMessagePorts) {
+        size_t numMessagePorts = coreMessagePorts->size();
+        for (size_t i = 0; i < numMessagePorts; ++i)
+            messagePorts.append(WebProcess::shared().addMessagePortChannel((*coreMessagePorts)[i]->channel()));
+    }
 }
 
 void IntentData::encode(CoreIPC::ArgumentEncoder* encoder) const
 }
 
 void IntentData::encode(CoreIPC::ArgumentEncoder* encoder) const
@@ -55,6 +64,7 @@ void IntentData::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(CoreIPC::DataReference(data));
     encoder->encode(extras);
     encoder->encode(suggestions);
     encoder->encode(CoreIPC::DataReference(data));
     encoder->encode(extras);
     encoder->encode(suggestions);
+    encoder->encode(messagePorts);
 }
 
 bool IntentData::decode(CoreIPC::ArgumentDecoder* decoder, IntentData& intentData)
 }
 
 bool IntentData::decode(CoreIPC::ArgumentDecoder* decoder, IntentData& intentData)
@@ -73,6 +83,8 @@ bool IntentData::decode(CoreIPC::ArgumentDecoder* decoder, IntentData& intentDat
         return false;
     if (!decoder->decode(intentData.suggestions))
         return false;
         return false;
     if (!decoder->decode(intentData.suggestions))
         return false;
+    if (!decoder->decode(intentData.messagePorts))
+        return false;
 
     return true;
 }
 
     return true;
 }
index 96e2d9f..e8435c2 100644 (file)
@@ -29,7 +29,8 @@
 #if ENABLE(WEB_INTENTS)
 
 #include "APIObject.h"
 #if ENABLE(WEB_INTENTS)
 
 #include "APIObject.h"
-#include "GenericCallback.h"
+#include <WebCore/KURL.h>
+#include <wtf/HashMap.h>
 #include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
 #include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
@@ -56,6 +57,7 @@ struct IntentData {
     Vector<uint8_t> data;
     HashMap<String, String> extras;
     Vector<WebCore::KURL> suggestions;
     Vector<uint8_t> data;
     HashMap<String, String> extras;
     Vector<WebCore::KURL> suggestions;
+    Vector<uint64_t> messagePorts;
 };
 
 } // namespace WebKit
 };
 
 } // namespace WebKit
index b8e1aec..3733650 100644 (file)
@@ -279,6 +279,7 @@ HEADERS += \
     WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \
     WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h \
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h \
     WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \
     WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h \
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h \
+    WebProcess/InjectedBundle/API/c/WKBundleIntent.h \
     WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h \
     WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h \
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h \
     WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.h \
     WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h \
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h \
@@ -292,6 +293,7 @@ HEADERS += \
     WebProcess/InjectedBundle/InjectedBundleClient.h \
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \
     WebProcess/InjectedBundle/InjectedBundleClient.h \
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h \
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.h \
+    WebProcess/InjectedBundle/InjectedBundleIntent.h \
     WebProcess/InjectedBundle/InjectedBundleIntentRequest.h \
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.h \
     WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h \
     WebProcess/InjectedBundle/InjectedBundleIntentRequest.h \
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.h \
     WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h \
@@ -631,6 +633,7 @@ SOURCES += \
     WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp \
+    WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleIntentRequest.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp \
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp \
@@ -646,6 +649,7 @@ SOURCES += \
     WebProcess/InjectedBundle/InjectedBundleClient.cpp \
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp \
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \
     WebProcess/InjectedBundle/InjectedBundleClient.cpp \
     WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp \
     WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \
+    WebProcess/InjectedBundle/InjectedBundleIntent.cpp \
     WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp \
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \
     WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp \
     WebProcess/InjectedBundle/InjectedBundleIntentRequest.cpp \
     WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \
     WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp \
index 7a92db5..92e6187 100644 (file)
@@ -31,6 +31,7 @@
 #include "WKAPICast.h"
 #include "WKDictionary.h"
 #include "WKString.h"
 #include "WKAPICast.h"
 #include "WKDictionary.h"
 #include "WKString.h"
+#include "WebSerializedScriptValue.h"
 
 #if ENABLE(WEB_INTENTS)
 #include "WebIntentData.h"
 
 #if ENABLE(WEB_INTENTS)
 #include "WebIntentData.h"
@@ -47,27 +48,6 @@ WKTypeID WKIntentDataGetTypeID()
 #endif
 }
 
 #endif
 }
 
-WKIntentDataRef WKIntentDataCreate(WKDictionaryRef initDictionaryRef)
-{
-#if ENABLE(WEB_INTENTS)
-    IntentData intentData;
-    WKStringRef action = static_cast<WKStringRef>(WKDictionaryGetItemForKey(initDictionaryRef, WKStringCreateWithUTF8CString("action")));
-    ASSERT(action);
-    intentData.action = toImpl(action)->string();
-    WKStringRef type = static_cast<WKStringRef>(WKDictionaryGetItemForKey(initDictionaryRef, WKStringCreateWithUTF8CString("type")));
-    ASSERT(type);
-    intentData.type = toImpl(type)->string();
-    WKSerializedScriptValueRef data = static_cast<WKSerializedScriptValueRef>(WKDictionaryGetItemForKey(initDictionaryRef, WKStringCreateWithUTF8CString("data")));
-    if (data)
-        intentData.data = toImpl(data)->dataReference().vector();
-
-    RefPtr<WebIntentData> webIntentData = WebIntentData::create(intentData);
-    return toAPI(webIntentData.release().leakRef());
-#else
-    return 0;
-#endif
-}
-
 WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef)
 {
 #if ENABLE(WEB_INTENTS)
 WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef)
 {
 #if ENABLE(WEB_INTENTS)
@@ -104,7 +84,7 @@ WKArrayRef WKIntentDataCopySuggestions(WKIntentDataRef intentRef)
 #endif
 }
 
 #endif
 }
 
-WKStringRef WKIntentDataCopyExtra(WKIntentDataRef intentRef, WKStringRef key)
+WKStringRef WKIntentDataCopyExtraValue(WKIntentDataRef intentRef, WKStringRef key)
 {
 #if ENABLE(WEB_INTENTS)
     return toCopiedAPI(toImpl(intentRef)->extra(toWTFString(key)));
 {
 #if ENABLE(WEB_INTENTS)
     return toCopiedAPI(toImpl(intentRef)->extra(toWTFString(key)));
index 1f809ec..caf1b45 100644 (file)
@@ -34,13 +34,11 @@ extern "C" {
 
 WK_EXPORT WKTypeID WKIntentDataGetTypeID();
 
 
 WK_EXPORT WKTypeID WKIntentDataGetTypeID();
 
-WK_EXPORT WKIntentDataRef WKIntentDataCreate(WKDictionaryRef initDictionary);
-
 WK_EXPORT WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef);
 WK_EXPORT WKStringRef WKIntentDataCopyType(WKIntentDataRef intentRef);
 WK_EXPORT WKURLRef WKIntentDataCopyService(WKIntentDataRef intentRef);
 WK_EXPORT WKArrayRef WKIntentDataCopySuggestions(WKIntentDataRef intentRef);
 WK_EXPORT WKStringRef WKIntentDataCopyAction(WKIntentDataRef intentRef);
 WK_EXPORT WKStringRef WKIntentDataCopyType(WKIntentDataRef intentRef);
 WK_EXPORT WKURLRef WKIntentDataCopyService(WKIntentDataRef intentRef);
 WK_EXPORT WKArrayRef WKIntentDataCopySuggestions(WKIntentDataRef intentRef);
-WK_EXPORT WKStringRef WKIntentDataCopyExtra(WKIntentDataRef intentRef, WKStringRef key);
+WK_EXPORT WKStringRef WKIntentDataCopyExtraValue(WKIntentDataRef intentRef, WKStringRef key);
 WK_EXPORT WKDictionaryRef WKIntentDataCopyExtras(WKIntentDataRef intentRef);
 
 #ifdef __cplusplus
 WK_EXPORT WKDictionaryRef WKIntentDataCopyExtras(WKIntentDataRef intentRef);
 
 #ifdef __cplusplus
index 8561793..5c2b219 100644 (file)
@@ -171,7 +171,7 @@ const char* ewk_intent_extra_get(const Ewk_Intent* intent, const char* key)
     EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
 
     WKRetainPtr<WKStringRef> keyRef = adoptWK(WKStringCreateWithUTF8CString(key));
     EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent, 0);
 
     WKRetainPtr<WKStringRef> keyRef = adoptWK(WKStringCreateWithUTF8CString(key));
-    WKRetainPtr<WKStringRef> wkValue(AdoptWK, WKIntentDataCopyExtra(wkIntent, keyRef.get()));
+    WKRetainPtr<WKStringRef> wkValue(AdoptWK, WKIntentDataCopyExtraValue(wkIntent, keyRef.get()));
     String value = toImpl(wkValue.get())->string();
     if (value.isEmpty())
         return 0;
     String value = toImpl(wkValue.get())->string();
     if (value.isEmpty())
         return 0;
index 96128db..632aa3b 100644 (file)
 
 #include "ImmutableArray.h"
 #include "ImmutableDictionary.h"
 
 #include "ImmutableArray.h"
 #include "ImmutableDictionary.h"
+#include "WebProcessProxy.h"
+#include "WebSerializedScriptValue.h"
 #include "WebString.h"
 #include "WebURL.h"
 
 namespace WebKit {
 
 #include "WebString.h"
 #include "WebURL.h"
 
 namespace WebKit {
 
-WebIntentData::WebIntentData(const IntentData& store)
+WebIntentData::WebIntentData(const IntentData& store, WebProcessProxy* process)
     : m_store(store)
     : m_store(store)
+    , m_process(process)
 {
 }
 
 {
 }
 
+WebIntentData::~WebIntentData()
+{
+    // Remove MessagePortChannels from WebProcess.
+    if (m_process) {
+        size_t numMessagePorts = m_store.messagePorts.size();
+        for (size_t i = 0; i < numMessagePorts; ++i)
+            m_process->removeMessagePortChannel(m_store.messagePorts[i]);
+    }
+}
+
 PassRefPtr<WebSerializedScriptValue> WebIntentData::data() const
 {
     Vector<uint8_t> dataCopy = m_store.data;
 PassRefPtr<WebSerializedScriptValue> WebIntentData::data() const
 {
     Vector<uint8_t> dataCopy = m_store.data;
@@ -66,6 +79,7 @@ PassRefPtr<ImmutableDictionary> WebIntentData::extras() const
     HashMap<String, String>::const_iterator end = m_store.extras.end();
     for (HashMap<String, String>::const_iterator it = m_store.extras.begin(); it != end; ++it)
         wkExtras.set(it->first, WebString::create(it->second));
     HashMap<String, String>::const_iterator end = m_store.extras.end();
     for (HashMap<String, String>::const_iterator it = m_store.extras.begin(); it != end; ++it)
         wkExtras.set(it->first, WebString::create(it->second));
+
     return ImmutableDictionary::adopt(wkExtras);
 }
 
     return ImmutableDictionary::adopt(wkExtras);
 }
 
index decf4ae..9d59f90 100644 (file)
 
 #include "APIObject.h"
 #include "IntentData.h"
 
 #include "APIObject.h"
 #include "IntentData.h"
-#include "WebSerializedScriptValue.h"
+#include <WebCore/KURL.h>
 #include <wtf/PassRefPtr.h>
 
 namespace WebKit {
 
 #include <wtf/PassRefPtr.h>
 
 namespace WebKit {
 
+class ImmutableArray;
+class ImmutableDictionary;
+class WebProcessProxy;
+class WebSerializedScriptValue;
+
 class WebIntentData : public APIObject {
 public:
     static const Type APIType = TypeIntentData;
 
 class WebIntentData : public APIObject {
 public:
     static const Type APIType = TypeIntentData;
 
-    static PassRefPtr<WebIntentData> create(const IntentData& store)
+    static PassRefPtr<WebIntentData> create(const IntentData& store, WebProcessProxy* process)
     {
     {
-        return adoptRef(new WebIntentData(store));
+        return adoptRef(new WebIntentData(store, process));
     }
 
     }
 
-    virtual ~WebIntentData() { }
+    virtual ~WebIntentData();
 
     const String& action() const { return m_store.action; }
     const String& payloadType() const { return m_store.type; }
 
     const String& action() const { return m_store.action; }
     const String& payloadType() const { return m_store.type; }
@@ -57,11 +62,12 @@ public:
     const IntentData& store() const { return m_store; }
 
 private:
     const IntentData& store() const { return m_store; }
 
 private:
-    WebIntentData(const IntentData&);
+    WebIntentData(const IntentData&, WebProcessProxy*);
 
     virtual Type type() const { return APIType; }
 
     IntentData m_store;
 
     virtual Type type() const { return APIType; }
 
     IntentData m_store;
+    WebProcessProxy* m_process;
 };
 
 } // namespace WebKit
 };
 
 } // namespace WebKit
index 9c4df8e..ff13743 100644 (file)
@@ -2206,7 +2206,7 @@ void WebPageProxy::didReceiveIntentForFrame(uint64_t frameID, const IntentData&
     WebFrameProxy* frame = process()->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
     WebFrameProxy* frame = process()->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
-    RefPtr<WebIntentData> webIntentData = WebIntentData::create(intentData);
+    RefPtr<WebIntentData> webIntentData = WebIntentData::create(intentData, process());
     m_loaderClient.didReceiveIntentForFrame(this, frame, webIntentData.get(), userData.get());
 }
 #endif
     m_loaderClient.didReceiveIntentForFrame(this, frame, webIntentData.get(), userData.get());
 }
 #endif
index 3e70fee..22a2b7f 100644 (file)
@@ -199,6 +199,16 @@ void WebProcessProxy::removeWebPage(uint64_t pageID)
     m_pageMap.remove(pageID);
 }
 
     m_pageMap.remove(pageID);
 }
 
+#if ENABLE(WEB_INTENTS)
+void WebProcessProxy::removeMessagePortChannel(uint64_t channelID)
+{
+    if (!isValid())
+        return;
+
+    send(Messages::WebProcess::RemoveMessagePortChannel(channelID), /* destinationID */ 0);
+}
+#endif
+
 WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) const
 {
     return m_backForwardListItemMap.get(itemID).get();
 WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) const
 {
     return m_backForwardListItemMap.get(itemID).get();
index 40ab548..2dc204f 100644 (file)
@@ -85,6 +85,10 @@ public:
     void addExistingWebPage(WebPageProxy*, uint64_t pageID);
     void removeWebPage(uint64_t pageID);
 
     void addExistingWebPage(WebPageProxy*, uint64_t pageID);
     void removeWebPage(uint64_t pageID);
 
+#if ENABLE(WEB_INTENTS)
+    void removeMessagePortChannel(uint64_t channelID);
+#endif
+
     WebBackForwardListItem* webBackForwardItem(uint64_t itemID) const;
 
     ResponsivenessTimer* responsivenessTimer() { return &m_responsivenessTimer; }
     WebBackForwardListItem* webBackForwardItem(uint64_t itemID) const;
 
     ResponsivenessTimer* responsivenessTimer() { return &m_responsivenessTimer; }
index 3355d08..018ef79 100644 (file)
@@ -46,6 +46,7 @@ class InjectedBundleBackForwardList;
 class InjectedBundleBackForwardListItem;
 class InjectedBundleDOMWindowExtension;
 class InjectedBundleHitTestResult;
 class InjectedBundleBackForwardListItem;
 class InjectedBundleDOMWindowExtension;
 class InjectedBundleHitTestResult;
+class InjectedBundleIntent;
 class InjectedBundleIntentRequest;
 class InjectedBundleNavigationAction;
 class InjectedBundleNodeHandle;
 class InjectedBundleIntentRequest;
 class InjectedBundleNavigationAction;
 class InjectedBundleNodeHandle;
@@ -64,6 +65,7 @@ WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtensi
 WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
 WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
 WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
 WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
 WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
 WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
+WK_ADD_API_MAPPING(WKBundleIntentRef, InjectedBundleIntent)
 WK_ADD_API_MAPPING(WKBundleIntentRequestRef, InjectedBundleIntentRequest)
 WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction)
 WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle)
 WK_ADD_API_MAPPING(WKBundleIntentRequestRef, InjectedBundleIntentRequest)
 WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction)
 WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.cpp
new file mode 100644 (file)
index 0000000..561a514
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * 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 "WKBundleIntent.h"
+
+#if ENABLE(WEB_INTENTS)
+#include "ImmutableArray.h"
+#include "ImmutableDictionary.h"
+#include "InjectedBundleIntent.h"
+#include "WKAPICast.h"
+#include "WKBundleAPICast.h"
+#include "WKDictionary.h"
+#include "WKString.h"
+#include "WebSerializedScriptValue.h"
+
+using namespace WebCore;
+using namespace WebKit;
+#endif
+
+WKTypeID WKBundleIntentGetTypeID()
+{
+#if ENABLE(WEB_INTENTS)
+    return toAPI(InjectedBundleIntent::APIType);
+#else
+    return 0;
+#endif
+}
+
+WKBundleIntentRef WKBundleIntentCreate(WKDictionaryRef dictionaryRef)
+{
+#if ENABLE(WEB_INTENTS)
+    WKStringRef action = static_cast<WKStringRef>(WKDictionaryGetItemForKey(dictionaryRef, WKStringCreateWithUTF8CString("action")));
+    ASSERT(action);
+    WKStringRef type = static_cast<WKStringRef>(WKDictionaryGetItemForKey(dictionaryRef, WKStringCreateWithUTF8CString("type")));
+    ASSERT(type);
+    WKSerializedScriptValueRef data = static_cast<WKSerializedScriptValueRef>(WKDictionaryGetItemForKey(dictionaryRef, WKStringCreateWithUTF8CString("data")));
+    MessagePortArray dummyPorts;
+    ExceptionCode ec;
+
+    RefPtr<Intent> coreIntent = Intent::create(toImpl(action)->string(), toImpl(type)->string(), data ? static_cast<SerializedScriptValue*>(toImpl(data)->internalRepresentation()) : 0, dummyPorts, ec);
+
+    return toAPI(InjectedBundleIntent::create(coreIntent.get()).leakRef());
+#else
+    return 0;
+#endif
+}
+
+WKStringRef WKBundleIntentCopyAction(WKBundleIntentRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+    return toCopiedAPI(toImpl(intentRef)->action());
+#else
+    return 0;
+#endif
+}
+
+WKStringRef WKBundleIntentCopyType(WKBundleIntentRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+    return toCopiedAPI(toImpl(intentRef)->payloadType());
+#else
+    return 0;
+#endif
+}
+
+WKURLRef WKBundleIntentCopyService(WKBundleIntentRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+    return toCopiedURLAPI(toImpl(intentRef)->service());
+#else
+    return 0;
+#endif
+}
+
+WKArrayRef WKBundleIntentCopySuggestions(WKBundleIntentRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+    return toAPI(toImpl(intentRef)->suggestions().leakRef());
+#else
+    return 0;
+#endif
+}
+
+WKStringRef WKBundleIntentCopyExtraValue(WKBundleIntentRef intentRef, WKStringRef key)
+{
+#if ENABLE(WEB_INTENTS)
+    return toCopiedAPI(toImpl(intentRef)->extra(toWTFString(key)));
+#else
+    return 0;
+#endif
+}
+
+WKDictionaryRef WKBundleIntentCopyExtras(WKBundleIntentRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+    return toAPI(toImpl(intentRef)->extras().leakRef());
+#else
+    return 0;
+#endif
+}
+
+size_t WKBundleIntentMessagePortCount(WKBundleIntentRef intentRef)
+{
+#if ENABLE(WEB_INTENTS)
+    MessagePortChannelArray* messagePorts = toImpl(intentRef)->coreIntent()->messagePorts();
+
+    return messagePorts ? messagePorts->size() : 0;
+#else
+    return 0;
+#endif
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleIntent.h
new file mode 100644 (file)
index 0000000..503fe02
--- /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.
+ */
+
+#ifndef WKBundleIntent_h
+#define WKBundleIntent_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKBundleIntentGetTypeID();
+
+WK_EXPORT WKBundleIntentRef WKBundleIntentCreate(WKDictionaryRef dictionaryRef);
+
+WK_EXPORT WKStringRef WKBundleIntentCopyAction(WKBundleIntentRef intentRef);
+WK_EXPORT WKStringRef WKBundleIntentCopyType(WKBundleIntentRef intentRef);
+WK_EXPORT WKURLRef WKBundleIntentCopyService(WKBundleIntentRef intentRef);
+WK_EXPORT WKArrayRef WKBundleIntentCopySuggestions(WKBundleIntentRef intentRef);
+WK_EXPORT WKStringRef WKBundleIntentCopyExtraValue(WKBundleIntentRef intentRef, WKStringRef key);
+WK_EXPORT WKDictionaryRef WKBundleIntentCopyExtras(WKBundleIntentRef intentRef);
+WK_EXPORT size_t WKBundleIntentMessagePortCount(WKBundleIntentRef intentRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKBundleIntent_h
index 81c95c6..a4772ea 100644 (file)
 #include "WKBundleIntentRequest.h"
 
 #if ENABLE(WEB_INTENTS)
 #include "WKBundleIntentRequest.h"
 
 #if ENABLE(WEB_INTENTS)
+#include "InjectedBundleIntent.h"
 #include "InjectedBundleIntentRequest.h"
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
 #include "InjectedBundleIntentRequest.h"
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
-#include "WebIntentData.h"
 
 using namespace WebKit;
 #endif
 
 using namespace WebKit;
 #endif
@@ -44,11 +44,11 @@ WKTypeID WKBundleIntentRequestGetTypeID()
 #endif
 }
 
 #endif
 }
 
-WKIntentDataRef WKBundleIntentRequestCopyIntentData(WKBundleIntentRequestRef requestRef)
+WKBundleIntentRef WKBundleIntentRequestCopyIntent(WKBundleIntentRequestRef requestRef)
 {
 #if ENABLE(WEB_INTENTS)
 {
 #if ENABLE(WEB_INTENTS)
-    RefPtr<WebIntentData> webIntentData = toImpl(requestRef)->intent();
-    return toAPI(webIntentData.release().leakRef());
+    RefPtr<InjectedBundleIntent> webIntent = toImpl(requestRef)->intent();
+    return toAPI(webIntent.release().leakRef());
 #else
     return 0;
 #endif
 #else
     return 0;
 #endif
index b18136d..105afa4 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
 
 WK_EXPORT WKTypeID WKBundleIntentRequestGetTypeID();
 
 
 WK_EXPORT WKTypeID WKBundleIntentRequestGetTypeID();
 
-WK_EXPORT WKIntentDataRef WKBundleIntentRequestCopyIntentData(WKBundleIntentRequestRef request);
+WK_EXPORT WKBundleIntentRef WKBundleIntentRequestCopyIntent(WKBundleIntentRequestRef request);
 
 WK_EXPORT void WKBundleIntentRequestPostResult(WKBundleIntentRequestRef request, WKSerializedScriptValueRef serializedData);
 WK_EXPORT void WKBundleIntentRequestPostFailure(WKBundleIntentRequestRef request, WKSerializedScriptValueRef serializedData);
 
 WK_EXPORT void WKBundleIntentRequestPostResult(WKBundleIntentRequestRef request, WKSerializedScriptValueRef serializedData);
 WK_EXPORT void WKBundleIntentRequestPostFailure(WKBundleIntentRequestRef request, WKSerializedScriptValueRef serializedData);
index 1f43a12..bf463ce 100644 (file)
@@ -47,7 +47,7 @@
 #include <WebCore/Page.h>
 
 #if ENABLE(WEB_INTENTS)
 #include <WebCore/Page.h>
 
 #if ENABLE(WEB_INTENTS)
-#include "WebIntentData.h"
+#include "InjectedBundleIntent.h"
 #endif
 
 using namespace WebKit;
 #endif
 
 using namespace WebKit;
@@ -316,10 +316,10 @@ double WKBundlePageGetBackingScaleFactor(WKBundlePageRef pageRef)
     return toImpl(pageRef)->deviceScaleFactor();
 }
 
     return toImpl(pageRef)->deviceScaleFactor();
 }
 
-void WKBundlePageDeliverIntentToFrame(WKBundlePageRef pageRef, WKBundleFrameRef frameRef, WKIntentDataRef intentRef)
+void WKBundlePageDeliverIntentToFrame(WKBundlePageRef pageRef, WKBundleFrameRef frameRef, WKBundleIntentRef intentRef)
 {
 #if ENABLE(WEB_INTENTS)
 {
 #if ENABLE(WEB_INTENTS)
-    toImpl(pageRef)->deliverIntentToFrame(toImpl(frameRef)->frameID(), toImpl(intentRef)->store());
+    toImpl(pageRef)->deliverCoreIntentToFrame(toImpl(frameRef)->frameID(), toImpl(intentRef)->coreIntent());
 #endif
 }
 
 #endif
 }
 
index 28eee5c..8bc7670 100644 (file)
@@ -410,7 +410,7 @@ WK_EXPORT WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBun
 
 WK_EXPORT double WKBundlePageGetBackingScaleFactor(WKBundlePageRef page);
 
 
 WK_EXPORT double WKBundlePageGetBackingScaleFactor(WKBundlePageRef page);
 
-WK_EXPORT void WKBundlePageDeliverIntentToFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKIntentDataRef intent);
+WK_EXPORT void WKBundlePageDeliverIntentToFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleIntentRef intent);
 
 #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
 WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
 
 #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
 WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.cpp
new file mode 100644 (file)
index 0000000..92de61c
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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 "InjectedBundleIntent.h"
+
+#if ENABLE(WEB_INTENTS)
+
+#include "ImmutableArray.h"
+#include "ImmutableDictionary.h"
+#include "WebSerializedScriptValue.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<InjectedBundleIntent> InjectedBundleIntent::create(WebCore::Intent* intent)
+{
+    return adoptRef(new InjectedBundleIntent(intent));
+}
+
+InjectedBundleIntent::InjectedBundleIntent(WebCore::Intent* intent)
+    : m_intent(intent)
+{
+}
+
+String InjectedBundleIntent::action() const
+{
+    return m_intent->action();
+}
+
+String InjectedBundleIntent::payloadType() const
+{
+    return m_intent->type();
+}
+
+WebCore::KURL InjectedBundleIntent::service() const
+{
+    return m_intent->service();
+}
+
+PassRefPtr<WebSerializedScriptValue> InjectedBundleIntent::data() const
+{
+    return WebSerializedScriptValue::create(m_intent->data());
+}
+
+String InjectedBundleIntent::extra(const String& key) const
+{
+    return m_intent->extras().get(key);
+}
+
+PassRefPtr<ImmutableDictionary> InjectedBundleIntent::extras() const
+{
+    const HashMap<String, String>& extras = m_intent->extras();
+    ImmutableDictionary::MapType wkExtras;
+    HashMap<String, String>::const_iterator end = extras.end();
+    for (HashMap<String, String>::const_iterator it = extras.begin(); it != end; ++it)
+        wkExtras.set(it->first, WebString::create(it->second));
+
+    return ImmutableDictionary::adopt(wkExtras);
+}
+
+PassRefPtr<ImmutableArray> InjectedBundleIntent::suggestions() const
+{
+    const Vector<KURL>& suggestions = m_intent->suggestions();
+    const size_t numSuggestions = suggestions.size();
+    Vector<RefPtr<APIObject> > wkSuggestions(numSuggestions);
+    for (unsigned i = 0; i < numSuggestions; ++i)
+        wkSuggestions[i] = WebURL::create(suggestions[i]);
+
+    return ImmutableArray::adopt(wkSuggestions);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_INTENTS)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleIntent.h
new file mode 100644 (file)
index 0000000..5d3f06c
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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 InjectedBundleIntent_h
+#define InjectedBundleIntent_h
+
+#if ENABLE(WEB_INTENTS)
+
+#include "APIObject.h"
+#include <WebCore/Intent.h>
+#include <WebCore/KURL.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class ImmutableArray;
+class ImmutableDictionary;
+class WebSerializedScriptValue;
+
+class InjectedBundleIntent : public APIObject {
+public:
+    static const Type APIType = TypeBundleIntent;
+
+    static PassRefPtr<InjectedBundleIntent> create(WebCore::Intent*);
+
+    String action() const;
+    String payloadType() const;
+    WebCore::KURL service() const;
+    PassRefPtr<WebSerializedScriptValue> data() const;
+    String extra(const String& key) const;
+    PassRefPtr<ImmutableDictionary> extras() const;
+    PassRefPtr<ImmutableArray> suggestions() const;
+
+    WebCore::Intent* coreIntent() const { return m_intent.get(); }
+
+private:
+    explicit InjectedBundleIntent(WebCore::Intent*);
+
+    virtual Type type() const { return APIType; }
+
+    RefPtr<WebCore::Intent> m_intent;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_INTENTS)
+
+#endif // InjectedBundleIntent_h
index 5ccb19c..eac0b83 100644 (file)
@@ -27,6 +27,7 @@
 #include "InjectedBundleIntentRequest.h"
 
 #if ENABLE(WEB_INTENTS)
 #include "InjectedBundleIntentRequest.h"
 
 #if ENABLE(WEB_INTENTS)
+#include "InjectedBundleIntent.h"
 #include <WebCore/IntentRequest.h>
 #include <WebSerializedScriptValue.h>
 
 #include <WebCore/IntentRequest.h>
 #include <WebSerializedScriptValue.h>
 
@@ -54,9 +55,9 @@ void InjectedBundleIntentRequest::postFailure(WebSerializedScriptValue* data)
     m_intentRequest->postFailure(static_cast<SerializedScriptValue*>(data->internalRepresentation()));
 }
 
     m_intentRequest->postFailure(static_cast<SerializedScriptValue*>(data->internalRepresentation()));
 }
 
-PassRefPtr<WebIntentData> InjectedBundleIntentRequest::intent() const
+PassRefPtr<InjectedBundleIntent> InjectedBundleIntentRequest::intent() const
 {
 {
-    return WebIntentData::create(IntentData(m_intentRequest->intent()));
+    return InjectedBundleIntent::create(m_intentRequest->intent());
 }
 
 } // namespace WebKit
 }
 
 } // namespace WebKit
index b5870d9..33a3192 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(WEB_INTENTS)
 
 #include "APIObject.h"
 #if ENABLE(WEB_INTENTS)
 
 #include "APIObject.h"
-#include "WebIntentData.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
@@ -40,6 +39,7 @@ class IntentRequest;
 
 namespace WebKit {
 
 
 namespace WebKit {
 
+class InjectedBundleIntent;
 class WebSerializedScriptValue;
 
 class InjectedBundleIntentRequest : public APIObject {
 class WebSerializedScriptValue;
 
 class InjectedBundleIntentRequest : public APIObject {
@@ -51,7 +51,7 @@ public:
     void postResult(WebSerializedScriptValue*);
     void postFailure(WebSerializedScriptValue*);
 
     void postResult(WebSerializedScriptValue*);
     void postFailure(WebSerializedScriptValue*);
 
-    PassRefPtr<WebIntentData> intent() const;
+    PassRefPtr<InjectedBundleIntent> intent() const;
 
 private:
     explicit InjectedBundleIntentRequest(WebCore::IntentRequest*);
 
 private:
     explicit InjectedBundleIntentRequest(WebCore::IntentRequest*);
index 19243be..fd6f4c8 100644 (file)
@@ -63,6 +63,8 @@
 #include "IntentData.h"
 #include <WebCore/DOMWindowIntents.h>
 #include <WebCore/DeliveredIntent.h>
 #include "IntentData.h"
 #include <WebCore/DOMWindowIntents.h>
 #include <WebCore/DeliveredIntent.h>
+#include <WebCore/Intent.h>
+#include <WebCore/PlatformMessagePortChannel.h>
 #endif
 
 #if PLATFORM(MAC) || PLATFORM(WIN)
 #endif
 
 #if PLATFORM(MAC) || PLATFORM(WIN)
@@ -246,13 +248,39 @@ void WebFrame::convertHandleToDownload(ResourceHandle* handle, const ResourceReq
 void WebFrame::deliverIntent(const IntentData& intentData)
 {
     OwnPtr<DeliveredIntentClient> dummyClient;
 void WebFrame::deliverIntent(const IntentData& intentData)
 {
     OwnPtr<DeliveredIntentClient> dummyClient;
-    OwnPtr<MessagePortArray> dummyPorts;
     Vector<uint8_t> dataCopy = intentData.data;
     Vector<uint8_t> dataCopy = intentData.data;
+
+    OwnPtr<WebCore::MessagePortChannelArray> channels;
+    if (!intentData.messagePorts.isEmpty()) {
+        channels = adoptPtr(new WebCore::MessagePortChannelArray(intentData.messagePorts.size()));
+        for (size_t i = 0; i < intentData.messagePorts.size(); ++i)
+            (*channels)[i] = MessagePortChannel::create(WebProcess::shared().messagePortChannel(intentData.messagePorts.at(i)));
+    }
+    OwnPtr<WebCore::MessagePortArray> messagePorts = WebCore::MessagePort::entanglePorts(*m_coreFrame->document()->domWindow()->scriptExecutionContext(), channels.release());
+
     RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_coreFrame, dummyClient.release(), intentData.action, intentData.type,
     RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_coreFrame, dummyClient.release(), intentData.action, intentData.type,
-                                                                      SerializedScriptValue::adopt(dataCopy), dummyPorts.release(),
+                                                                      SerializedScriptValue::adopt(dataCopy), messagePorts.release(),
                                                                       intentData.extras);
     WebCore::DOMWindowIntents::from(m_coreFrame->document()->domWindow())->deliver(deliveredIntent.release());
 }
                                                                       intentData.extras);
     WebCore::DOMWindowIntents::from(m_coreFrame->document()->domWindow())->deliver(deliveredIntent.release());
 }
+
+void WebFrame::deliverIntent(WebCore::Intent* intent)
+{
+    OwnPtr<DeliveredIntentClient> dummyClient;
+
+    OwnPtr<WebCore::MessagePortChannelArray> channels;
+    WebCore::MessagePortChannelArray* origChannels = intent->messagePorts();
+    if (origChannels && origChannels->size()) {
+        channels = adoptPtr(new WebCore::MessagePortChannelArray(origChannels->size()));
+        for (size_t i = 0; i < origChannels->size(); ++i)
+            (*channels)[i] = origChannels->at(i).release();
+    }
+    OwnPtr<WebCore::MessagePortArray> messagePorts = WebCore::MessagePort::entanglePorts(*m_coreFrame->document()->domWindow()->scriptExecutionContext(), channels.release());
+
+    RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_coreFrame, dummyClient.release(), intent->action(), intent->type(),
+                                                                      intent->data(), messagePorts.release(), intent->extras());
+    WebCore::DOMWindowIntents::from(m_coreFrame->document()->domWindow())->deliver(deliveredIntent.release());
+}
 #endif
 
 String WebFrame::source() const 
 #endif
 
 String WebFrame::source() const 
index bd6c038..eea09b7 100644 (file)
@@ -42,6 +42,9 @@
 namespace WebCore {
     class Frame;
     class HTMLFrameOwnerElement;
 namespace WebCore {
     class Frame;
     class HTMLFrameOwnerElement;
+#if ENABLE(WEB_INTENTS)
+    class Intent;
+#endif
     class KURL;
 }
 
     class KURL;
 }
 
@@ -81,6 +84,7 @@ public:
 
 #if ENABLE(WEB_INTENTS)
     void deliverIntent(const IntentData&);
 
 #if ENABLE(WEB_INTENTS)
     void deliverIntent(const IntentData&);
+    void deliverIntent(WebCore::Intent*);
 #endif
 
     String source() const;
 #endif
 
     String source() const;
index 7989b29..eb191e6 100644 (file)
 
 #if ENABLE(WEB_INTENTS)
 #include "IntentData.h"
 
 #if ENABLE(WEB_INTENTS)
 #include "IntentData.h"
+#include <WebCore/Intent.h>
 #endif
 
 #if ENABLE(VIBRATION)
 #endif
 
 #if ENABLE(VIBRATION)
@@ -1959,6 +1960,12 @@ void WebPage::deliverIntentToFrame(uint64_t frameID, const IntentData& intentDat
 
     frame->deliverIntent(intentData);
 }
 
     frame->deliverIntent(intentData);
 }
+
+void WebPage::deliverCoreIntentToFrame(uint64_t frameID, Intent* coreIntent)
+{
+    if (WebFrame* frame = WebProcess::shared().webFrame(frameID))
+        frame->deliverIntent(coreIntent);
+}
 #endif
 
 void WebPage::preferencesDidChange(const WebPreferencesStore& store)
 #endif
 
 void WebPage::preferencesDidChange(const WebPreferencesStore& store)
index bbfabd0..ec5af0e 100644 (file)
@@ -106,6 +106,9 @@ namespace WebCore {
     class Frame;
     class FrameView;
     class HTMLPlugInElement;
     class Frame;
     class FrameView;
     class HTMLPlugInElement;
+#if ENABLE(WEB_INTENTS)
+    class Intent;
+#endif
     class KeyboardEvent;
     class Page;
     class PrintContext;
     class KeyboardEvent;
     class Page;
     class PrintContext;
@@ -476,7 +479,7 @@ public:
 #endif
 
 #if ENABLE(WEB_INTENTS)
 #endif
 
 #if ENABLE(WEB_INTENTS)
-    void deliverIntentToFrame(uint64_t frameID, const IntentData&);
+    void deliverCoreIntentToFrame(uint64_t frameID, WebCore::Intent*);
 #endif
 
     void replaceSelectionWithText(WebCore::Frame*, const String&);
 #endif
 
     void replaceSelectionWithText(WebCore::Frame*, const String&);
@@ -641,6 +644,10 @@ private:
     void contextMenuHidden() { m_isShowingContextMenu = false; }
 #endif
 
     void contextMenuHidden() { m_isShowingContextMenu = false; }
 #endif
 
+#if ENABLE(WEB_INTENTS)
+    void deliverIntentToFrame(uint64_t frameID, const IntentData&);
+#endif
+
     static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
     static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
 
     static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
     static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
 
index 3e756ec..480cd71 100644 (file)
 #include <wtf/PassRefPtr.h>
 #include <wtf/RandomNumber.h>
 
 #include <wtf/PassRefPtr.h>
 #include <wtf/RandomNumber.h>
 
+#if ENABLE(WEB_INTENTS)
+#include <WebCore/PlatformMessagePortChannel.h>
+#endif
+
 #if ENABLE(NETWORK_INFO)
 #include "WebNetworkInfoManagerMessages.h"
 #endif
 #if ENABLE(NETWORK_INFO)
 #include "WebNetworkInfoManagerMessages.h"
 #endif
@@ -791,6 +795,26 @@ WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupDat
     return result.iterator->second.get();
 }
 
     return result.iterator->second.get();
 }
 
+#if ENABLE(WEB_INTENTS)
+uint64_t WebProcess::addMessagePortChannel(PassRefPtr<PlatformMessagePortChannel> messagePortChannel)
+{
+    static uint64_t channelID = 0;
+    m_messagePortChannels.add(++channelID, messagePortChannel);
+
+    return channelID;
+}
+
+PlatformMessagePortChannel* WebProcess::messagePortChannel(uint64_t channelID)
+{
+    return m_messagePortChannels.get(channelID).get();
+}
+
+void WebProcess::removeMessagePortChannel(uint64_t channelID)
+{
+    m_messagePortChannels.remove(channelID);
+}
+#endif
+
 static bool canPluginHandleResponse(const ResourceResponse& response)
 {
     String pluginPath;
 static bool canPluginHandleResponse(const ResourceResponse& response)
 {
     String pluginPath;
index 0d005a4..d3df1b7 100644 (file)
@@ -78,6 +78,9 @@ QT_END_NAMESPACE
 namespace WebCore {
     class IntSize;
     class PageGroup;
 namespace WebCore {
     class IntSize;
     class PageGroup;
+#if ENABLE(WEB_INTENTS)
+    class PlatformMessagePortChannel;
+#endif
     class ResourceRequest;
     class ResourceResponse;
 }
     class ResourceRequest;
     class ResourceResponse;
 }
@@ -112,7 +115,13 @@ public:
     void createWebPage(uint64_t pageID, const WebPageCreationParameters&);
     void removeWebPage(uint64_t pageID);
     WebPage* focusedWebPage() const;
     void createWebPage(uint64_t pageID, const WebPageCreationParameters&);
     void removeWebPage(uint64_t pageID);
     WebPage* focusedWebPage() const;
-    
+
+#if ENABLE(WEB_INTENTS) 
+    uint64_t addMessagePortChannel(PassRefPtr<WebCore::PlatformMessagePortChannel>);
+    WebCore::PlatformMessagePortChannel* messagePortChannel(uint64_t);
+    void removeMessagePortChannel(uint64_t);
+#endif
+
     InjectedBundle* injectedBundle() const { return m_injectedBundle.get(); }
 
     bool isSeparateProcess() const;
     InjectedBundle* injectedBundle() const { return m_injectedBundle.get(); }
 
     bool isSeparateProcess() const;
@@ -300,6 +309,10 @@ private:
 
     HashMap<uint64_t, WebFrame*> m_frameMap;
 
 
     HashMap<uint64_t, WebFrame*> m_frameMap;
 
+#if ENABLE(WEB_INTENTS)
+    HashMap<uint64_t, RefPtr<WebCore::PlatformMessagePortChannel> > m_messagePortChannels;
+#endif
+
     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
 
     TextCheckerState m_textCheckerState;
     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
 
     TextCheckerState m_textCheckerState;
index 0f83d5b..22716ce 100644 (file)
@@ -27,6 +27,10 @@ messages -> WebProcess {
     # Create a new page.
     CreateWebPage(uint64_t newPageID, WebKit::WebPageCreationParameters pageCreationParameters)
 
     # Create a new page.
     CreateWebPage(uint64_t newPageID, WebKit::WebPageCreationParameters pageCreationParameters)
 
+#if ENABLE(WEB_INTENTS)
+    RemoveMessagePortChannel(uint64_t channelID);
+#endif
+
     # Visited link tracking.
     SetVisitedLinkTable(WebKit::SharedMemory::Handle handle)
     VisitedLinkStateChanged(Vector<WebCore::LinkHash> linkHashes)
     # Visited link tracking.
     SetVisitedLinkTable(WebKit::SharedMemory::Handle handle)
     VisitedLinkStateChanged(Vector<WebCore::LinkHash> linkHashes)
index eef0a64..3f12872 100644 (file)
@@ -1,3 +1,22 @@
+2012-08-15  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2] Add support for Web Intents MessagePorts
+        https://bugs.webkit.org/show_bug.cgi?id=89072
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Use WKBundleIntent instead of WebIntentData in
+        WebKitTestRunner. WTR now prints the number of
+        MessagePorts in received Web intents as
+        expected by the following layout tests:
+        webintents/web-intents-invoke-port.html
+        webintents/web-intents-obj-constructor.html
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::didReceiveIntentForFrame):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::deliverWebIntent):
+
 2012-08-14  Ryosuke Niwa  <rniwa@webkit.org>
 
         Build fix after r125516. Revert the erroneous rename since we need to keep exposing
 2012-08-14  Ryosuke Niwa  <rniwa@webkit.org>
 
         Build fix after r125516. Revert the erroneous rename since we need to keep exposing
index 6e2f508..3bc035c 100644 (file)
@@ -51,8 +51,8 @@
 #endif
 
 #if ENABLE(WEB_INTENTS)
 #endif
 
 #if ENABLE(WEB_INTENTS)
+#include <WebKit2/WKBundleIntent.h>
 #include <WebKit2/WKBundleIntentRequest.h>
 #include <WebKit2/WKBundleIntentRequest.h>
-#include <WebKit2/WKIntentData.h>
 #endif
 #if ENABLE(WEB_INTENTS_TAG)
 #include <WebKit2/WKIntentServiceInfo.h>
 #endif
 #if ENABLE(WEB_INTENTS_TAG)
 #include <WebKit2/WKIntentServiceInfo.h>
@@ -548,19 +548,24 @@ void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundle
 {
 #if ENABLE(WEB_INTENTS)
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->m_currentIntentRequest = intentRequest;
 {
 #if ENABLE(WEB_INTENTS)
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->m_currentIntentRequest = intentRequest;
-    WKRetainPtr<WKIntentDataRef> intent(AdoptWK, WKBundleIntentRequestCopyIntentData(intentRequest));
+    WKRetainPtr<WKBundleIntentRef> intent(AdoptWK, WKBundleIntentRequestCopyIntent(intentRequest));
 
     InjectedBundle::shared().stringBuilder()->append("Received Web Intent: action=");
 
     InjectedBundle::shared().stringBuilder()->append("Received Web Intent: action=");
-    WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKIntentDataCopyAction(intent.get()));
+    WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKBundleIntentCopyAction(intent.get()));
     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkAction.get()));
     InjectedBundle::shared().stringBuilder()->append(" type=");
     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkAction.get()));
     InjectedBundle::shared().stringBuilder()->append(" type=");
-    WKRetainPtr<WKStringRef> wkType(AdoptWK, WKIntentDataCopyType(intent.get()));
+    WKRetainPtr<WKStringRef> wkType(AdoptWK, WKBundleIntentCopyType(intent.get()));
     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkType.get()));
     InjectedBundle::shared().stringBuilder()->append("\n");
 
     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkType.get()));
     InjectedBundle::shared().stringBuilder()->append("\n");
 
-    // FIXME: Print number of ports when exposed in WebKit2
+    const size_t numMessagePorts = WKBundleIntentMessagePortCount(intent.get());
+    if (numMessagePorts) {
+        InjectedBundle::shared().stringBuilder()->append("Have ");
+        InjectedBundle::shared().stringBuilder()->append(WTF::String::number(numMessagePorts));
+        InjectedBundle::shared().stringBuilder()->append(" ports\n");
+    }
 
 
-    WKRetainPtr<WKURLRef> wkServiceUrl(AdoptWK, WKIntentDataCopyService(intent.get()));
+    WKRetainPtr<WKURLRef> wkServiceUrl(AdoptWK, WKBundleIntentCopyService(intent.get()));
     if (wkServiceUrl) {
         WKRetainPtr<WKStringRef> wkService(AdoptWK, WKURLCopyString(wkServiceUrl.get()));
         if (wkService && !WKStringIsEmpty(wkService.get())) {
     if (wkServiceUrl) {
         WKRetainPtr<WKStringRef> wkService(AdoptWK, WKURLCopyString(wkServiceUrl.get()));
         if (wkService && !WKStringIsEmpty(wkService.get())) {
@@ -570,7 +575,7 @@ void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundle
         }
     }
 
         }
     }
 
-    WKRetainPtr<WKDictionaryRef> wkExtras(AdoptWK, WKIntentDataCopyExtras(intent.get()));
+    WKRetainPtr<WKDictionaryRef> wkExtras(AdoptWK, WKBundleIntentCopyExtras(intent.get()));
     WKRetainPtr<WKArrayRef> wkExtraKeys(AdoptWK, WKDictionaryCopyKeys(wkExtras.get()));
     const size_t numExtraKeys = WKArrayGetSize(wkExtraKeys.get());
     for (size_t i = 0; i < numExtraKeys; ++i) {
     WKRetainPtr<WKArrayRef> wkExtraKeys(AdoptWK, WKDictionaryCopyKeys(wkExtras.get()));
     const size_t numExtraKeys = WKArrayGetSize(wkExtraKeys.get());
     for (size_t i = 0; i < numExtraKeys; ++i) {
@@ -583,7 +588,7 @@ void InjectedBundlePage::didReceiveIntentForFrame(WKBundlePageRef page, WKBundle
         InjectedBundle::shared().stringBuilder()->append("\n");
     }
 
         InjectedBundle::shared().stringBuilder()->append("\n");
     }
 
-    WKRetainPtr<WKArrayRef> wkSuggestions(AdoptWK, WKIntentDataCopySuggestions(intent.get()));
+    WKRetainPtr<WKArrayRef> wkSuggestions(AdoptWK, WKBundleIntentCopySuggestions(intent.get()));
     const size_t numSuggestions = WKArrayGetSize(wkSuggestions.get());
     for (size_t i = 0; i < numSuggestions; ++i) {
         WKStringRef wkSuggestion = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSuggestions.get(), i));
     const size_t numSuggestions = WKArrayGetSize(wkSuggestions.get());
     for (size_t i = 0; i < numSuggestions; ++i) {
         WKStringRef wkSuggestion = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSuggestions.get(), i));
index 7d1f784..b865a89 100644 (file)
@@ -49,8 +49,8 @@
 #include <wtf/text/StringBuilder.h>
 
 #if ENABLE(WEB_INTENTS)
 #include <wtf/text/StringBuilder.h>
 
 #if ENABLE(WEB_INTENTS)
+#include <WebKit2/WKBundleIntent.h>
 #include <WebKit2/WKBundleIntentRequest.h>
 #include <WebKit2/WKBundleIntentRequest.h>
-#include <WebKit2/WKIntentData.h>
 #endif
 
 namespace WTR {
 #endif
 
 namespace WTR {
@@ -652,8 +652,8 @@ void LayoutTestController::deliverWebIntent(JSStringRef action, JSStringRef type
     WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("type"), typeWK.get());
     WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("data"), dataWK.get());
 
     WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("type"), typeWK.get());
     WKDictionaryAddItem(intentInitDict.get(), WKStringCreateWithUTF8CString("data"), dataWK.get());
 
-    WKRetainPtr<WKIntentDataRef> wkIntentData(AdoptWK, WKIntentDataCreate(intentInitDict.get()));
-    WKBundlePageDeliverIntentToFrame(InjectedBundle::shared().page()->page(), mainFrame, wkIntentData.get());
+    WKRetainPtr<WKBundleIntentRef> wkIntent(AdoptWK, WKBundleIntentCreate(intentInitDict.get()));
+    WKBundlePageDeliverIntentToFrame(InjectedBundle::shared().page()->page(), mainFrame, wkIntent.get());
 #endif
 }
 
 #endif
 }