Title: [152182] trunk/Source/WebKit2
Revision
152182
Author
[email protected]
Date
2013-06-28 11:57:39 -0700 (Fri, 28 Jun 2013)

Log Message

Make the UI process run the Java Updater
https://bugs.webkit.org/show_bug.cgi?id=118197
<rdar://problem/14255677>

Reviewed by Sam Weinig.

Patch the relevant NSWorkspace method and pipe through the request to launch the Java updater to the UI process.

* PluginProcess/PluginProcess.h:
* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::replacedNSWorkspace_launchApplicationAtURL_options_configuration_error):
(WebKit::initializeCocoaOverrides):
(WebKit::PluginProcess::launchApplicationAtURL):
* UIProcess/Plugins/PluginProcessProxy.h:
* UIProcess/Plugins/PluginProcessProxy.messages.in:
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::isJavaUpdaterURL):
(WebKit::shouldLaunchApplicationAtURL):
(WebKit::PluginProcessProxy::launchApplicationAtURL):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (152181 => 152182)


--- trunk/Source/WebKit2/ChangeLog	2013-06-28 18:47:55 UTC (rev 152181)
+++ trunk/Source/WebKit2/ChangeLog	2013-06-28 18:57:39 UTC (rev 152182)
@@ -1,3 +1,25 @@
+2013-06-28  Anders Carlsson  <[email protected]>
+
+        Make the UI process run the Java Updater
+        https://bugs.webkit.org/show_bug.cgi?id=118197
+        <rdar://problem/14255677>
+
+        Reviewed by Sam Weinig.
+
+        Patch the relevant NSWorkspace method and pipe through the request to launch the Java updater to the UI process.
+
+        * PluginProcess/PluginProcess.h:
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::replacedNSWorkspace_launchApplicationAtURL_options_configuration_error):
+        (WebKit::initializeCocoaOverrides):
+        (WebKit::PluginProcess::launchApplicationAtURL):
+        * UIProcess/Plugins/PluginProcessProxy.h:
+        * UIProcess/Plugins/PluginProcessProxy.messages.in:
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        (WebKit::isJavaUpdaterURL):
+        (WebKit::shouldLaunchApplicationAtURL):
+        (WebKit::PluginProcessProxy::launchApplicationAtURL):
+
 2013-06-28  Tim Horton  <[email protected]>
 
         WARN_UNUSED_RESULT can't be used in API headers, but WKBundlePageExtendIncrementalRenderingSuppression tries to

Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.h (152181 => 152182)


--- trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2013-06-28 18:47:55 UTC (rev 152181)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2013-06-28 18:57:39 UTC (rev 152182)
@@ -58,6 +58,7 @@
 #endif
 
     bool launchProcess(const String& launchPath, const Vector<String>& arguments);
+    bool launchApplicationAtURL(const String& urlString, const Vector<String>& arguments);
     bool openURL(const String& urlString, int32_t& status, String& launchedURLString);
 
 #endif

Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm (152181 => 152182)


--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm	2013-06-28 18:47:55 UTC (rev 152181)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm	2013-06-28 18:57:39 UTC (rev 152182)
@@ -279,13 +279,39 @@
     NSConcreteTask_launch(self, _cmd);
 }
 
+static NSRunningApplication *(*NSWorkspace_launchApplicationAtURL_options_configuration_error)(NSWorkspace *, SEL, NSURL *, NSWorkspaceLaunchOptions, NSDictionary *, NSError **);
+
+static NSRunningApplication *replacedNSWorkspace_launchApplicationAtURL_options_configuration_error(NSWorkspace *self, SEL _cmd, NSURL *url, NSWorkspaceLaunchOptions options, NSDictionary *configuration, NSError **error)
+{
+    Vector<String> arguments;
+    if (NSArray *argumentsArray = [configuration objectForKey:NSWorkspaceLaunchConfigurationArguments]) {
+        if ([argumentsArray isKindOfClass:[NSArray array]]) {
+            for (NSString *argument in argumentsArray) {
+                if ([argument isKindOfClass:[NSString class]])
+                    arguments.append(argument);
+            }
+        }
+    }
+
+    if (PluginProcess::shared().launchApplicationAtURL(KURL(url).string(), arguments)) {
+        if (error)
+            *error = nil;
+        return nil;
+    }
+
+    return NSWorkspace_launchApplicationAtURL_options_configuration_error(self, _cmd, url, options, configuration, error);
+}
+
 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 -[NSWorkspace launchApplicationAtURL:options:configuration:error:]
