Web Intents chromium API modifications to track IntentRequest invocation method
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 02:03:48 +0000 (02:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 02:03:48 +0000 (02:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76014

Patch by Greg Billock <gbillock@google.com> on 2012-01-19
Reviewed by Darin Fisher.

* public/WebFrameClient.h:
(WebKit::WebFrameClient::dispatchIntent):
* public/WebIntent.h:
* public/WebIntentRequest.h: Added.
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::dispatchIntent):
* src/FrameLoaderClientImpl.h:
* src/WebIntent.cpp:
* src/WebIntentRequest.cpp: Added.

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

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/public/WebFrameClient.h
Source/WebKit/chromium/public/WebIntent.h
Source/WebKit/chromium/public/WebIntentRequest.h [new file with mode: 0644]
Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
Source/WebKit/chromium/src/FrameLoaderClientImpl.h
Source/WebKit/chromium/src/WebIntent.cpp
Source/WebKit/chromium/src/WebIntentRequest.cpp [new file with mode: 0644]

index 1dfa576..f6d81c2 100644 (file)
@@ -1,3 +1,20 @@
+2012-01-19  Greg Billock  <gbillock@google.com>
+
+        Web Intents chromium API modifications to track IntentRequest invocation method
+        https://bugs.webkit.org/show_bug.cgi?id=76014
+
+        Reviewed by Darin Fisher.
+
+        * public/WebFrameClient.h:
+        (WebKit::WebFrameClient::dispatchIntent):
+        * public/WebIntent.h:
+        * public/WebIntentRequest.h: Added.
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit::FrameLoaderClientImpl::dispatchIntent):
+        * src/FrameLoaderClientImpl.h:
+        * src/WebIntent.cpp:
+        * src/WebIntentRequest.cpp: Added.
+
 2012-01-19  Michal Mocny  <mmocny@google.com>
 
         [chromium] Replace WGC3D visibility extension with resource_usage extension. [Part 1 of 3]
index 2cac573..cc1fc13 100644 (file)
                 'public/WebInputElement.h',
                 'public/WebInputEvent.h',
                 'public/WebIntent.h',
+                'public/WebIntentRequest.h',
                 'public/WebIntentServiceInfo.h',
                 'public/WebKit.h',
                 'public/WebLabelElement.h',
                 'src/WebInputEventConversion.cpp',
                 'src/WebInputEventConversion.h',
                 'src/WebIntent.cpp',
+                'src/WebIntentRequest.cpp',
                 'src/WebIntentServiceInfo.cpp',
                 'src/WebKit.cpp',
                 'src/WebLabelElement.cpp',
index 1d8dbb7..d0507e3 100644 (file)
@@ -55,8 +55,9 @@ class WebDataSource;
 class WebDOMEvent;
 class WebFormElement;
 class WebFrame;
-class WebIntentServiceInfo;
 class WebIntent;
+class WebIntentRequest;
+class WebIntentServiceInfo;
 class WebMediaPlayer;
 class WebMediaPlayerClient;
 class WebNode;
@@ -380,9 +381,9 @@ public:
     // Register a service to handle Web Intents.
     virtual void registerIntentService(WebFrame*, const WebIntentServiceInfo&) { }
 
-    // Start a Web Intents activity. Replies to this request should be sent to
-    // the WebFrame starting the activity.
-    virtual void dispatchIntent(WebFrame*, const WebIntent&) { }
+    // Start a Web Intents activity. The callee uses the |WebIntentRequest|
+    // object to coordinate replies to the intent invocation.
+    virtual void dispatchIntent(WebFrame*, const WebIntentRequest&) { }
 
     // Messages ------------------------------------------------------
 
index 4ce0342..a64e7ee 100644 (file)
 #define WebIntent_h
 
 #include "platform/WebCommon.h"
+#include "platform/WebPrivatePtr.h"
 #include "platform/WebString.h"
 
