Title: [123391] trunk/Source/WebKit/blackberry
Revision
123391
Author
[email protected]
Date
2012-07-23 15:34:11 -0700 (Mon, 23 Jul 2012)

Log Message

[BlackBerry] Move about: URL handling out of WebCore
https://bugs.webkit.org/show_bug.cgi?id=91541

Patch by Yong Li <[email protected]> on 2012-07-23
Reviewed by Rob Buis.

PR# 181304.
Move about: URL handling to the right place (FrameLoaderClientBlackBerry::createDocumentLoader), so
reload and history navigation can work.
Other changes: Remove about:version which makes little sense. Make about:memory partially visible.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::load): Remove the call to loadAbout()
* Api/WebPage_p.h: Remove loadAbout()
(WebPagePrivate):
* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::createDocumentLoader): Construct about: data here.
* WebKitSupport/AboutData.cpp:
(BlackBerry::WebKit::numberToHTMLTr): Make it static
(BlackBerry::WebKit::configPage): Make it static
(BlackBerry::WebKit::memoryPage): Make it static
(BlackBerry::WebKit::cachePage):
(BlackBerry::WebKit::buildPage):
(BlackBerry::WebKit::creditsPage):
(BlackBerry::WebKit::cookiePage):
(BlackBerry::WebKit::aboutData): The only export function that returns HTML source for a given about: URL.
(WebKit):
* WebKitSupport/AboutData.h:
(WebKit):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (123390 => 123391)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-07-23 22:09:51 UTC (rev 123390)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-07-23 22:34:11 UTC (rev 123391)
@@ -19,8 +19,6 @@
 #include "config.h"
 #include "WebPage.h"
 
-#include "AboutData.h"
-#include "AboutTemplate.html.cpp"
 #include "ApplicationCacheStorage.h"
 #include "AutofillManager.h"
 #include "BackForwardController.h"
@@ -157,8 +155,6 @@
 #include <BlackBerryPlatformMouseEvent.h>
 #include <BlackBerryPlatformScreen.h>
 #include <BlackBerryPlatformSettings.h>
-#include <BlackBerryPlatformWebKitCredits.h>
-#include <BuildInformation.h>
 #include <_javascript_Core/APICast.h>
 #include <_javascript_Core/JSContextRef.h>
 #include <_javascript_Core/JSStringRef.h>
@@ -619,84 +615,6 @@
     }
 };
 
