Source/WebCore/ChangeLog

 12012-05-22 Greg Billock <gbillock@google.com>
 2
 3 New constructor for WebIntent to be used for delivery
 4 https://bugs.webkit.org/show_bug.cgi?id=87143
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Modules/intents/Intent.cpp:
 9 (WebCore::Intent::setExtras):
 10 (WebCore):
 11 * Modules/intents/Intent.h:
 12 (Intent):
 13
1142012-05-23 Ryosuke Niwa <rniwa@webkit.org>
215
316 WebKit spends ~20% of time in HTMLTextAreaElement::defaultValue() when opening a review page

Source/WebKit/chromium/ChangeLog

 12012-05-22 Greg Billock <gbillock@google.com>
 2
 3 New constructor for WebIntent to be used for delivery
 4 https://bugs.webkit.org/show_bug.cgi?id=87143
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 When delivering an intent to webkit, the caller needs to be able to
 9 the action, type, and data, and also extra data and ports.
 10
 11 * public/WebIntent.h:
 12 (WebIntent):
 13 * src/WebFrameImpl.cpp:
 14 (WebKit::WebFrameImpl::deliverIntent):
 15 * src/WebIntent.cpp:
 16 (WebKit::WebIntent::WebIntent):
 17 (WebKit):
 18 (WebKit::WebIntent::reset):
 19 (WebKit::WebIntent::messagePortChannelsRelease):
 20
1212012-05-22 Alexandre Elias <aelias@google.com>
222
323 [chromium] Apply viewport tag initial-scale only once

Source/WebCore/Modules/intents/Intent.cpp

@@Intent::Intent(const String& action, const String& type,
135135 m_data = SerializedScriptValue::nullValue();
136136}
137137
 138void Intent::setExtras(const WTF::HashMap<String, String>& extras)
 139{
 140 m_extras = extras;
 141}
 142
138143} // namespace WebCore
139144
140145#endif // ENABLE(WEB_INTENTS)

Source/WebCore/Modules/intents/Intent.h

@@public:
6565 const HashMap<String, String>& extras() const { return m_extras; }
6666 const Vector<KURL>& suggestions() const { return m_suggestions; }
6767
 68 void setExtras(const WTF::HashMap<String, String>&);
 69
