Changeset 117384 in webkit


Ignore:
Timestamp:
May 16, 2012 8:17:02 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

IDL and implementation for Web Intents delivery
https://bugs.webkit.org/show_bug.cgi?id=83634

Patch by Greg Billock <gbillock@google.com> on 2012-05-16
Reviewed by Adam Barth.

Source/WebCore:

The delivered intent has some extra fields and methods (extras,
postResult, postFailure) from the invocation intent. It is implemented
as a subclass. Responses from the service JS are passed to an embedder
client object provided when the intent is delivered.
See http://dvcs.w3.org/hg/web-intents/raw-file/tip/spec/Overview.html
Test: webintents/web-intents-delivery.html

  • Modules/intents/DOMWindowIntents.cpp: Copied from Source/WebCore/Modules/intents/DOMWindowIntents.idl.

(WebCore):
(WebCore::DOMWindowIntents::DOMWindowIntents):
(WebCore::DOMWindowIntents::~DOMWindowIntents):
(WebCore::DOMWindowIntents::from):
(WebCore::DOMWindowIntents::webkitIntent):
(WebCore::DOMWindowIntents::deliver):

  • Modules/intents/DOMWindowIntents.h: Copied from Source/WebCore/Modules/intents/DOMWindowIntents.idl.

(WebCore):
(DOMWindowIntents):

  • Modules/intents/DOMWindowIntents.idl:
  • Modules/intents/DeliveredIntent.cpp: Copied from Source/WebCore/Modules/intents/Intent.h.

(WebCore):
(WebCore::DeliveredIntent::create):
(WebCore::DeliveredIntent::DeliveredIntent):
(WebCore::DeliveredIntent::ports):
(WebCore::DeliveredIntent::getExtra):
(WebCore::DeliveredIntent::postResult):
(WebCore::DeliveredIntent::postFailure):

  • Modules/intents/DeliveredIntent.h: Copied from Source/WebCore/Modules/intents/Intent.h.

(WebCore):
(DeliveredIntent):
(WebCore::DeliveredIntent::~DeliveredIntent):

  • Modules/intents/DeliveredIntent.idl: Copied from Source/WebCore/Modules/intents/Intent.h.
  • Modules/intents/Intent.h:

(WebCore::Intent::~Intent):
(Intent):

  • WebCore.gyp/WebCore.gyp:
  • WebCore.gypi:
  • bindings/v8/custom/V8DeliveredIntentCustom.cpp: Copied from Source/WebCore/Modules/intents/Intent.h.

(WebCore):
(WebCore::V8DeliveredIntent::portsAccessorGetter):

Source/WebKit/chromium:

The embedder will implement the WebDeliveredIntentClient interface, which
will get notifications of postResult/postFailure from the service page.

  • public/WebDeliveredIntentClient.h:
  • public/WebFrame.h:

(WebKit):
(WebFrame):

  • src/WebDeliveredIntentClient.cpp:
  • src/WebFrameImpl.cpp:

(WebKit::WebFrameImpl::deliverIntent):
(WebKit):

  • src/WebFrameImpl.h:

(WebFrameImpl):