-bool WebPagePrivate::loadAbout(const char* aboutURL)
-{
-    if (strncasecmp(aboutURL, "about:", 6))
-        return false;
-
-    // First 6 chars are "about:".
-    String aboutWhat(aboutURL + 6);
-
-    String result;
-
-    if (equalIgnoringCase(aboutWhat, "credits")) {
-        result.append(writeHeader("Credits"));
-        result.append(String("<style> .about {padding:14px;} </style>"));
-        result.append(String(BlackBerry::Platform::WEBKITCREDITS));
-        result.append(String("</body></html>"));
-    } else if (aboutWhat.startsWith("cache?query=", false)) {
-        BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get();
-        ASSERT(client);
-        std::string key(aboutWhat.substring(12, aboutWhat.length() - 12).utf8().data()); // 12 is length of "cache?query=".
-        result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>"));
-        result.append(String(key.data()));
-        result.append(String("<hr>"));
-        result.append(String(client->generateHtmlFragmentForCacheHeaders(key).data()));
-        result.append(String("</body></html>"));
-    } else if (equalIgnoringCase(aboutWhat, "cache")) {
-        BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get();
-        ASSERT(client);
-        result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>"));
-        result.append(String(client->generateHtmlFragmentForCacheKeys().data()));
-        result.append(String("</body></html>"));
-#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
-    } else if (equalIgnoringCase(aboutWhat, "cache/disable")) {
-        BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get();
-        ASSERT(client);
-        client->setDiskCacheEnabled(false);
-        result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>Http disk cache is disabled.</body></html>"));
-    } else if (equalIgnoringCase(aboutWhat, "cache/enable")) {
-        BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get();
-        ASSERT(client);
-        client->setDiskCacheEnabled(true);
-        result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>Http disk cache is enabled.</body></html>"));
-    } else if (equalIgnoringCase(aboutWhat, "cookie")) {
-        result.append(String("<html><head><title>BlackBerry Browser cookie information</title></head><body>"));
-        result.append(cookieManager().generateHtmlFragmentForCookies());
-        result.append(String("</body></html>"));
-    } else if (equalIgnoringCase(aboutWhat, "version")) {
-        result.append(writeHeader("Version"));
-        result.append(String("<div class='box'><div class='box-title'>Build Time</div><br>"));
-        result.append(String(BlackBerry::Platform::BUILDTIME));
-        result.append(String("</div><br><div style='font-size:10px;text-align:center;'>Also see the <A href=''>build information</A>.</body></html>"));
-    } else if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "config")) {
-        result = configPage();
-    } else if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "build")) {
-        result.append(writeHeader("Build"));
-        result.append(String("<div class='box'><div class='box-title'>Basic</div><table>"));
-        result.append(String("<tr><td>Built On:  </td><td>"));
-        result.append(String(BlackBerry::Platform::BUILDCOMPUTER));
-        result.append(String("</td></tr>"));
-        result.append(String("<tr><td>Build User:  </td><td>"));
-        result.append(String(BlackBerry::Platform::BUILDUSER));
-        result.append(String("</td></tr>"));
-        result.append(String("<tr><td>Build Time:  </td><td>"));
-        result.append(String(BlackBerry::Platform::BUILDTIME));
-        result.append(String("</table></div><br>"));
-        result.append(String(BlackBerry::Platform::BUILDINFO_WEBKIT));
-        result.append(String(BlackBerry::Platform::BUILDINFO_PLATFORM));
-        result.append(String(BlackBerry::Platform::BUILDINFO_LIBWEBVIEW));
-        result.append(String("</body></html>"));
-    } else if (equalIgnoringCase(aboutWhat, "memory")) {
-        result = memoryPage();
-#endif
-    } else
-        return false;
-
-    loadString(result.latin1().data(), aboutURL, "text/html");
-    return true;
-}
-
 void WebPagePrivate::load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally, bool forceDownload, const char* overrideContentType, const char* suggestedSaveName)
 {
     stopCurrentLoad();
@@ -747,8 +665,6 @@
 
 void WebPage::load(const char* url, const char* networkToken, bool isInitial)
 {
-    if (d->loadAbout(url))
-        return;
     d->load(url, networkToken, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, isInitial, false);
 }
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (123390 => 123391)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-07-23 22:09:51 UTC (rev 123390)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-07-23 22:34:11 UTC (rev 123391)
@@ -97,7 +97,6 @@
     bool handleMouseEvent(WebCore::PlatformMouseEvent&);
     bool handleWheelEvent(WebCore::PlatformWheelEvent&);
 
-    bool loadAbout(const char* aboutURL);
     void load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally = false, bool forceDownload = false, const char* overrideContentType = "", const char* suggestedSaveName = "");
     void loadString(const char* string, const char* baseURL, const char* mimeType, const char* failingURL = 0);
     bool executeJavaScript(const char* script, _javascript_DataType& returnType, WebString& returnValue);

Modified: trunk/Source/WebKit/blackberry/ChangeLog (123390 => 123391)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-07-23 22:09:51 UTC (rev 123390)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-07-23 22:34:11 UTC (rev 123391)
@@ -1,3 +1,34 @@
+2012-07-23  Yong Li  <[email protected]>
+
+        [BlackBerry] Move about: URL handling out of WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=91541
+
+        Reviewed by Rob Buis.
+
+        PR# 181304.
+        Move about: URL handling to the right place (FrameLoaderClientBlackBerry::createDocumentLoader), so
+        reload and history navigation can work.
+        Other changes: Remove about:version which makes little sense. Make about:memory partially visible.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPage::load): Remove the call to loadAbout()
+        * Api/WebPage_p.h: Remove loadAbout()
+        (WebPagePrivate):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::createDocumentLoader): Construct about: data here.
+        * WebKitSupport/AboutData.cpp:
+        (BlackBerry::WebKit::numberToHTMLTr): Make it static
+        (BlackBerry::WebKit::configPage): Make it static
+        (BlackBerry::WebKit::memoryPage): Make it static
+        (BlackBerry::WebKit::cachePage):
+        (BlackBerry::WebKit::buildPage):
+        (BlackBerry::WebKit::creditsPage):
+        (BlackBerry::WebKit::cookiePage):
+        (BlackBerry::WebKit::aboutData): The only export function that returns HTML source for a given about: URL.
+        (WebKit):
+        * WebKitSupport/AboutData.h:
+        (WebKit):
+
 2012-07-23  Pierre Rossi  <[email protected]>
 
         Unify numTouchEventHandlersChanged and needTouchEvents in the chrome client

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (123390 => 123391)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-07-23 22:09:51 UTC (rev 123390)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-07-23 22:34:11 UTC (rev 123391)
@@ -19,6 +19,7 @@
 #include "config.h"
 #include "FrameLoaderClientBlackBerry.h"
 
