]> git.saurik.com Git - wxWidgets.git/commitdiff
Use the data scheme to load resources in the WebKitGTK+ implementation, rather than...
authorSteve Lamerton <steve.lamerton@gmail.com>
Fri, 12 Aug 2011 09:35:41 +0000 (09:35 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Fri, 12 Aug 2011 09:35:41 +0000 (09:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68648 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/webview_webkit.cpp

index e88a5bfe8c31cafb2db481d501046ccf4c0b49ff..d4de44070cf7fb70661bdaa431f51f4e91833c3c 100644 (file)
@@ -17,6 +17,7 @@
 #include "wx/gtk/control.h"
 #include "wx/gtk/private.h"
 #include "wx/filesys.h"
+#include "wx/base64.h"
 #include "webkit/webkit.h"
 
 // ----------------------------------------------------------------------------
@@ -352,19 +353,16 @@ wxgtk_webview_webkit_resource_req(WebKitWebView *,
         wxFSFile* file = handler->GetFile(uri);
         if(file)
         {
-            //We redirect to a temp file for now, small things could be loaded
-            //using the data scheme
+            //We load the data into a data url to save it being written out again
             size_t size = file->GetStream()->GetLength();
             char *buffer = new char[size];
-            wxFile tempfile;
-            wxString path = wxFileName::CreateTempFileName("wxwebview_", &tempfile);
-            //We can then stream from the archive to the temp file
             file->GetStream()->Read(buffer, size);
-            tempfile.Write(buffer, size);
-            tempfile.Close();
+            wxString data = wxBase64Encode(buffer, size);
             delete[] buffer;
+            wxString mime = file->GetMimeType();
+            wxString path = "data:" + mime + ";base64," + data;
             //Then we can redirect the call
-            webkit_network_request_set_uri(request, "file://" + path);
+            webkit_network_request_set_uri(request, path);
         }
         
     }