bool NetscapePlugin::platformPostInitialize() { #if PLATFORM(GTK) if (moduleMixesGtkSymbols(m_pluginModule->module())) return false; #endif uint64_t windowID = 0; bool needsXEmbed = false; if (m_isWindowed) { NPP_GetValue(NPPVpluginNeedsXEmbed, &needsXEmbed); if (needsXEmbed) { windowID = controller()->createPluginContainer(); if (!windowID) return false; } else { notImplemented(); return false; } } if (!(m_pluginDisplay = getPluginDisplay())) return false; NPSetWindowCallbackStruct* callbackStruct = new NPSetWindowCallbackStruct; callbackStruct->type = 0; m_npWindow.ws_info = callbackStruct; if (m_isWindowed) return platformPostInitializeWindowed(needsXEmbed, windowID); return platformPostInitializeWindowless(); }
bool PluginPackage::load() { if (m_isLoaded) { m_loadCount++; return true; } GOwnPtr<gchar> finalPath(g_strdup(m_path.utf8().data())); while (g_file_test(finalPath.get(), G_FILE_TEST_IS_SYMLINK)) { GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(finalPath.get())); GRefPtr<GFile> dir = adoptGRef(g_file_get_parent(file.get())); GOwnPtr<gchar> linkPath(g_file_read_link(finalPath.get(), 0)); GRefPtr<GFile> resolvedFile = adoptGRef(g_file_resolve_relative_path(dir.get(), linkPath.get())); finalPath.set(g_file_get_path(resolvedFile.get())); } // No joke. If there is a netscape component in the path, go back // to the symlink, as flash breaks otherwise. // See http://src.chromium.org/viewvc/chrome/trunk/src/webkit/glue/plugins/plugin_list_posix.cc GOwnPtr<gchar> baseName(g_path_get_basename(finalPath.get())); if (!g_strcmp0(baseName.get(), "libflashplayer.so") && g_strstr_len(finalPath.get(), -1, "/netscape/")) finalPath.set(g_strdup(m_path.utf8().data())); m_module = g_module_open(finalPath.get(), G_MODULE_BIND_LOCAL); if (!m_module) { LOG(Plugins,"Module Load Failed :%s, Error:%s\n", (m_path.utf8()).data(), g_module_error()); return false; } if (moduleMixesGtkSymbols(m_module)) { LOG(Plugins, "Ignoring module '%s' to avoid mixing GTK+ 2 and GTK+ 3 symbols.\n", m_path.utf8().data()); return false; } m_isLoaded = true; if (!g_strcmp0(baseName.get(), "libflashplayer.so")) { // Flash plugin can produce X errors that are handled by the GDK X error handler, which // exits the process. Since we don't want to crash due to flash bugs, we install a // custom error handler to show a warning when a X error happens without aborting. XSetErrorHandler(webkitgtkXError); } NP_InitializeFuncPtr NP_Initialize = 0; m_NPP_Shutdown = 0; NPError npErr; g_module_symbol(m_module, "NP_Initialize", (void**)&NP_Initialize); g_module_symbol(m_module, "NP_Shutdown", (void**)&m_NPP_Shutdown); if (!NP_Initialize || !m_NPP_Shutdown) goto abort; memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs)); m_pluginFuncs.size = sizeof(m_pluginFuncs); initializeBrowserFuncs(); npErr = NP_Initialize(&m_browserFuncs, &m_pluginFuncs); if (npErr != NPERR_NO_ERROR) goto abort; m_loadCount++; return true; abort: unloadWithoutShutdown(); return false; }
bool NetscapePluginModule::tryLoad() { m_module = std::make_unique<Module>(m_pluginPath); if (!m_module->load()) return false; #if PLATFORM(GTK) if (moduleMixesGtkSymbols(m_module.get())) return false; #endif NP_InitializeFuncPtr initializeFuncPtr = m_module->functionPointer<NP_InitializeFuncPtr>("NP_Initialize"); if (!initializeFuncPtr) return false; #if !PLUGIN_ARCHITECTURE(X11) NP_GetEntryPointsFuncPtr getEntryPointsFuncPtr = m_module->functionPointer<NP_GetEntryPointsFuncPtr>("NP_GetEntryPoints"); if (!getEntryPointsFuncPtr) return false; #endif m_shutdownProcPtr = m_module->functionPointer<NPP_ShutdownProcPtr>("NP_Shutdown"); if (!m_shutdownProcPtr) return false; m_pluginFuncs.size = sizeof(NPPluginFuncs); m_pluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; // On Mac, NP_Initialize must be called first, then NP_GetEntryPoints. On Windows, the order is // reversed. Failing to follow this order results in crashes (e.g., in Silverlight on Mac and // in Flash and QuickTime on Windows). #if PLUGIN_ARCHITECTURE(MAC) #ifndef NP_NO_CARBON #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" // Plugins (at least QT) require that you call UseResFile on the resource file before loading it. ResFileRefNum currentResourceFile = CurResFile(); ResFileRefNum pluginResourceFile = m_module->bundleResourceMap(); UseResFile(pluginResourceFile); #endif bool result = initializeFuncPtr(netscapeBrowserFuncs()) == NPERR_NO_ERROR && getEntryPointsFuncPtr(&m_pluginFuncs) == NPERR_NO_ERROR; #ifndef NP_NO_CARBON // Restore the resource file. UseResFile(currentResourceFile); #pragma clang diagnostic pop #endif return result; #elif PLUGIN_ARCHITECTURE(X11) if (initializeFuncPtr(netscapeBrowserFuncs(), &m_pluginFuncs) != NPERR_NO_ERROR) return false; #endif return true; }