+#include "AboutData.h"
 #include "AutofillManager.h"
 #include "BackForwardController.h"
 #include "BackForwardListImpl.h"
@@ -386,9 +387,21 @@
             newRequest.setToken(originalRequest.token());
     }
 
+    SubstituteData substituteDataLocal = substituteData;
+    if (isMainFrame() && request.url().protocolIs("about")) {
+        // The first 6 letters is "about:"
+        String aboutWhat = request.url().string().substring(6);
+        String source = aboutData(aboutWhat);
+        if (!source.isEmpty()) {
+            // Always ignore existing substitute data if any.
+            WTF::RefPtr<SharedBuffer> buffer = SharedBuffer::create(source.is8Bit() ? reinterpret_cast<const char*>(source.characters8()) : source.latin1().data(), source.length());
+            substituteDataLocal = SubstituteData(buffer, "text/html", "latin1", KURL());
+        }
+    }
+
     // FIXME: This should probably be shared.
-    RefPtr<DocumentLoader> loader = DocumentLoader::create(newRequest, substituteData);
-    if (substituteData.isValid())
+    RefPtr<DocumentLoader> loader = DocumentLoader::create(newRequest, substituteDataLocal);
+    if (substituteDataLocal.isValid())
         loader->setDeferMainResourceDataLoad(false);
     return loader.release();
 }

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp (123390 => 123391)


--- trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp	2012-07-23 22:09:51 UTC (rev 123390)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp	2012-07-23 22:34:11 UTC (rev 123391)
@@ -21,13 +21,19 @@
 
 #include "AboutTemplate.html.cpp"
 #include "CString.h"
+#include "CookieManager.h"
 #include "JSDOMWindow.h"
 #include "MemoryCache.h"
 #include "MemoryStatistics.h"
 #include "SurfacePool.h"
 #include "WebKitVersion.h"
 
+#include <BlackBerryPlatformClient.h>
+#include <BlackBerryPlatformLog.h>
+#include <BlackBerryPlatformMemory.h>
 #include <BlackBerryPlatformSettings.h>
+#include <BlackBerryPlatformWebKitCredits.h>
+#include <BuildInformation.h>
 #include <heap/Heap.h>
 #include <process.h>
 #include <runtime/JSGlobalData.h>
@@ -50,7 +56,7 @@
     return ret;
 }
 
-template<class T> String numberToHTMLTr(const String& description, T number)
+template<class T> static String numberToHTMLTr(const String& description, T number)
 {
     return String("<tr><td>") + description + "</td><td>" + String::number(number) + "</td></tr>";
 }
@@ -60,7 +66,7 @@
     return String("<tr><td>") + description + "</td><td>" + (truth?"true":"false") + "</td></tr>";
 }
 
-String configPage()
+static String configPage()
 {
     String page;
 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
@@ -202,7 +208,7 @@
         tableHTML += numberToHTMLTr(iter->first, iter->second);
 }
 
-String memoryPage()
+static String memoryPage()
 {
     String page;
 
@@ -255,6 +261,8 @@
     if (!stat(String::format("/proc/%u/as", getpid()).latin1().data(), &processInfo))
         page += numberToHTMLTr("Total mapped memory", processInfo.st_size);
 
+    page += numberToHTMLTr("System free memory", BlackBerry::Platform::systemFreeMemory());
+
     page += "</table></div><br>";
 
     page += "<div class='box'><div class='box-title'>JS engine memory usage</div><table class='fixed-table'><col width=75%><col width=25%>";
@@ -299,5 +307,112 @@
     return page;
 }
 
