Title: [150620] trunk/Source/WebKit2
Revision
150620
Author
[email protected]
Date
2013-05-23 17:43:10 -0700 (Thu, 23 May 2013)

Log Message

Shim Flash plug-in to allow its updater to run
https://bugs.webkit.org/show_bug.cgi?id=116692
<rdar://problem/13938510>

Reviewed by Sam Weinig.

* PluginProcess/PluginProcess.h:
* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::replacedNSConcreteTask_launch):
(WebKit::initializeCocoaOverrides):
Patch -[NSConcreteTask launch] to call PluginProcess::launchProcess.

(WebKit::PluginProcess::launchProcess):
Send a LaunchProcess message to the UI process.

* UIProcess/Plugins/PluginProcessProxy.cpp:
* UIProcess/Plugins/PluginProcessProxy.h:
Remove PluginProcessProxy::didReceiveMessage.

(PluginProcessProxy):
* UIProcess/Plugins/PluginProcessProxy.messages.in:
Add LaunchProcess message and remove LegacyReceiver attribute.

* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::isFlashUpdater):
Helper function to determine whether the process is the flash updater.

(WebKit::shouldLaunchProcess):
Return whether we should launch this process.

(WebKit::PluginProcessProxy::launchProcess):
Determine if we should launch this process and then do so.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (150619 => 150620)


--- trunk/Source/WebKit2/ChangeLog	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-24 00:43:10 UTC (rev 150620)
@@ -1,5 +1,40 @@
 2013-05-23  Anders Carlsson  <[email protected]>
 
+        Shim Flash plug-in to allow its updater to run
+        https://bugs.webkit.org/show_bug.cgi?id=116692
+        <rdar://problem/13938510>
+
+        Reviewed by Sam Weinig.
+
+        * PluginProcess/PluginProcess.h:
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::replacedNSConcreteTask_launch):
+        (WebKit::initializeCocoaOverrides):
+        Patch -[NSConcreteTask launch] to call PluginProcess::launchProcess.
+
+        (WebKit::PluginProcess::launchProcess):
+        Send a LaunchProcess message to the UI process.
+
+        * UIProcess/Plugins/PluginProcessProxy.cpp:
+        * UIProcess/Plugins/PluginProcessProxy.h:
+        Remove PluginProcessProxy::didReceiveMessage.
+
+        (PluginProcessProxy):
+        * UIProcess/Plugins/PluginProcessProxy.messages.in:
+        Add LaunchProcess message and remove LegacyReceiver attribute.
+
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        (WebKit::isFlashUpdater):
+        Helper function to determine whether the process is the flash updater.
+
+        (WebKit::shouldLaunchProcess):
+        Return whether we should launch this process.
+
+        (WebKit::PluginProcessProxy::launchProcess):
+        Determine if we should launch this process and then do so.
+
+2013-05-23  Anders Carlsson  <[email protected]>
+
         Don't run all plug-ins unsandboxed
         https://bugs.webkit.org/show_bug.cgi?id=116690
         <rdar://problem/13975569>

Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.h (150619 => 150620)


--- trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2013-05-24 00:43:10 UTC (rev 150620)
@@ -56,6 +56,8 @@
 #if USE(ACCELERATED_COMPOSITING)
     mach_port_t compositingRenderServerPort() const { return m_compositingRenderServerPort; }
 #endif
+
+    bool launchProcess(const String& launchPath, const Vector<String>& arguments);
 #endif
 
 private:

Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm (150619 => 150620)


--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm	2013-05-24 00:43:10 UTC (rev 150620)
@@ -29,6 +29,7 @@
 
 #if ENABLE(PLUGIN_PROCESS)
 
+#import "ArgumentCoders.h"
 #import "NetscapePlugin.h"
 #import "PluginProcessCreationParameters.h"
 #import "PluginProcessProxyMessages.h"
@@ -249,8 +250,30 @@
 }
 #endif
 
+static IMP NSConcreteTask_launch;
+
+static void replacedNSConcreteTask_launch(NSTask *self, SEL _cmd)
+{
+    String launchPath = self.launchPath;
+
+    Vector<String> arguments;
+    arguments.reserveInitialCapacity(self.arguments.count);
+    for (NSString *argument in self.arguments)
+        arguments.uncheckedAppend(argument);
+
+    if (PluginProcess::shared().launchProcess(launchPath, arguments))
+        return;
+
+    NSConcreteTask_launch(self, _cmd);
+}
+
 static void initializeCocoaOverrides()
 {
+    // Override -[NSConcreteTask launch:]
+    Method launchMethod = class_getInstanceMethod(objc_getClass("NSConcreteTask"), @selector(launch));
+
+    NSConcreteTask_launch = method_setImplementation(launchMethod, reinterpret_cast<IMP>(replacedNSConcreteTask_launch));
+
     // Override -[NSApplication runModalForWindow:]
     Method runModalForWindowMethod = class_getInstanceMethod(objc_getClass("NSApplication"), @selector(runModalForWindow:));
     NSApplication_RunModalForWindow = method_setImplementation(runModalForWindowMethod, reinterpret_cast<IMP>(replacedRunModalForWindow));
@@ -283,6 +306,15 @@
     parentProcessConnection()->send(Messages::PluginProcessProxy::SetFullscreenWindowIsShowing(fullscreenWindowIsShowing), 0);
 }
 