6870protected:
6971 Intent(const String& action, const String& type,
7072 PassRefPtr<SerializedScriptValue> data, PassOwnPtr<MessagePortChannelArray> ports,

Source/WebKit/chromium/public/WebIntent.h

@@namespace WebCore { class Intent; }
4242
4343namespace WebKit {
4444
 45class WebBlob;
 46
4547// Holds data passed through a Web Intents invocation call from the Javascript
4648// Intent object.
4749// See spec at http://www.chromium.org/developers/design-documents/webintentsapi

@@class WebIntent {
4951public:
5052 WebIntent() { }
5153 WEBKIT_EXPORT WebIntent(const WebString& action, const WebString& type, const WebString& data);
 54 WEBKIT_EXPORT WebIntent(const WebString& action, const WebString& type, const WebString& data,
 55 WebMessagePortChannelArray* ports, const WebVector<WebString>& extrasNames, const WebVector<WebString> extrasValues);
 56 WEBKIT_EXPORT WebIntent(const WebString& action, const WebString& type, const WebString& unserializedData,
 57 const WebVector<WebString>& extrasNames, const WebVector<WebString> extrasValues);
 58 WEBKIT_EXPORT WebIntent(const WebString& action, const WebString& type, WebBlob*,
 59 const WebVector<WebString>& extrasNames, const WebVector<WebString> extrasValues);
 60
5261 WebIntent(const WebIntent& other) { assign(other); }
5362 ~WebIntent() { reset(); }
5463
 64 // Note: this will NOT transfer ownership of any owned ports.
5565 WebIntent& operator=(const WebIntent& other)
5666 {
5767 assign(other);

@@public:
8797
8898private:
8999 WebPrivatePtr<WebCore::Intent> m_private;
 100 mutable WebMessagePortChannelArray* m_ownedChannels;
90101};
91102
92103} // namespace WebKit

Source/WebKit/chromium/src/WebFrameImpl.cpp

109109#include "IconURL.h"
110110#include "InspectorController.h"
111111#include "KURL.h"
 112#include "MessagePort.h"
112113#include "Node.h"
113114#include "Page.h"
114115#include "PageOverlay.h"
115116#include "Performance.h"
 117#include "PlatformMessagePortChannel.h"
116118#include "PlatformSupport.h"
117119#include "PluginDocument.h"
118120#include "PrintContext.h"

@@void WebFrameImpl::deliverIntent(const WebIntent& intent, WebDeliveredIntentClie
19061908#if ENABLE(WEB_INTENTS)
19071909 OwnPtr<WebCore::DeliveredIntentClient> client(adoptPtr(new DeliveredIntentClientImpl(intentClient)));
19081910
1909  OwnPtr<MessagePortArray> ports;
19101911 WebSerializedScriptValue intentData = WebSerializedScriptValue::fromString(intent.data());
19111912 const WebCore::Intent* webcoreIntent = intent;
 1913
 1914 // See PlatformMessagePortChannel.cpp
 1915 OwnPtr<MessagePortChannelArray> channels;
 1916 WebMessagePortChannelArray* webChannels = intent.messagePortChannelsRelease();
 1917 if (webChannels && webChannels->size()) {
 1918 channels = adoptPtr(new MessagePortChannelArray(webChannels->size()));
 1919 for (size_t i = 0; i < webChannels->size(); ++i) {
 1920 RefPtr<PlatformMessagePortChannel> platformChannel = PlatformMessagePortChannel::create((*webChannels)[i]);
 1921 (*webChannels)[i]->setClient(platformChannel.get());
 1922 (*channels)[i] = MessagePortChannel::create(platformChannel);
 1923 }
 1924 }
 1925 OwnPtr<MessagePortArray> ports = WebCore::MessagePort::entanglePorts(*(m_frame->domWindow()->scriptExecutionContext()), channels.release());
 1926
19121927 RefPtr<DeliveredIntent> deliveredIntent = DeliveredIntent::create(m_frame, client.release(), intent.action(), intent.type(), intentData, ports.release(), webcoreIntent->extras());
19131928
19141929 DOMWindowIntents::from(m_frame->domWindow())->deliver(deliveredIntent.release());

Source/WebKit/chromium/src/WebIntent.cpp

3535#include "MessagePort.h"
3636#include "PlatformMessagePortChannel.h"
3737#include "SerializedScriptValue.h"
 38#include "WebBlob.h"
 39#include "platform/WebSerializedScriptValue.h"
 40#include "v8.h"
3841#include <wtf/HashMap.h>
3942
4043namespace WebKit {

@@WebIntent::WebIntent(const WebString& action, const WebString& type, const WebSt
4952 return;
5053
5154 m_private = intent.release();
 55 m_ownedChannels = 0;
 56#endif
 57}
 58
 59WebIntent::WebIntent(const WebString& action, const WebString& type, const WebString& data,
 60 WebMessagePortChannelArray* ports, const WebVector<WebString>& extrasNames, const WebVector<WebString> extrasValues)
 61{
 62#if ENABLE(WEB_INTENTS)
 63 WebCore::ExceptionCode ec = 0;
 64 WebCore::MessagePortArray dummyPorts;
 65 RefPtr<WebCore::Intent> intent = WebCore::Intent::create(action, type, WebCore::SerializedScriptValue::createFromWire(data), dummyPorts, ec);
 66 if (ec)
 67 return;
 68
 69 HashMap<String, String> extras;
 70 for (size_t i = 0; i < extrasNames.size() && i < extrasValues.size(); ++i)
 71 extras.add(extrasNames[i], extrasValues[i]);
 72 intent->setExtras(extras);
 73
 74 m_private = intent.release();
 75 m_ownedChannels = ports;
 76#endif
 77}
 78
 79WebIntent::WebIntent(const WebString& action, const WebString& type, const WebString& unserializedData,
 80 const WebVector<WebString>& extrasNames, const WebVector<WebString> extrasValues)
 81{
 82#if ENABLE(WEB_INTENTS)
 83#if WEBKIT_USING_V8
 84 v8::HandleScope scope;
 85 v8::Local<v8::String> dataV8 = v8::String::New(reinterpret_cast<const uint16_t*>(unserializedData.data()),
 86 static_cast<int>(unserializedData.length()));
 87 WebSerializedScriptValue serializedData = WebSerializedScriptValue::serialize(dataV8);
 88
 89 WebCore::ExceptionCode ec = 0;
 90 WebCore::MessagePortArray dummyPorts;
 91 RefPtr<WebCore::Intent> intent = WebCore::Intent::create(action, type, serializedData, dummyPorts, ec);
 92 if (ec)
 93 return;
 94
 95 HashMap<String, String> extras;
 96 for (size_t i = 0; i < extrasNames.size() && i < extrasValues.size(); ++i)
 97 extras.add(extrasNames[i], extrasValues[i]);
 98 intent->setExtras(extras);
 99
 100 m_private = intent.release();
 101 m_ownedChannels = 0;
 102#endif
 103#endif
 104}
 105
 106WebIntent::WebIntent(const WebString& action, const WebString& type, WebBlob* blob,
 107 const WebVector<WebString>& extrasNames, const WebVector<WebString> extrasValues)
 108{
 109#if ENABLE(WEB_INTENTS)
 110#if WEBKIT_USING_V8
 111 WebSerializedScriptValue serializedData = WebSerializedScriptValue::serialize(blob->toV8Value());
 112 WebCore::ExceptionCode ec = 0;
 113 WebCore::MessagePortArray dummyPorts;
 114 RefPtr<WebCore::Intent> intent = WebCore::Intent::create(action, type, serializedData, dummyPorts, ec);
 115 if (ec)
 116 return;
 117
 118 HashMap<String, String> extras;
 119 for (size_t i = 0; i < extrasNames.size() && i < extrasValues.size(); ++i)
 120 extras.add(extrasNames[i], extrasValues[i]);
 121 intent->setExtras(extras);
 122
 123 m_private = intent.release();
 124 m_ownedChannels = 0;
 125#endif
52126#endif
53127}
54128
55129#if ENABLE(WEB_INTENTS)
56130WebIntent::WebIntent(const PassRefPtr<WebCore::Intent>& intent)
57131 : m_private(intent)
 132 , m_ownedChannels(0)
58133{
59134}
60135#endif

@@void WebIntent::reset()
64139#if ENABLE(WEB_INTENTS)
65140 m_private.reset();
66141#endif
 142
 143 if (m_ownedChannels) {
 144 delete m_ownedChannels;
 145 m_ownedChannels = 0;
 146 }
67147}
68148
69149bool WebIntent::isNull() const

@@WebVector<WebURL> WebIntent::suggestions() const
141221
142222WebMessagePortChannelArray* WebIntent::messagePortChannelsRelease() const
143223{
 224 if (m_ownedChannels) {
 225 WebMessagePortChannelArray* channels = m_ownedChannels;
 226 m_ownedChannels = 0;
 227 return channels;
 228 }
 229
144230 // Note: see PlatformMessagePortChannel::postMessageToRemote.
145231 WebMessagePortChannelArray* webChannels = 0;
146232 WebCore::MessagePortChannelArray* messagePorts = m_private->messagePorts();