Title: [174104] trunk/Source/WebKit2
Revision
174104
Author
[email protected]
Date
2014-09-30 06:33:50 -0700 (Tue, 30 Sep 2014)

Log Message

[GTK] The remote web inspector shows the HTML content as plain text
https://bugs.webkit.org/show_bug.cgi?id=137250

Reviewed by Gustavo Noronha Silva.

Use GResource API directly to get the resource data, instead of
using the GFile API, and use g_content_type_guess() to get the
MIME Type.

* UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp:
(WebKit::WebInspectorServer::platformResourceForPath):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (174103 => 174104)


--- trunk/Source/WebKit2/ChangeLog	2014-09-30 13:28:07 UTC (rev 174103)
+++ trunk/Source/WebKit2/ChangeLog	2014-09-30 13:33:50 UTC (rev 174104)
@@ -1,5 +1,19 @@
 2014-09-30  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] The remote web inspector shows the HTML content as plain text
+        https://bugs.webkit.org/show_bug.cgi?id=137250
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Use GResource API directly to get the resource data, instead of
+        using the GFile API, and use g_content_type_guess() to get the
+        MIME Type.
+
+        * UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp:
+        (WebKit::WebInspectorServer::platformResourceForPath):
+
+2014-09-30  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Move GtkPopupMenu implementation to WebPopupMenuProxyGtk
         https://bugs.webkit.org/show_bug.cgi?id=137193
 

Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp (174103 => 174104)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp	2014-09-30 13:28:07 UTC (rev 174103)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp	2014-09-30 13:33:50 UTC (rev 174104)
@@ -49,36 +49,34 @@
     }
 
     // Point the default path to a formatted page that queries the page list and display them.
-    CString resourceURI = makeString("resource:///org/webkitgtk/inspector/UserInterface", ((path == "/") ? "/inspectorPageIndex.html" : path)).utf8();
-    if (resourceURI.isNull())
+    CString resourcePath = makeString("/org/webkitgtk/inspector/UserInterface", (path == "/" ? "/inspectorPageIndex.html" : path)).utf8();
+    if (resourcePath.isNull())
         return false;
 
-    GRefPtr<GFile> file = adoptGRef(g_file_new_for_uri(resourceURI.data()));
     GUniqueOutPtr<GError> error;
-    GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, 0, &error.outPtr()));
-    if (!fileInfo) {
+    GRefPtr<GBytes> resourceBytes = adoptGRef(g_resources_lookup_data(resourcePath.data(), G_RESOURCE_LOOKUP_FLAGS_NONE, &error.outPtr()));
+    if (!resourceBytes) {
         StringBuilder builder;
         builder.appendLiteral("<!DOCTYPE html><html><head></head><body>Error: ");
         builder.appendNumber(error->code);
         builder.appendLiteral(", ");
         builder.append(error->message);
         builder.appendLiteral(" occurred during fetching inspector resource files.</body></html>");
-        CString cstr = builder.toString().utf8();
-        data.append(cstr.data(), cstr.length());
+
+        CString errorHTML = builder.toString().utf8();
+        data.append(errorHTML.data(), errorHTML.length());
         contentType = "text/html; charset=utf-8";
-        g_warning("Error fetching webinspector resource files: %d, %s", error->code, error->message);
-        return true;
-    }
 
-    GRefPtr<GFileInputStream> inputStream = adoptGRef(g_file_read(file.get(), 0, 0));
-    if (!inputStream)
+        WTFLogAlways("Error fetching webinspector resource files: %d, %s", error->code, error->message);
         return false;
+    }
 
-    data.grow(g_file_info_get_size(fileInfo.get()));
-    if (!g_input_stream_read_all(G_INPUT_STREAM(inputStream.get()), data.data(), data.size(), 0, 0, 0))
-        return false;
+    gsize resourceDataSize;
+    gconstpointer resourceData = g_bytes_get_data(resourceBytes.get(), &resourceDataSize);
+    data.append(static_cast<const char*>(resourceData), resourceDataSize);
 
-    contentType = GUniquePtr<gchar>(g_file_info_get_attribute_as_string(fileInfo.get(), G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE)).get();
+    GUniquePtr<gchar> mimeType(g_content_type_guess(resourcePath.data(), static_cast<const guchar*>(resourceData), resourceDataSize, nullptr));
+    contentType = mimeType.get();
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to