Location:
trunk
Files:
8 added
18 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117383 r117384  
     12012-05-16  Greg Billock  <gbillock@google.com>
     2
     3        IDL and implementation for Web Intents delivery
     4        https://bugs.webkit.org/show_bug.cgi?id=83634
     5
     6        Reviewed by Adam Barth.
     7
     8        The delivered intent has some extra fields and methods (extras,
     9        postResult, postFailure) from the invocation intent. It is implemented
     10        as a subclass. Responses from the service JS are passed to an embedder
     11        client object provided when the intent is delivered.
     12        See http://dvcs.w3.org/hg/web-intents/raw-file/tip/spec/Overview.html
     13        Test: webintents/web-intents-delivery.html
     14
     15        * Modules/intents/DOMWindowIntents.cpp: Copied from Source/WebCore/Modules/intents/DOMWindowIntents.idl.
     16        (WebCore):
     17        (WebCore::DOMWindowIntents::DOMWindowIntents):
     18        (WebCore::DOMWindowIntents::~DOMWindowIntents):
     19        (WebCore::DOMWindowIntents::from):
     20        (WebCore::DOMWindowIntents::webkitIntent):
     21        (WebCore::DOMWindowIntents::deliver):
     22        * Modules/intents/DOMWindowIntents.h: Copied from Source/WebCore/Modules/intents/DOMWindowIntents.idl.
     23        (WebCore):
     24        (DOMWindowIntents):
     25        * Modules/intents/DOMWindowIntents.idl:
     26        * Modules/intents/DeliveredIntent.cpp: Copied from Source/WebCore/Modules/intents/Intent.h.
     27        (WebCore):
     28        (WebCore::DeliveredIntent::create):
     29        (WebCore::DeliveredIntent::DeliveredIntent):
     30        (WebCore::DeliveredIntent::ports):
     31        (WebCore::DeliveredIntent::getExtra):
     32        (WebCore::DeliveredIntent::postResult):
     33        (WebCore::DeliveredIntent::postFailure):
     34        * Modules/intents/DeliveredIntent.h: Copied from Source/WebCore/Modules/intents/Intent.h.
     35        (WebCore):
     36        (DeliveredIntent):
     37        (WebCore::DeliveredIntent::~DeliveredIntent):
     38        * Modules/intents/DeliveredIntent.idl: Copied from Source/WebCore/Modules/intents/Intent.h.
     39        * Modules/intents/Intent.h:
     40        (WebCore::Intent::~Intent):
     41        (Intent):
     42        * WebCore.gyp/WebCore.gyp:
     43        * WebCore.gypi:
     44        * bindings/v8/custom/V8DeliveredIntentCustom.cpp: Copied from Source/WebCore/Modules/intents/Intent.h.
     45        (WebCore):
     46        (WebCore::V8DeliveredIntent::portsAccessorGetter):
     47
    1482012-05-16  Kentaro Hara  <haraken@chromium.org>
    249
  • trunk/Source/WebCore/Modules/intents/DOMWindowIntents.h

    r117383 r117384  
    2525 */
    2626
    27 module window {
     27#ifndef DOMWindowIntents_h
     28#define DOMWindowIntents_h
    2829
    29     interface [
    30         Conditional=WEB_INTENTS,
    31         Supplemental=DOMWindow
    32     ] DOMWindowIntents {
    33         attribute IntentConstructor WebKitIntent;
    34     };
     30#if ENABLE(WEB_INTENTS)
    3531
    36 }
     32#include "DOMWindowProperty.h"
     33#include "Supplementable.h"
     34
     35namespace WebCore {
     36
     37class DOMWindow;
     38class DeliveredIntent;
     39
     40class DOMWindowIntents : public DOMWindowProperty, public Supplement<DOMWindow> {
     41public:
     42    virtual ~DOMWindowIntents();
     43    static DOMWindowIntents* from(DOMWindow*);
     44
     45    static DeliveredIntent* webkitIntent(DOMWindow*);
     46
     47    void deliver(PassRefPtr<DeliveredIntent>);
     48
     49private:
     50    explicit DOMWindowIntents(DOMWindow*);
     51
     52    DeliveredIntent* webkitIntent();
     53
     54    RefPtr<DeliveredIntent> m_intent;
     55};
     56
     57} // namespace WebCore
     58
     59#endif // ENABLE(WEB_INTENTS)
     60
     61#endif // DOMWindowIntents_h
  • trunk/Source/WebCore/Modules/intents/DOMWindowIntents.idl

    r113282 r117384  
    3232    ] DOMWindowIntents {
    3333        attribute IntentConstructor WebKitIntent;
     34
     35        readonly attribute [Replaceable] DeliveredIntent webkitIntent;
    3436    };
    3537
  • trunk/Source/WebCore/Modules/intents/DeliveredIntent.h

    r117383 r117384  
    2727 */
    2828
    29 #ifndef Intent_h
    30 #define Intent_h
     29#ifndef DeliveredIntent_h
     30#define DeliveredIntent_h
    3131
    3232#if ENABLE(WEB_INTENTS)
    3333
    34 #include "Dictionary.h"
    35 #include "KURL.h"
     34#include "FrameDestructionObserver.h"
     35#include "Intent.h"
    3636#include "MessagePort.h"
    37 #include "MessagePortChannel.h"
    38 #include "ScriptState.h"
    3937#include <wtf/Forward.h>
     38#include <wtf/HashMap.h>
    4039#include <wtf/PassRefPtr.h>
    4140#include <wtf/RefCounted.h>
     
    4544namespace WebCore {
    4645
     46class Frame;
    4747class SerializedScriptValue;
    4848
    49 typedef int ExceptionCode;
     49// JS calls to postResult/postFailure on DeliveredIntent will be forwarded
     50// to this client interface. The object is owned by the DeliveredIntent to
     51// which it is attached, and will be deleted when the delivered intent will issue
     52// no further calls to it. Before that point, the destroy() method is invoked.
     53class DeliveredIntentClient {
     54public:
     55    virtual ~DeliveredIntentClient() { }
    5056
    51 class Intent : public RefCounted<Intent> {
     57    virtual void postResult(PassRefPtr<SerializedScriptValue> data) = 0;
     58    virtual void postFailure(PassRefPtr<SerializedScriptValue> data) = 0;
     59};
     60
     61class DeliveredIntent : public Intent, public FrameDestructionObserver {
    5262public:
    53     static PassRefPtr<Intent> create(const String& action, const String& type, PassRefPtr<SerializedScriptValue> data, const MessagePortArray& ports, ExceptionCode&);
    54     static PassRefPtr<Intent> create(ScriptState*, const Dictionary&, ExceptionCode&);
     63    static PassRefPtr<DeliveredIntent> create(Frame*, PassOwnPtr<DeliveredIntentClient>, const String& action, const String& type,
     64                                              PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortArray>,
     65                                              const HashMap<String, String>&);
    5566
    56     const String& action() const { return m_action; }
    57     const String& type() const { return m_type; }
    58     SerializedScriptValue* data() const { return m_data.get(); }
     67    virtual ~DeliveredIntent() { }
    5968
    60     MessagePortChannelArray* messagePorts() const { return m_ports.get(); }
    61     const KURL& service() const { return m_service; }
    62     const WTF::HashMap<String, String>& extras() const { return m_extras; }
     69    MessagePortArray* ports() const;
     70    String getExtra(const String& key);
     71    void postResult(PassRefPtr<SerializedScriptValue> data);
     72    void postFailure(PassRefPtr<SerializedScriptValue> data);
    6373
    64 protected:
    65     Intent(const String& action, const String& type,
    66            PassRefPtr<SerializedScriptValue> data, PassOwnPtr<MessagePortChannelArray> ports,
    67            const WTF::HashMap<String, String>& extras, const KURL& service);
     74    void setClient(PassRefPtr<DeliveredIntentClient>);
     75
     76    virtual void frameDestroyed() OVERRIDE;
    6877
    6978private:
     79    DeliveredIntent(Frame*, PassOwnPtr<DeliveredIntentClient>, const String& action, const String& type,
     80                    PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortArray>,
     81                    const HashMap<String, String>&);
    7082
    71     String m_action;
    72     String m_type;
    73     RefPtr<SerializedScriptValue> m_data;
    74     OwnPtr<MessagePortChannelArray> m_ports;
    75     KURL m_service;
    76     WTF::HashMap<String, String> m_extras;
     83    OwnPtr<DeliveredIntentClient> m_client;
     84    OwnPtr<MessagePortArray> m_ports;
    7785};
    7886
  • trunk/Source/WebCore/Modules/intents/Intent.h

    r116763 r117384  
    5454    static PassRefPtr<Intent> create(ScriptState*, const Dictionary&, ExceptionCode&);
    5555
     56    virtual ~Intent() { }
     57
    5658    const String& action() const { return m_action; }
    5759    const String& type() const { return m_type; }
     
    6870
    6971private:
    70 
    7172    String m_action;
    7273    String m_type;
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r117209 r117384  
    10221022              '--include', '../Modules/filesystem',
    10231023              '--include', '../Modules/indexeddb',
     1024              '--include', '../Modules/intents',
    10241025              '--include', '../Modules/mediastream',
    10251026              '--include', '../Modules/webaudio',
  • trunk/Source/WebCore/WebCore.gypi

    r117369 r117384  
    813813            'Modules/indexeddb/IDBVersionChangeRequest.idl',
    814814            'Modules/indexeddb/WorkerContextIndexedDatabase.idl',
     815            'Modules/intents/DeliveredIntent.idl',
    815816            'Modules/intents/DOMWindowIntents.idl',
    816817            'Modules/intents/Intent.idl',
     
    15071508            'Modules/indexeddb/WorkerContextIndexedDatabase.cpp',
    15081509            'Modules/indexeddb/WorkerContextIndexedDatabase.h',
     1510            'Modules/intents/DeliveredIntent.cpp',
     1511            'Modules/intents/DeliveredIntent.h',
     1512            'Modules/intents/DOMWindowIntents.cpp',
     1513            'Modules/intents/DOMWindowIntents.h',
    15091514            'Modules/intents/Intent.cpp',
    15101515            'Modules/intents/Intent.h',
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r117374 r117384  
    989989        }
    990990    } elsif ($attribute->signature->type eq "MessagePortArray") {
    991         AddToImplIncludes("V8Array.h");
    992991        AddToImplIncludes("MessagePort.h");
     992        AddToImplIncludes("V8MessagePort.h");
    993993        my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name);
    994994        push(@implContentDecls, <<END);
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp

    r115797 r117384  
    2828#include "RuntimeEnabledFeatures.h"
    2929#include "SerializedScriptValue.h"
    30 #include "V8Array.h"
    3130#include "V8Binding.h"
    3231#include "V8BindingMacros.h"
     
    3433#include "V8DOMWrapper.h"
    3534#include "V8IsolatedContext.h"
     35#include "V8MessagePort.h"
    3636#include "V8Proxy.h"
    3737#include <wtf/ArrayBuffer.h>
  • trunk/Source/WebKit/chromium/ChangeLog

    r117379 r117384  
     12012-05-16  Greg Billock  <gbillock@google.com>
     2
     3        IDL and implementation for Web Intents delivery
     4        https://bugs.webkit.org/show_bug.cgi?id=83634
     5
     6        Reviewed by Adam Barth.
     7
     8        The embedder will implement the WebDeliveredIntentClient interface, which
     9        will get notifications of postResult/postFailure from the service page.
     10
     11        * public/WebDeliveredIntentClient.h:
     12        * public/WebFrame.h:
     13        (WebKit):
     14        (WebFrame):
     15        * src/WebDeliveredIntentClient.cpp:
     16        * src/WebFrameImpl.cpp:
     17        (WebKit::WebFrameImpl::deliverIntent):
     18        (WebKit):
     19        * src/WebFrameImpl.h:
     20        (WebFrameImpl):
     21
    1222012-05-16  James Robinson  <jamesr@chromium.org>
    223
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r117213 r117384  
    129129                'public/WebDatabase.h',
    130130                'public/WebDatabaseObserver.h',
     131                'public/WebDeliveredIntentClient.h',
    131132                'public/WebDevToolsAgent.h',
    132133                'public/WebDevToolsAgentClient.h',
     
    389390                'src/ContextMenuClientImpl.h',
    390391                'src/DatabaseObserver.cpp',
     392                'src/DeliveredIntentClientImpl.cpp',
     393                'src/DeliveredIntentClientImpl.h',
    391394                'src/DeviceOrientationClientProxy.cpp',
    392395                'src/DeviceOrientationClientProxy.h',
  • trunk/Source/WebKit/chromium/public/WebDeliveredIntentClient.h

    r117383 r117384  
    2929 */
    3030
    31 #ifndef WebIntent_h
    32 #define WebIntent_h
     31#ifndef WebDeliveredIntentClient_h
     32#define WebDeliveredIntentClient_h
    3333
    34 #include "WebMessagePortChannel.h"
    3534#include "platform/WebCommon.h"
    36 #include "platform/WebPrivatePtr.h"
    37 #include "platform/WebString.h"
    38 #include "platform/WebURL.h"
    39 #include "platform/WebVector.h"
    40 
    41 namespace WebCore { class Intent; }
    4235
    4336namespace WebKit {
    4437
    45 // Holds data passed through a Web Intents invocation call from the Javascript
    46 // Intent object.
     38class WebSerializedScriptValue;
     39
     40// The embedder implements this interface to receive reply calls from the service
     41// in response to the delivery of a web intent. This client must remain valid
     42// until the destroy() method is called.
    4743// See spec at http://www.chromium.org/developers/design-documents/webintentsapi
    48 class WebIntent {
     44class WebDeliveredIntentClient {
    4945public:
    50     WebIntent() { }
    51     WebIntent(const WebIntent& other) { assign(other); }
    52     ~WebIntent() { reset(); }
     46    virtual ~WebDeliveredIntentClient() { }
    5347
    54     WebIntent& operator=(const WebIntent& other)
    55     {
    56        assign(other);
    57        return *this;
    58     }
    59     WEBKIT_EXPORT void reset();
    60     WEBKIT_EXPORT bool isNull() const;
    61     WEBKIT_EXPORT bool equals(const WebIntent&) const;
    62     WEBKIT_EXPORT void assign(const WebIntent&);
    63 
    64     WEBKIT_EXPORT WebString action() const;
    65     WEBKIT_EXPORT WebString type() const;
    66     WEBKIT_EXPORT WebString data() const;
    67     WEBKIT_EXPORT WebURL service() const;
    68 
    69     // Retrieve a list of the names of extra metadata associated with the
    70     // intent.
    71     WEBKIT_EXPORT WebVector<WebString> extrasNames() const;
    72 
    73     // Retrieve the value of an extra metadata element. The argument should
    74     // be one of the names retrieved with |extrasNames|. Returns an empty
    75     // string if the name is invalid.
    76     WEBKIT_EXPORT WebString extrasValue(const WebString&) const;
    77 
    78     // Caller takes ownership of the ports.
    79     WEBKIT_EXPORT WebMessagePortChannelArray* messagePortChannelsRelease() const;
    80 
    81 #if WEBKIT_IMPLEMENTATION
    82     WebIntent(const WTF::PassRefPtr<WebCore::Intent>&);
    83 #endif
    84 
    85 private:
    86     WebPrivatePtr<WebCore::Intent> m_private;
     48    virtual void postResult(const WebSerializedScriptValue& data) const = 0;
     49    virtual void postFailure(const WebSerializedScriptValue& data) const = 0;
     50    virtual void destroy() = 0;
    8751};
    8852
    8953} // namespace WebKit
    9054
    91 #endif // WebIntent_h
     55#endif // WebDeliveredIntentClient_h
  • trunk/Source/WebKit/chromium/public/WebFrame.h

    r117200 r117384  
    5858class WebData;
    5959class WebDataSource;
     60class WebDeliveredIntentClient;
    6061class WebDocument;
    6162class WebElement;
     
    6364class WebHistoryItem;
    6465class WebInputElement;
     66class WebIntent;
    6567class WebPerformance;
    6668class WebRange;
     
    606608    // Web Intents ---------------------------------------------------------
    607609
    608     // Forwards a web intents reply from the invoked activity back to the
    609     // appropriate registered Javascript callback. The |intentIdentifier| is
    610     // the WebIntent parameter received from the dispatchIntent method.
    611     virtual void handleIntentResult(int intentIdentifier, const WebString&) = 0;
    612 
    613     // Forwards a web intents failure notification from the invoked activity
    614     // or intervening browser logic back to the appropriate registered
    615     // Javascript callback. The |intentIdentifier| is the WebIntent parameter
    616     // received from the dispatchIntent method.
    617     virtual void handleIntentFailure(int intentIdentifier, const WebString&) = 0;
     610    // Called on a target service page to deliver an intent to the window.
     611    virtual void deliverIntent(const WebIntent&, WebDeliveredIntentClient*) = 0;
    618612
    619613
  • trunk/Source/WebKit/chromium/public/WebIntent.h

    r115264 r117384  
    4949public:
    5050    WebIntent() { }
     51    WebIntent(const WebString& action, const WebString& type, const WebString& data);
    5152    WebIntent(const WebIntent& other) { assign(other); }
    5253    ~WebIntent() { reset(); }
     
    8182#if WEBKIT_IMPLEMENTATION
    8283    WebIntent(const WTF::PassRefPtr<WebCore::Intent>&);
     84    operator WebCore::Intent*() const;
    8385#endif
    8486
  • trunk/Source/WebKit/chromium/src/DeliveredIntentClientImpl.h

    r117383 r117384  
    2929 */
    3030
    31 #ifndef WebIntent_h
    32 #define WebIntent_h
     31#ifndef DeliveredIntentClientImpl_h
     32#define DeliveredIntentClientImpl_h
    3333
    34 #include "WebMessagePortChannel.h"
     34#include "DeliveredIntent.h"
     35#include "SerializedScriptValue.h"
    3536#include "platform/WebCommon.h"
    36 #include "platform/WebPrivatePtr.h"
    37 #include "platform/WebString.h"
    38 #include "platform/WebURL.h"
    39 #include "platform/WebVector.h"
    40 
    41 namespace WebCore { class Intent; }
     37#include <wtf/PassRefPtr.h>
    4238
    4339namespace WebKit {
    4440
    45 // Holds data passed through a Web Intents invocation call from the Javascript
    46 // Intent object.
     41class WebDeliveredIntentClient;
     42class WebSerializedScriptValue;
     43
     44// The embedder implements this interface to receive reply calls from the service
     45// in response to the delivery of a web intent. This client must remain valid
     46// until the destroy() method is called, or until the WebFrame to which it is
     47// delivered is destroyed.
    4748// See spec at http://www.chromium.org/developers/design-documents/webintentsapi
    48 class WebIntent {
     49class DeliveredIntentClientImpl : public WebCore::DeliveredIntentClient {
     50    WTF_MAKE_NONCOPYABLE(DeliveredIntentClientImpl);
    4951public:
    50     WebIntent() { }
    51     WebIntent(const WebIntent& other) { assign(other); }
    52     ~WebIntent() { reset(); }
     52    explicit DeliveredIntentClientImpl(WebDeliveredIntentClient*);
     53    virtual ~DeliveredIntentClientImpl();
    5354
    54     WebIntent& operator=(const WebIntent& other)
    55     {
    56        assign(other);
    57        return *this;
    58     }
    59     WEBKIT_EXPORT void reset();
    60     WEBKIT_EXPORT bool isNull() const;
    61     WEBKIT_EXPORT bool equals(const WebIntent&) const;
    62     WEBKIT_EXPORT void assign(const WebIntent&);
    63 
    64     WEBKIT_EXPORT WebString action() const;
    65     WEBKIT_EXPORT WebString type() const;
    66     WEBKIT_EXPORT WebString data() const;
    67     WEBKIT_EXPORT WebURL service() const;
    68 
    69     // Retrieve a list of the names of extra metadata associated with the
    70     // intent.
    71     WEBKIT_EXPORT WebVector<WebString> extrasNames() const;
    72 
    73     // Retrieve the value of an extra metadata element. The argument should
    74     // be one of the names retrieved with |extrasNames|. Returns an empty
    75     // string if the name is invalid.
    76     WEBKIT_EXPORT WebString extrasValue(const WebString&) const;
    77 
    78     // Caller takes ownership of the ports.
    79     WEBKIT_EXPORT WebMessagePortChannelArray* messagePortChannelsRelease() const;
    80 
    81 #if WEBKIT_IMPLEMENTATION
    82     WebIntent(const WTF::PassRefPtr<WebCore::Intent>&);
    83 #endif
     55    virtual void postResult(PassRefPtr<WebCore::SerializedScriptValue> data);
     56    virtual void postFailure(PassRefPtr<WebCore::SerializedScriptValue> data);
    8457
    8558private:
    86     WebPrivatePtr<WebCore::Intent> m_private;
     59    WebDeliveredIntentClient* m_client;
    8760};
    8861
    8962} // namespace WebKit
    9063
    91 #endif // WebIntent_h
     64#endif // DeliveredIntentClientImpl_h
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r117210 r117384  
    7979#include "DOMUtilitiesPrivate.h"
    8080#include "DOMWindow.h"
     81#include "DOMWindowIntents.h"
     82#include "DeliveredIntent.h"
     83#include "DeliveredIntentClientImpl.h"
    8184#include "Document.h"
    8285#include "DocumentLoader.h"
     
    143146#include "WebDOMEventListener.h"
    144147#include "WebDataSourceImpl.h"
     148#include "WebDeliveredIntentClient.h"
    145149#include "WebDevToolsAgentPrivate.h"
    146150#include "WebDocument.h"
     
    151155#include "WebIconURL.h"
    152156#include "WebInputElement.h"
     157#include "WebIntent.h"
    153158#include "WebNode.h"
    154159#include "WebPerformance.h"
     
    165170#include "platform/WebPoint.h"
    166171#include "platform/WebRect.h"
     172#include "platform/WebSerializedScriptValue.h"
    167173#include "platform/WebSize.h"
    168174#include "platform/WebURLError.h"
     
    172178#include <public/Platform.h>
    173179#include <wtf/CurrentTime.h>
     180#include <wtf/HashMap.h>
    174181
    175182#if USE(V8)
     
    506513    return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0;
    507514}
    508 
    509515
    510516// WebFrame -------------------------------------------------------------------
     
    18711877}
    18721878
    1873 void WebFrameImpl::handleIntentResult(int intentIdentifier, const WebString& reply)
    1874 {
    1875 }
    1876 
    1877 void WebFrameImpl::handleIntentFailure(int intentIdentifier, const WebString& reply)
    1878 {
    1879 }
    1880 
    18811879void WebFrameImpl::sendOrientationChangeEvent(int orientation)
    18821880{
     
    19171915    // Pass an empty call stack, since we don't have the one from the other process.
    19181916    m_frame->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrigin.get(), event, 0);
     1917}
     1918
     1919void WebFrameImpl::deliverIntent(const WebIntent& intent, WebDeliveredIntentClient* intentClient)
     1920{
     1921#if ENABLE(WEB_INTENTS)
     1922    OwnPtr<WebCore::DeliveredIntentClient> client(adoptPtr(new DeliveredIntentClientImpl(intentClient)));
     1923
     1924    OwnPtr<MessagePortArray> ports;
     1925    WebSerializedScriptValue intentData = WebSerializedScriptValue::fromString(intent.data());
     1926    const WebCore::Intent* webcoreIntent = intent;
     1927    RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_frame, client.release(), intent.action(), intent.type(), intentData, ports.release(), webcoreIntent->extras());
     1928
     1929    DOMWindowIntents::from(m_frame->domWindow())->deliver(deliveredIntent.release());
     1930#endif
    19191931}
    19201932
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.h

    r117200 r117384  
    5656class ChromePrintContext;
    5757class WebDataSourceImpl;
     58class WebDeliveredIntentClient;
    5859class WebInputElement;
     60class WebIntent;
    5961class WebFrameClient;
    6062class WebPerformance;
     
    211213    virtual void resetMatchCount();
    212214
    213     virtual void handleIntentResult(int, const WebString&);
    214     virtual void handleIntentFailure(int, const WebString&);
    215 
    216215    virtual void sendOrientationChangeEvent(int orientation);
    217216
     
    224223        const WebSecurityOrigin& intendedTargetOrigin,
    225224        const WebDOMEvent&);
     225
     226    virtual void deliverIntent(const WebIntent&, WebDeliveredIntentClient*);
    226227
    227228    virtual WebString contentAsText(size_t maxChars) const;
  • trunk/Source/WebKit/chromium/src/WebIntent.cpp

    r115264 r117384  
    3333
    3434#include "Intent.h"
     35#include "MessagePort.h"
    3536#include "PlatformMessagePortChannel.h"
    3637#include "SerializedScriptValue.h"
     
    3839
    3940namespace WebKit {
     41
     42WebIntent::WebIntent(const WebString& action, const WebString& type, const WebString& data)
     43{
     44#if ENABLE(WEB_INTENTS)
     45    WebCore::ExceptionCode ec = 0;
     46    WebCore::MessagePortArray ports;
     47    RefPtr<WebCore::Intent> intent = WebCore::Intent::create(action, type, WebCore::SerializedScriptValue::createFromWire(data), ports, ec);
     48    if (ec)
     49        return;
     50
     51    m_private = intent.release();
     52#endif
     53}
    4054
    4155#if ENABLE(WEB_INTENTS)
     
    131145}
    132146
     147WebIntent::operator WebCore::Intent*() const
     148{
     149    return m_private.get();
     150}
     151
    133152WebVector<WebString> WebIntent::extrasNames() const
    134153{
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp

    r116729 r117384  
    5050#include "WebIDBFactory.h"
    5151#include "WebInputElement.h"
     52#include "WebIntent.h"
    5253#include "WebIntentRequest.h"
    5354#include "WebKit.h"
     
    8081using namespace std;
    8182
     83class EmptyWebDeliveredIntentClient : public WebKit::WebDeliveredIntentClient {
     84public:
     85    EmptyWebDeliveredIntentClient() { }
     86    ~EmptyWebDeliveredIntentClient() { }
     87
     88    virtual void postResult(const WebSerializedScriptValue& data) const { }
     89    virtual void postFailure(const WebSerializedScriptValue& data) const { }
     90    virtual void destroy() { }
     91};
     92
    8293LayoutTestController::LayoutTestController(TestShell* shell)
    8394    : m_shell(shell)
     
    8697    , m_showDebugLayerTree(false)
    8798    , m_workQueue(this)
     99    , m_intentClient(adoptPtr(new EmptyWebDeliveredIntentClient))
    88100    , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
    89101{
     
    272284    bindProperty("workerThreadCount", &LayoutTestController::workerThreadCount);
    273285    bindMethod("sendWebIntentResponse", &LayoutTestController::sendWebIntentResponse);
     286    bindMethod("deliverWebIntent", &LayoutTestController::deliverWebIntent);
    274287}
    275288
     
    21542167}
    21552168
     2169void LayoutTestController::deliverWebIntent(const CppArgumentList& arguments, CppVariant* result)
     2170{
     2171    if (arguments.size() <  3)
     2172        return;
     2173
     2174    v8::HandleScope scope;
     2175    v8::Local<v8::Context> ctx = m_shell->webView()->mainFrame()->mainWorldScriptContext();
     2176    result->set(m_shell->webView()->mainFrame()->selectionAsMarkup().utf8());
     2177    v8::Context::Scope cscope(ctx);
     2178
     2179    WebString action = cppVariantToWebString(arguments[0]);
     2180    WebString type = cppVariantToWebString(arguments[1]);
     2181    WebKit::WebCString data = cppVariantToWebString(arguments[2]).utf8();
     2182    WebSerializedScriptValue serializedData = WebSerializedScriptValue::serialize(
     2183        v8::String::New(data.data(), data.length()));
     2184
     2185    WebIntent intent(action, type, serializedData.toString());
     2186
     2187    m_shell->webView()->mainFrame()->deliverIntent(intent, m_intentClient.get());
     2188}
     2189
    21562190void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
    21572191{
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h

    r116729 r117384  
    4444#include "CppBoundClass.h"
    4545#include "Task.h"
     46#include "WebDeliveredIntentClient.h"
    4647#include "platform/WebArrayBufferView.h"
    4748#include "platform/WebString.h"
     
    439440
    440441    // Expects one string argument for sending successful result, zero
    441     // for sending a failure result.
     442    // arguments for sending a failure result.
    442443    void sendWebIntentResponse(const CppArgumentList&, CppVariant*);
     444
     445    // Cause the web intent to be delivered to this context.
     446    void deliverWebIntent(const CppArgumentList&, CppVariant*);
    443447
    444448public:
     
    706710    WebKit::WebArrayBufferView m_audioData;
    707711
     712    // Mock object for testing delivering web intents.
     713    OwnPtr<WebKit::WebDeliveredIntentClient> m_intentClient;
     714
    708715    bool m_shouldStayOnPageAfterHandlingBeforeUnload;
    709716
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r117190 r117384  
    5959#include "platform/WebRect.h"
    6060#include "WebScreenInfo.h"
     61#include "platform/WebSerializedScriptValue.h"
    6162#include "platform/WebSize.h"
    6263#include "WebStorageNamespace.h"
     
    13531354               request.intent().extrasValue(extras[i]).utf8().data());
    13541355    }
     1356}
     1357
     1358void WebViewHost::deliveredIntentResult(WebFrame* frame, int id, const WebSerializedScriptValue& data)
     1359{
     1360    printf("Web intent success for id %d\n", id);
     1361}
     1362
     1363void WebViewHost::deliveredIntentFailure(WebFrame* frame, int id, const WebSerializedScriptValue& data)
     1364{
     1365    printf("Web intent failure for id %d\n", id);
    13551366}
    13561367
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.h

    r116384 r117384  
    5959class WebGeolocationServiceMock;
    6060class WebIntentServiceInfo;
     61class WebSerializedScriptValue;
    6162class WebSharedWorkerClient;
    6263class WebSpeechInputController;
     
    243244    virtual void registerIntentService(WebKit::WebFrame*, const WebKit::WebIntentServiceInfo&);
    244245    virtual void dispatchIntent(WebKit::WebFrame*, const WebKit::WebIntentRequest&);
     246    virtual void deliveredIntentResult(WebKit::WebFrame*, int, const WebKit::WebSerializedScriptValue&);
     247    virtual void deliveredIntentFailure(WebKit::WebFrame*, int, const WebKit::WebSerializedScriptValue&);
    245248
    246249    WebKit::WebDeviceOrientationClientMock* deviceOrientationClientMock();
Note: See TracChangeset for help on using the changeset viewer.