Title: [98759] trunk/Source/WebKit2
Revision
98759
Author
timo...@apple.com
Date
2011-10-28 13:51:52 -0700 (Fri, 28 Oct 2011)

Log Message

Support using a different front-end for the Web Inspector in WebKit2.

rdar://problem/10318665
https://webkit.org/b/71089

Reviewed by Sam Weinig.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode): Added webInspectorBasePath and webInspectorLocalizedStringsPath.
(WebKit::WebProcessCreationParameters::decode): Ditto.
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextSetOverrideWebInspectorBaseDirectory): Added. Calls through to WebContext.
(WKContextSetOverrideWebInspectorPagePath): Ditto.
(WKContextSetOverrideWebInspectorLocalizedStringsPath): Ditto.
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::ensureWebProcess): Set webInspectorBasePath and webInspectorLocalizedStringsPath.
* UIProcess/WebContext.h:
(WebKit::WebContext::overrideWebInspectorBaseDirectory): Added.
(WebKit::WebContext::setOverrideWebInspectorBaseDirectory): Added.
(WebKit::WebContext::overrideWebInspectorPagePath): Added.
(WebKit::WebContext::setOverrideWebInspectorPagePath): Added.
(WebKit::WebContext::setOverrideWebInspectorLocalizedStringsPath): Added.
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::inspectorPageURL): Use WebContext::overrideWebInspectorPagePath if set.
(WebKit::WebInspectorProxy::inspectorBaseURL): Use WebContext::overrideWebInspectorBaseDirectory if set.
* WebProcess/WebPage/WebInspector.h:
* WebProcess/WebPage/mac/WebInspectorMac.mm:
(WebKit::globalInspectorLocalizedStringsURL): Added. Static storage for the setting.
(WebKit::WebInspector::setLocalizedStringsPath): Added. Set globalInspectorLocalizedStringsURL.
(WebKit::WebInspector::localizedStringsURL): Return globalInspectorLocalizedStringsURL.
* WebProcess/com.apple.WebProcess.sb: Added read-only subpath for WEBKIT_WEB_INSPECTOR_DIR.
* WebProcess/mac/WebProcessMac.mm:
(WebKit::appendReadonlySandboxDirectory): Check path for empty to prevent an exception when
calling through to fileSystemRepresentation.
(WebKit::initializeSandbox): Added WEBKIT_WEB_INSPECTOR_DIR parameter.
(WebKit::WebProcess::platformInitializeWebProcess): Call WebInspector::setLocalizedStringsPath.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (98758 => 98759)


--- trunk/Source/WebKit2/ChangeLog	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-28 20:51:52 UTC (rev 98759)
@@ -1,3 +1,44 @@
+2011-10-28  Timothy Hatcher  <timo...@apple.com>
+
+        Support using a different front-end for the Web Inspector in WebKit2.
+
+        rdar://problem/10318665
+        https://webkit.org/b/71089
+
+        Reviewed by Sam Weinig.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode): Added webInspectorBasePath and webInspectorLocalizedStringsPath.
+        (WebKit::WebProcessCreationParameters::decode): Ditto.
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetOverrideWebInspectorBaseDirectory): Added. Calls through to WebContext.
+        (WKContextSetOverrideWebInspectorPagePath): Ditto.
+        (WKContextSetOverrideWebInspectorLocalizedStringsPath): Ditto.
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::ensureWebProcess): Set webInspectorBasePath and webInspectorLocalizedStringsPath.
+        * UIProcess/WebContext.h:
+        (WebKit::WebContext::overrideWebInspectorBaseDirectory): Added.
+        (WebKit::WebContext::setOverrideWebInspectorBaseDirectory): Added.
+        (WebKit::WebContext::overrideWebInspectorPagePath): Added.
+        (WebKit::WebContext::setOverrideWebInspectorPagePath): Added.
+        (WebKit::WebContext::setOverrideWebInspectorLocalizedStringsPath): Added.
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::inspectorPageURL): Use WebContext::overrideWebInspectorPagePath if set.
+        (WebKit::WebInspectorProxy::inspectorBaseURL): Use WebContext::overrideWebInspectorBaseDirectory if set.
+        * WebProcess/WebPage/WebInspector.h:
+        * WebProcess/WebPage/mac/WebInspectorMac.mm:
+        (WebKit::globalInspectorLocalizedStringsURL): Added. Static storage for the setting.
+        (WebKit::WebInspector::setLocalizedStringsPath): Added. Set globalInspectorLocalizedStringsURL.
+        (WebKit::WebInspector::localizedStringsURL): Return globalInspectorLocalizedStringsURL.
+        * WebProcess/com.apple.WebProcess.sb: Added read-only subpath for WEBKIT_WEB_INSPECTOR_DIR.
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::appendReadonlySandboxDirectory): Check path for empty to prevent an exception when
+        calling through to fileSystemRepresentation.
+        (WebKit::initializeSandbox): Added WEBKIT_WEB_INSPECTOR_DIR parameter.
+        (WebKit::WebProcess::platformInitializeWebProcess): Call WebInspector::setLocalizedStringsPath.
+
 2011-10-28  Alexey Proskuryakov  <a...@apple.com>
 
         Clean up BuiltInPDFView a little

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (98758 => 98759)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2011-10-28 20:51:52 UTC (rev 98759)
@@ -54,6 +54,7 @@
     encoder->encode(applicationCacheDirectory);
     encoder->encode(databaseDirectory);
     encoder->encode(localStorageDirectory);
