Enable library validation on the Web Content service
[WebKit-https.git] / Source / WebKit / UIProcess / mac / WebProcessProxyMac.mm
index 212623b7aeb175e8bf81314763c697e7b56e14da..d917ad0ea4f3ca41931467bad3b8f7ff7d576a93 100644 (file)
@@ -24,6 +24,7 @@
  */
  
 #import "config.h"
+#import "WebProcessPool.h"
 #import "WebProcessProxy.h"
 
 #if PLATFORM(MAC)
@@ -37,6 +38,24 @@ bool WebProcessProxy::fullKeyboardAccessEnabled()
     return [WKFullKeyboardAccessWatcher fullKeyboardAccessEnabled];
 }
 
+bool WebProcessProxy::shouldAllowNonValidInjectedCode() const
+{
+    static bool isSystemWebKit = [] {
+#if WK_API_ENABLED
+        NSBundle *webkit2Bundle = [NSBundle bundleForClass:NSClassFromString(@"WKWebView")];
+#else
+        NSBundle *webkit2Bundle = [NSBundle bundleForClass:NSClassFromString(@"WKView")];
+#endif
+        return [webkit2Bundle.bundlePath hasPrefix:@"/System/"];
+    }();
+
+    if (!isSystemWebKit)
+        return false;
+
+    const String& path = m_processPool->configuration().injectedBundlePath();
+    return !path.isEmpty() && !path.startsWith("/System/");
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)