Changeset 86097 in webkit
- Timestamp:
- May 9, 2011 3:49:41 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r86089 r86097 1 2011-05-09 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Create a plug-in's MIME types preferences plist if it doesn't exist. 6 https://bugs.webkit.org/show_bug.cgi?id=57204 7 <rdar://problem/9195048> 8 9 Spawn a plug-in process and let it create the plist. For now, we'll do this on the 10 main thread since it's a rare one-time computation and we have an API function, 11 WKFrameCanShowMIMEType, which would have to block anyway. 12 13 * PluginProcess/mac/PluginProcessMainMac.mm: 14 (WebKit::PluginProcessMain): 15 If -createPluginMIMETypesPreferences is one of the command line argument keys, 16 the plug-in path will be the argument value. Call NetscapePluginModule::createPluginMIMETypesPreferences 17 to create the preferences file and then exit. 18 19 * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm: 20 (WebKit::contentsOfPropertyListAtURL): 21 Move code to read a property list out into a helper function. 22 23 (WebKit::getMIMETypesFromPluginBundle): 24 If there's no property list file, try to create one. 25 26 (WebKit::NetscapePluginModule::createPluginMIMETypesPreferences): 27 Load the plug-in, find the BP_CreatePluginMIMETypesPreferences and call it. 28 29 * UIProcess/Plugins/mac/PluginProcessProxyMac.mm: 30 (WebKit::PluginProcessProxy::createPropertyListFile): 31 Spawn a plug-in process and pass the -createPluginMIMETypesPreferences flag to it and then wait 32 for it to exit. 33 1 34 2011-05-09 Anders Carlsson <andersca@apple.com> 2 35 -
trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm
r80014 r86097 30 30 31 31 #import "CommandLine.h" 32 #import "NetscapePluginModule.h" 32 33 #import "PluginProcess.h" 33 34 #import "RunLoop.h" … … 54 55 // by any child processes that the plug-in may launch. 55 56 unsetenv("DYLD_INSERT_LIBRARIES"); 57 58 // Check if we're being spawned to write a MIME type preferences file. 59 String pluginPath = commandLine["createPluginMIMETypesPreferences"]; 60 if (!pluginPath.isEmpty()) { 61 JSC::initializeThreading(); 62 WTF::initializeMainThread(); 63 64 if (!NetscapePluginModule::createPluginMIMETypesPreferences(pluginPath)) 65 return EXIT_FAILURE; 66 67 return EXIT_SUCCESS; 68 } 56 69 57 70 String serviceName = commandLine["servicename"]; -
trunk/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
r84638 r86097 62 62 Module* module() const { return m_module.get(); } 63 63 64 #if PLUGIN_ARCHITECTURE(MAC) 65 static bool createPluginMIMETypesPreferences(const String& pluginPath); 66 #endif 67 64 68 private: 65 69 explicit NetscapePluginModule(const String& pluginPath); -
trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm
r86076 r86097 27 27 #import "NetscapePluginModule.h" 28 28 29 #import "PluginProcessProxy.h" 29 30 #import <WebCore/WebCoreNSStringExtras.h> 30 31 #import <wtf/HashSet.h> 32 31 33 32 34 using namespace WebCore; … … 87 89 return false; 88 90 } 89 90 static RetainPtr<CFDictionaryRef> getMIMETypesFromPluginBundle(CFBundleRef bundle) 91 92 static RetainPtr<CFDictionaryRef> contentsOfPropertyListAtURL(CFURLRef propertyListURL) 93 { 94 CFDataRef propertyListData; 95 CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, propertyListURL, &propertyListData, 0, 0, 0); 96 if (!propertyListData) 97 return 0; 98 99 RetainPtr<CFPropertyListRef> propertyList(AdoptCF, CFPropertyListCreateWithData(kCFAllocatorDefault, propertyListData, kCFPropertyListImmutable, 0, 0)); 100 CFRelease(propertyListData); 101 102 if (!propertyList) 103 return 0; 104 105 if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID()) 106 return 0; 107 108 return RetainPtr<CFDictionaryRef>(AdoptCF, static_cast<CFDictionaryRef>(propertyList.leakRef())); 109 } 110 111 static RetainPtr<CFDictionaryRef> getMIMETypesFromPluginBundle(CFBundleRef bundle, const PluginInfoStore::Plugin& plugin) 91 112 { 92 113 CFStringRef propertyListFilename = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypesFilename"))); … … 95 116 RetainPtr<CFURLRef> propertyListURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, propertyListPath.get(), kCFURLPOSIXPathStyle, FALSE)); 96 117 97 CFDataRef propertyListData; 98 CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, propertyListURL.get(), &propertyListData, 0, 0, 0); 99 RetainPtr<CFPropertyListRef> propertyList(AdoptCF, CFPropertyListCreateWithData(kCFAllocatorDefault, propertyListData, kCFPropertyListImmutable, 0, 0)); 100 if (propertyListData) 101 CFRelease(propertyListData); 102 103 // FIXME: Have the plug-in create the MIME types property list if it doesn't exist. 104 // https://bugs.webkit.org/show_bug.cgi?id=57204 105 if (!propertyList || CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID()) 118 RetainPtr<CFDictionaryRef> propertyList = contentsOfPropertyListAtURL(propertyListURL.get()); 119 120 #if ENABLE(PLUGIN_PROCESS) 121 if (!propertyList && PluginProcessProxy::createPropertyListFile(plugin)) 122 propertyList = contentsOfPropertyListAtURL(propertyListURL.get()); 123 #endif 124 125 if (!propertyList) 106 126 return 0; 107 127 108 return static_cast<CFDictionaryRef>(CFDictionaryGetValue( static_cast<CFDictionaryRef>(propertyList.get()), CFSTR("WebPluginMIMETypes")));128 return static_cast<CFDictionaryRef>(CFDictionaryGetValue(propertyList.get(), CFSTR("WebPluginMIMETypes"))); 109 129 } 110 130 … … 114 134 static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfoStore::Plugin& plugin) 115 135 { 116 RetainPtr<CFDictionaryRef> mimeTypes = getMIMETypesFromPluginBundle(bundle );136 RetainPtr<CFDictionaryRef> mimeTypes = getMIMETypesFromPluginBundle(bundle, plugin); 117 137 if (!mimeTypes || CFGetTypeID(mimeTypes.get()) != CFDictionaryGetTypeID()) 118 138 return false; … … 363 383 } 364 384 385 bool NetscapePluginModule::createPluginMIMETypesPreferences(const String& pluginPath) 386 { 387 RetainPtr<CFStringRef> bundlePath(AdoptCF, pluginPath.createCFString()); 388 RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, false)); 389 390 // Try to initialize the bundle. 391 RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get())); 392 if (!bundle) 393 return false; 394 395 if (!CFBundleLoadExecutable(bundle.get())) 396 return false; 397 398 void (*createPluginMIMETypesPreferences)(void) = reinterpret_cast<void (*)(void)>(CFBundleGetFunctionPointerForName(bundle.get(), CFSTR("BP_CreatePluginMIMETypesPreferences"))); 399 if (!createPluginMIMETypesPreferences) 400 return false; 401 402 createPluginMIMETypesPreferences(); 403 return true; 404 } 405 365 406 void NetscapePluginModule::determineQuirks() 366 407 { -
trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h
r84302 r86097 55 55 class PluginProcessProxy : CoreIPC::Connection::Client, ProcessLauncher::Client { 56 56 public: 57 #if PLATFORM(MAC)58 static bool pluginNeedsExecutableHeap(const PluginInfoStore::Plugin&);59 #endif60 57 static PassOwnPtr<PluginProcessProxy> create(PluginProcessManager*, const PluginInfoStore::Plugin&); 61 58 ~PluginProcessProxy(); … … 75 72 // Terminates the plug-in process. 76 73 void terminate(); 74 75 #if PLATFORM(MAC) 76 // Returns whether the plug-in needs the heap to be marked executable. 77 static bool pluginNeedsExecutableHeap(const PluginInfoStore::Plugin&); 78 79 // Creates a property list in ~/Library/Preferences that contains all the MIME types supported by the plug-in. 80 static bool createPropertyListFile(const PluginInfoStore::Plugin&); 81 #endif 77 82 78 83 private: -
trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
r83109 r86097 29 29 #if ENABLE(PLUGIN_PROCESS) 30 30 31 #import "EnvironmentVariables.h" 31 32 #import "PluginProcessCreationParameters.h" 32 33 #import "WebKitSystemInterface.h" 34 #import <WebCore/FileSystem.h> 35 #import <spawn.h> 36 #import <wtf/text/CString.h> 33 37 34 38 @interface WKPlaceholderModalWindow : NSWindow … … 46 50 @end 47 51 52 using namespace WebCore; 53 48 54 namespace WebKit { 49 55 … … 57 63 return false; 58 64 65 return true; 66 } 67 68 bool PluginProcessProxy::createPropertyListFile(const PluginInfoStore::Plugin& plugin) 69 { 70 NSBundle *webKit2Bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit2"]; 71 NSString *frameworksPath = [[webKit2Bundle bundlePath] stringByDeletingLastPathComponent]; 72 const char* frameworkExecutablePath = [[webKit2Bundle executablePath] fileSystemRepresentation]; 73 74 NSString *processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"PluginProcess.app"]; 75 NSString *processAppExecutablePath = [[NSBundle bundleWithPath:processPath] executablePath]; 76 77 CString pluginPathString = fileSystemRepresentation(plugin.path); 78 79 posix_spawnattr_t attr; 80 posix_spawnattr_init(&attr); 81 82 cpu_type_t cpuTypes[] = { plugin.pluginArchitecture }; 83 size_t outCount = 0; 84 posix_spawnattr_setbinpref_np(&attr, 1, cpuTypes, &outCount); 85 86 EnvironmentVariables environmentVariables; 87 88 // To make engineering builds work, if the path is outside of /System set up 89 // DYLD_FRAMEWORK_PATH to pick up other frameworks, but don't do it for the 90 // production configuration because it involves extra file system access. 91 if (![frameworksPath hasPrefix:@"/System/"]) 92 environmentVariables.appendValue("DYLD_FRAMEWORK_PATH", [frameworksPath fileSystemRepresentation], ':'); 93 94 const char* args[] = { [processAppExecutablePath fileSystemRepresentation], frameworkExecutablePath, "-type", "pluginprocess", "-createPluginMIMETypesPreferences", pluginPathString.data(), 0 }; 95 96 pid_t pid; 97 int result = posix_spawn(&pid, args[0], 0, &attr, const_cast<char* const*>(args), environmentVariables.environmentPointer()); 98 posix_spawnattr_destroy(&attr); 99 100 if (result < 0) 101 return false; 102 int status; 103 if (waitpid(pid, &status, 0) < 0) 104 return false; 105 106 if (!WIFEXITED(status)) 107 return false; 108 109 if (WEXITSTATUS(status) != EXIT_SUCCESS) 110 return false; 111 59 112 return true; 60 113 }
Note: See TracChangeset
for help on using the changeset viewer.