+bool PluginProcess::launchProcess(const String& launchPath, const Vector<String>& arguments)
+{
+    bool result;
+    if (!parentProcessConnection()->sendSync(Messages::PluginProcessProxy::LaunchProcess(launchPath, arguments), Messages::PluginProcessProxy::LaunchProcess::Reply(result), 0))
+        return false;
+
+    return result;
+}
+
 static void muteAudio(void)
 {
     AudioObjectPropertyAddress propertyAddress = { kAudioHardwarePropertyProcessIsAudible, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp (150619 => 150620)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2013-05-24 00:43:10 UTC (rev 150620)
@@ -156,11 +156,6 @@
     m_pluginProcessManager->removePluginProcessProxy(this);
 }
 
-void PluginProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder)
-{
-    didReceivePluginProcessProxyMessage(connection, decoder);
-}
-
 void PluginProcessProxy::didClose(CoreIPC::Connection*)
 {
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h (150619 => 150620)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h	2013-05-24 00:43:10 UTC (rev 150620)
@@ -107,6 +107,8 @@
 
     // CoreIPC::Connection::Client
     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
+    virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
+
     virtual void didClose(CoreIPC::Connection*) OVERRIDE;
     virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName) OVERRIDE;
 
@@ -114,7 +116,6 @@
     virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier);
 
     // Message handlers
-    void didReceivePluginProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
     void didCreateWebProcessConnection(const CoreIPC::Attachment&, bool supportsAsynchronousPluginInitialization);
     void didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID);
     void didClearSiteData(uint64_t callbackID);
@@ -134,6 +135,7 @@
 
     void applicationDidBecomeActive();
     void openPluginPreferencePane();
+    void launchProcess(const String& launchPath, const Vector<String>& arguments, bool& result);
 #endif
 
     void platformInitializePluginProcess(PluginProcessCreationParameters& parameters);

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in (150619 => 150620)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in	2013-05-24 00:43:10 UTC (rev 150620)
@@ -22,7 +22,7 @@
 
 #if ENABLE(PLUGIN_PROCESS)
 
-messages -> PluginProcessProxy LegacyReceiver {
+messages -> PluginProcessProxy {
     DidCreateWebProcessConnection(CoreIPC::Attachment connectionIdentifier, bool supportsAsynchronousPluginInitialization)
 
     DidGetSitesWithData(Vector<WTF::String> sites, uint64_t callbackID)
@@ -34,6 +34,9 @@
     
     # Open the plug-ins preference pane (as specified in the plug-in's Info.plist file).
     OpenPluginPreferencePane()
+
+    # Returns true if the UI process launched the process.
+    LaunchProcess(WTF::String launchPath, Vector<WTF::String> arguments) -> (bool result)
 #endif
 }
 

Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm (150619 => 150620)


--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm	2013-05-24 00:41:30 UTC (rev 150619)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm	2013-05-24 00:43:10 UTC (rev 150620)
@@ -358,6 +358,44 @@
         LOG_ERROR("LSOpenFromURLSpec to open \"%@\" failed with error %d.", (NSString *)m_pluginProcessAttributes.moduleInfo.preferencePanePath, error);
 }
 
+static bool isFlashUpdater(const String& launchPath, const Vector<String>& arguments)
+{
+    if (launchPath != "/Applications/Utilities/Adobe Flash Player Install Manager.app/Contents/MacOS/Adobe Flash Player Install Manager")
+        return false;
+
+    if (arguments.size() != 1)
+        return false;
+
+    if (arguments[0] != "-update")
+        return false;
+
+    return true;
+}
+
+static bool shouldLaunchProcess(const PluginProcessAttributes& pluginProcessAttributes, const String& launchPath, const Vector<String>& arguments)
+{
+    if (pluginProcessAttributes.moduleInfo.bundleIdentifier == "com.macromedia.Flash Player.plugin")
+        return isFlashUpdater(launchPath, arguments);
+
+    return false;
+}
+
+void PluginProcessProxy::launchProcess(const String& launchPath, const Vector<String>& arguments, bool& result)
+{
+    if (!shouldLaunchProcess(m_pluginProcessAttributes, launchPath, arguments)) {
+        result = false;
+        return;
+    }
+
+    result = true;
+
+    RetainPtr<NSMutableArray> argumentsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:arguments.size()]);
+    for (size_t i = 0; i < arguments.size(); ++i)
+        [argumentsArray addObject:(NSString *)arguments[i]];
+
+    [NSTask launchedTaskWithLaunchPath:launchPath arguments:argumentsArray.get()];
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(PLUGIN_PROCESS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to