Backed out changeset e9d391fdf0be (bug 1179262) a=backout
authorWes Kocher <wkocher@mozilla.com>
Wed, 05 Aug 2015 21:21:57 -0700
changeset 281807 e25ebb70a80f4f31920461ea8482f219082ee4d0
parent 281806 5c3a30a76af9922d12ec9296a5af15fff6e69c4b
child 281808 6b7f6fdb97f0873b6e860fee8f226a99ecf6a686
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1179262
milestone41.0a2
backs oute9d391fdf0bee5881aa77a7ce1f5465ecbb40118
Backed out changeset e9d391fdf0be (bug 1179262) a=backout
browser/extensions/pdfjs/content/PdfJs.jsm
browser/extensions/pdfjs/content/PdfStreamConverter.jsm
docshell/base/nsWebNavigationInfo.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsObjectLoadingContent.cpp
--- a/browser/extensions/pdfjs/content/PdfJs.jsm
+++ b/browser/extensions/pdfjs/content/PdfJs.jsm
@@ -122,30 +122,21 @@ Factory.prototype = {
     this._classID = proto.classID;
 
     var factory = XPCOMUtils._getFactory(targetConstructor);
     this._factory = factory;
 
     var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
     registrar.registerFactory(proto.classID, proto.classDescription,
                               proto.contractID, factory);
-
-    if (proto.classID2) {
-      this._classID2 = proto.classID2;
-      registrar.registerFactory(proto.classID2, proto.classDescription,
-                                proto.contractID2, factory);
-    }
   },
 
   unregister: function unregister() {
     var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
     registrar.unregisterFactory(this._classID, this._factory);
-    if (this._classID2) {
-      registrar.unregisterFactory(this._classID2, this._factory);
-    }
     this._factory = null;
   }
 };
 
 let PdfJs = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
   _registered: false,
   _initialized: false,
@@ -324,23 +315,36 @@ let PdfJs = {
   _ensureRegistered: function _ensureRegistered() {
     if (this._registered) {
       return;
     }
     this._pdfStreamConverterFactory = new Factory();
     Cu.import('resource://pdf.js/PdfStreamConverter.jsm');
     this._pdfStreamConverterFactory.register(PdfStreamConverter);
 
+    this._pdfRedirectorFactory = new Factory();
+    Cu.import('resource://pdf.js/PdfRedirector.jsm');
+    this._pdfRedirectorFactory.register(PdfRedirector);
+
+    Svc.pluginHost.registerPlayPreviewMimeType(PDF_CONTENT_TYPE, true,
+      'data:application/x-moz-playpreview-pdfjs;,');
+
     this._registered = true;
   },
 
   _ensureUnregistered: function _ensureUnregistered() {
     if (!this._registered) {
       return;
     }
     this._pdfStreamConverterFactory.unregister();
     Cu.unload('resource://pdf.js/PdfStreamConverter.jsm');
     delete this._pdfStreamConverterFactory;
 
+    this._pdfRedirectorFactory.unregister();
+    Cu.unload('resource://pdf.js/PdfRedirector.jsm');
+    delete this._pdfRedirectorFactory;
+
+    Svc.pluginHost.unregisterPlayPreviewMimeType(PDF_CONTENT_TYPE);
+
     this._registered = false;
   }
 };
 
--- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
+++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
@@ -808,19 +808,16 @@ function PdfStreamConverter() {
 
 PdfStreamConverter.prototype = {
 
   // properties required for XPCOM registration:
   classID: Components.ID('{d0c5195d-e798-49d4-b1d3-9324328b2291}'),
   classDescription: 'pdf.js Component',
   contractID: '@mozilla.org/streamconv;1?from=application/pdf&to=*/*',
 
-  classID2: Components.ID('{d0c5195d-e798-49d4-b1d3-9324328b2292}'),
-  contractID2: '@mozilla.org/streamconv;1?from=application/pdf&to=text/html',
-
   QueryInterface: XPCOMUtils.generateQI([
       Ci.nsISupports,
       Ci.nsIStreamConverter,
       Ci.nsIStreamListener,
       Ci.nsIRequestObserver
   ]),
 
   /*
--- a/docshell/base/nsWebNavigationInfo.cpp
+++ b/docshell/base/nsWebNavigationInfo.cpp
@@ -39,23 +39,16 @@ nsWebNavigationInfo::IsTypeSupported(con
   // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
   // an nsSHistory, but not much we can do with that).  So if we start using
   // it here, we need to be careful to get to the docshell correctly.
 
   // For now just report what the Gecko-Content-Viewers category has
   // to say for itself.
   *aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;
 
-  // We want to claim that the type for PDF documents is unsupported,
-  // so that the internal PDF viewer's stream converted will get used.
-  if (aType.LowerCaseEqualsLiteral("application/pdf") &&
-      nsContentUtils::IsPDFJSEnabled()) {
-    return NS_OK;
-  }
-
   const nsCString& flatType = PromiseFlatCString(aType);
   nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (*aIsTypeSupported) {
     return rv;
   }
 
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -147,17 +147,16 @@
 #include "nsIPluginHost.h"
 #include "nsIRequest.h"
 #include "nsIRunnable.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptError.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsIStreamConverterService.h"
 #include "nsIStringBundle.h"
 #include "nsIURI.h"
 #include "nsIURL.h"
 #include "nsIWebNavigation.h"
 #include "nsIWordBreaker.h"
 #include "nsIXPConnect.h"
 #include "nsJSUtils.h"
 #include "nsLWBrkCIID.h"
@@ -6496,30 +6495,16 @@ nsContentUtils::AllowXULXBLForPrincipal(
   nsCOMPtr<nsIURI> princURI;
   aPrincipal->GetURI(getter_AddRefs(princURI));
   
   return princURI &&
          ((sAllowXULXBL_for_file && SchemeIs(princURI, "file")) ||
           IsSitePermAllow(aPrincipal, "allowXULXBL"));
 }
 
-bool
-nsContentUtils::IsPDFJSEnabled()
-{
-   nsCOMPtr<nsIStreamConverterService> convServ =
-     do_GetService("@mozilla.org/streamConverters;1");
-   nsresult rv = NS_ERROR_FAILURE;
-   bool canConvert = false;
-   if (convServ) {
-     rv = convServ->CanConvert("application/pdf", "text/html", &canConvert);
-   }
-   return NS_SUCCEEDED(rv) && canConvert;
-}
-
-
 already_AddRefed<nsIDocumentLoaderFactory>
 nsContentUtils::FindInternalContentViewer(const nsACString& aType,
                                           ContentViewerType* aLoaderType)
 {
   if (aLoaderType) {
     *aLoaderType = TYPE_UNSUPPORTED;
   }
 
@@ -7932,9 +7917,9 @@ nsContentUtils::SetFetchReferrerURIWithP
   }
 
   if (!referrerURI) {
     referrerURI = principalURI;
   }
 
   net::ReferrerPolicy referrerPolicy = aDoc->GetReferrerPolicy();
   return aChannel->SetReferrerWithPolicy(referrerURI, referrerPolicy);
-}
+}
\ No newline at end of file
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2065,21 +2065,16 @@ public:
    */
   static bool AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal);
 
   /**
    * Perform cleanup that's appropriate for XPCOM shutdown.
    */
   static void XPCOMShutdown();
 
-  /**
-   * Checks if internal PDF viewer is enabled.
-   */
-  static bool IsPDFJSEnabled();
-
   enum ContentViewerType
   {
       TYPE_UNSUPPORTED,
       TYPE_CONTENT,
       TYPE_PLUGIN,
       TYPE_UNKNOWN
   };
 
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -547,21 +547,16 @@ IsPluginEnabledByExtension(nsIURI* uri, 
 {
   nsAutoCString ext;
   GetExtensionFromURI(uri, ext);
 
   if (ext.IsEmpty()) {
     return false;
   }
 
-  // Disables any native PDF plugins, when internal PDF viewer is enabled.
-  if (ext.EqualsIgnoreCase("pdf") && nsContentUtils::IsPDFJSEnabled()) {
-    return false;
-  }
-
   nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
 
   if (!pluginHost) {
     NS_NOTREACHED("No pluginhost");
     return false;
   }
 
   return pluginHost->HavePluginForExtension(ext, mimeType);
@@ -2672,23 +2667,16 @@ nsObjectLoadingContent::GetTypeOfContent
   }
 
   uint32_t caps = GetCapabilities();
 
   if ((caps & eSupportImages) && IsSupportedImage(aMIMEType)) {
     return eType_Image;
   }
 
-  // Faking support of the PDF content as a document for EMBED tags
-  // when internal PDF viewer is enabled.
-  if (aMIMEType.LowerCaseEqualsLiteral("application/pdf") &&
-      nsContentUtils::IsPDFJSEnabled()) {
-    return eType_Document;
-  }
-
   // SVGs load as documents, but are their own capability
   bool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml");
   Capabilities supportType = isSVG ? eSupportSVG : eSupportDocuments;
   if ((caps & supportType) && IsSupportedDocument(aMIMEType)) {
     return eType_Document;
   }
 
   nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();