+namespace WebCore { class Intent; }
+
 namespace WebKit {
 
 // Holds data passed through a Web Intents invocation call from the Javascript
@@ -41,29 +44,33 @@ namespace WebKit {
 // See spec at http://www.chromium.org/developers/design-documents/webintentsapi
 class WebIntent {
 public:
-    ~WebIntent() { }
+    WebIntent() { }
+    WebIntent(const WebIntent& other) { assign(other); }
+    ~WebIntent() { reset(); }
 
-    WEBKIT_EXPORT WebString action() const;
-    WEBKIT_EXPORT void setAction(const WebString&);
+    WebIntent& operator=(const WebIntent& other)
+    {
+       assign(other);
+       return *this;
+    }
+    WEBKIT_EXPORT void reset();
+    WEBKIT_EXPORT bool isNull() const;
+    WEBKIT_EXPORT bool equals(const WebIntent&) const;
+    WEBKIT_EXPORT void assign(const WebIntent&);
 
+    WEBKIT_EXPORT WebString action() const;
     WEBKIT_EXPORT WebString type() const;
-    WEBKIT_EXPORT void setType(const WebString&);
-
     WEBKIT_EXPORT WebString data() const;
-    WEBKIT_EXPORT void setData(const WebString&);
 
+    // FIXME: delete this.
     WEBKIT_EXPORT int identifier() const;
-    WEBKIT_EXPORT void setIdentifier(int);
 
 #if WEBKIT_IMPLEMENTATION
-    WebIntent();
+    WebIntent(const WTF::PassRefPtr<WebCore::Intent>&);
 #endif
 
 private:
-    WebString m_action;
-    WebString m_type;
-    WebString m_data;
-    int m_identifier;
+    WebPrivatePtr<WebCore::Intent> m_private;
 };
 
 } // namespace WebKit
diff --git a/Source/WebKit/chromium/public/WebIntentRequest.h b/Source/WebKit/chromium/public/WebIntentRequest.h
new file mode 100644 (file)
index 0000000..7934f13
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIntentRequest_h
+#define WebIntentRequest_h
+
+#include "platform/WebCommon.h"
+#include "platform/WebPrivatePtr.h"
+#include "platform/WebString.h"
+
+namespace WebCore { class IntentRequest; }
+
+namespace WebKit {
+
+class WebIntent;
+class WebSerializedScriptValue;
+
+// Holds data passed through a Web Intents invocation call from the Javascript
+// Intent object.
+// See spec at http://www.chromium.org/developers/design-documents/webintentsapi
+class WebIntentRequest {
+public:
+    WebIntentRequest() { }
+    WebIntentRequest(const WebIntentRequest& other) { assign(other); }
+    ~WebIntentRequest() { reset(); }
+
+    WebIntentRequest& operator=(const WebIntentRequest& other)
+    {
+       assign(other);
+       return *this;
+    }
+    WEBKIT_EXPORT void reset();
+    WEBKIT_EXPORT bool isNull() const;
+    WEBKIT_EXPORT bool equals(const WebIntentRequest&) const;
+    WEBKIT_EXPORT void assign(const WebIntentRequest&);
+
+    WEBKIT_EXPORT void postResult(const WebSerializedScriptValue&);
+    WEBKIT_EXPORT void postFailure(const WebSerializedScriptValue&);
+
+    WEBKIT_EXPORT WebIntent intent() const;
+
+#if WEBKIT_IMPLEMENTATION
+    WebIntentRequest(const WTF::PassRefPtr<WebCore::IntentRequest>&);
+#endif
+
+private:
+    WebPrivatePtr<WebCore::IntentRequest> m_private;
+};
+
+} // namespace WebKit
+
+#endif // WebIntentRequest_h
index 72e71b9..aec28c5 100644 (file)
@@ -66,6 +66,7 @@
 #include "WebFormElement.h"
 #include "WebFrameClient.h"
 #include "WebFrameImpl.h"
+#include "WebIntentRequest.h"
 #include "WebKit.h"
 #include "platform/WebKitPlatformSupport.h"
 #include <public/WebMimeRegistry.h>
@@ -1629,4 +1630,11 @@ bool FrameLoaderClientImpl::willCheckAndDispatchMessageEvent(
         m_webFrame, WebSecurityOrigin(target), WebDOMMessageEvent(event));
 }
 
+#if ENABLE(WEB_INTENTS)
+void FrameLoaderClientImpl::dispatchIntent(PassRefPtr<WebCore::IntentRequest> intentRequest)
+{
+    m_webFrame->client()->dispatchIntent(webFrame(), intentRequest);
+}
+#endif
+
 } // namespace WebKit
index b1b85ba..0bf935d 100644 (file)
@@ -208,6 +208,10 @@ public:
     virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext();
     virtual bool willCheckAndDispatchMessageEvent(WebCore::SecurityOrigin* target, WebCore::MessageEvent*) const;
 
+#if ENABLE(WEB_INTENTS)
+    virtual void dispatchIntent(PassRefPtr<WebCore::IntentRequest>) OVERRIDE;
+#endif
+
 private:
     void makeDocumentView();
 
