Bug 1622042 - Refactor nsContentutils::isjpdfjs r=ckerschb
authorSebastian Streich <sstreich@mozilla.com>
Thu, 26 Mar 2020 13:20:40 +0000
changeset 520555 754ef19255961ef35d4b7155882fe6a49026e00d
parent 520554 9fb3f7cd8f275e9b82c01d292aab5ca34237f05d
child 520556 8c01b88853e7d95d53db55341eaf46354812e0f2
push id37253
push usernerli@mozilla.com
push dateThu, 26 Mar 2020 21:36:52 +0000
treeherdermozilla-central@c644dd16e2cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1622042
milestone76.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 1622042 - Refactor nsContentutils::isjpdfjs r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D66635
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6387,20 +6387,20 @@ bool nsContentUtils::IsPDFJSEnabled() {
       "@mozilla.org/streamconv;1?from=application/pdf&to=text/html");
   return conv;
 }
 
 bool nsContentUtils::IsPDFJS(nsIPrincipal* aPrincipal) {
   if (!aPrincipal) {
     return false;
   }
-  nsCOMPtr<nsIURI> uri;
-  aPrincipal->GetURI(getter_AddRefs(uri));
-  return uri && uri->GetSpecOrDefault().EqualsLiteral(
-                    "resource://pdf.js/web/viewer.html");
+  nsAutoCString spec;
+  nsresult rv = aPrincipal->GetAsciiSpec(spec);
+  NS_ENSURE_SUCCESS(rv, false);
+  return spec.EqualsLiteral("resource://pdf.js/web/viewer.html");
 }
 
 already_AddRefed<nsIDocumentLoaderFactory>
 nsContentUtils::FindInternalContentViewer(const nsACString& aType,
                                           ContentViewerType* aLoaderType) {
   if (aLoaderType) {
     *aLoaderType = TYPE_UNSUPPORTED;
   }