Update how the Web Inspector resources are loaded.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2012 14:36:17 +0000 (14:36 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2012 14:36:17 +0000 (14:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80814
rdar://problem/10359959

Reviewed by John Sullivan.

* Shared/WebPreferencesStore.h:
(WebKit): Added InspectorUsesWebKitUserInterface.
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode): Removed webInspectorLocalizedStringsPath.
(WebKit::WebProcessCreationParameters::decode): Ditto.
* Shared/WebProcessCreationParameters.h: Ditto.
(WebProcessCreationParameters): Ditto.
* UIProcess/API/C/WKContext.cpp:
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetInspectorUsesWebKitUserInterface): Added.
(WKPreferencesGetInspectorUsesWebKitUserInterface): Added.
* UIProcess/API/C/WKPreferencesPrivate.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::ensureWebProcess): Removed webInspectorLocalizedStringsPath.
* UIProcess/WebContext.h:
(WebContext): Ditto.
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::inspectorReallyUsesWebKitUserInterface): Added.
(WebKit::WebInspectorProxy::createInspectorWindow): Use inspectorReallyUsesWebKitUserInterface
to determine if texture should be used.
(WebKit::WebInspectorProxy::inspectorPageURL): Choose the right path.
(WebKit::WebInspectorProxy::inspectorBaseURL): Ditto.
* WebProcess/WebPage/WebInspector.h:
* WebProcess/WebPage/mac/WebInspectorMac.mm:
(WebKit::inspectorReallyUsesWebKitUserInterface):
(WebKit::WebInspector::setInspectorUsesWebKitUserInterface): Added.
(WebKit::WebInspector::localizedStringsURL):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformPreferencesDidChange): Call WebInspector::setInspectorUsesWebKitUserInterface.
* WebProcess/mac/WebProcessMac.mm:
(WebKit::WebProcess::platformInitializeWebProcess): Removed call to WebInspector::setLocalizedStringsPath.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110425 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit2/WebProcess/WebPage/WebInspector.h
Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKit2/WebProcess/mac/WebProcessMac.mm

index 3a3c778..de29df9 100644 (file)
@@ -1,3 +1,45 @@
+2012-03-11  Timothy Hatcher  <timothy@apple.com>
+
+        Update how the Web Inspector resources are loaded.
+
+        https://bugs.webkit.org/show_bug.cgi?id=80814
+        rdar://problem/10359959
+
+        Reviewed by John Sullivan.
+
+        * Shared/WebPreferencesStore.h:
+        (WebKit): Added InspectorUsesWebKitUserInterface.
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode): Removed webInspectorLocalizedStringsPath.
+        (WebKit::WebProcessCreationParameters::decode): Ditto.
+        * Shared/WebProcessCreationParameters.h: Ditto.
+        (WebProcessCreationParameters): Ditto.
+        * UIProcess/API/C/WKContext.cpp:
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetInspectorUsesWebKitUserInterface): Added.
+        (WKPreferencesGetInspectorUsesWebKitUserInterface): Added.
+        * UIProcess/API/C/WKPreferencesPrivate.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::ensureWebProcess): Removed webInspectorLocalizedStringsPath.
+        * UIProcess/WebContext.h:
+        (WebContext): Ditto.
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::inspectorReallyUsesWebKitUserInterface): Added.
+        (WebKit::WebInspectorProxy::createInspectorWindow): Use inspectorReallyUsesWebKitUserInterface
+        to determine if texture should be used.
+        (WebKit::WebInspectorProxy::inspectorPageURL): Choose the right path.
+        (WebKit::WebInspectorProxy::inspectorBaseURL): Ditto.
+        * WebProcess/WebPage/WebInspector.h:
+        * WebProcess/WebPage/mac/WebInspectorMac.mm:
+        (WebKit::inspectorReallyUsesWebKitUserInterface):
+        (WebKit::WebInspector::setInspectorUsesWebKitUserInterface): Added.
+        (WebKit::WebInspector::localizedStringsURL):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformPreferencesDidChange): Call WebInspector::setInspectorUsesWebKitUserInterface.
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess): Removed call to WebInspector::setLocalizedStringsPath.
+
 2012-03-11  Andy Estes  <aestes@apple.com>
 
         Remove unnecessary call to NSSizeToCGSize().
index cb70309..0ffcd39 100644 (file)
@@ -95,6 +95,7 @@ namespace WebKit {
     macro(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, false) \
     macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, true) \
     macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
+    macro(InspectorUsesWebKitUserInterface, inspectorUsesWebKitUserInterface, Bool, bool, false) \
     macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
     macro(MockScrollbarsEnabled, mockScrollbarsEnabled, Bool, bool, false) \
     macro(WebAudioEnabled, webAudioEnabled, Bool, bool, false) \
index 8e1d164..c8ecafe 100644 (file)
@@ -54,7 +54,6 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(applicationCacheDirectory);
     encoder->encode(databaseDirectory);
     encoder->encode(localStorageDirectory);
