Changeset 152182 in webkit


Ignore:
Timestamp:
Jun 28, 2013 11:57:39 AM (11 years ago)
Author:
andersca@apple.com
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):

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r152177 r152182  
     12013-06-28  Anders Carlsson  <andersca@apple.com>
     2
     3        Make the UI process run the Java Updater
     4        https://bugs.webkit.org/show_bug.cgi?id=118197
     5        <rdar://problem/14255677>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Patch the relevant NSWorkspace method and pipe through the request to launch the Java updater to the UI process.
     10
     11        * PluginProcess/PluginProcess.h:
     12        * PluginProcess/mac/PluginProcessMac.mm:
     13        (WebKit::replacedNSWorkspace_launchApplicationAtURL_options_configuration_error):
     14        (WebKit::initializeCocoaOverrides):
     15        (WebKit::PluginProcess::launchApplicationAtURL):
     16        * UIProcess/Plugins/PluginProcessProxy.h:
     17        * UIProcess/Plugins/PluginProcessProxy.messages.in:
     18        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
     19        (WebKit::isJavaUpdaterURL):
     20        (WebKit::shouldLaunchApplicationAtURL):
     21        (WebKit::PluginProcessProxy::launchApplicationAtURL):
     22
    1232013-06-28  Tim Horton  <timothy_horton@apple.com>
    224
  • trunk/Source/WebKit2/PluginProcess/PluginProcess.h

    r151748 r152182  
    5959
    6060    bool launchProcess(const String& launchPath, const Vector<String>& arguments);
     61    bool launchApplicationAtURL(const String& urlString, const Vector<String>& arguments);
    6162    bool openURL(const String& urlString, int32_t& status, String& launchedURLString);
    6263
  • trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm

    r151748 r152182  
    280280}
    281281
     282static NSRunningApplication *(*NSWorkspace_launchApplicationAtURL_options_configuration_error)(NSWorkspace *, SEL, NSURL *, NSWorkspaceLaunchOptions, NSDictionary *, NSError **);
     283
     284static NSRunningApplication *replacedNSWorkspace_launchApplicationAtURL_options_configuration_error(NSWorkspace *self, SEL _cmd, NSURL *url, NSWorkspaceLaunchOptions options, NSDictionary *configuration, NSError **error)
     285{
     286    Vector<String> arguments;
     287    if (NSArray *argumentsArray = [configuration objectForKey:NSWorkspaceLaunchConfigurationArguments]) {
     288        if ([argumentsArray isKindOfClass:[NSArray array]]) {
     289            for (NSString *argument in argumentsArray) {
     290                if ([argument isKindOfClass:[NSString class]])
     291                    arguments.append(argument);
     292            }
     293        }
     294    }
     295
     296    if (PluginProcess::shared().launchApplicationAtURL(KURL(url).string(), arguments)) {
     297        if (error)
     298            *error = nil;
     299        return nil;
     300    }
     301
     302    return NSWorkspace_launchApplicationAtURL_options_configuration_error(self, _cmd, url, options, configuration, error);
     303}
     304
    282305static void initializeCocoaOverrides()
    283306{
    284307    // Override -[NSConcreteTask launch:]
    285308    Method launchMethod = class_getInstanceMethod(objc_getClass("NSConcreteTask"), @selector(launch));
    286 
    287309    NSConcreteTask_launch = method_setImplementation(launchMethod, reinterpret_cast<IMP>(replacedNSConcreteTask_launch));
     310
     311    // Override -[NSWorkspace launchApplicationAtURL:options:configuration:error:]
     312    Method launchApplicationAtURLOptionsConfigurationErrorMethod = class_getInstanceMethod(objc_getClass("NSWorkspace"), @selector(launchApplicationAtURL:options:configuration:error:));
     313    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)));
    288314
    289315    // Override -[NSApplication runModalForWindow:]
     
    328354}
    329355
     356bool PluginProcess::launchApplicationAtURL(const String& urlString, const Vector<String>& arguments)
     357{
     358    bool result = false;
     359    if (!parentProcessConnection()->sendSync(Messages::PluginProcessProxy::LaunchApplicationAtURL(urlString, arguments), Messages::PluginProcessProxy::LaunchProcess::Reply(result), 0))
     360        return false;
     361
     362    return result;
     363}
     364
    330365bool PluginProcess::openURL(const String& urlString, int32_t& status, String& launchedURLString)
    331366{
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h

    r151748 r152182  
    137137    void openPluginPreferencePane();
    138138    void launchProcess(const String& launchPath, const Vector<String>& arguments, bool& result);
     139    void launchApplicationAtURL(const String& urlString, const Vector<String>& arguments, bool& result);
    139140    void openURL(const String& url, bool& result, int32_t& status, String& launchedURLString);
    140141#endif
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in

    r151748 r152182  
    3939    LaunchProcess(WTF::String launchPath, Vector<WTF::String> arguments) -> (bool result)
    4040
     41    # Returns true if the UI process launched the application.
     42    LaunchApplicationAtURL(WTF::String url, Vector<WTF::String> arguments) -> (bool result)
     43
    4144    # Returns true if the UI process did open the URL.
    4245    OpenURL(WTF::String urlString) -> (bool result, int32_t status, WTF::String launchedURLString)
  • trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm

    r151748 r152182  
    398398}
    399399
     400static bool isJavaUpdaterURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
     401{
     402    NSURL *javaUpdaterURL = [NSURL fileURLWithPathComponents:[NSArray arrayWithObjects:(NSString *)pluginProcessAttributes.moduleInfo.path, @"Contents/Resources/Java Updater.app", nil]];
     403
     404    return [[NSURL URLWithString:urlString] isEqual:javaUpdaterURL];
     405}
     406
     407static bool shouldLaunchApplicationAtURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
     408{
     409    if (pluginProcessAttributes.moduleInfo.bundleIdentifier == "com.oracle.java.JavaAppletPlugin")
     410        return isJavaUpdaterURL(pluginProcessAttributes, urlString);
     411
     412    return false;
     413}
     414
     415void PluginProcessProxy::launchApplicationAtURL(const String& urlString, const Vector<String>& arguments, bool& result)
     416{
     417    if (!shouldLaunchApplicationAtURL(m_pluginProcessAttributes, urlString)) {
     418        result = false;
     419        return;
     420    }
     421
     422    result = true;
     423
     424    RetainPtr<NSMutableArray> argumentsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:arguments.size()]);
     425    for (size_t i = 0; i < arguments.size(); ++i)
     426        [argumentsArray addObject:(NSString *)arguments[i]];
     427
     428    NSDictionary *configuration = [NSDictionary dictionaryWithObject:argumentsArray.get() forKey:NSWorkspaceLaunchConfigurationArguments];
     429    [[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL URLWithString:urlString] options:NSWorkspaceLaunchAsync configuration:configuration error:nullptr];
     430}
     431
    400432static bool isSilverlightPreferencesURL(const PluginProcessAttributes& pluginProcessAttributes, const String& urlString)
    401433{
Note: See TracChangeset for help on using the changeset viewer.