From 2dfac4d1ea97266de0c7ecb71596aaec7dcf8644 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Fri, 20 Jan 2012 02:03:48 +0000 Subject: [PATCH] Web Intents chromium API modifications to track IntentRequest invocation method https://bugs.webkit.org/show_bug.cgi?id=76014 Patch by Greg Billock 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 | 17 ++++ Source/WebKit/chromium/WebKit.gyp | 2 + Source/WebKit/chromium/public/WebFrameClient.h | 9 +- Source/WebKit/chromium/public/WebIntent.h | 31 +++--- Source/WebKit/chromium/public/WebIntentRequest.h | 79 ++++++++++++++++ .../WebKit/chromium/src/FrameLoaderClientImpl.cpp | 8 ++ Source/WebKit/chromium/src/FrameLoaderClientImpl.h | 4 + Source/WebKit/chromium/src/WebIntent.cpp | 66 +++++++++---- Source/WebKit/chromium/src/WebIntentRequest.cpp | 105 +++++++++++++++++++++ 9 files changed, 288 insertions(+), 33 deletions(-) create mode 100644 Source/WebKit/chromium/public/WebIntentRequest.h create mode 100644 Source/WebKit/chromium/src/WebIntentRequest.cpp diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 1dfa576..f6d81c2 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,20 @@ +2012-01-19 Greg Billock + + 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 [chromium] Replace WGC3D visibility extension with resource_usage extension. [Part 1 of 3] diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index 2cac573..cc1fc13 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -188,6 +188,7 @@ 'public/WebInputElement.h', 'public/WebInputEvent.h', 'public/WebIntent.h', + 'public/WebIntentRequest.h', 'public/WebIntentServiceInfo.h', 'public/WebKit.h', 'public/WebLabelElement.h', @@ -579,6 +580,7 @@ 'src/WebInputEventConversion.cpp', 'src/WebInputEventConversion.h', 'src/WebIntent.cpp', + 'src/WebIntentRequest.cpp', 'src/WebIntentServiceInfo.cpp', 'src/WebKit.cpp', 'src/WebLabelElement.cpp', diff --git a/Source/WebKit/chromium/public/WebFrameClient.h b/Source/WebKit/chromium/public/WebFrameClient.h index 1d8dbb7..d0507e3 100644 --- a/Source/WebKit/chromium/public/WebFrameClient.h +++ b/Source/WebKit/chromium/public/WebFrameClient.h @@ -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 ------------------------------------------------------ diff --git a/Source/WebKit/chromium/public/WebIntent.h b/Source/WebKit/chromium/public/WebIntent.h index 4ce0342..a64e7ee 100644 --- a/Source/WebKit/chromium/public/WebIntent.h +++ b/Source/WebKit/chromium/public/WebIntent.h @@ -32,8 +32,11 @@ #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&); #endif private: - WebString m_action; - WebString m_type; - WebString m_data; - int m_identifier; + WebPrivatePtr m_private; }; } // namespace WebKit diff --git a/Source/WebKit/chromium/public/WebIntentRequest.h b/Source/WebKit/chromium/public/WebIntentRequest.h new file mode 100644 index 0000000..7934f13 --- /dev/null +++ b/Source/WebKit/chromium/public/WebIntentRequest.h @@ -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&); +#endif + +private: + WebPrivatePtr m_private; +}; + +} // namespace WebKit + +#endif // WebIntentRequest_h diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp index 72e71b9..aec28c5 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp @@ -66,6 +66,7 @@ #include "WebFormElement.h" #include "WebFrameClient.h" #include "WebFrameImpl.h" +#include "WebIntentRequest.h" #include "WebKit.h" #include "platform/WebKitPlatformSupport.h" #include @@ -1629,4 +1630,11 @@ bool FrameLoaderClientImpl::willCheckAndDispatchMessageEvent( m_webFrame, WebSecurityOrigin(target), WebDOMMessageEvent(event)); } +#if ENABLE(WEB_INTENTS) +void FrameLoaderClientImpl::dispatchIntent(PassRefPtr intentRequest) +{ + m_webFrame->client()->dispatchIntent(webFrame(), intentRequest); +} +#endif + } // namespace WebKit diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h index b1b85ba..0bf935d 100644 --- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h +++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h @@ -208,6 +208,10 @@ public: virtual PassRefPtr createNetworkingContext(); virtual bool willCheckAndDispatchMessageEvent(WebCore::SecurityOrigin* target, WebCore::MessageEvent*) const; +#if ENABLE(WEB_INTENTS) + virtual void dispatchIntent(PassRefPtr) OVERRIDE; +#endif + private: void makeDocumentView(); diff --git a/Source/WebKit/chromium/src/WebIntent.cpp b/Source/WebKit/chromium/src/WebIntent.cpp index 13540e1..2358bfa 100644 --- a/Source/WebKit/chromium/src/WebIntent.cpp +++ b/Source/WebKit/chromium/src/WebIntent.cpp @@ -31,48 +31,80 @@ #include "config.h" #include "WebIntent.h" +#include "Intent.h" +#include "SerializedScriptValue.h" + namespace WebKit { -WebIntent::WebIntent() { } +#if ENABLE(WEB_INTENTS) +WebIntent::WebIntent(const PassRefPtr& 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 index 0000000..64d3412 --- /dev/null +++ b/Source/WebKit/chromium/src/WebIntentRequest.cpp @@ -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& 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(data).get()); +#endif +} + +void WebIntentRequest::postFailure(const WebSerializedScriptValue& data) +{ +#if ENABLE(WEB_INTENTS) + m_private->postFailure(PassRefPtr(data).get()); +#endif +} + + +} // namespace WebKit -- 2.7.4