-    encoder->encode(webInspectorLocalizedStringsPath);
     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
     encoder->encode(urlSchemesRegisteredAsSecure);
     encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
@@ -117,8 +116,6 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         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))
index 3a3764d..9b51f64 100644 (file)
@@ -57,7 +57,6 @@ struct WebProcessCreationParameters {
     String applicationCacheDirectory;    
     String databaseDirectory;
     String localStorageDirectory;
-    String webInspectorLocalizedStringsPath;
 
     Vector<String> urlSchemesRegistererdAsEmptyDocument;
     Vector<String> urlSchemesRegisteredAsSecure;
index cef8977..8890e80 100644 (file)
@@ -235,21 +235,6 @@ void WKContextSetLocalStorageDirectory(WKContextRef contextRef, WKStringRef loca
     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();
index ad69da1..01dac4b 100644 (file)
@@ -62,9 +62,6 @@ WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef ic
 // 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.
index 39903bc..55c3382 100644 (file)
@@ -678,6 +678,16 @@ bool WKPreferencesGetApplicationChromeModeEnabled(WKPreferencesRef preferencesRe
     return toImpl(preferencesRef)->applicationChromeMode();
 }
 
+void WKPreferencesSetInspectorUsesWebKitUserInterface(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setInspectorUsesWebKitUserInterface(enabled);
+}
+
+bool WKPreferencesGetInspectorUsesWebKitUserInterface(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->inspectorUsesWebKitUserInterface();
+}
+
 void WKPreferencesSetSuppressesIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled)
 {
     toImpl(preferencesRef)->setSuppressesIncrementalRendering(enabled);
index 36950e8..7fcd662 100644 (file)
@@ -167,6 +167,10 @@ WK_EXPORT bool WKPreferencesGetMockScrollbarsEnabled(WKPreferencesRef preference
 WK_EXPORT void WKPreferencesSetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetInspectorUsesWebKitUserInterface(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetInspectorUsesWebKitUserInterface(WKPreferencesRef preferencesRef);
+
 WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef);
 
 #ifdef __cplusplus
index 23ca56b..77661d8 100644 (file)
@@ -259,10 +259,8 @@ void WebContext::ensureWebProcess()
     parameters.applicationCacheDirectory = applicationCacheDirectory();
     parameters.databaseDirectory = databaseDirectory();
     parameters.localStorageDirectory = localStorageDirectory();
-    parameters.webInspectorLocalizedStringsPath = m_overrideWebInspectorLocalizedStringsPath;
 
 #if PLATFORM(MAC)
-    parameters.webInspectorBaseDirectory = m_overrideWebInspectorBaseDirectory;
     parameters.presenterApplicationPid = getpid();
 #endif
 
index c378725..9bd47eb 100644 (file)
@@ -174,14 +174,6 @@ public:
     String iconDatabasePath() const;
     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();
 
@@ -315,9 +307,6 @@ private:
     String m_overrideDatabaseDirectory;
     String m_overrideIconDatabasePath;
     String m_overrideLocalStorageDirectory;
-    String m_overrideWebInspectorBaseDirectory;
-    String m_overrideWebInspectorPagePath;
-    String m_overrideWebInspectorLocalizedStringsPath;
 
     bool m_processTerminationEnabled;
     
index 0db662c..259784c 100644 (file)
 #import <WebKitSystemInterface.h>
 #import <WebCore/InspectorFrontendClientLocal.h>
 #import <WebCore/LocalizedStrings.h>
-#import <WebCore/NotImplemented.h>
+#import <WebCore/SoftLinking.h>
 #import <wtf/text/WTFString.h>
 
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(WebInspector)
+
 using namespace WebCore;
 using namespace WebKit;
 
@@ -102,11 +104,24 @@ static const CGFloat windowContentBorderThickness = 55;
 
 namespace WebKit {
 
+static bool inspectorReallyUsesWebKitUserInterface(WebPreferences* preferences)
+{
+    // This matches a similar check in WebInspectorMac.mm. Keep them in sync.
+
+    // Call the soft link framework function to dlopen it, then [NSBundle bundleWithIdentifier:] will work.
+    WebInspectorLibrary();
+
+    if (![[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] pathForResource:@"Main" ofType:@"html"])
+        return true;
+
+    return preferences->inspectorUsesWebKitUserInterface();
+}
+
 void WebInspectorProxy::createInspectorWindow()
 {
     ASSERT(!m_inspectorWindow);
 
-    bool useTexturedWindow = page()->process()->context()->overrideWebInspectorPagePath().isEmpty();
+    bool useTexturedWindow = inspectorReallyUsesWebKitUserInterface(page()->pageGroup()->preferences());
 
     NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask);
     if (useTexturedWindow)
@@ -302,9 +317,11 @@ void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned height)
 
 String WebInspectorProxy::inspectorPageURL() const
 {
-    NSString *path = page()->process()->context()->overrideWebInspectorPagePath();
-    if (![path length])
+    NSString *path;
+    if (inspectorReallyUsesWebKitUserInterface(page()->pageGroup()->preferences()))
         path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
+    else
+        path = [[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] pathForResource:@"Main" ofType:@"html"];
 
     ASSERT([path length]);
 
@@ -313,11 +330,11 @@ String WebInspectorProxy::inspectorPageURL() const
 
 String WebInspectorProxy::inspectorBaseURL() const
 {
-    NSString *path = page()->process()->context()->overrideWebInspectorBaseDirectory();
-    if (![path length]) {
-        // WebCore's Web Inspector uses localized strings, which are not contained within inspector directory.
+    NSString *path;
+    if (inspectorReallyUsesWebKitUserInterface(page()->pageGroup()->preferences()))
         path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] resourcePath];
-    }
+    else
+        path = [[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] resourcePath];
 
     ASSERT([path length]);
 
index 1c354f7..0906e64 100644 (file)
@@ -30,8 +30,8 @@
 
 #include "APIObject.h"
 #include "Connection.h"
-#include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
@@ -62,7 +62,7 @@ public:
     void stopPageProfiling();
 
 #if PLATFORM(MAC)
-    static void setLocalizedStringsPath(const String&);
+    void setInspectorUsesWebKitUserInterface(bool);
 #endif
 
 private:
@@ -108,6 +108,9 @@ private:
     WebPage* m_page;
     WebPage* m_inspectorPage;
     WebInspectorFrontendClient* m_frontendClient;
+#if PLATFORM(MAC)
+    String m_localizedStringsURL;
+#endif
 };
 
 } // namespace WebKit
index d64bf9c..5a6ac4e 100644 (file)
 #import "config.h"
 #import "WebInspector.h"
 
-#import <wtf/text/WTFString.h>
+#import <WebCore/SoftLinking.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(WebInspector)
 
 namespace WebKit {
 
-static String& globalInspectorLocalizedStringsURL()
+static bool inspectorReallyUsesWebKitUserInterface(bool preference)
 {
-    DEFINE_STATIC_LOCAL(String, inspectorLocalizedStringsURL, ());
-    return inspectorLocalizedStringsURL;
+    // This matches a similar check in WebInspectorProxyMac.mm. Keep them in sync.
+
+    // Call the soft link framework function to dlopen it, then [NSBundle bundleWithIdentifier:] will work.
+    WebInspectorLibrary();
+
+    if (![[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] pathForResource:@"Main" ofType:@"html"])
+        return true;
+
+    return preference;
 }
 
-void WebInspector::setLocalizedStringsPath(const String& path)
+void WebInspector::setInspectorUsesWebKitUserInterface(bool flag)
 {
-    if (!path.isEmpty())
-        globalInspectorLocalizedStringsURL() = [[NSURL fileURLWithPath:path] absoluteString];
+    NSString *bundleIdentifier = inspectorReallyUsesWebKitUserInterface(flag) ? @"com.apple.WebCore" : @"com.apple.WebInspector";
+    NSString *path = [[NSBundle bundleWithIdentifier:bundleIdentifier] pathForResource:@"localizedStrings" ofType:@"js"];
+    if ([path length])
+        m_localizedStringsURL = [[NSURL fileURLWithPath:path] absoluteString];
     else
-        globalInspectorLocalizedStringsURL() = String();
+        m_localizedStringsURL = String();
 }
 
 String WebInspector::localizedStringsURL() const
 {
-    return globalInspectorLocalizedStringsURL();
+    return m_localizedStringsURL;
 }
 
 } // namespace WebKit
index d876a8d..ff1b8ac 100644 (file)
@@ -35,7 +35,9 @@
 #import "WebEvent.h"
 #import "WebEventConversion.h"
 #import "WebFrame.h"
+#import "WebInspector.h"
 #import "WebPageProxyMessages.h"
+#import "WebPreferencesStore.h"
 #import "WebProcess.h"
 #import <WebCore/AXObjectCache.h>
 #import <WebCore/FocusController.h>
@@ -83,8 +85,10 @@ void WebPage::platformInitialize()
     m_mockAccessibilityElement = mockAccessibilityElement;
 }
 
-void WebPage::platformPreferencesDidChange(const WebPreferencesStore&)
+void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
 {
+    if (WebInspector* inspector = this->inspector())
+        inspector->setInspectorUsesWebKitUserInterface(store.getBoolValueForKey(WebPreferencesKey::inspectorUsesWebKitUserInterfaceKey()));
 }
 
 typedef HashMap<String, String> SelectorNameMap;
index 7d0d69c..fa0380f 100644 (file)
@@ -249,10 +249,8 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
         [NSURLCache setSharedURLCache:parentProcessURLCache.get()];
     }
 
-    WebInspector::setLocalizedStringsPath(parameters.webInspectorLocalizedStringsPath);
-
     m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
-    
+
 #if ENABLE(NOTIFICATIONS)
     m_notificationManager.initialize(parameters.notificationPermissions);
 #endif