[WK2] Implement Web Intent delivery
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jun 2012 17:22:10 +0000 (17:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jun 2012 17:22:10 +0000 (17:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88989

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-06-20
Reviewed by Anders Carlsson.

Add a deliverIntent() method to the WebFrame so that
Web intents can be delivered once matched to a
specific service.

* UIProcess/WebFrameProxy.cpp:
(WebKit):
(WebKit::WebFrameProxy::deliverIntent):
* UIProcess/WebFrameProxy.h:
(WebKit):
(WebFrameProxy):
* UIProcess/WebIntentData.h:
(WebKit::WebIntentData::store):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit):
(WebKit::WebFrame::deliverIntent):
* WebProcess/WebPage/WebFrame.h:
(WebKit):
(WebFrame):
* WebProcess/WebPage/WebPage.cpp:
(WebKit):
(WebKit::WebPage::deliverIntentToFrame):
* WebProcess/WebPage/WebPage.h:
(WebKit):
(WebPage):
* WebProcess/WebPage/WebPage.messages.in:

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebFrameProxy.cpp
Source/WebKit2/UIProcess/WebFrameProxy.h
Source/WebKit2/UIProcess/WebIntentData.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/WebPage/WebPage.messages.in

index acc1407..35cbf6f 100644 (file)
@@ -1,3 +1,36 @@
+2012-06-20  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2] Implement Web Intent delivery
+        https://bugs.webkit.org/show_bug.cgi?id=88989
+
+        Reviewed by Anders Carlsson.
+
+        Add a deliverIntent() method to the WebFrame so that
+        Web intents can be delivered once matched to a
+        specific service.
+
+        * UIProcess/WebFrameProxy.cpp:
+        (WebKit):
+        (WebKit::WebFrameProxy::deliverIntent):
+        * UIProcess/WebFrameProxy.h:
+        (WebKit):
+        (WebFrameProxy):
+        * UIProcess/WebIntentData.h:
+        (WebKit::WebIntentData::store):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit):
+        (WebKit::WebFrame::deliverIntent):
+        * WebProcess/WebPage/WebFrame.h:
+        (WebKit):
+        (WebFrame):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit):
+        (WebKit::WebPage::deliverIntentToFrame):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit):
+        (WebPage):
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2012-06-20  Alexis Menard  <alexis.menard@openbossa.org>
 
         REGRESSION (120705) : LayerTreeHostQt asserts in debug.
index f60fab0..f97d85b 100644 (file)
 #include <stdio.h>
 #include <wtf/text/WTFString.h>
 
+#if ENABLE(WEB_INTENTS)
+#include "WebIntentData.h"
+#endif
+
 using namespace WebCore;
 using namespace std;
 
@@ -94,6 +98,19 @@ void WebFrameProxy::stopLoading() const
 
     m_page->process()->send(Messages::WebPage::StopLoadingFrame(m_frameID), m_page->pageID());
 }
