diff --git a/mozilla/modules/plugin/base/public/MANIFEST b/mozilla/modules/plugin/base/public/MANIFEST index 510f94a6ffb..13000c07ec9 100644 --- a/mozilla/modules/plugin/base/public/MANIFEST +++ b/mozilla/modules/plugin/base/public/MANIFEST @@ -53,3 +53,4 @@ nsPluginLogging.h nsPluginError.h npapi.h npupp.h +nsDefaultPlugin.h diff --git a/mozilla/modules/plugin/base/public/Makefile.in b/mozilla/modules/plugin/base/public/Makefile.in index f8f80134663..74461eebe4d 100644 --- a/mozilla/modules/plugin/base/public/Makefile.in +++ b/mozilla/modules/plugin/base/public/Makefile.in @@ -55,6 +55,7 @@ EXPORTS = \ nsPIPluginHost.h \ nsPluginLogging.h \ nsPluginError.h \ + nsDefaultPlugin.h \ $(NULL) # 4.x headers moved from mozilla/include diff --git a/mozilla/modules/plugin/base/public/makefile.win b/mozilla/modules/plugin/base/public/makefile.win index b50c0d9955a..be49eefa31e 100644 --- a/mozilla/modules/plugin/base/public/makefile.win +++ b/mozilla/modules/plugin/base/public/makefile.win @@ -40,7 +40,8 @@ EXPORTS = \ nsICookieStorage.h \ nsPIPluginHost.h \ nsPluginLogging.h \ - nsPluginError.h + nsPluginError.h \ + nsDefaultPlugin.h # 4.x headers moved from mozilla/include EXPORTS = $(EXPORTS) \ diff --git a/mozilla/modules/plugin/base/public/npupp.h b/mozilla/modules/plugin/base/public/npupp.h index d59bbaeb67b..c1382a7ee72 100644 --- a/mozilla/modules/plugin/base/public/npupp.h +++ b/mozilla/modules/plugin/base/public/npupp.h @@ -38,7 +38,7 @@ /* - * npupp.h $Revision: 3.9 $ + * npupp.h $Revision: 3.10 $ * function call mecahnics needed by platform specific glue code. */ @@ -1259,6 +1259,8 @@ NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs); NPError OSCALL NP_Shutdown(); +char* NP_GetMIMEDescription(); + #ifdef __cplusplus } #endif diff --git a/mozilla/modules/plugin/base/public/nsDefaultPlugin.h b/mozilla/modules/plugin/base/public/nsDefaultPlugin.h new file mode 100644 index 00000000000..70566d082af --- /dev/null +++ b/mozilla/modules/plugin/base/public/nsDefaultPlugin.h @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _DEFAULT_H_ +#define _DEFAULT_H_ + +// This mimetype is reserved for use with the Netscape +// Default Plugin only. Using it in any other plugin will break +// the basic functionality of the Mozilla based browsers +#define NS_PLUGIN_DEFAULT_MIME_DESCRIPTION "*" + +#endif // _DEFAULT_H_ diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index b9e9fa0918d..33f71fca243 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -149,6 +149,7 @@ #include "nsUnicharUtils.h" #include "imgILoader.h" +#include "nsDefaultPlugin.h" #ifdef XP_UNIX #if defined(MOZ_WIDGET_GTK) @@ -2577,12 +2578,15 @@ nsPluginHostImpl::nsPluginHostImpl() mIsDestroyed = PR_FALSE; mUnusedLibraries = nsnull; mOverrideInternalTypes = PR_FALSE; + mAllowAlienStarHandler = PR_FALSE; // check to see if pref is set at startup to let plugins take over in // full page mode for certain image mime types that we handle internally nsCOMPtr prefs(do_GetService(kPrefServiceCID)); - if (prefs) + if (prefs) { prefs->GetBoolPref("plugin.override_internal_types", &mOverrideInternalTypes); + prefs->GetBoolPref("plugin.allow_alien_star_handler", &mAllowAlienStarHandler); + } nsCOMPtr obsService = do_GetService("@mozilla.org/observer-service;1"); if (obsService) @@ -4675,6 +4679,45 @@ static int PR_CALLBACK ComparePluginFileInDirectory (const void *v1, const void return result; } +typedef NS_4XPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void); + +static nsresult FixUpPluginInfo(nsPluginInfo &aInfo, nsPluginFile &aPluginFile) +{ +#ifndef XP_WIN + retrun NS_OK; +#endif + + for (PRUint32 i = 0; i < aInfo.fVariantCount; i++) { + if (PL_strcmp(aInfo.fMimeTypeArray[i], "*")) + continue; + + // we got "*" type + // check if this is an alien plugin (not our default plugin) + // by trying to find a special entry point + PRLibrary *library = nsnull; + if (NS_FAILED(aPluginFile.LoadPlugin(library)) || !library) + return NS_ERROR_FAILURE; + + NP_GETMIMEDESCRIPTION pf = (NP_GETMIMEDESCRIPTION)PR_FindSymbol(library, "NP_GetMIMEDescription"); + if (pf) { + // if we found it, this is the default plugin, return + char * mimedescription = pf(); + if (!PL_strncmp(mimedescription, NS_PLUGIN_DEFAULT_MIME_DESCRIPTION, 1)) + return NS_OK; + } + + // if we are here that means we have an alien plugin + // which wants to take over "*" type + + // change its "*" mime type to "[*]" + PL_strfree(aInfo.fMimeTypeArray[i]); + aInfo.fMimeTypeArray[i] = PL_strdup("[*]"); + + // continue the loop? + } + return NS_OK; +} + //////////////////////////////////////////////////////////////////////// nsresult nsPluginHostImpl::ScanPluginsDirectory(nsIFile * pluginsDir, nsIComponentManager * compManager, @@ -4805,7 +4848,13 @@ nsresult nsPluginHostImpl::ScanPluginsDirectory(nsIFile * pluginsDir, pluginFile.FreePluginInfo(info); continue; } - + + // Check for any potential '*' mime type handlers which are not our + // own default plugin and disable them as they will break the plugin + // finder service, see Bugzilla bug 132430 + if (!mAllowAlienStarHandler) + FixUpPluginInfo(info, pluginFile); + pluginTag = new nsPluginTag(&info); pluginFile.FreePluginInfo(info); diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index 3b25b782203..89b9edfef58 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -471,7 +471,8 @@ private: PRBool mPluginsLoaded; PRBool mDontShowBadPluginMessage; PRBool mIsDestroyed; - PRBool mOverrideInternalTypes; // set by pref plugin.override_internal_types + PRBool mOverrideInternalTypes; // set by pref plugin.override_internal_types + PRBool mAllowAlienStarHandler; // set by pref plugin.allow_alien_star_handler nsActivePluginList mActivePluginList; nsUnusedLibrary *mUnusedLibraries;