Changeset 149619 in webkit


Ignore:
Timestamp:
May 6, 2013 11:40:29 AM (11 years ago)
Author:
ap@apple.com
Message:

<rdar://problem/13479806> [Mac] Pass plug-in bundle ID to LaunchServices
https://bugs.webkit.org/show_bug.cgi?id=115483

Reviewed by Darin Adler.

  • PluginProcess/PluginProcess.h: Added m_pluginBundleIdentifier. We now need it in multiple places, so it's easier to pre-compute it.
  • PluginProcess/mac/PluginProcessMac.mm: (WebKit::loadSandboxProfileForDirectory): Changed to use precomputed bundle ID. (WebKit::loadSandboxProfile): Ditto. (WebKit::PluginProcess::platformInitializeProcess): Pre-compute bundle ID. (WebKit::PluginProcess::initializeProcessName): Pass it to LaunchServices. (WebKit::PluginProcess::initializeSandbox): Pass precomputed bundle ID instead of a path.
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r149618 r149619  
     12013-05-06  Alexey Proskuryakov  <ap@apple.com>
     2
     3        <rdar://problem/13479806> [Mac] Pass plug-in bundle ID to LaunchServices
     4        https://bugs.webkit.org/show_bug.cgi?id=115483
     5
     6        Reviewed by Darin Adler.
     7
     8        * PluginProcess/PluginProcess.h: Added m_pluginBundleIdentifier. We now need it
     9        in multiple places, so it's easier to pre-compute it.
     10
     11        * PluginProcess/mac/PluginProcessMac.mm:
     12        (WebKit::loadSandboxProfileForDirectory): Changed to use precomputed bundle ID.
     13        (WebKit::loadSandboxProfile): Ditto.
     14        (WebKit::PluginProcess::platformInitializeProcess): Pre-compute bundle ID.
     15        (WebKit::PluginProcess::initializeProcessName): Pass it to LaunchServices.
     16        (WebKit::PluginProcess::initializeSandbox): Pass precomputed bundle ID instead of
     17        a path.
     18
    1192013-05-06  Anders Carlsson  <andersca@apple.com>
    220
  • trunk/Source/WebKit2/PluginProcess/PluginProcess.h

    r148038 r149619  
    9898    String m_pluginPath;
    9999
     100#if PLATFORM(MAC)
     101    String m_pluginBundleIdentifier;
     102#endif
     103
    100104    // The plug-in module.
    101105    RefPtr<NetscapePluginModule> m_pluginModule;
  • trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm

    r149255 r149619  
    4545using namespace WebCore;
    4646
     47const CFStringRef kLSPlugInBundleIdentifierKey = CFSTR("LSPlugInBundleIdentifierKey");
     48
    4749namespace WebKit {
    4850
     
    281283}
    282284
    283 static String loadSandboxProfileForDirectory(const String& pluginPath, NSString *sandboxProfileDirectoryPath)
    284 {
    285     RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
    286     if (!pluginURL)
    287         return String();
    288 
    289     RetainPtr<CFBundleRef> pluginBundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, pluginURL.get()));
    290     if (!pluginBundle)
    291         return String();
    292 
    293     String bundleIdentifier = CFBundleGetIdentifier(pluginBundle.get());
     285static String loadSandboxProfileForDirectory(const String& bundleIdentifier, NSString *sandboxProfileDirectoryPath)
     286{
    294287    if (bundleIdentifier.isEmpty())
    295288        return String();
    296289
    297290    // Fold all / characters to : to prevent the plugin bundle-id from trying to escape the profile directory
    298     bundleIdentifier.replace('/', ':');
     291    String sanitizedBundleIdentifier = bundleIdentifier;
     292    sanitizedBundleIdentifier.replace('/', ':');
    299293
    300294    RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, (CFStringRef)sandboxProfileDirectoryPath, kCFURLPOSIXPathStyle, TRUE));
    301295
    302     RetainPtr<CFStringRef> sandboxFileName = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%@.sb"), bundleIdentifier.createCFString().get()));
     296    RetainPtr<CFStringRef> sandboxFileName = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%@.sb"), sanitizedBundleIdentifier.createCFString().get()));
    303297    RetainPtr<CFURLRef> sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, sandboxFileName.get(), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));
    304298
     
    316310}
    317311
    318 static String loadSandboxProfile(const String& pluginPath)
     312static String loadSandboxProfile(const String& bundleIdentifier)
    319313{
    320314    // First look in the WebKit2 bundle.
    321     String sandboxProfile = loadSandboxProfileForDirectory(pluginPath, [[[NSBundle bundleForClass:NSClassFromString(@"WKView")] resourcePath] stringByAppendingPathComponent:@"PlugInSandboxProfiles"]);
     315    String sandboxProfile = loadSandboxProfileForDirectory(bundleIdentifier, [[[NSBundle bundleForClass:NSClassFromString(@"WKView")] resourcePath] stringByAppendingPathComponent:@"PlugInSandboxProfiles"]);
    322316    if (!sandboxProfile.isEmpty())
    323317        return sandboxProfile;
    324318
    325319    // Then try /System/Library/Sandbox/Profiles/.
    326     sandboxProfile = loadSandboxProfileForDirectory(pluginPath, @"/System/Library/Sandbox/Profiles/");
     320    sandboxProfile = loadSandboxProfileForDirectory(bundleIdentifier, @"/System/Library/Sandbox/Profiles/");
    327321    if (!sandboxProfile.isEmpty())
    328322        return sandboxProfile;
     
    365359    [defaults release];
    366360#endif
     361
     362    RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, m_pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
     363    if (!pluginURL)
     364        return;
     365
     366    RetainPtr<CFBundleRef> pluginBundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, pluginURL.get()));
     367    if (!pluginBundle)
     368        return;
     369
     370    m_pluginBundleIdentifier = CFBundleGetIdentifier(pluginBundle.get());
    367371}
    368372
     
    371375    NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ (%@ Internet plug-in)", "visible name of the plug-in host process. The first argument is the plug-in name and the second argument is the application name."), [[(NSString *)m_pluginPath lastPathComponent] stringByDeletingPathExtension], (NSString *)parameters.uiProcessName];
    372376    WKSetVisibleApplicationName((CFStringRef)applicationName);
     377#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     378    if (!m_pluginBundleIdentifier.isEmpty())
     379        WKSetApplicationInformationItem(kLSPlugInBundleIdentifierKey, m_pluginBundleIdentifier.createCFString().get());
     380#endif
    373381}
    374382
    375383void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters)
    376384{
    377     String sandboxProfile = loadSandboxProfile(m_pluginPath);
     385    String sandboxProfile = loadSandboxProfile(m_pluginBundleIdentifier);
    378386    if (sandboxProfile.isEmpty())
    379387        return;
Note: See TracChangeset for help on using the changeset viewer.