Bug 313700 - Stale information in about:plugins (pluginreg.dat) after a plugin update. r=josh
authorSteven Michaud <smichaud@pobox.com>
Tue, 10 Apr 2012 10:56:49 -0500
changeset 91320 95a886a80f9bee11f1cac4c31f4b49f04ca84719
parent 91319 8a59c745c563f334651d9d896c995e755e84b974
child 91321 b1bed3ae047663cf7431986276ebc2d46cde805a
push id22438
push usermbrubeck@mozilla.com
push dateWed, 11 Apr 2012 15:56:36 +0000
treeherdermozilla-central@63f78a93ae5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs313700
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 313700 - Stale information in about:plugins (pluginreg.dat) after a plugin update. r=josh
dom/plugins/base/nsPluginHost.cpp
xpcom/io/nsILocalFileMac.idl
xpcom/io/nsLocalFileUnix.cpp
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -63,16 +63,19 @@
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIURL.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsIProtocolProxyService.h"
 #include "nsIStreamConverterService.h"
 #include "nsIFile.h"
+#if defined(XP_MACOSX)
+#include "nsILocalFileMac.h"
+#endif
 #include "nsIInputStream.h"
 #include "nsIIOService.h"
 #include "nsIURL.h"
 #include "nsIChannel.h"
 #include "nsISeekableStream.h"
 #include "nsNetUtil.h"
 #include "nsIProgressEventSink.h"
 #include "nsIDocument.h"
@@ -1986,17 +1989,29 @@ nsresult nsPluginHost::ScanPluginsDirect
     nsCOMPtr<nsILocalFile>& localfile = pluginFiles[i];
 
     nsString utf16FilePath;
     rv = localfile->GetPath(utf16FilePath);
     if (NS_FAILED(rv))
       continue;
 
     PRInt64 fileModTime = LL_ZERO;
+#if defined(XP_MACOSX)
+    // On OS X the date of a bundle's "contents" (i.e. of its Info.plist file)
+    // is a much better guide to when it was last modified than the date of
+    // its package directory.  See bug 313700.
+    nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface(localfile);
+    if (localFileMac) {
+      localFileMac->GetBundleContentsLastModifiedTime(&fileModTime);
+    } else {
+      localfile->GetLastModifiedTime(&fileModTime);
+    }
+#else
     localfile->GetLastModifiedTime(&fileModTime);
+#endif
 
     // Look for it in our cache
     NS_ConvertUTF16toUTF8 filePath(utf16FilePath);
     nsRefPtr<nsPluginTag> pluginTag;
     RemoveCachedPluginsInfo(filePath.get(),
                             getter_AddRefs(pluginTag));
 
     bool enabled = true;
--- a/xpcom/io/nsILocalFileMac.idl
+++ b/xpcom/io/nsILocalFileMac.idl
@@ -45,17 +45,17 @@
 %}
 
       native OSType(OSType);
       native FSSpec(FSSpec);
       native FSRef(FSRef);
 [ptr] native FSRefPtr(FSRef);
       native CFURLRef(CFURLRef);
 
-[scriptable, uuid(DE4C75BE-D42B-4F8C-95D9-284C83CF29A4)]
+[scriptable, uuid(E5DE2CC9-BF06-4329-8F91-5D2D45284500)]
 interface nsILocalFileMac : nsILocalFile
 {
    /**
     * initWithCFURL
     *
     * Init this object with a CFURLRef
     *
     * NOTE: Supported only for XP_MACOSX
@@ -188,16 +188,25 @@ interface nsILocalFileMac : nsILocalFile
    readonly attribute AString bundleDisplayName;
 
    /**
     * bundleIdentifier
     *
     * returns the identifier of the bundle
     */
    readonly attribute AUTF8String bundleIdentifier;
+
+    /**
+     * Last modified time of a bundle's contents (as opposed to its package
+     * directory).  Our convention is to make the bundle's Info.plist file
+     * stand in for the rest of its contents -- since this file contains the
+     * bundle's version information and other identifiers.  For non-bundles
+     * this is the same as lastModifiedTime.
+     */
+    readonly attribute PRInt64 bundleContentsLastModifiedTime;
 };
 
 %{C++
 extern "C"
 {
 NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowSymlinks, nsILocalFileMac** result);
 NS_EXPORT nsresult NS_NewLocalFileWithCFURL(const CFURLRef aURL, bool aFollowSymlinks, nsILocalFileMac** result);
 }
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -2435,16 +2435,44 @@ nsLocalFile::GetBundleIdentifier(nsACStr
       ::CFRelease(bundle);
     }
     ::CFRelease(urlRef);
   }
 
   return rv;
 }
 
+NS_IMETHODIMP
+nsLocalFile::GetBundleContentsLastModifiedTime(PRInt64 *aLastModTime)
+{
+  CHECK_mPath();
+  NS_ENSURE_ARG_POINTER(aLastModTime);
+
+  bool isPackage = false;
+  nsresult rv = IsPackage(&isPackage);
+  if (NS_FAILED(rv) || !isPackage) {
+    return GetLastModifiedTime(aLastModTime);
+  }
+
+  nsCAutoString infoPlistPath(mPath);
+  infoPlistPath.AppendLiteral("/Contents/Info.plist");
+  PRFileInfo64 info;
+  if (PR_GetFileInfo64(infoPlistPath.get(), &info) != PR_SUCCESS) {
+    return GetLastModifiedTime(aLastModTime);
+  }
+  PRInt64 modTime = PRInt64(info.modifyTime);
+  if (modTime == 0) {
+    *aLastModTime = 0;
+  } else {
+    *aLastModTime = modTime / PRInt64(PR_USEC_PER_MSEC);
+  }
+
+  return NS_OK;
+}
+
 NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile *aFile)
 {
   NS_ENSURE_ARG(aFile);
 
   nsCAutoString nativePath;
   nsresult rv = aFile->GetNativePath(nativePath);
   if (NS_FAILED(rv))
     return rv;