+    encoder->encode(webInspectorLocalizedStringsPath);
     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
     encoder->encode(urlSchemesRegisteredAsSecure);
     encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
@@ -80,6 +81,7 @@
     encoder->encode(nsURLCacheDiskCapacity);
     encoder->encode(acceleratedCompositingPort);
     encoder->encode(uiProcessBundleResourcePath);
+    encoder->encode(webInspectorBaseDirectory);
 #elif PLATFORM(WIN)
     encoder->encode(shouldPaintNativeControls);
     encoder->encode(cfURLCachePath);
@@ -110,6 +112,8 @@
         return false;
     if (!decoder->decode(parameters.localStorageDirectory))
         return false;
+    if (!decoder->decode(parameters.webInspectorLocalizedStringsPath))
+        return false;
     if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument))
         return false;
     if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
@@ -159,6 +163,8 @@
         return false;
     if (!decoder->decode(parameters.uiProcessBundleResourcePath))
         return false;
+    if (!decoder->decode(parameters.webInspectorBaseDirectory))
+        return false;
 #elif PLATFORM(WIN)
     if (!decoder->decode(parameters.shouldPaintNativeControls))
         return false;

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (98758 => 98759)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h	2011-10-28 20:51:52 UTC (rev 98759)
@@ -56,6 +56,8 @@
     String applicationCacheDirectory;    
     String databaseDirectory;
     String localStorageDirectory;
+    String webInspectorLocalizedStringsPath;
+
     Vector<String> urlSchemesRegistererdAsEmptyDocument;
     Vector<String> urlSchemesRegisteredAsSecure;
     Vector<String> urlSchemesForWhichDomainRelaxationIsForbidden;
@@ -99,6 +101,8 @@
 
     String uiProcessBundleResourcePath;
 
+    String webInspectorBaseDirectory;
+
 #elif PLATFORM(WIN)
     String cfURLCachePath;
     uint64_t cfURLCacheDiskCapacity;

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (98758 => 98759)


--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp	2011-10-28 20:51:52 UTC (rev 98759)
@@ -225,6 +225,21 @@
     toImpl(contextRef)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string());
 }
 
+void WKContextSetOverrideWebInspectorBaseDirectory(WKContextRef contextRef, WKStringRef webInspectorBaseDirectory)
+{
+    toImpl(contextRef)->setOverrideWebInspectorBaseDirectory(toImpl(webInspectorBaseDirectory)->string());
+}
+
+void WKContextSetOverrideWebInspectorPagePath(WKContextRef contextRef, WKStringRef webInspectorPagePath)
+{
+    toImpl(contextRef)->setOverrideWebInspectorPagePath(toImpl(webInspectorPagePath)->string());
+}
+
+void WKContextSetOverrideWebInspectorLocalizedStringsPath(WKContextRef contextRef, WKStringRef webInspectorLocalizedStringsPath)
+{
+    toImpl(contextRef)->setOverrideWebInspectorLocalizedStringsPath(toImpl(webInspectorLocalizedStringsPath)->string());
+}
+
 void WKContextDisableProcessTermination(WKContextRef contextRef)
 {
     toImpl(contextRef)->disableProcessTermination();

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h (98758 => 98759)


--- trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h	2011-10-28 20:51:52 UTC (rev 98759)
@@ -62,6 +62,9 @@
 // we should really change these settings to be on WebPreferences and changeable at runtime.
 WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory);
 WK_EXPORT void WKContextSetLocalStorageDirectory(WKContextRef context, WKStringRef localStorageDirectory);