+
+#if ENABLE(WEB_INTENTS)
+void WebFrameProxy::deliverIntent(WebIntentData* webIntentData)
+{
+    if (!m_page)
+        return;
+
+    if (!m_page->isValid())
+        return;
+
+    m_page->process()->send(Messages::WebPage::DeliverIntentToFrame(m_frameID, webIntentData->store()), m_page->pageID());
+}
+#endif
     
 bool WebFrameProxy::canProvideSource() const
 {
index de5a58c..1f7329b 100644 (file)
@@ -50,6 +50,10 @@ class WebFormSubmissionListenerProxy;
 class WebFramePolicyListenerProxy;
 class WebPageProxy;
 
+#if ENABLE(WEB_INTENTS)
+class WebIntentData;
+#endif
+
 typedef GenericCallback<WKDataRef> DataCallback;
 
 class WebFrameProxy : public APIObject {
@@ -86,6 +90,10 @@ public:
     bool isFrameSet() const { return m_isFrameSet; }
 
     LoadState loadState() const { return m_loadState; }
+
+#if ENABLE(WEB_INTENTS)
+    void deliverIntent(WebIntentData*);
+#endif
     
     void stopLoading() const;
 
index 3caef50..28fdfdd 100644 (file)
@@ -52,6 +52,7 @@ public:
     PassRefPtr<WebSerializedScriptValue> data() const;
     const HashMap<String, String>& extras() const { return m_store.extras; }
     const Vector<WebCore::KURL>& suggestions() const { return m_store.suggestions; }
+    const IntentData& store() const { return m_store; }
 
 private:
     WebIntentData(const IntentData&);
index ac869fb..db2ed41 100644 (file)
 #include <WebCore/TextResourceDecoder.h>
 #include <wtf/text/StringBuilder.h>
 
+#if ENABLE(WEB_INTENTS)
+#include "IntentData.h"
+#include <WebCore/DOMWindowIntents.h>
+#include <WebCore/DeliveredIntent.h>
+#endif
+
 #if PLATFORM(MAC) || PLATFORM(WIN)
 #include <WebCore/LegacyWebArchive.h>
 #endif
@@ -236,6 +242,19 @@ void WebFrame::convertHandleToDownload(ResourceHandle* handle, const ResourceReq
     m_policyDownloadID = 0;
 }
 
+#if ENABLE(WEB_INTENTS)
+void WebFrame::deliverIntent(const IntentData& intentData)
+{
+    OwnPtr<DeliveredIntentClient> dummyClient;
+    OwnPtr<MessagePortArray> dummyPorts;
+    Vector<uint8_t> dataCopy = intentData.data;
+    RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_coreFrame, dummyClient.release(), intentData.action, intentData.type,
+                                                                      SerializedScriptValue::adopt(dataCopy), dummyPorts.release(),
+                                                                      intentData.extras);
+    WebCore::DOMWindowIntents::from(m_coreFrame->domWindow())->deliver(deliveredIntent.release());
+}
+#endif
+
 String WebFrame::source() const 
 {
     if (!m_coreFrame)
index 839b579..bd6c038 100644 (file)
@@ -52,6 +52,10 @@ class InjectedBundleRangeHandle;
 class InjectedBundleScriptWorld;
 class WebPage;
 
+#if ENABLE(WEB_INTENTS)
+struct IntentData;
+#endif
+
 class WebFrame : public APIObject {
 public:
     static const Type APIType = TypeBundleFrame;
@@ -75,6 +79,10 @@ public:
     void startDownload(const WebCore::ResourceRequest&);
     void convertHandleToDownload(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
 
+#if ENABLE(WEB_INTENTS)
+    void deliverIntent(const IntentData&);
+#endif
+
     String source() const;
     String contentsAsString() const;
     String selectionAsString() const;
index ff94102..4961505 100644 (file)
 #endif
 #endif
 
+#if ENABLE(WEB_INTENTS)
+#include "IntentData.h"
+#endif
+
 #if PLATFORM(MAC)
 #include "BuiltInPDFView.h"
 #endif
@@ -1914,6 +1918,17 @@ void WebPage::forceRepaint(uint64_t callbackID)
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
+#if ENABLE(WEB_INTENTS)
+void WebPage::deliverIntentToFrame(uint64_t frameID, const IntentData& intentData)
+{
+    WebFrame* frame = WebProcess::shared().webFrame(frameID);
+    if (!frame)
+        return;
+
+    frame->deliverIntent(intentData);
+}
+#endif
+
 void WebPage::preferencesDidChange(const WebPreferencesStore& store)
 {
     WebPreferencesStore::removeTestRunnerOverrides();
index 32d4332..f1e1142 100644 (file)
@@ -143,6 +143,10 @@ struct PrintInfo;
 struct WebPageCreationParameters;
 struct WebPreferencesStore;
 
+#if ENABLE(WEB_INTENTS)
+struct IntentData;
+#endif
+
 #if ENABLE(GESTURE_EVENTS)
 class WebGestureEvent;
 #endif
@@ -635,6 +639,10 @@ private:
     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
     void forceRepaint(uint64_t callbackID);
 
+#if ENABLE(WEB_INTENTS)
+    void deliverIntentToFrame(uint64_t frameID, const IntentData&);
+#endif
+
     void preferencesDidChange(const WebPreferencesStore&);
     void platformPreferencesDidChange(const WebPreferencesStore&);
     void updatePreferences(const WebPreferencesStore&);
index 7a7f4eb..6404401 100644 (file)
@@ -220,6 +220,11 @@ messages -> WebPage {
     SetCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel)
     SetCanRunModal(bool canRunModal)
 
+    # Web Intents
+#if ENABLE(WEB_INTENTS)
+    DeliverIntentToFrame(uint64_t frameID, WebKit::IntentData intentData);
+#endif
+
 #if PLATFORM(QT)
     SetComposition(WTF::String text, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
     ConfirmComposition(WTF::String text, int64_t selectionStart, int64_t selectionLength)