Bug 633463: Never scan old XPCOM/OJI Java plugin directory. r=jmathies a=blocking2.0betaN+
authorJosh Aas <joshmoz@gmail.com>
Thu, 17 Feb 2011 03:45:20 -0500
changeset 62749 7f8e4c2ca53f2c51b26226f9153f52123e9120fa
parent 62748 1c61363cc39ff56bc72b7f59286291ea7b1d45ee
child 62750 e66fc103a55eb1781c529302fd494f11cc42df28
push idunknown
push userunknown
push dateunknown
reviewersjmathies, blocking2.0betaN
bugs633463
milestone2.0b12pre
Bug 633463: Never scan old XPCOM/OJI Java plugin directory. r=jmathies a=blocking2.0betaN+
modules/plugin/base/src/nsPluginDirServiceProvider.cpp
--- a/modules/plugin/base/src/nsPluginDirServiceProvider.cpp
+++ b/modules/plugin/base/src/nsPluginDirServiceProvider.cpp
@@ -302,17 +302,16 @@ nsPluginDirServiceProvider::GetFile(cons
     verBlock maxVer;
     ClearVersion(&maxVer);
     WCHAR curKey[_MAX_PATH] = L"Software\\JavaSoft\\Java Runtime Environment";
     WCHAR path[_MAX_PATH];
     // Add + 15 to prevent buffer overrun when adding \bin (+ optionally
     // \new_plugin)
 #define JAVA_PATH_SIZE _MAX_PATH + 15
     WCHAR newestPath[JAVA_PATH_SIZE];
-    const WCHAR mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla";
     WCHAR browserJavaVersion[_MAX_PATH];
 
     newestPath[0] = 0;
     LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ,
                                   &baseloc);
     if (ERROR_SUCCESS != result)
       return NS_ERROR_FAILURE;
 
@@ -366,58 +365,41 @@ nsPluginDirServiceProvider::GetFile(cons
           }
           ::RegCloseKey(keyloc);
         }
       }
     } while (ERROR_SUCCESS == result);
 
     ::RegCloseKey(baseloc);
 
-    static const WCHAR kMozillaVersion[] = NS_L(MOZILLA_VERSION);
+    if (newestPath[0] == 0) {
+      return NS_ERROR_FAILURE;
+    }
 
-    // If nothing is found, then don't add \bin dir and don't set
-    // CurrentVersion for Mozilla
-    if (newestPath[0] != 0) {
+    // We require the newer NPAPI Java plugin.
+    wcscat(newestPath, L"\\bin\\new_plugin");
+
+    rv = NS_NewLocalFile(nsDependentString(newestPath),
+                         PR_TRUE, getter_AddRefs(localFile));
+
+    if (NS_SUCCEEDED(rv)) {
+      const WCHAR mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla";
       if (ERROR_SUCCESS == ::RegCreateKeyExW(HKEY_LOCAL_MACHINE, mozPath, 0,
                                              NULL, REG_OPTION_NON_VOLATILE,
                                              KEY_SET_VALUE|KEY_QUERY_VALUE,
                                              NULL, &entryloc, NULL)) {
         if (ERROR_SUCCESS != ::RegQueryValueExW(entryloc, L"CurrentVersion", 0,
-                                               NULL, NULL, NULL)) {
+                                                NULL, NULL, NULL)) {
+          static const WCHAR kMozillaVersion[] = NS_L(MOZILLA_VERSION);
           ::RegSetValueExW(entryloc, L"CurrentVersion", 0, REG_SZ,
                            (const BYTE*) kMozillaVersion,
                            NS_ARRAY_LENGTH(kMozillaVersion));
         }
         ::RegCloseKey(entryloc);
       }
-
-      wcscat(newestPath, L"\\bin");
-
-      // See whether the "new_plugin" directory exists
-      WCHAR tmpPath[JAVA_PATH_SIZE];
-      nsCOMPtr<nsILocalFile> tmpFile;
-
-      wcscpy(tmpPath, newestPath);
-      wcscat(tmpPath, L"\\new_plugin");
-      rv = NS_NewLocalFile(nsDependentString(tmpPath),
-                           PR_TRUE, getter_AddRefs(tmpFile));
-      if (NS_SUCCEEDED(rv) && tmpFile) {
-        PRBool exists = PR_FALSE;
-        PRBool isDir = PR_FALSE;
-        if (NS_SUCCEEDED(tmpFile->Exists(&exists)) && exists &&
-            NS_SUCCEEDED(tmpFile->IsDirectory(&isDir)) && isDir) {
-          // Assume we're supposed to use this as the search
-          // directory for the Java Plug-In instead of the normal
-          // one
-          wcscpy(newestPath, tmpPath);
-        }
-      }
-
-      rv = NS_NewLocalFile(nsDependentString(newestPath),
-                           PR_TRUE, getter_AddRefs(localFile));
     }
   } else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
     nsXPIDLCString strVer;
     if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
       return NS_ERROR_FAILURE;
     verBlock minVer;
     TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);