Title: [141004] trunk/Source/WebKit2
Revision
141004
Author
[email protected]
Date
2013-01-28 13:42:22 -0800 (Mon, 28 Jan 2013)

Log Message

PDFPlugin: getMainResourceDataOfFrame should return PDFPlugin's data so that Save... works
https://bugs.webkit.org/show_bug.cgi?id=108060
<rdar://problem/13075454>

Reviewed by Sam Weinig.

* WebProcess/Plugins/Netscape/NetscapePlugin.h: Implement getResourceData.
* WebProcess/Plugins/PDF/SimplePDFPlugin.h:
* WebProcess/Plugins/PDF/SimplePDFPlugin.mm: Implement getResourceData, returning the accumulated
data if it exists and has finished loading.
(WebKit::SimplePDFPlugin::getResourceData):
* WebProcess/Plugins/Plugin.h: Add getResourceData, which hands out a raw pointer/size pair
to the plugin's "main resource" data.
* WebProcess/Plugins/PluginProxy.h: Implement getResourceData.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::getResourceData): Forward getResourceData through to the plugin.
* WebProcess/Plugins/PluginView.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getMainResourceDataOfFrame): If the requested frame is backed by a PluginDocument,
attempt to ask the PluginView for its resource data.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (141003 => 141004)


--- trunk/Source/WebKit2/ChangeLog	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-28 21:42:22 UTC (rev 141004)
@@ -1,5 +1,28 @@
 2013-01-28  Tim Horton  <[email protected]>
 
+        PDFPlugin: getMainResourceDataOfFrame should return PDFPlugin's data so that Save... works
+        https://bugs.webkit.org/show_bug.cgi?id=108060
+        <rdar://problem/13075454>
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h: Implement getResourceData.
+        * WebProcess/Plugins/PDF/SimplePDFPlugin.h:
+        * WebProcess/Plugins/PDF/SimplePDFPlugin.mm: Implement getResourceData, returning the accumulated
+        data if it exists and has finished loading.
+        (WebKit::SimplePDFPlugin::getResourceData):
+        * WebProcess/Plugins/Plugin.h: Add getResourceData, which hands out a raw pointer/size pair
+        to the plugin's "main resource" data.
+        * WebProcess/Plugins/PluginProxy.h: Implement getResourceData.
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::getResourceData): Forward getResourceData through to the plugin.
+        * WebProcess/Plugins/PluginView.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::getMainResourceDataOfFrame): If the requested frame is backed by a PluginDocument,
+        attempt to ask the PluginView for its resource data.
+
+2013-01-28  Tim Horton  <[email protected]>
+
         [wk2] WKView's intrinsicContentSize should only report a flexible width if the content width is less than the minimum width
         https://bugs.webkit.org/show_bug.cgi?id=108056
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2013-01-28 21:42:22 UTC (rev 141004)
@@ -247,6 +247,8 @@
     // converted (if the transformation matrix isn't invertible).
     bool convertFromRootView(const WebCore::IntPoint& pointInRootViewCoordinates, WebCore::IntPoint& pointInPluginCoordinates);
 
+    virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const OVERRIDE { return false; }
+
     void updateNPNPrivateMode();
 
 #if PLUGIN_ARCHITECTURE(WIN)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h	2013-01-28 21:42:22 UTC (rev 141004)
@@ -177,6 +177,8 @@
     virtual unsigned countFindMatches(const String&, WebCore::FindOptions, unsigned) OVERRIDE { return 0; }
     virtual bool findString(const String&, WebCore::FindOptions, unsigned) OVERRIDE { return false; }
 
+    virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const OVERRIDE;
+
     WebCore::IntSize m_scrollOffset;
 
 private:

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm	2013-01-28 21:42:22 UTC (rev 141004)
@@ -672,6 +672,18 @@
     pdfDocumentDidLoad();
 }
 
+bool SimplePDFPlugin::getResourceData(const unsigned char*& bytes, unsigned& length) const
+{
+    if (m_data && m_pdfDocument) {
+        bytes = CFDataGetBytePtr(m_data.get());
+        length = CFDataGetLength(m_data.get());
+
+        return length;
+    }
+
+    return false;
+}
+
 void SimplePDFPlugin::manualStreamDidFail(bool)
 {
     m_data.clear();

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2013-01-28 21:42:22 UTC (rev 141004)
@@ -263,6 +263,8 @@
 
     virtual bool shouldAlwaysAutoStart() const { return false; }
 
+    virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const = 0;
+
 protected:
     Plugin();
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2013-01-28 21:42:22 UTC (rev 141004)
@@ -133,6 +133,8 @@
 
     virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const OVERRIDE;
 
+    virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const OVERRIDE { return false; }
+
     float contentsScaleFactor();
     bool needsBackingStore() const;
     bool updateBackingStore();

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2013-01-28 21:42:22 UTC (rev 141004)
@@ -879,6 +879,14 @@
     return m_plugin->shouldAllowNavigationFromDrags();
 }
 
+bool PluginView::getResourceData(const unsigned char*& bytes, unsigned& length) const
+{
+    if (!m_isInitialized || !m_plugin)
+        return false;
+
+    return m_plugin->getResourceData(bytes, length);
+}
+
 void PluginView::notifyWidget(WidgetNotification notification)
 {
     switch (notification) {

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2013-01-28 21:42:22 UTC (rev 141004)
@@ -99,6 +99,8 @@
 
     bool shouldAllowScripting();
 
+    bool getResourceData(const unsigned char*& bytes, unsigned& length) const;
+
 private:
     PluginView(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters& parameters);
     virtual ~PluginView();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (141003 => 141004)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-01-28 21:36:49 UTC (rev 141003)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-01-28 21:42:22 UTC (rev 141004)
@@ -2158,10 +2158,20 @@
 
     RefPtr<ResourceBuffer> buffer;
     if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) {
-        if (DocumentLoader* loader = frame->coreFrame()->loader()->documentLoader()) {
-            if ((buffer = loader->mainResourceData()))
-                dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
+        if (PluginView* pluginView = pluginViewForFrame(frame->coreFrame())) {
+            const unsigned char* bytes;
+            unsigned length;
+
+            if (pluginView->getResourceData(bytes, length))
+                dataReference = CoreIPC::DataReference(bytes, length);
         }
+
+        if (dataReference.isEmpty()) {
+            if (DocumentLoader* loader = frame->coreFrame()->loader()->documentLoader()) {
+                if ((buffer = loader->mainResourceData()))
+                    dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
+            }
+        }
     }
 
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to