index 13540e1..2358bfa 100644 (file)
 #include "config.h"
 #include "WebIntent.h"
 
+#include "Intent.h"
+#include "SerializedScriptValue.h"
+
 namespace WebKit {
 
-WebIntent::WebIntent() { }
+#if ENABLE(WEB_INTENTS)
+WebIntent::WebIntent(const PassRefPtr<WebCore::Intent>& intent)
+    : m_private(intent)
+{
+}
+#endif
 
-WebString WebIntent::action() const
+void WebIntent::reset()
 {
-    return m_action;
+#if ENABLE(WEB_INTENTS)
+    m_private.reset();
+#endif
 }
 
-void WebIntent::setAction(const WebString& action)
+bool WebIntent::isNull() const
 {
-    m_action = action;
+#if ENABLE(WEB_INTENTS)
+    return m_private.isNull();
+#else
+    return true;
+#endif
 }
 
-WebString WebIntent::type() const
+bool WebIntent::equals(const WebIntent& other) const
 {
-    return m_type;
+#if ENABLE(WEB_INTENTS)
+    return (m_private.get() == other.m_private.get());
+#else
+    return true;
+#endif
 }
 
-void WebIntent::setType(const WebString& type)
+void WebIntent::assign(const WebIntent& other)
 {
-    m_type = type;
+#if ENABLE(WEB_INTENTS)
+    m_private = other.m_private;
+#endif
 }
 
-WebString WebIntent::data() const
+WebString WebIntent::action() const
 {
-    return m_data;
+#if ENABLE(WEB_INTENTS)
+    return m_private->action();
+#else
+    return WebString();
+#endif
 }
 
-void WebIntent::setData(const WebString& data)
+WebString WebIntent::type() const
 {
-    m_data = data;
+#if ENABLE(WEB_INTENTS)
+    return m_private->type();
+#else
+    return WebString();
+#endif
 }
 
-int WebIntent::identifier() const
+WebString WebIntent::data() const
 {
-    return m_identifier;
+#if ENABLE(WEB_INTENTS)
+    return m_private->data()->toWireString();
+#else
+    return WebString();
+#endif
 }
 
-void WebIntent::setIdentifier(int identifier)
+int WebIntent::identifier() const
 {
-    m_identifier = identifier;
+    return 0;
 }
 
 } // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebIntentRequest.cpp b/Source/WebKit/chromium/src/WebIntentRequest.cpp
new file mode 100644 (file)
index 0000000..64d3412
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIntentRequest.h"
+
+#include "Intent.h"
+#include "IntentRequest.h"
+#include "SerializedScriptValue.h"
+#include "WebIntent.h"
+#include "platform/WebSerializedScriptValue.h"
+
+namespace WebKit {
+
+#if ENABLE(WEB_INTENTS)
+WebIntentRequest::WebIntentRequest(const PassRefPtr<WebCore::IntentRequest>& intentRequest)
+    : m_private(intentRequest)
+{
+}
+#endif
+
+void WebIntentRequest::reset()
+{
+#if ENABLE(WEB_INTENTS)
+    m_private.reset();
+#endif
+}
+
+bool WebIntentRequest::isNull() const
+{
+#if ENABLE(WEB_INTENTS)
+    return m_private.isNull();
+#else
+    return true;
+#endif
+}
+
+bool WebIntentRequest::equals(const WebIntentRequest& other) const
+{
+#if ENABLE(WEB_INTENTS)
+    return (m_private.get() == other.m_private.get());
+#else
+    return true;
+#endif
+}
+
+void WebIntentRequest::assign(const WebIntentRequest& other)
+{
+#if ENABLE(WEB_INTENTS)
+    m_private = other.m_private;
+#endif
+}
+
+WebIntent WebIntentRequest::intent() const
+{
+#if ENABLE(WEB_INTENTS)
+    return WebIntent(m_private->intent());
+#else
+    return WebIntent();
+#endif
+}
+
+void WebIntentRequest::postResult(const WebSerializedScriptValue& data)
+{
+#if ENABLE(WEB_INTENTS)
+    m_private->postResult(PassRefPtr<WebCore::SerializedScriptValue>(data).get());
+#endif
+}
+
+void WebIntentRequest::postFailure(const WebSerializedScriptValue& data)
+{
+#if ENABLE(WEB_INTENTS)
+    m_private->postFailure(PassRefPtr<WebCore::SerializedScriptValue>(data).get());
+#endif
+}
+
+
+} // namespace WebKit