[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 11:12:20 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 3f40724d73c5014d228659b1e4680549bd58ddba
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jul 15 01:03:26 2010 +0000
More work on plug-in streams
https://bugs.webkit.org/show_bug.cgi?id=42308
Reviewed by Sam Weinig.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::loadURL):
If the target is null, create a NetscapePluginStream and add it to the m_streams map.
(WebKit::NetscapePlugin::removePluginStream):
Remove the given NetscapePluginStream from the m_streams map.
(WebKit::NetscapePlugin::NPP_NewStream):
(WebKit::NetscapePlugin::NPP_DestroyStream):
Add NPP_ wrappers.
(WebKit::NetscapePlugin::streamFromID):
Return the plug-in stream given a stream ID.
(WebKit::NetscapePlugin::didEvaluateJavaScript):
Find the plug-in stream and call sendJavaScriptStream.
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
Initialize member variables.
(WebKit::NetscapePluginStream::~NetscapePluginStream):
Assert that we aren't started.
(WebKit::NetscapePluginStream::sendJavaScriptStream):
If the JavaScript request was successful, start the stream. Otherwise call stop() which just
ends up calling NPP_URLNotify when the stream isn't started.
(WebKit::NetscapePluginStream::start):
Set up the NPStream object. Call NPP_NewStream. Return false if the call was not successful, or if
the requested stream type is one that we don't yet support.
(WebKit::NetscapePluginStream::stop):
Call NPP_DestroyStream if the stream is started. Call NPP_URLNotify if necessary.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::performJavaScriptURLRequest):
Remove unneeded comment.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63385 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2ff0c64..269981a 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,49 @@
+2010-07-14 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ More work on plug-in streams
+ https://bugs.webkit.org/show_bug.cgi?id=42308
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::loadURL):
+ If the target is null, create a NetscapePluginStream and add it to the m_streams map.
+
+ (WebKit::NetscapePlugin::removePluginStream):
+ Remove the given NetscapePluginStream from the m_streams map.
+
+ (WebKit::NetscapePlugin::NPP_NewStream):
+ (WebKit::NetscapePlugin::NPP_DestroyStream):
+ Add NPP_ wrappers.
+
+ (WebKit::NetscapePlugin::streamFromID):
+ Return the plug-in stream given a stream ID.
+
+ (WebKit::NetscapePlugin::didEvaluateJavaScript):
+ Find the plug-in stream and call sendJavaScriptStream.
+
+ * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
+ (WebKit::NetscapePluginStream::NetscapePluginStream):
+ Initialize member variables.
+
+ (WebKit::NetscapePluginStream::~NetscapePluginStream):
+ Assert that we aren't started.
+
+ (WebKit::NetscapePluginStream::sendJavaScriptStream):
+ If the JavaScript request was successful, start the stream. Otherwise call stop() which just
+ ends up calling NPP_URLNotify when the stream isn't started.
+
+ (WebKit::NetscapePluginStream::start):
+ Set up the NPStream object. Call NPP_NewStream. Return false if the call was not successful, or if
+ the requested stream type is one that we don't yet support.
+
+ (WebKit::NetscapePluginStream::stop):
+ Call NPP_DestroyStream if the stream is started. Call NPP_URLNotify if necessary.
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::performJavaScriptURLRequest):
+ Remove unneeded comment.
+
2010-07-14 Sam Weinig <sam at webkit.org>
Reviewed by John Sullivan.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index a88cad3..0a1c876 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -25,6 +25,7 @@
#include "NetscapePlugin.h"
+#include "NetscapePluginStream.h"
#include "PluginController.h"
#include <WebCore/GraphicsContext.h>
#include <WebCore/IntRect.h>
@@ -104,17 +105,32 @@ void NetscapePlugin::loadURL(const String& urlString, const String& target, bool
{
uint64_t requestID = ++m_nextRequestID;
- if (!target.isNull() && sendNotification) {
+ // FIXME: Handle popups.
+ bool allowPopups = false;
+ m_pluginController->loadURL(requestID, urlString, target, allowPopups);
+
+ if (target.isNull()) {
+ // The browser is going to send the data in a stream, create a plug-in stream.
+ RefPtr<NetscapePluginStream> pluginStream = NetscapePluginStream::create(this, requestID, sendNotification, notificationData);
+ ASSERT(!m_streams.contains(requestID));
+
+ m_streams.set(requestID, pluginStream.release());
+ return;
+ }
+
+ if (sendNotification) {
// Eventually we are going to get a frameDidFinishLoading or frameDidFail call for this request.
// Keep track of the notification data so we can call NPP_URLNotify.
ASSERT(!m_pendingURLNotifications.contains(requestID));
m_pendingURLNotifications.set(requestID, make_pair(urlString, notificationData));
}
+}
- // FIXME: Handle popups.
- bool allowPopups = false;
- m_pluginController->loadURL(requestID, urlString, target, allowPopups);
+void NetscapePlugin::removePluginStream(NetscapePluginStream* pluginStream)
+{
+ ASSERT(m_streams.get(pluginStream->streamID()) == pluginStream);
+ m_streams.remove(pluginStream->streamID());
}
NPError NetscapePlugin::NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* savedData)
@@ -132,6 +148,16 @@ NPError NetscapePlugin::NPP_SetWindow(NPWindow* npWindow)
return m_pluginModule->pluginFuncs().setwindow(&m_npp, npWindow);
}
+NPError NetscapePlugin::NPP_NewStream(NPMIMEType mimeType, NPStream* stream, NPBool seekable, uint16_t* streamType)
+{
+ return m_pluginModule->pluginFuncs().newstream(&m_npp, mimeType, stream, seekable, streamType);
+}
+
+NPError NetscapePlugin::NPP_DestroyStream(NPStream* stream, NPReason reason)
+{
+ return m_pluginModule->pluginFuncs().destroystream(&m_npp, stream, reason);
+}
+
void NetscapePlugin::NPP_URLNotify(const char* url, NPReason reason, void* notifyData)
{
m_pluginModule->pluginFuncs().urlnotify(&m_npp, url, reason, notifyData);
@@ -151,6 +177,11 @@ void NetscapePlugin::callSetWindow()
NPP_SetWindow(&m_npWindow);
}
+NetscapePluginStream* NetscapePlugin::streamFromID(uint64_t streamID)
+{
+ return m_streams.get(streamID).get();
+}
+
bool NetscapePlugin::initialize(PluginController* pluginController, const Parameters& parameters)
{
ASSERT(!m_pluginController);
@@ -263,7 +294,8 @@ void NetscapePlugin::frameDidFail(uint64_t requestID, bool wasCancelled)
void NetscapePlugin::didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result)
{
- // FIXME: Implement.
+ if (NetscapePluginStream* pluginStream = streamFromID(requestID))
+ pluginStream->sendJavaScriptStream(requestURLString, result);
}
PluginController* NetscapePlugin::controller()
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 7475d5d..4786034 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -33,6 +33,8 @@
namespace WebKit {
+class NetscapePluginStream;
+
class NetscapePlugin : public Plugin {
public:
static PassRefPtr<NetscapePlugin> create(PassRefPtr<NetscapePluginModule> pluginModule)
@@ -52,10 +54,14 @@ public:
const char* userAgent();
void loadURL(const WebCore::String& urlString, const WebCore::String& target, bool sendNotification, void* notificationData);
+ void removePluginStream(NetscapePluginStream*);
+
// Member functions for calling into the plug-in.
- NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* savedData);
- NPError NPP_Destroy(NPSavedData** savedData);
+ NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData*);
+ NPError NPP_Destroy(NPSavedData**);
NPError NPP_SetWindow(NPWindow*);
+ NPError NPP_NewStream(NPMIMEType, NPStream*, NPBool seekable, uint16_t* stype);
+ NPError NPP_DestroyStream(NPStream*, NPReason);
void NPP_URLNotify(const char* url, NPReason reason, void* notifyData);
private:
@@ -63,6 +69,8 @@ private:
void callSetWindow();
+ NetscapePluginStream* streamFromID(uint64_t streamID);
+
bool platformPostInitialize();
void platformPaint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
@@ -83,6 +91,8 @@ private:
typedef HashMap<uint64_t, std::pair<WebCore::String, void*> > PendingURLNotifyMap;
PendingURLNotifyMap m_pendingURLNotifications;
+ HashMap<uint64_t, RefPtr<NetscapePluginStream> > m_streams;
+
RefPtr<NetscapePluginModule> m_pluginModule;
NPP_t m_npp;
NPWindow m_npWindow;
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
index c2fa572..651b6f9 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
@@ -27,6 +27,8 @@
#include "NetscapePlugin.h"
+using namespace WebCore;
+
namespace WebKit {
NetscapePluginStream::NetscapePluginStream(PassRefPtr<NetscapePlugin> plugin, uint64_t streamID, bool sendNotification, void* notificationData)
@@ -34,11 +36,82 @@ NetscapePluginStream::NetscapePluginStream(PassRefPtr<NetscapePlugin> plugin, ui
, m_streamID(streamID)
, m_sendNotification(sendNotification)
, m_notificationData(notificationData)
+ , m_npStream()
+ , m_transferMode(NP_NORMAL)
+ , m_offset(0)
+ , m_isStarted(false)
{
}
NetscapePluginStream::~NetscapePluginStream()
{
+ ASSERT(!m_isStarted);
+}
+
+void NetscapePluginStream::sendJavaScriptStream(const String& requestURLString, const String& result)
+{
+ CString resultCString = requestURLString.utf8();
+ if (resultCString.isNull()) {
+ // There was an error evaluating the JavaScript, just call stop.
+ stop(NPRES_NETWORK_ERR);
+ return;
+ }
+
+ if (!start(requestURLString, resultCString.length(), 0, "text/plain", "")) {
+ stop(NPRES_NETWORK_ERR);
+ return;
+ }
+
+ // FIXME: Send the JavaScript string as well.
+}
+
+bool NetscapePluginStream::start(const WebCore::String& responseURLString, uint32_t expectedContentLength,
+ uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers)
+{
+ m_responseURL = responseURLString.utf8();
+ m_mimeType = mimeType.utf8();
+ m_headers = headers.utf8();
+
+ m_npStream.ndata = this;
+ m_npStream.url = m_responseURL.data();
+ m_npStream.end = expectedContentLength;
+ m_npStream.lastmodified = lastModifiedTime;
+ m_npStream.notifyData = 0;
+ m_npStream.headers = m_headers.length() == 0 ? 0 : m_headers.data();
+
+ NPError error = m_plugin->NPP_NewStream(const_cast<char*>(m_mimeType.data()), &m_npStream, false, &m_transferMode);
+ if (error != NPERR_NO_ERROR)
+ return false;
+
+ // We successfully started the stream.
+ m_isStarted = true;
+
+ switch (m_transferMode) {
+ case NP_NORMAL:
+ break;
+ // FIXME: We don't support streaming to files.
+ case NP_ASFILEONLY:
+ case NP_ASFILE:
+ return false;
+ // FIXME: We don't support seekable streams.
+ case NP_SEEK:
+ return false;
+ }
+
+ return true;
+}
+
+void NetscapePluginStream::stop(NPReason reason)
+{
+ if (m_isStarted) {
+ m_plugin->NPP_DestroyStream(&m_npStream, reason);
+ m_isStarted = false;
+ }
+
+ if (m_sendNotification)
+ m_plugin->NPP_URLNotify(m_responseURL.data(), reason, m_notificationData);
+
+ m_plugin->removePluginStream(this);
}
} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
index 6274456..e02d707 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
@@ -26,9 +26,15 @@
#ifndef NetscapePluginStream_h
#define NetscapePluginStream_h
+#include <WebCore/npapi.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+ class String;
+}
namespace WebKit {
@@ -42,14 +48,33 @@ public:
}
~NetscapePluginStream();
+ uint64_t streamID() const { return m_streamID; }
+
+ void sendJavaScriptStream(const WebCore::String& requestURLString, const WebCore::String& result);
+
private:
NetscapePluginStream(PassRefPtr<NetscapePlugin>, uint64_t streamID, bool sendNotification, void* notificationData);
+ bool start(const WebCore::String& responseURLString, uint32_t expectedContentLength,
+ uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
+ void stop(NPReason);
+
RefPtr<NetscapePlugin> m_plugin;
uint64_t m_streamID;
bool m_sendNotification;
void* m_notificationData;
+
+ NPStream m_npStream;
+ uint16_t m_transferMode;
+ int32_t m_offset;
+
+ // Whether NPP_NewStream has successfully been called.
+ bool m_isStarted;
+
+ CString m_responseURL;
+ CString m_mimeType;
+ CString m_headers;
};
} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index aea7f37..88bb3e1 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -279,7 +279,7 @@ void PluginView::performJavaScriptURLRequest(URLRequest* request)
}
// Evaluate the JavaScript code. Note that running JavaScript here could cause the plug-in to be destroyed, so we
- // grab references to the plug-in here. (We already have a reference to the frame).
+ // grab references to the plug-in here.
RefPtr<Plugin> plugin = m_plugin;
ScriptValue result = m_pluginElement->document()->frame()->script()->executeScript(jsString);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list