From 5f866fa0f54f6714b011580923a034cc32b89865 Mon Sep 17 00:00:00 2001 From: "ccarlen%netscape.com" Date: Sat, 17 Nov 2001 15:26:02 +0000 Subject: [PATCH] Bug 77231 - find plugins using directory service. r=av/sr=waterson git-svn-id: svn://10.0.0.236/trunk@108378 18797224-902f-48f8-a5cc-f745e15eee43 --- .../modules/plugin/base/macbuild/plugin.mcp | Bin 120957 -> 120957 bytes mozilla/modules/plugin/base/src/Makefile.in | 1 + mozilla/modules/plugin/base/src/makefile.win | 1 + .../modules/plugin/base/src/ns4xPlugin.cpp | 49 +-- mozilla/modules/plugin/base/src/ns4xPlugin.h | 1 + .../plugin/base/src/nsPluginHostImpl.cpp | 354 +++++++++--------- .../plugin/base/src/nsPluginHostImpl.h | 13 +- .../modules/plugin/base/src/nsPluginsDir.h | 25 +- .../plugin/base/src/nsPluginsDirBeOS.cpp | 25 -- .../plugin/base/src/nsPluginsDirMac.cpp | 31 -- .../plugin/base/src/nsPluginsDirOS2.cpp | 18 - .../plugin/base/src/nsPluginsDirUnix.cpp | 33 +- .../plugin/base/src/nsPluginsDirWin.cpp | 134 ------- 13 files changed, 196 insertions(+), 489 deletions(-) diff --git a/mozilla/modules/plugin/base/macbuild/plugin.mcp b/mozilla/modules/plugin/base/macbuild/plugin.mcp index d2e051183ba0d4740b08a74150a197818642f225..6e269feb03f466c34dbc9510271113bca4a2ca77 100644 GIT binary patch delta 331 zcmeynf&K3W_6=_t137#$cG1dSLNL>PcjU|czQjj%K4I-tN(AYL~4kMLBE9nx>afqMEk&lK5Xz-YQT$aOm7=C^K2 za%_Ua5aVk%PfE39<=7!r^Yj1z%QrV~6#2zC`D~6D`wppEMh1qA$rl6kHy;o=&A9pB zQVGV%6T(;~73eT>P1Y^Y2ih1~@XmnY?%lgYVpiGLusSit@`cQ&NjI2Ohn`wAtl^${*HsP(2FUdyg>cb27SY W-+Pu(n3?qeFdSUAU%kM%f*k;&)q6(( delta 302 zcmeynf&K3W_6=_tRZSTf7#$cG1cezGL>PcFKmZaEc9&69Cy8{69eQoyPQz@GhN~cqsI0L dM;LWD86CFoJRemove(PR_TRUE); + if (mPrivateDirServiceProvider) + { + nsCOMPtr dirService(do_GetService(kDirectoryServiceContractID, &rv)); + if (NS_SUCCEEDED(rv)) + dirService->UnregisterProvider(mPrivateDirServiceProvider); + mPrivateDirServiceProvider = nsnull; + } + return NS_OK; } @@ -4023,7 +4033,11 @@ public: NS_METHOD GetFilename(nsAWritableString& aFilename) { +#ifdef XP_MAC + return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFullPath, aFilename); +#else return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFileName, aFilename); +#endif } NS_METHOD GetName(nsAWritableString& aName) @@ -4292,6 +4306,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi if (NS_FAILED(rv)) rv = ns4xPlugin::CreatePlugin(serviceManager, pluginTag->mFileName, + pluginTag->mFullPath, pluginTag->mLibrary, &pluginTag->mEntryPoint); @@ -4381,29 +4396,53 @@ static PRBool isUnwantedPlugin(nsPluginTag * tag) //////////////////////////////////////////////////////////////////////// -nsresult nsPluginHostImpl::ScanPluginsDirectory(nsPluginsDir& pluginsDir, +nsresult nsPluginHostImpl::ScanPluginsDirectory(nsIFile * pluginsDir, nsIComponentManager * compManager, nsIFile * layoutPath, PRBool checkForUnwantedPlugins) { + nsresult rv; + +#ifdef PLUGIN_LOGGING + nsXPIDLCString dirPath; + pluginsDir->GetPath(getter_Copies(dirPath)); PLUGIN_LOG(PLUGIN_LOG_BASIC, - ("nsPluginHostImpl::ScanPluginsDirectory dir=%s\n", pluginsDir.GetCString())); + ("nsPluginHostImpl::ScanPluginsDirectory dir=%s\n", dirPath.get())); +#endif - for (nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++) + nsCOMPtr iter; + rv = pluginsDir->GetDirectoryEntries(getter_AddRefs(iter)); + if (NS_FAILED(rv)) + return rv; + + PRBool hasMore; + while (NS_SUCCEEDED(iter->HasMoreElements(&hasMore)) && hasMore) { - nsFileSpec file = iter; - if (pluginsDir.IsPluginFile(file)) + nsCOMPtr supports; + rv = iter->GetNext(getter_AddRefs(supports)); + if (NS_FAILED(rv)) + continue; + nsCOMPtr dirEntry(do_QueryInterface(supports, &rv)); + if (NS_FAILED(rv)) + continue; + nsXPIDLCString filePath; + rv = dirEntry->GetPath(getter_Copies(filePath)); + if (NS_FAILED(rv)) + continue; + + nsFileSpec file(filePath); + PRBool wasSymlink; + file.ResolveSymlink(wasSymlink); + + if (nsPluginsDir::IsPluginFile(file)) { // Look for it in our cache nsPluginTag *pluginTag = RemoveCachedPluginsInfo(file.GetCString()); // Get file mod time - // XXX if we use nsIFile we will get a 64 bit timestamp. - // XXX filespec does only 32 bit. Grrr... - PRUint32 shortFileModTime = 0; - file.GetModDate(shortFileModTime); PRInt64 fileModTime; - LL_UI2L(fileModTime, shortFileModTime); + LL_I2L(fileModTime, 0); + dirEntry->GetLastModificationTime(&fileModTime); if (pluginTag) { PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC, @@ -4419,7 +4458,7 @@ nsresult nsPluginHostImpl::ScanPluginsDirectory(nsPluginsDir& pluginsDir, } else { PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC, - ("ScanPluginsDirectory : Plugin NOT found in cache : %s\n", file.GetCString())); + ("ScanPluginsDirectory : Plugin NOT found in cache : %s\n", filePath.get())); } @@ -4515,6 +4554,25 @@ nsresult nsPluginHostImpl::ScanPluginsDirectory(nsPluginsDir& pluginsDir, return NS_OK; } +nsresult nsPluginHostImpl::ScanPluginsDirectoryList(nsISimpleEnumerator * dirEnum, + nsIComponentManager * compManager, + nsIFile * layoutPath, + PRBool checkForUnwantedPlugins) +{ + PRBool hasMore; + while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) { + nsCOMPtr supports; + nsresult rv = dirEnum->GetNext(getter_AddRefs(supports)); + if (NS_FAILED(rv)) + continue; + nsCOMPtr nextDir(do_QueryInterface(supports, &rv)); + if (NS_FAILED(rv)) + continue; + + ScanPluginsDirectory(nextDir, compManager, layoutPath, checkForUnwantedPlugins); + } + return NS_OK; +} //////////////////////////////////////////////////////////////////////// #include "nsITimelineService.h" @@ -4532,11 +4590,12 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins() NS_INIT_PLUGIN_SAFE_CALLS; #endif + nsresult rv; + // If the create instance failed, then it automatically disables all // our caching functions and we will just end up loading the plugins // on startup. nsCOMPtr registry = do_CreateInstance(kRegistryCID); - nsresult rv; if (registry) { rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry); if (NS_FAILED(rv)) { @@ -4548,191 +4607,70 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins() LoadCachedPluginsInfo(registry); // retrieve a path for layout module. Needed for plugin mime types registration - nsCOMPtr path; - PRBool isLayoutPath = PR_FALSE; + nsCOMPtr layoutPath; nsCOMPtr compManager = do_GetService(kComponentManagerCID, &rv); if (NS_SUCCEEDED(rv) && compManager) { - isLayoutPath = NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path))); - rv = LoadXPCOMPlugins(compManager, path); + PRBool gotLayoutPath = NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(layoutPath))); + rv = LoadXPCOMPlugins(compManager, layoutPath); + if (!gotLayoutPath) + layoutPath = nsnull; } - - nsCOMPtr theprefs = do_GetService(NS_PREF_CONTRACTID); - // scan the 4x plugins directory for eligible legacy plugin libraries + // Failure here is not a show-stopper so just warn. + rv = EnsurePrivateDirServiceProvider(); + NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to register dir service provider."); + + nsCOMPtr dirService(do_GetService(kDirectoryServiceContractID, &rv)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr dirList; + + // 1. Scan the app-defined list of plugin dirs. + rv = dirService->Get(NS_APP_PLUGINS_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList)); + if (NS_SUCCEEDED(rv)) + ScanPluginsDirectoryList(dirList, compManager, layoutPath); + + // 2. Scan the system-defined list of plugin dirs + rv = dirService->Get(NS_OS_PLUGINS_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList)); + if (NS_SUCCEEDED(rv)) + ScanPluginsDirectoryList(dirList, compManager, layoutPath); -#if !defined(XP_WIN) && !defined (XP_MAC) // old plugin finding logic + mPluginsLoaded = PR_TRUE; // at this point 'some' plugins have been loaded, + // the rest is optional + +#if defined (XP_WIN) + nsCOMPtr dirToScan; - // scan Mozilla plugins dir - nsPluginsDir pluginsDir; - - if (pluginsDir.Valid()) - { - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - - ScanPluginsDirectory(pluginsDir, compManager, lpath); - } -#endif - -#if defined (XP_MAC) - // try to scan plugins dir ("Plug-ins") for Mac - // should we check for duplicate plugins here? We probably should. - nsPluginsDir pluginsDirMac(PLUGINS_DIR_LOCATION_MOZ_LOCAL); - - // on Mac there is a common folder for storing plugins. Go and look there next - nsPluginsDir pluginsDirMacSystem(PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER); - - if (pluginsDirMacSystem.Valid()) - { - PRBool skipSystem = PR_FALSE; - if (theprefs) - theprefs->GetBoolPref("browser.plugins.skipSystemInternetFolder",&skipSystem); - - // now do the "Internet plug-ins" - if (!skipSystem) - { - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - - ScanPluginsDirectory(pluginsDirMacSystem, - compManager, - lpath, - PR_FALSE); // don't check for specific plugins - } - } - - if (pluginsDirMac.Valid()) - { - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - - ScanPluginsDirectory(pluginsDirMac, - compManager, - lpath, - PR_FALSE); // don't check for specific plugins - } -#endif // XP_MAC - -#if defined (XP_WIN) // XP_WIN go for new plugin finding logic on Windows - - // currently we decided to look in both local plugins dir and - // that of the previous 4.x installation combining plugins from both places. - // See bug #21938 - // As of 1.27.00 this selective mechanism is natively supported in Windows - // native implementation of nsPluginsDir. - - // first, make a list from MOZ_LOCAL installation - nsPluginsDir pluginsDirMoz(PLUGINS_DIR_LOCATION_MOZ_LOCAL); - - if (pluginsDirMoz.Valid()) - { - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - - ScanPluginsDirectory(pluginsDirMoz, compManager, lpath); - } - - // now check the 4.x plugins dir and add new files - // Specifying the last two params as PR_TRUE we make sure that: + // Scan 4.x plugins location. + // Specifying PR_TRUE for the last param to ScanPluginsDirectory, we make sure that: // 1. we search for a match in the list of MOZ_LOCAL plugins, ignore if found, // add if not found (check for dups) // 2. we ignore 4.x Java plugins no matter what and other // unwanted plugins as per temporary decision described in bug #23856 - nsPluginsDir pluginsDir4x(PLUGINS_DIR_LOCATION_4DOTX); - if (pluginsDir4x.Valid()) - { - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - - ScanPluginsDirectory(pluginsDir4x, - compManager, - lpath, - PR_TRUE); // check for specific plugins - } -#endif - - mPluginsLoaded = PR_TRUE; // at this point 'some' plugins have been loaded, - // the rest is optional - -#ifdef XP_WIN - // Checks the installation path of Sun's JRE in scanning for plugins if the prefs are enabled - - if (theprefs) // we got the pref service + rv = dirService->Get("NS_4DOTX_PLUGINS_DIR", NS_GET_IID(nsIFile), getter_AddRefs(dirToScan)); + if (NS_SUCCEEDED(rv)) + ScanPluginsDirectory(dirToScan, compManager, layoutPath, PR_TRUE); + + // Scan the installation path of Sun's JRE if the prefs are enabled + nsCOMPtr prefService = do_GetService(NS_PREF_CONTRACTID); + if (prefService) // we got the pref service { PRBool javaEnabled = PR_FALSE; // don't bother the scan if java is OFF PRBool doJREPluginScan = PR_FALSE; - if (NS_SUCCEEDED(theprefs->GetBoolPref("security.enable_java",&javaEnabled)) && - NS_SUCCEEDED(theprefs->GetBoolPref("plugin.do_JRE_Plugin_Scan",&doJREPluginScan)) && + if (NS_SUCCEEDED(prefService->GetBoolPref("security.enable_java",&javaEnabled)) && + NS_SUCCEEDED(prefService->GetBoolPref("plugin.do_JRE_Plugin_Scan",&doJREPluginScan)) && javaEnabled && doJREPluginScan) { - nsPluginsDir pluginsDirJavaJRE(PLUGINS_DIR_LOCATION_JAVA_JRE); - - if (pluginsDirJavaJRE.Valid()) - { - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - ScanPluginsDirectory(pluginsDirJavaJRE, compManager, lpath); - } - } - - - // Check the windows registry for extra paths to scan for plugins - // - // We are going to get this registry key location from the pref: - // browser.plugins.registry_plugins_folder_key_location - // The key name is "Plugins Folders" - // - // So, for example, in winprefs.js put in this line: - // pref ("browser.plugins.registry_plugins_folder_key_location","Software\\Mozilla\\Common"); - // Then, in HKEY_LOCAL_MACHINE\Software\Mozilla\Common - // Make a string key "Plugins Folder" who's value is a list of paths sperated by semi-colons - - char * regkey; - rv = theprefs->CopyCharPref(_NS_PREF_COMMON_PLUGIN_REG_KEY_,®key); - if (NS_SUCCEEDED(rv) && regkey) { - unsigned char valbuf[_MAXKEYVALUE_]; - char* pluginPath; - HKEY newkey; - LONG result; - DWORD type = REG_SZ; - DWORD length = _MAXKEYVALUE_; - - // set up layout path (if not done above) - nsCOMPtr lpath = nsnull; - if(isLayoutPath) - lpath = path; - - result = RegOpenKeyEx( HKEY_LOCAL_MACHINE, regkey, NULL, KEY_QUERY_VALUE, &newkey ); - - if ( ERROR_SUCCESS == result ) { - result = RegQueryValueEx( newkey, _NS_COMMON_PLUGIN_KEY_NAME_, nsnull, &type, valbuf, &length ); - RegCloseKey( newkey ); - if ( ERROR_SUCCESS == result ) { - // tokenize reg key value by semi-colons - for ( pluginPath = strtok((char *)&valbuf, ";"); pluginPath; pluginPath = strtok(NULL, ";") ) { - nsFileSpec winRegPluginPath (pluginPath); - if (winRegPluginPath.Exists()) { // check for validity of path first -#ifdef DEBUG - printf("found some more plugins at: %s\n", pluginPath); -#endif - ScanPluginsDirectory( (nsPluginsDir)winRegPluginPath, compManager, lpath, PR_FALSE); // check for even unwanted plugins - } - } - } - } - free (regkey); // clean up + rv = dirService->Get("NS_WIN_JAVA_JRE_DIR", NS_GET_IID(nsIFile), getter_AddRefs(dirToScan)); + if (NS_SUCCEEDED(rv)) + ScanPluginsDirectory(dirToScan, compManager, layoutPath); } } -#endif // !XP_WIN - +#endif + // Update the plugins info cache if (mSyncCachedPlugins) { mSyncCachedPlugins = PR_FALSE; @@ -5195,6 +5133,26 @@ nsPluginHostImpl::RemoveCachedPluginsInfo(const char *filename) return nsnull; } +nsresult +nsPluginHostImpl::EnsurePrivateDirServiceProvider() +{ + if (!mPrivateDirServiceProvider) + { + nsresult rv; + nsCOMPtr provider = new nsPluginDirServiceProvider; + if (!provider) + return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr dirService(do_GetService(kDirectoryServiceContractID, &rv)); + if (NS_FAILED(rv)) + return rv; + rv = dirService->RegisterProvider(provider); + if (NS_FAILED(rv)) + return rv; + mPrivateDirServiceProvider = provider; + } + return NS_OK; +} + //////////////////////////////////////////////////////////////////////// /* Called by GetURL and PostURL */ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, @@ -5625,18 +5583,44 @@ nsresult nsPluginHostImpl::NewFullPagePluginStream(nsIStreamListener *&aStreamLi //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsPluginHostImpl::GetProgramPath(const char* *result) { - static nsSpecialSystemDirectory programDir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); - *result = programDir; - return NS_OK; + nsresult rv; + NS_ENSURE_ARG_POINTER(result); + *result = nsnull; + + nsCOMPtr dirService(do_GetService(kDirectoryServiceContractID, &rv)); + if (NS_FAILED(rv)) + return rv; + nsCOMPtr programDir; + rv = dirService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(programDir)); + if (NS_FAILED(rv)) + return rv; + + char *temp; + rv = programDir->GetPath(&temp); + *result = temp; + return rv; } //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsPluginHostImpl::GetTempDirPath(const char* *result) { - static nsSpecialSystemDirectory tempDir(nsSpecialSystemDirectory::OS_TemporaryDirectory); - *result = tempDir; - return NS_OK; + nsresult rv; + NS_ENSURE_ARG_POINTER(result); + *result = nsnull; + + nsCOMPtr dirService(do_GetService(kDirectoryServiceContractID, &rv)); + if (NS_FAILED(rv)) + return rv; + nsCOMPtr tempDir; + rv = dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(tempDir)); + if (NS_FAILED(rv)) + return rv; + + char *temp; + rv = tempDir->GetPath(&temp); + *result = temp; + return rv; } diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index 6fbb6fc02e4..6415c26a343 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -51,6 +51,7 @@ #include "nsICookieStorage.h" #include "nsPluginsDir.h" #include "nsVoidArray.h" // array for holding "active" streams +#include "nsIDirectoryService.h" class ns4xPlugin; class nsFileSpec; @@ -435,10 +436,16 @@ private: RegisterPluginMimeTypesWithLayout(nsPluginTag *pluginTag, nsIComponentManager * compManager, nsIFile * layoutPath); nsresult - ScanPluginsDirectory(nsPluginsDir& pluginsDir, + ScanPluginsDirectory(nsIFile * pluginsDir, nsIComponentManager * compManager, nsIFile * layoutPath, PRBool checkForUnwantedPlugins = PR_FALSE); + + nsresult + ScanPluginsDirectoryList(nsISimpleEnumerator * dirEnum, + nsIComponentManager * compManager, + nsIFile * layoutPath, + PRBool checkForUnwantedPlugins = PR_FALSE); PRBool IsRunningPlugin(nsPluginTag * plugin); void AddToUnusedLibraryList(PRLibrary * aLibrary); @@ -451,6 +458,8 @@ private: // Given a filename, returns the plugins info from our cache and removes // it from the cache. nsPluginTag* RemoveCachedPluginsInfo(const char *filename); + + nsresult EnsurePrivateDirServiceProvider(); char *mPluginPath; nsPluginTag *mPlugins; @@ -462,6 +471,8 @@ private: nsActivePluginList mActivePluginList; nsUnusedLibrary *mUnusedLibraries; + + nsCOMPtr mPrivateDirServiceProvider; }; #endif diff --git a/mozilla/modules/plugin/base/src/nsPluginsDir.h b/mozilla/modules/plugin/base/src/nsPluginsDir.h index a1f098791ec..c8e0616c906 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDir.h +++ b/mozilla/modules/plugin/base/src/nsPluginsDir.h @@ -42,33 +42,16 @@ #include "nsFileSpec.h" /** - * Provides a cross-platform way to obtain the location of the plugins - * directory. Once constructed, can be used with nsDirectoryIterator to - * scan the plugins directory. An nsPluginFileSpec can be constructed from the - * nsFileSpec returned by the iterator. + * nsPluginsDir is nearly obsolete. Directory Service should be used instead. + * It exists for the sake of one static function. */ -/* Where to seek for plugins dir */ -#define PLUGINS_DIR_LOCATION_AUTO 0 -#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1 -#define PLUGINS_DIR_LOCATION_4DOTX 2 -#define PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER 3 -#define PLUGINS_DIR_LOCATION_JAVA_JRE 4 - -class nsPluginsDir : public nsFileSpec { +class nsPluginsDir { public: - /** - * Locates the plugins directory in a platform-dependent manner. - */ - nsPluginsDir(PRUint16 location = PLUGINS_DIR_LOCATION_AUTO); - nsPluginsDir(nsFileSpec plugDir) : - nsFileSpec(plugDir) { } - virtual ~nsPluginsDir(); - /** * Determines whether or not the given file is actually a plugin file. */ - PRBool IsPluginFile(const nsFileSpec& fileSpec); + static PRBool IsPluginFile(const nsFileSpec& fileSpec); }; struct PRLibrary; diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp index 9ea08b3b884..9741609239f 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp @@ -51,7 +51,6 @@ #include "prmem.h" #include "nsReadableUtils.h" -#include "nsSpecialSystemDirectory.h" #include #include @@ -116,30 +115,6 @@ static nsresult GetMimeExtensions(const char *mimeType, char *extensions, int ex /* nsPluginsDir implementation */ -nsPluginsDir::nsPluginsDir(PRUint16 location) -{ - // this is somewhat lacking, in that it doesn't fall back to any other directories. - // then again, I'm not sure we should be falling back at all. plugins have been (and probably - // should continue to be) loaded from both /plugins and ~/.mozilla/plugins. There - // doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening. - // - - // use MOZILLA_FIVE_HOME/plugins - - nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); - sysdir += "plugins"; - const char *pluginsDir = sysdir.GetCString(); // native path - if (pluginsDir != NULL) - { - *(nsFileSpec*)this = pluginsDir; - } -} - -nsPluginsDir::~nsPluginsDir() -{ - // do nothing -} - PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec) { const char* pathname = fileSpec.GetCString(); diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirMac.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirMac.cpp index 014b28267fd..63b65e503bf 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirMac.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirMac.cpp @@ -45,7 +45,6 @@ #include "nsPluginsDir.h" #include "prlink.h" -#include "nsSpecialSystemDirectory.h" #include #include @@ -118,36 +117,6 @@ static nsresult getApplicationSpec(FSSpec& outAppSpec) return (result == noErr ? NS_OK : NS_ERROR_FAILURE); } -nsPluginsDir::nsPluginsDir(PRUint16 location) -{ - PRBool wasAliased; - - switch (location) - { - case PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER: - // The system's shared "Plugin-ins" folder -#if TARGET_CARBON // on OS X, we must try kLocalDomain first - mError = ::FindFolder(kLocalDomain, kInternetPlugInFolderType, kDontCreateFolder, & mSpec.vRefNum, &mSpec.parID); - if (mError) -#endif - mError = ::FindFolder(kOnAppropriateDisk, kInternetPlugInFolderType, kDontCreateFolder, & mSpec.vRefNum, &mSpec.parID); - if (!mError) - mError = ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, "\p", &mSpec); - break; - case PLUGINS_DIR_LOCATION_MOZ_LOCAL: - default: - // The "Plug-ins" folder in the application's directory is where plugins are loaded from. - // Use the Moz_BinDirectory - nsSpecialSystemDirectory plugDir(nsSpecialSystemDirectory::Moz_BinDirectory); - *(nsFileSpec*)this = plugDir + "Plug-ins"; - break; - } - if (IsSymlink()) - ResolveSymlink(wasAliased); -} - -nsPluginsDir::~nsPluginsDir() {} - PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec) { // look at file's creator/type and make sure it is a code fragment, etc. diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirOS2.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirOS2.cpp index 9eb79eceeb3..1297550081b 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirOS2.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirOS2.cpp @@ -29,7 +29,6 @@ #include "prlink.h" #include "plstr.h" #include "prmem.h" -#include "nsSpecialSystemDirectory.h" #include "nsPluginDefs.h" /* Load a string stored as RCDATA in a resource segment */ @@ -123,23 +122,6 @@ static void FreeStringArray(PRUint32 variants, char ** array) // nsPluginsDir class -nsPluginsDir::nsPluginsDir(PRUint16 location) -{ - // XXX This isn't right for the embedded case, but it's as close - // as we can do right now. - nsSpecialSystemDirectory appdir( nsSpecialSystemDirectory::OS_CurrentProcessDirectory); - appdir += "plugins"; - - if( !appdir.Exists()) - appdir.CreateDirectory(); - - *(nsFileSpec*)this = appdir; -} - -nsPluginsDir::~nsPluginsDir() -{ -} - PRBool nsPluginsDir::IsPluginFile( const nsFileSpec &fileSpec) { PRBool rc = PR_FALSE; diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirUnix.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirUnix.cpp index 07d750894b3..f639578942d 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirUnix.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirUnix.cpp @@ -51,7 +51,6 @@ #include "nsIMemory.h" #include "nsIPluginStreamListener.h" #include "nsPluginsDir.h" -#include "nsSpecialSystemDirectory.h" #include "prmem.h" #include "prenv.h" #include "prerror.h" @@ -304,36 +303,6 @@ static void LoadExtraSharedLibs() /* nsPluginsDir implementation */ -// Get path to plugin directory. -// If already defined in environment, use it; otherwise, use native path. -nsPluginsDir::nsPluginsDir(PRUint16 location) -{ - nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory:: - OS_CurrentProcessDirectory); - const char *pluginsDir; - char *tmp_dir; - - if ((tmp_dir = PR_GetEnv(PLUGIN_PATH))) { - pluginsDir = (const char *)tmp_dir; - } else { - sysdir += "plugins"; - pluginsDir = sysdir.GetCString(); // native path - } - - if (pluginsDir != NULL) { - *(nsFileSpec*)this = pluginsDir; - } - -#ifdef NS_DEBUG - printf("********** Got plugins path: %s\n", pluginsDir); -#endif -} - -nsPluginsDir::~nsPluginsDir() -{ - // do nothing -} - PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec) { const char* pathname = fileSpec.GetCString(); @@ -443,7 +412,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) } else { // It's old sk00l // if fileName parameter == 0 ns4xPlugin::CreatePlugin() will not call NP_Initialize() - rv = ns4xPlugin::CreatePlugin(mgr, 0, pLibrary, + rv = ns4xPlugin::CreatePlugin(mgr, 0, 0, pLibrary, getter_AddRefs(plugin)); if (NS_FAILED(rv)) return rv; } diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirWin.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirWin.cpp index b2dde1767d3..40fb1eef8b9 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirWin.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirWin.cpp @@ -52,7 +52,6 @@ #include "windows.h" #include "winbase.h" -#include "nsSpecialSystemDirectory.h" /////////////////////////////////////////////////////////////////////////// @@ -165,139 +164,6 @@ static void FreeStringArray(PRUint32 variants, char ** array) /* nsPluginsDir implementation */ -nsPluginsDir::nsPluginsDir(PRUint16 location) -{ - DWORD pathlen; - char path[_MAX_PATH]; - char newestPath[_MAX_PATH + 4]; // to prevent buffer overrun when adding /bin - newestPath[0] = 0; - const char* allocPath; - // Use the Moz_BinDirectory - nsSpecialSystemDirectory plugDir(nsSpecialSystemDirectory::Moz_BinDirectory); - - if((location == PLUGINS_DIR_LOCATION_AUTO) || (location == PLUGINS_DIR_LOCATION_MOZ_LOCAL)) - { - // look for a plugin folder that exists in the same directory as - // the mozilla bin directory - - plugDir += "plugins"; - *(nsFileSpec*)this = plugDir; - PR_snprintf(path, sizeof(path), "%s", (const char *) plugDir); - - } - - if(((location == PLUGINS_DIR_LOCATION_AUTO) && !Exists()) || - (location == PLUGINS_DIR_LOCATION_4DOTX)) - { - // look for the plugin folder that the user has in their Communicator 4x install - HKEY keyloc; - long result; - DWORD type; - char szKey[512] = "Software\\Netscape\\Netscape Navigator"; - - path[0] = 0; - result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); - - if (result == ERROR_SUCCESS) - { - char current_version[80]; - DWORD length = sizeof(current_version); - - result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length); - - ::RegCloseKey(keyloc); - PL_strcat(szKey, "\\"); - PL_strcat(szKey, current_version); - PL_strcat(szKey, "\\Main"); - result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); - } - - if (result == ERROR_SUCCESS) - { - pathlen = sizeof(path); - - result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen); - ::RegCloseKey(keyloc); - } - - allocPath = path; - *(nsFileSpec*)this = allocPath; - } - - if (PLUGINS_DIR_LOCATION_JAVA_JRE == location) - { - // Case for looking for the Java OJI plugin via the JRE install path - HKEY baseloc; - HKEY keyloc; - FILETIME modTime = {0,0}; // initilize variables - FILETIME curVer = {0,0}; - DWORD type; - DWORD index = 0; - DWORD numChars = _MAX_PATH; - char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Plug-in"; - - LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc); - - // we must enumerate through the keys because what if there is more than one version? - while (ERROR_SUCCESS == result) - { - path[0] = 0; - numChars = _MAX_PATH; - pathlen = sizeof(path); - result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); - index++; - if (ERROR_SUCCESS == result) - { - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) - { - // we have a sub key - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, &type, (LPBYTE)&path, &pathlen)) - { - // Compare time stamps from registry lookup - // Only use the key with the latest time stamp because there could be several - // - // NOTE: This may not be the highest version revsion number (szKey) - // if the user installed an older version AFTER a newer one - // This assumes the last version installed is the one the user wants to use - // We can also tweak this for checking for a minimum version on szKey - if (::CompareFileTime(&modTime,&curVer) >= 0 && atof(curKey) >= 1.3) - { - PL_strcpy(newestPath,path); - curVer = modTime; - } - ::RegCloseKey(keyloc); - } - } - } - } - - ::RegCloseKey(baseloc); - - // if nothing is found, then don't add \bin dir - // a null path may be returned so .Valid() should be used. - if (newestPath[0] != 0) - PL_strcat(newestPath,"\\bin"); - - allocPath = newestPath; - *(nsFileSpec*)this = allocPath; - -#ifdef NS_DEBUG - if (newestPath[0] != 0) - PL_strcpy(path,newestPath); // so the debug below will print out correct -#endif - } - -#ifdef NS_DEBUG - if (path[0] != 0) - printf("Searching for plugins at: %s\n", path); -#endif -} - -nsPluginsDir::~nsPluginsDir() -{ - // do nothing -} - PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec) { const char* filename;