+WK_EXPORT void WKContextSetOverrideWebInspectorBaseDirectory(WKContextRef context, WKStringRef webInspectorBaseDirectory);
+WK_EXPORT void WKContextSetOverrideWebInspectorPagePath(WKContextRef context, WKStringRef webInspectorPagePath);
+WK_EXPORT void WKContextSetOverrideWebInspectorLocalizedStringsPath(WKContextRef context, WKStringRef webInspectorLocalizedStringsPath);
 
 // FIXME: This is a workaround for testing purposes only and should be removed once a better
 // solution has been found for testing.

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (98758 => 98759)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2011-10-28 20:51:52 UTC (rev 98759)
@@ -244,7 +244,10 @@
     parameters.applicationCacheDirectory = applicationCacheDirectory();
     parameters.databaseDirectory = databaseDirectory();
     parameters.localStorageDirectory = localStorageDirectory();
+    parameters.webInspectorLocalizedStringsPath = m_overrideWebInspectorLocalizedStringsPath;
+
 #if PLATFORM(MAC)
+    parameters.webInspectorBaseDirectory = m_overrideWebInspectorBaseDirectory;
     parameters.presenterApplicationPid = getpid();
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (98758 => 98759)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2011-10-28 20:51:52 UTC (rev 98759)
@@ -169,6 +169,14 @@
     void setIconDatabasePath(const String&);
     void setLocalStorageDirectory(const String& dir) { m_overrideLocalStorageDirectory = dir; }
 
+    String overrideWebInspectorBaseDirectory() const { return m_overrideWebInspectorBaseDirectory; }
+    void setOverrideWebInspectorBaseDirectory(const String& path) { m_overrideWebInspectorBaseDirectory = path; }
+
+    String overrideWebInspectorPagePath() const { return m_overrideWebInspectorPagePath; }
+    void setOverrideWebInspectorPagePath(const String& path) { m_overrideWebInspectorPagePath = path; }
+
+    void setOverrideWebInspectorLocalizedStringsPath(const String& path) { m_overrideWebInspectorLocalizedStringsPath = path; }
+
     void ensureWebProcess();
     void warmInitialProcess();
 
@@ -279,10 +287,13 @@
 #if PLATFORM(MAC)
     RetainPtr<CFTypeRef> m_enhancedAccessibilityObserver;
 #endif
-    
+
     String m_overrideDatabaseDirectory;
     String m_overrideIconDatabasePath;
     String m_overrideLocalStorageDirectory;
+    String m_overrideWebInspectorBaseDirectory;
+    String m_overrideWebInspectorPagePath;
+    String m_overrideWebInspectorLocalizedStringsPath;
 
     bool m_processTerminationEnabled;
     

Modified: trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm (98758 => 98759)


--- trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2011-10-28 20:51:52 UTC (rev 98759)
@@ -29,6 +29,7 @@
 #if ENABLE(INSPECTOR)
 
 #import "WKAPICast.h"
+#import "WebContext.h"
 #import "WKInspectorMac.h"
 #import "WKViewPrivate.h"
 #import "WebPageProxy.h"
@@ -248,18 +249,25 @@
 
 String WebInspectorProxy::inspectorPageURL() const
 {
-    NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
-    ASSERT(path);
+    NSString *path = page()->process()->context()->overrideWebInspectorPagePath();
+    if (![path length])
+        path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
 
+    ASSERT([path length]);
+
     return [[NSURL fileURLWithPath:path] absoluteString];
 }
 
 String WebInspectorProxy::inspectorBaseURL() const
 {
-    // Web Inspector uses localized strings, so it's not contained within inspector directory.
-    NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] resourcePath];
-    ASSERT(path);
+    NSString *path = page()->process()->context()->overrideWebInspectorBaseDirectory();
+    if (![path length]) {
+        // WebCore's Web Inspector uses localized strings, which are not contained within inspector directory.
+        path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] resourcePath];
+    }
 