+static String cachePage(String cacheCommand)
+{
+    String result;
+
+    result.append(String("<html><head><title>BlackBerry Browser Disk Cache</title></head><body>"));
+
+    BlackBerry::Platform::Client* client = BlackBerry::Platform::Client::get();
+    ASSERT(client);
+
+    if (cacheCommand.isEmpty())
+        result.append(String(client->generateHtmlFragmentForCacheKeys().data()));
+    else if (cacheCommand.startsWith("?query=", false)) {
+        std::string key(cacheCommand.substring(7).utf8().data()); // 7 is length of "query=".
+        result.append(String(key.data()));
+        result.append(String("<hr>"));
+        result.append(String(client->generateHtmlFragmentForCacheHeaders(key).data()));
+    }
+#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
+    else if (equalIgnoringCase(cacheCommand, "/disable")) {
+        client->setDiskCacheEnabled(false);
+        result.append("Http disk cache is disabled.");
+    } else if (equalIgnoringCase(cacheCommand, "/enable")) {
+        client->setDiskCacheEnabled(true);
+        result.append("Http disk cache is enabled.");
+    }
+#endif
+    else {
+        // Unknown cache command.
+        return String();
+    }
+
+    result.append(String("</body></html>"));
+
+    return result;
+}
+
+static String buildPage()
+{
+    String result;
+
+    result.append(writeHeader("Build"));
+    result.append(String("<div class='box'><div class='box-title'>Basic</div><table>"));
+    result.append(String("<tr><td>Built On:  </td><td>"));
+    result.append(String(BlackBerry::Platform::BUILDCOMPUTER));
+    result.append(String("</td></tr>"));
+    result.append(String("<tr><td>Build User:  </td><td>"));
+    result.append(String(BlackBerry::Platform::BUILDUSER));
+    result.append(String("</td></tr>"));
+    result.append(String("<tr><td>Build Time:  </td><td>"));
+    result.append(String(BlackBerry::Platform::BUILDTIME));
+    result.append(String("</table></div><br>"));
+    result.append(String(BlackBerry::Platform::BUILDINFO_WEBKIT));
+    result.append(String(BlackBerry::Platform::BUILDINFO_PLATFORM));
+    result.append(String(BlackBerry::Platform::BUILDINFO_LIBWEBVIEW));
+    result.append(String("</body></html>"));
+
+    return result;
+}
+
+static String creditsPage()
+{
+    String result;
+
+    result.append(writeHeader("Credits"));
+    result.append(String("<style> .about {padding:14px;} </style>"));
+    result.append(String(BlackBerry::Platform::WEBKITCREDITS));
+    result.append(String("</body></html>"));
+
+    return result;
+}
+
+static String cookiePage()
+{
+    String result;
+
+    result.append(String("<html><head><title>BlackBerry Browser cookie information</title></head><body>"));
+    result.append(cookieManager().generateHtmlFragmentForCookies());
+    result.append(String("</body></html>"));
+
+    return result;
+}
+
+String aboutData(String aboutWhat)
+{
+    if (equalIgnoringCase(aboutWhat, "credits"))
+        return creditsPage();
+
+    if (aboutWhat.startsWith("cache"))
+        return cachePage(aboutWhat.substring(5));
+
+    if (equalIgnoringCase(aboutWhat, "memory"))
+        return memoryPage();
+
+#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
+    if (equalIgnoringCase(aboutWhat, "cookie"))
+        return cookiePage();
+
+    if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "build"))
+        return buildPage();
+
+    if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "config"))
+        return configPage();
+#endif
+
+    return String();
+}
+
 } // namespace WebKit
 } // namespace BlackBerry

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.h (123390 => 123391)


--- trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.h	2012-07-23 22:09:51 UTC (rev 123390)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.h	2012-07-23 22:34:11 UTC (rev 123391)
@@ -24,8 +24,7 @@
 namespace BlackBerry {
 namespace WebKit {
 
-String configPage();
-String memoryPage();
+String aboutData(String aboutWhat);
 
 } // namespace WebKit
 } // namespace BlackBerry
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to