+    Method launchApplicationAtURLOptionsConfigurationErrorMethod = class_getInstanceMethod(objc_getClass("NSWorkspace"), @selector(launchApplicationAtURL:options:configuration:error:));
+    NSWorkspace_launchApplicationAtURL_options_configuration_error = reinterpret_cast<NSRunningApplication *(*)(NSWorkspace *, SEL, NSURL *, NSWorkspaceLaunchOptions, NSDictionary *, NSError **)>(method_setImplementation(launchApplicationAtURLOptionsConfigurationErrorMethod, reinterpret_cast<IMP>(replacedNSWorkspace_launchApplicationAtURL_options_configuration_error)));
+
     // Override -[NSApplication runModalForWindow:]
     Method runModalForWindowMethod = class_getInstanceMethod(objc_getClass("NSApplication"), @selector(runModalForWindow:));
     NSApplication_RunModalForWindow = method_setImplementation(runModalForWindowMethod, reinterpret_cast<IMP>(replacedRunModalForWindow));
@@ -327,6 +353,15 @@
     return result;
 }
 
+bool PluginProcess::launchApplicationAtURL(const String& urlString, const Vector<String>& arguments)
+{
+    bool result = false;
+    if (!parentProcessConnection()->sendSync(Messages::PluginProcessProxy::LaunchApplicationAtURL(urlString, arguments), Messages::PluginProcessProxy::LaunchProcess::Reply(result), 0))
+        return false;
+
+    return result;
+}
+
 bool PluginProcess::openURL(const String& urlString, int32_t& status, String& launchedURLString)
 {
     bool result;

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h (152181 => 152182)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h	2013-06-28 18:47:55 UTC (rev 152181)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h	2013-06-28 18:57:39 UTC (rev 152182)
@@ -136,6 +136,7 @@
     void applicationDidBecomeActive();
     void openPluginPreferencePane();
     void launchProcess(const String& launchPath, const Vector<String>& arguments, bool& result);
+    void launchApplicationAtURL(const String& urlString, const Vector<String>& arguments, bool& result);
     void openURL(const String& url, bool& result, int32_t& status, String& launchedURLString);
 #endif
 

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


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in	2013-06-28 18:47:55 UTC (rev 152181)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in	2013-06-28 18:57:39 UTC (rev 152182)
@@ -38,6 +38,9 @@
     # Returns true if the UI process launched the process.
     LaunchProcess(WTF::String launchPath, Vector<WTF::String> arguments) -> (bool result)
 
+    # Returns true if the UI process launched the application.
+    LaunchApplicationAtURL(WTF::String url, Vector<WTF::String> arguments) -> (bool result)
+
     # Returns true if the UI process did open the URL.
     OpenURL(WTF::String urlString) -> (bool result, int32_t status, WTF::String launchedURLString)
 #endif

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


--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm	2013-06-28 18:47:55 UTC (rev 152181)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm	2013-06-28 18:57:39 UTC (rev 152182)
@@ -397,6 +397,38 @@
     [NSTask launchedTaskWithLaunchPath:launchPath arguments:argumentsArray.get()];
 }
 
+static bool isJavaUpdaterURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
+{
+    NSURL *javaUpdaterURL = [NSURL fileURLWithPathComponents:[NSArray arrayWithObjects:(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources/Java Updater.app", nil]];
+
+    return [[NSURL URLWithString:urlString] isEqual:javaUpdaterURL];
+}
+
+static bool shouldLaunchApplicationAtURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
+{
+    if (pluginProcessAttributes.moduleInfo.bundleIdentifier == "com.oracle.java.JavaAppletPlugin")
+        return isJavaUpdaterURL(pluginProcessAttributes, urlString);
+
+    return false;
+}
+
+void PluginProcessProxy::launchApplicationAtURL(const String& urlString, const Vector<String>& arguments, bool& result)
+{
+    if (!shouldLaunchApplicationAtURL(m_pluginProcessAttributes, urlString)) {
+        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]];
+
+    NSDictionary *configuration = [NSDictionary dictionaryWithObject:argumentsArray.get() forKey:NSWorkspaceLaunchConfigurationArguments];
+    [[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL URLWithString:urlString] options:NSWorkspaceLaunchAsync configuration:configuration error:nullptr];
+}
+
 static bool isSilverlightPreferencesURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
 {
     NSURL *silverlightPreferencesURL = [NSURL fileURLWithPathComponents:[NSArray arrayWithObjects:(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources/Silverlight Preferences.app", nil]];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to