+    ASSERT([path length]);
+
     return [[NSURL fileURLWithPath:path] absoluteString];
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h (98758 => 98759)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2011-10-28 20:51:52 UTC (rev 98759)
@@ -60,6 +60,10 @@
     void startPageProfiling();
     void stopPageProfiling();
 
+#if PLATFORM(MAC)
+    static void setLocalizedStringsPath(const String&);
+#endif
+
 private:
     friend class WebInspectorClient;
     friend class WebInspectorFrontendClient;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm (98758 => 98759)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm	2011-10-28 20:51:52 UTC (rev 98759)
@@ -30,12 +30,23 @@
 
 namespace WebKit {
 
+static String& globalInspectorLocalizedStringsURL()
+{
+    DEFINE_STATIC_LOCAL(String, inspectorLocalizedStringsURL, ());
+    return inspectorLocalizedStringsURL;
+}
+
+void WebInspector::setLocalizedStringsPath(const String& path)
+{
+    if (!path.isEmpty())
+        globalInspectorLocalizedStringsURL() = [[NSURL fileURLWithPath:path] absoluteString];
+    else
+        globalInspectorLocalizedStringsURL() = String();
+}
+
 String WebInspector::localizedStringsURL() const
 {
-    NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"localizedStrings" ofType:@"js"];
-    if (path)
-        return [[NSURL fileURLWithPath:path] absoluteString];
-    return String();
+    return globalInspectorLocalizedStringsURL();
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb (98758 => 98759)


--- trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb	2011-10-28 20:51:52 UTC (rev 98759)
@@ -121,6 +121,10 @@
 (if (positive? (string-length (param "WEBKIT_APPLICATION_CACHE_DIR")))
     (allow file* (subpath (param "WEBKIT_APPLICATION_CACHE_DIR"))))
 
+;; The Web Inspector directory.
+(if (positive? (string-length (param "WEBKIT_WEB_INSPECTOR_DIR")))
+    (allow file-read* (subpath (param "WEBKIT_WEB_INSPECTOR_DIR"))))
+
 ;; The NSURLCache directory.
 (if (positive? (string-length (param "NSURL_CACHE_DIR")))
     (allow file* (subpath (param "NSURL_CACHE_DIR"))))

Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm (98758 => 98759)


--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm	2011-10-28 20:46:29 UTC (rev 98758)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm	2011-10-28 20:51:52 UTC (rev 98759)
@@ -28,6 +28,7 @@
 
 #import "SandboxExtension.h"
 #import "WKFullKeyboardAccessWatcher.h"
+#import "WebInspector.h"
 #import "WebPage.h"
 #import "WebProcessCreationParameters.h"
 #import "WebProcessProxyMessages.h"
@@ -159,7 +160,7 @@
 
 static void appendReadonlySandboxDirectory(Vector<const char*>& vector, const char* name, NSString *path)
 {
-    appendSandboxParameterPathInternal(vector, name, [(NSString *)path fileSystemRepresentation]);
+    appendSandboxParameterPathInternal(vector, name, [path length] ? [(NSString *)path fileSystemRepresentation] : "");
 }
 
 static void appendReadwriteSandboxDirectory(Vector<const char*>& vector, const char* name, NSString *path)
@@ -188,6 +189,7 @@
     // These are read-only.
     appendReadonlySandboxDirectory(sandboxParameters, "WEBKIT2_FRAMEWORK_DIR", [[[NSBundle bundleForClass:NSClassFromString(@"WKView")] bundlePath] stringByDeletingLastPathComponent]);
     appendReadonlySandboxDirectory(sandboxParameters, "UI_PROCESS_BUNDLE_RESOURCE_DIR", parameters.uiProcessBundleResourcePath);
+    appendReadonlySandboxDirectory(sandboxParameters, "WEBKIT_WEB_INSPECTOR_DIR", parameters.webInspectorBaseDirectory);
 
     // These are read-write getconf paths.
     appendReadwriteConfDirectory(sandboxParameters, "DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR);
@@ -245,6 +247,8 @@
         [NSURLCache setSharedURLCache:parentProcessURLCache.get()];
     }
 
+    WebInspector::setLocalizedStringsPath(parameters.webInspectorLocalizedStringsPath);
+
     m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
 
     // rdar://9118639 accessibilityFocusedUIElement in NSApplication defaults to use the keyWindow. Since there's
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to