--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -141,38 +141,17 @@ static const char *kPrefLoadInParentPref
static const char *kPrefDisableFullPage = "plugin.disable_full_page_plugin_for_types";
static const char *kPrefJavaMIME = "plugin.java.mime";
// How long we wait before unloading an idle plugin process.
// Defaults to 30 seconds.
static const char *kPrefUnloadPluginTimeoutSecs = "dom.ipc.plugins.unloadTimeoutSecs";
static const uint32_t kDefaultPluginUnloadingTimeout = 30;
-// Version of cached plugin info
-// 0.01 first implementation
-// 0.02 added caching of CanUnload to fix bug 105935
-// 0.03 changed name, description and mime desc from string to bytes, bug 108246
-// 0.04 added new mime entry point on Mac, bug 113464
-// 0.05 added new entry point check for the default plugin, bug 132430
-// 0.06 strip off suffixes in mime description strings, bug 53895
-// 0.07 changed nsIRegistry to flat file support for caching plugins info
-// 0.08 mime entry point on MachO, bug 137535
-// 0.09 the file encoding is changed to UTF-8, bug 420285
-// 0.10 added plugin versions on appropriate platforms, bug 427743
-// 0.11 file name and full path fields now store expected values on all platforms, bug 488181
-// 0.12 force refresh due to quicktime pdf claim fix, bug 611197
-// 0.13 add architecture and list of invalid plugins, bug 616271
-// 0.14 force refresh due to locale comparison fix, bug 611296
-// 0.15 force refresh due to bug in reading Java plist MIME data, bug 638171
-// 0.16 version bump to avoid importing the plugin flags in newer versions
-// 0.17 added flag on whether plugin is loaded from an XPI
-// The current plugin registry version (and the maximum version we know how to read)
-static const char *kPluginRegistryVersion = "0.17";
-// The minimum registry version we know how to read
-static const char *kMinimumRegistryVersion = "0.9";
+static const char *kPluginRegistryVersion = "0.18";
static const char kDirectoryServiceContractID[] = "@mozilla.org/file/directory_service;1";
#define kPluginRegistryFilename NS_LITERAL_CSTRING("pluginreg.dat")
#ifdef PLUGIN_LOGGING
LazyLogModule nsPluginLogging::gNPNLog(NPN_LOG_NAME);
LazyLogModule nsPluginLogging::gNPPLog(NPP_LOG_NAME);
@@ -2985,20 +2964,16 @@ nsPluginHost::WritePluginInfo()
nsresult
nsPluginHost::ReadPluginInfo()
{
MOZ_ASSERT(XRE_IsParentProcess());
const long PLUGIN_REG_MIMETYPES_ARRAY_SIZE = 12;
const long PLUGIN_REG_MAX_MIMETYPES = 1000;
- // we need to import the legacy flags from the plugin registry once
- const bool pluginStateImported =
- Preferences::GetDefaultBool("plugin.importedState", false);
-
nsresult rv;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
if (NS_FAILED(rv))
return rv;
directoryService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(mPluginRegFile));
@@ -3080,138 +3055,78 @@ nsPluginHost::ReadPluginInfo()
// VersionLiteral, kPluginRegistryVersion
if (2 != reader.ParseLine(values, 2))
return rv;
// VersionLiteral
if (PL_strcmp(values[0], "Version"))
return rv;
- // kPluginRegistryVersion
- int32_t vdiff = mozilla::CompareVersions(values[1], kPluginRegistryVersion);
- mozilla::Version version(values[1]);
- // If this is a registry from some future version then don't attempt to read it
- if (vdiff > 0)
+ // If we're reading an old registry, ignore it
+ if (!strcmp(values[1], kPluginRegistryVersion)) {
return rv;
- // If this is a registry from before the minimum then don't attempt to read it
- if (version < kMinimumRegistryVersion)
+ }
+
+ char* archValues[6];
+ if (!reader.NextLine()) {
+ return rv;
+ }
+
+ // ArchLiteral, Architecture
+ if (2 != reader.ParseLine(archValues, 2)) {
return rv;
-
- // Registry v0.10 and upwards includes the plugin version field
- bool regHasVersion = (version >= "0.10");
-
- // Registry v0.13 and upwards includes the architecture
- if (version >= "0.13") {
- char* archValues[6];
-
- if (!reader.NextLine()) {
- return rv;
- }
-
- // ArchLiteral, Architecture
- if (2 != reader.ParseLine(archValues, 2)) {
- return rv;
- }
-
- // ArchLiteral
- if (PL_strcmp(archValues[0], "Arch")) {
- return rv;
- }
-
- nsCOMPtr<nsIXULRuntime> runtime = do_GetService("@mozilla.org/xre/runtime;1");
- if (!runtime) {
- return rv;
- }
-
- nsAutoCString arch;
- if (NS_FAILED(runtime->GetXPCOMABI(arch))) {
- return rv;
- }
-
- // If this is a registry from a different architecture then don't attempt to read it
- if (PL_strcmp(archValues[1], arch.get())) {
- return rv;
- }
+ }
+
+ // ArchLiteral
+ if (PL_strcmp(archValues[0], "Arch")) {
+ return rv;
+ }
+
+ nsCOMPtr<nsIXULRuntime> runtime = do_GetService("@mozilla.org/xre/runtime;1");
+ if (!runtime) {
+ return rv;
}
- // Registry v0.13 and upwards includes the list of invalid plugins
- const bool hasInvalidPlugins = (version >= "0.13");
-
- // Registry v0.16 and upwards always have 0 for their plugin flags, prefs are used instead
- const bool hasValidFlags = (version < "0.16");
-
- // Registry v0.17 and upwards store whether the plugin comes from an XPI.
- const bool hasFromExtension = (version >= "0.17");
-
-#if defined(XP_MACOSX)
- const bool hasFullPathInFileNameField = false;
-#else
- const bool hasFullPathInFileNameField = (version < "0.11");
-#endif
+ nsAutoCString arch;
+ if (NS_FAILED(runtime->GetXPCOMABI(arch))) {
+ return rv;
+ }
+
+ // If this is a registry from a different architecture then don't attempt to read it
+ if (PL_strcmp(archValues[1], arch.get())) {
+ return rv;
+ }
if (!ReadSectionHeader(reader, "PLUGINS"))
return rv;
while (reader.NextLine()) {
- const char *filename;
- const char *fullpath;
- nsAutoCString derivedFileName;
-
- if (hasInvalidPlugins && *reader.LinePtr() == '[') {
+ if (*reader.LinePtr() == '[') {
break;
}
- if (hasFullPathInFileNameField) {
- fullpath = reader.LinePtr();
- if (!reader.NextLine())
- return rv;
- // try to derive a file name from the full path
- if (fullpath) {
- nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1");
- file->InitWithNativePath(nsDependentCString(fullpath));
- file->GetNativeLeafName(derivedFileName);
- filename = derivedFileName.get();
- } else {
- filename = nullptr;
- }
-
- // skip the next line, useless in this version
- if (!reader.NextLine())
- return rv;
- } else {
- filename = reader.LinePtr();
- if (!reader.NextLine())
- return rv;
-
- fullpath = reader.LinePtr();
- if (!reader.NextLine())
- return rv;
- }
+ const char* filename = reader.LinePtr();
+ if (!reader.NextLine())
+ return rv;
+
+ const char* fullpath = reader.LinePtr();
+ if (!reader.NextLine())
+ return rv;
const char *version;
- if (regHasVersion) {
- version = reader.LinePtr();
- if (!reader.NextLine())
- return rv;
- } else {
- version = "0";
- }
+ version = reader.LinePtr();
+ if (!reader.NextLine())
// lastModifiedTimeStamp|canUnload|tag.mFlag|fromExtension
- const int count = hasFromExtension ? 4 : 3;
- if (reader.ParseLine(values, count) != count)
+ if (4 != reader.ParseLine(values, 4))
return rv;
- // If this is an old plugin registry mark this plugin tag to be refreshed
- int64_t lastmod = (vdiff == 0) ? nsCRT::atoll(values[0]) : -1;
+ int64_t lastmod = nsCRT::atoll(values[0]);
uint32_t tagflag = atoi(values[2]);
- bool fromExtension = false;
- if (hasFromExtension) {
- fromExtension = atoi(values[3]);
- }
+ bool fromExtension = atoi(values[3]);
if (!reader.NextLine())
return rv;
char *description = reader.LinePtr();
if (!reader.NextLine())
return rv;
#if MOZ_WIDGET_ANDROID
@@ -3277,61 +3192,52 @@ nsPluginHost::ReadPluginInfo()
(const char* const*)mimetypes,
(const char* const*)mimedescriptions,
(const char* const*)extensions,
mimetypecount, lastmod, fromExtension, true);
if (heapalloced)
delete [] heapalloced;
// Import flags from registry into prefs for old registry versions
- if (hasValidFlags && !pluginStateImported) {
- tag->ImportFlagsToPrefs(tagflag);
- }
-
MOZ_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC,
("LoadCachedPluginsInfo : Loading Cached plugininfo for %s\n", tag->FileName().get()));
if (!ShouldAddPlugin(tag)) {
continue;
}
tag->mNext = mCachedPlugins;
mCachedPlugins = tag;
}
// On Android we always want to try to load a plugin again (Flash). Bug 935676.
#ifndef MOZ_WIDGET_ANDROID
- if (hasInvalidPlugins) {
- if (!ReadSectionHeader(reader, "INVALID")) {
+ if (!ReadSectionHeader(reader, "INVALID")) {
+ return rv;
+ }
+
+ while (reader.NextLine()) {
+ const char *fullpath = reader.LinePtr();
+ if (!reader.NextLine()) {
return rv;
}
- while (reader.NextLine()) {
- const char *fullpath = reader.LinePtr();
- if (!reader.NextLine()) {
- return rv;
- }
-
- const char *lastModifiedTimeStamp = reader.LinePtr();
- int64_t lastmod = (vdiff == 0) ? nsCRT::atoll(lastModifiedTimeStamp) : -1;
-
- RefPtr<nsInvalidPluginTag> invalidTag = new nsInvalidPluginTag(fullpath, lastmod);
-
- invalidTag->mNext = mInvalidPlugins;
- if (mInvalidPlugins) {
- mInvalidPlugins->mPrev = invalidTag;
- }
- mInvalidPlugins = invalidTag;
+ const char *lastModifiedTimeStamp = reader.LinePtr();
+ int64_t lastmod = nsCRT::atoll(lastModifiedTimeStamp);
+
+ RefPtr<nsInvalidPluginTag> invalidTag = new nsInvalidPluginTag(fullpath, lastmod);
+
+ invalidTag->mNext = mInvalidPlugins;
+ if (mInvalidPlugins) {
+ mInvalidPlugins->mPrev = invalidTag;
}
+ mInvalidPlugins = invalidTag;
}
#endif
- // flip the pref so we don't import the legacy flags again
- Preferences::SetBool("plugin.importedState", true);
-
return NS_OK;
}
void
nsPluginHost::RemoveCachedPluginsInfo(const char *filePath, nsPluginTag **result)
{
RefPtr<nsPluginTag> prev;
RefPtr<nsPluginTag> tag = mCachedPlugins;