⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 117793 in webkit


Ignore:
Timestamp:
May 21, 2012, 9:24:06 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

Add suggestions field to web intents API.
https://bugs.webkit.org/show_bug.cgi?id=86791

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

Source/WebCore:

The |suggestions| field is used by the client to avoid an empty
web intents selection window (picker). The UA can add the given
suggestions to the picker if it would otherwise be empty. See
http://dvcs.w3.org/hg/web-intents/raw-file/tip/spec/Overview.html#intent-parameters-dictionary

  • Modules/intents/DeliveredIntent.cpp:

(WebCore::DeliveredIntent::DeliveredIntent):

  • Modules/intents/Intent.cpp:

(WebCore::Intent::create):
(WebCore::Intent::Intent):

  • Modules/intents/Intent.h:

(WebCore::Intent::suggestions):
(Intent):

Source/WebKit/chromium:

  • public/WebIntent.h:

(WebIntent):

  • src/WebIntent.cpp:

(WebKit::WebIntent::suggestions):
(WebKit):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/webintents/web-intents-obj-constructor-expected.txt

    r115264 r117793  
    66Received Web Intent: action=action1 type=text/plain+port
    77Have 1 ports
     8Received Web Intent: action=action1 type=text/plain+suggestions
     9Have suggestion http://www.example.com/
    810PASS successfullyParsed is true
    911
     
    4446* sent intent with extras
    4547* sent intent with port
     48PASS new WebKitIntent(badPortIntentObj) threw exception Error: DATA_CLONE_ERR: DOM Exception 25.
     49PASS new WebKitIntent(suggestionsIntent) threw exception Error: SYNTAX_ERR: DOM Exception 12.
     50PASS new WebKitIntent(suggestionsIntent) threw exception Error: SYNTAX_ERR: DOM Exception 12.
     51* sent intent with suggestions
    4652
  • trunk/LayoutTests/webintents/web-intents-obj-constructor.html

    r115264 r117793  
    9393        navigator.webkitStartActivity(portIntent);
    9494        debug("* sent intent with port");
     95
     96        // Ports, if present, must be put in |transfer|.
     97        var badchannel = new MessageChannel();
     98        badchannel.port2.onMessage = function() {
     99            debug("* got message");
     100        }
     101        badPortIntentObj =
     102            {"action":"action1",
     103             "type":"text/plain+badport",
     104             "data":badchannel.port1};
     105        shouldThrow("new WebKitIntent(badPortIntentObj)", "'Error: DATA_CLONE_ERR: DOM Exception 25'");
     106
     107        suggestionsIntent =
     108            {"action":"action1",
     109             "type":"text/plain+suggestions",
     110             "data":"message",
     111             "suggestions":["www.example.com/", "http://ww2.example.com"]};
     112        shouldThrow("new WebKitIntent(suggestionsIntent)", "'Error: SYNTAX_ERR: DOM Exception 12'");
     113
     114        suggestionsIntent.suggestions = [15];
     115        shouldThrow("new WebKitIntent(suggestionsIntent)", "'Error: SYNTAX_ERR: DOM Exception 12'");
     116
     117        suggestionsIntent.suggestions = ["http://www.example.com/"];
     118        navigator.webkitStartActivity(new WebKitIntent(suggestionsIntent));
     119        debug("* sent intent with suggestions");
     120
    95121    }
    96122    </script>
  • trunk/Source/WebCore/ChangeLog

    r117792 r117793  
     12012-05-21  Greg Billock  <gbillock@google.com>
     2
     3        Add suggestions field to web intents API.
     4        https://bugs.webkit.org/show_bug.cgi?id=86791
     5
     6        Reviewed by Adam Barth.
     7
     8        The |suggestions| field is used by the client to avoid an empty
     9        web intents selection window (picker). The UA can add the given
     10        suggestions to the picker if it would otherwise be empty. See
     11        http://dvcs.w3.org/hg/web-intents/raw-file/tip/spec/Overview.html#intent-parameters-dictionary
     12
     13        * Modules/intents/DeliveredIntent.cpp:
     14        (WebCore::DeliveredIntent::DeliveredIntent):
     15        * Modules/intents/Intent.cpp:
     16        (WebCore::Intent::create):
     17        (WebCore::Intent::Intent):
     18        * Modules/intents/Intent.h:
     19        (WebCore::Intent::suggestions):
     20        (Intent):
     21
    1222012-05-21  Stephen Chenney  <schenney@chromium.org>
    223
  • trunk/Source/WebCore/Modules/intents/DeliveredIntent.cpp

    r117384 r117793  
    3636#include "Frame.h"
    3737#include "SerializedScriptValue.h"
     38#include <wtf/Vector.h>
    3839
    3940namespace WebCore {
     
    4950                                 PassRefPtr<SerializedScriptValue> data, PassOwnPtr<MessagePortArray> ports,
    5051                                 const HashMap<String, String>& extras)
    51     : Intent(action, type, data, PassOwnPtr<MessagePortChannelArray>(), extras, KURL())
     52    : Intent(action, type, data, PassOwnPtr<MessagePortChannelArray>(), extras, KURL(), Vector<KURL>())
    5253    , FrameDestructionObserver(frame)
    5354    , m_client(client)
  • trunk/Source/WebCore/Modules/intents/Intent.cpp

    r116763 r117793  
    3535#include "MessagePort.h"
    3636#include "SerializedScriptValue.h"
     37#include <wtf/HashSet.h>
    3738
    3839namespace WebCore {
     
    5152    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(&ports, ec);
    5253
    53     WTF::HashMap<String, String> extras;
    54     KURL serviceUrl;
     54    HashMap<String, String> extras;
     55    KURL serviceURL;
     56    Vector<KURL> suggestions;
    5557
    56     return adoptRef(new Intent(action, type, data, channels.release(), extras, serviceUrl));
     58    return adoptRef(new Intent(action, type, data, channels.release(), extras, serviceURL, suggestions));
    5759}
    5860
     
    9799    }
    98100
    99     WTF::HashMap<String, String> extras;
     101    HashMap<String, String> extras;
    100102    Dictionary extrasDictionary;
    101103    if (options.get("extras", extrasDictionary))
    102104        extrasDictionary.getOwnPropertiesAsStringHashMap(extras);
    103105
    104     return adoptRef(new Intent(action, type, serializedData.release(), channels.release(), extras, serviceUrl));
     106    HashSet<AtomicString> suggestionsStrings;
     107    Vector<KURL> suggestions;
     108    if (options.get("suggestions", suggestionsStrings)) {
     109        for (HashSet<AtomicString>::iterator iter = suggestionsStrings.begin(); iter != suggestionsStrings.end(); ++iter) {
     110            KURL suggestedURL = KURL(KURL(), *iter);
     111            if (!suggestedURL.isValid()) {
     112                ec = SYNTAX_ERR;
     113                return 0;
     114            }
     115            suggestions.append(suggestedURL);
     116        }
     117    }
     118
     119    return adoptRef(new Intent(action, type, serializedData.release(), channels.release(), extras, serviceUrl, suggestions));
    105120}
    106121
    107122Intent::Intent(const String& action, const String& type,
    108123               PassRefPtr<SerializedScriptValue> data, PassOwnPtr<MessagePortChannelArray> ports,
    109                const WTF::HashMap<String, String>& extras, const KURL& service)
     124               const HashMap<String, String>& extras, const KURL& service, const Vector<KURL>& suggestions)
    110125    : m_action(action)
    111126    , m_type(type)
     
    113128    , m_service(service)
    114129    , m_extras(extras)
     130    , m_suggestions(suggestions)
    115131{
    116132    if (data)
  • trunk/Source/WebCore/Modules/intents/Intent.h

    r117384 r117793  
    4141#include <wtf/RefCounted.h>
    4242#include <wtf/RefPtr.h>
     43#include <wtf/Vector.h>
    4344#include <wtf/text/WTFString.h>
    4445
     
    6263    MessagePortChannelArray* messagePorts() const { return m_ports.get(); }
    6364    const KURL& service() const { return m_service; }
    64     const WTF::HashMap<String, String>& extras() const { return m_extras; }
     65    const HashMap<String, String>& extras() const { return m_extras; }
     66    const Vector<KURL>& suggestions() const { return m_suggestions; }
    6567
    6668protected:
    6769    Intent(const String& action, const String& type,
    6870           PassRefPtr<SerializedScriptValue> data, PassOwnPtr<MessagePortChannelArray> ports,
    69            const WTF::HashMap<String, String>& extras, const KURL& service);
     71           const HashMap<String, String>& extras, const KURL& service, const Vector<KURL>& suggestions);
    7072
    7173private:
     
    7577    OwnPtr<MessagePortChannelArray> m_ports;
    7678    KURL m_service;
    77     WTF::HashMap<String, String> m_extras;
     79    HashMap<String, String> m_extras;
     80    Vector<KURL> m_suggestions;
    7881};
    7982
  • trunk/Source/WebKit/chromium/ChangeLog

    r117766 r117793  
     12012-05-21  Greg Billock  <gbillock@google.com>
     2
     3        Add suggestions field to web intents API.
     4        https://bugs.webkit.org/show_bug.cgi?id=86791
     5
     6        Reviewed by Adam Barth.
     7
     8        * public/WebIntent.h:
     9        (WebIntent):
     10        * src/WebIntent.cpp:
     11        (WebKit::WebIntent::suggestions):
     12        (WebKit):
     13
    1142012-05-20  Kinuko Yasuda  <kinuko@chromium.org>
    215
  • trunk/Source/WebKit/chromium/public/WebIntent.h

    r117423 r117793  
    6767    WEBKIT_EXPORT WebString data() const;
    6868    WEBKIT_EXPORT WebURL service() const;
     69    WEBKIT_EXPORT WebVector<WebURL> suggestions() const;
    6970
    7071    // Retrieve a list of the names of extra metadata associated with the
  • trunk/Source/WebKit/chromium/src/WebIntent.cpp

    r117384 r117793  
    128128}
    129129
     130WebVector<WebURL> WebIntent::suggestions() const
     131{
     132#if ENABLE(WEB_INTENTS)
     133    WebVector<WebURL> suggestions(m_private->suggestions().size());
     134    for (size_t i = 0; i < m_private->suggestions().size(); ++i)
     135        suggestions[i] = m_private->suggestions().at(i);
     136    return suggestions;
     137#else
     138    return WebVector<WebURL>();
     139#endif
     140}
     141
    130142WebMessagePortChannelArray* WebIntent::messagePortChannelsRelease() const
    131143{
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r117680 r117793  
    13471347        delete ports;
    13481348    }
     1349
    13491350    if (!request.intent().service().isEmpty())
    13501351        printf("Explicit intent service: %s\n", request.intent().service().spec().data());
     1352
    13511353    WebVector<WebString> extras = request.intent().extrasNames();
    13521354    for (size_t i = 0; i < extras.size(); ++i) {
     
    13541356               request.intent().extrasValue(extras[i]).utf8().data());
    13551357    }
     1358
     1359    WebVector<WebURL> suggestions = request.intent().suggestions();
     1360    for (size_t i = 0; i < suggestions.size(); ++i)
     1361        printf("Have suggestion %s\n", suggestions[i].spec().data());
    13561362}
    13571363
Note: See TracChangeset for help on using the changeset viewer.