Bug 1136388. Change nsIDocumentLoaderFactory and nsIURIContentListener to take MIME types as an XPCOM string, not a char*. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 25 Feb 2015 10:26:51 -0500
changeset 230745 d6e3bc0ea63f2f9f6afef366028fd2e8c279bd09
parent 230744 5f1012f39d2ce42dcbfe716ecd51c14722d478f2
child 230746 5db197d838c41b1561582a139162637c3efcefe7
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs1136388
milestone39.0a1
Bug 1136388. Change nsIDocumentLoaderFactory and nsIURIContentListener to take MIME types as an XPCOM string, not a char*. r=smaug
docshell/base/nsDSURIContentListener.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIDocumentLoaderFactory.idl
docshell/base/nsWebNavigationInfo.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsDocument.cpp
image/src/SVGDocumentWrapper.cpp
layout/build/nsContentDLF.cpp
layout/build/nsContentDLF.h
security/manager/ssl/src/PSMContentListener.cpp
uriloader/base/nsIURIContentListener.idl
uriloader/base/nsURILoader.cpp
xpfe/components/directory/nsDirectoryViewer.cpp
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -82,17 +82,17 @@ nsDSURIContentListener::OnStartURIOpen(n
   if (parentListener) {
     return parentListener->OnStartURIOpen(aURI, aAbortOpen);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDSURIContentListener::DoContent(const char* aContentType,
+nsDSURIContentListener::DoContent(const nsACString& aContentType,
                                   bool aIsContentPreferred,
                                   nsIRequest* aRequest,
                                   nsIStreamListener** aContentHandler,
                                   bool* aAbortProcess)
 {
   nsresult rv;
   NS_ENSURE_ARG_POINTER(aContentHandler);
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
@@ -126,17 +126,17 @@ nsDSURIContentListener::DoContent(const 
   // create new viewer since the one we already have is capable of
   // rendering multipart jpeg correctly (see bug 625012)
   nsCOMPtr<nsIChannel> baseChannel;
   if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
     mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
   }
 
   bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
-                 nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
+                 aContentType.EqualsLiteral("image/jpeg");
 
   if (mExistingJPEGStreamListener && reuseCV) {
     nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
     copy.forget(aContentHandler);
     rv = NS_OK;
   } else {
     rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
     if (NS_SUCCEEDED(rv) && reuseCV) {
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -7924,17 +7924,17 @@ nsDocShell::CreateAboutBlankContentViewe
 
   // Now make sure we don't think we're in the middle of firing unload after
   // this point.  This will make us fire unload when the about:blank document
   // unloads... but that's ok, more or less.  Would be nice if it fired load
   // too, of course.
   mFiredUnloadEvent = false;
 
   nsCOMPtr<nsIDocumentLoaderFactory> docFactory =
-    nsContentUtils::FindInternalContentViewer("text/html");
+    nsContentUtils::FindInternalContentViewer(NS_LITERAL_CSTRING("text/html"));
 
   if (docFactory) {
     nsCOMPtr<nsIPrincipal> principal;
     if (mSandboxFlags & SANDBOXED_ORIGIN) {
       principal = nsNullPrincipal::CreateWithInheritedAttributes(aPrincipal);
       NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
     } else {
       principal = aPrincipal;
@@ -8882,17 +8882,17 @@ nsDocShell::RestoreFromHistory()
   if (shell) {
     shell->Thaw();
   }
 
   return privWin->FireDelayedDOMEvents();
 }
 
 nsresult
-nsDocShell::CreateContentViewer(const char* aContentType,
+nsDocShell::CreateContentViewer(const nsACString& aContentType,
                                 nsIRequest* aRequest,
                                 nsIStreamListener** aContentHandler)
 {
   *aContentHandler = nullptr;
 
   // Can we check the content type of the current content viewer
   // and reuse it without destroying it and re-creating it?
 
@@ -9078,17 +9078,17 @@ nsDocShell::CreateContentViewer(const ch
   if (onLocationChangeNeeded) {
     FireOnLocationChange(this, aRequest, mCurrentURI, 0);
   }
 
   return NS_OK;
 }
 
 nsresult
-nsDocShell::NewContentViewerObj(const char* aContentType,
+nsDocShell::NewContentViewerObj(const nsACString& aContentType,
                                 nsIRequest* aRequest, nsILoadGroup* aLoadGroup,
                                 nsIStreamListener** aContentHandler,
                                 nsIContentViewer** aViewer)
 {
   nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
 
   nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
     nsContentUtils::FindInternalContentViewer(aContentType);
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -285,20 +285,20 @@ protected:
 
   // Content Viewer Management
   nsresult EnsureContentViewer();
   // aPrincipal can be passed in if the caller wants.  If null is
   // passed in, the about:blank principal will end up being used.
   nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
                                          nsIURI* aBaseURI,
                                          bool aTryToSaveOldPresentation = true);
-  nsresult CreateContentViewer(const char* aContentType,
+  nsresult CreateContentViewer(const nsACString& aContentType,
                                nsIRequest* aRequest,
                                nsIStreamListener** aContentHandler);
-  nsresult NewContentViewerObj(const char* aContentType,
+  nsresult NewContentViewerObj(const nsACString& aContentType,
                                nsIRequest* aRequest, nsILoadGroup* aLoadGroup,
                                nsIStreamListener** aContentHandler,
                                nsIContentViewer** aViewer);
   nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
 
   void SetupReferrerFromChannel(nsIChannel* aChannel);
 
   nsresult GetEldestPresContext(nsPresContext** aPresContext);
--- a/docshell/base/nsIDocumentLoaderFactory.idl
+++ b/docshell/base/nsIDocumentLoaderFactory.idl
@@ -17,22 +17,22 @@ interface nsIPrincipal;
 /**
  * To get a component that implements nsIDocumentLoaderFactory
  * for a given mimetype, use nsICategoryManager to find an entry
  * with the mimetype as its name in the category "Gecko-Content-Viewers".
  * The value of the entry is the contractid of the component.
  * The component is a service, so use GetService, not CreateInstance to get it.
  */
 
-[scriptable, uuid(70905274-8494-4e39-b011-d559adde3733)]
+[scriptable, uuid(e795239e-9d3c-47c4-b063-9e600fb3b287)]
 interface nsIDocumentLoaderFactory : nsISupports {
     nsIContentViewer createInstance(in string aCommand,
                               in nsIChannel aChannel,
                               in nsILoadGroup aLoadGroup,
-                              in string aContentType, 
+                              in ACString aContentType, 
                               in nsIDocShell aContainer,
                               in nsISupports aExtraInfo,
                               out nsIStreamListener aDocListenerResult);
 
     nsIContentViewer createInstanceForDocument(in nsISupports aContainer,
                                          in nsIDocument aDocument,
                                          in string aCommand);
 
--- a/docshell/base/nsWebNavigationInfo.cpp
+++ b/docshell/base/nsWebNavigationInfo.cpp
@@ -84,17 +84,17 @@ nsresult
 nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
                                              uint32_t* aIsSupported)
 {
   NS_PRECONDITION(aIsSupported, "Null out param?");
 
   nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
 
   nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
-    nsContentUtils::FindInternalContentViewer(aType.get(), &vtype);
+    nsContentUtils::FindInternalContentViewer(aType, &vtype);
 
   switch (vtype) {
     case nsContentUtils::TYPE_UNSUPPORTED:
       *aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
       break;
 
     case nsContentUtils::TYPE_PLUGIN:
       *aIsSupported = nsIWebNavigationInfo::PLUGIN;
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6401,46 +6401,48 @@ nsContentUtils::AllowXULXBLForPrincipal(
   aPrincipal->GetURI(getter_AddRefs(princURI));
   
   return princURI &&
          ((sAllowXULXBL_for_file && SchemeIs(princURI, "file")) ||
           IsSitePermAllow(aPrincipal, "allowXULXBL"));
 }
 
 already_AddRefed<nsIDocumentLoaderFactory>
-nsContentUtils::FindInternalContentViewer(const char* aType,
+nsContentUtils::FindInternalContentViewer(const nsACString& aType,
                                           ContentViewerType* aLoaderType)
 {
   if (aLoaderType) {
     *aLoaderType = TYPE_UNSUPPORTED;
   }
 
   // one helper factory, please
   nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
   if (!catMan)
     return nullptr;
 
   nsCOMPtr<nsIDocumentLoaderFactory> docFactory;
 
   nsXPIDLCString contractID;
-  nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", aType, getter_Copies(contractID));
+  nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers",
+                                         PromiseFlatCString(aType).get(),
+                                         getter_Copies(contractID));
   if (NS_SUCCEEDED(rv)) {
     docFactory = do_GetService(contractID);
     if (docFactory && aLoaderType) {
       if (contractID.EqualsLiteral(CONTENT_DLF_CONTRACTID))
         *aLoaderType = TYPE_CONTENT;
       else if (contractID.EqualsLiteral(PLUGIN_DLF_CONTRACTID))
         *aLoaderType = TYPE_PLUGIN;
       else
       *aLoaderType = TYPE_UNKNOWN;
     }
     return docFactory.forget();
   }
 
-  if (DecoderTraits::IsSupportedInVideoDocument(nsDependentCString(aType))) {
+  if (DecoderTraits::IsSupportedInVideoDocument(aType)) {
     docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
     if (docFactory && aLoaderType) {
       *aLoaderType = TYPE_CONTENT;
     }
     return docFactory.forget();
   }
 
   return nullptr;
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2015,17 +2015,17 @@ public:
   {
       TYPE_UNSUPPORTED,
       TYPE_CONTENT,
       TYPE_PLUGIN,
       TYPE_UNKNOWN
   };
 
   static already_AddRefed<nsIDocumentLoaderFactory>
-  FindInternalContentViewer(const char* aType,
+  FindInternalContentViewer(const nsACString& aType,
                             ContentViewerType* aLoaderType = nullptr);
 
   /**
    * This helper method returns true if the aPattern pattern matches aValue.
    * aPattern should not contain leading and trailing slashes (/).
    * The pattern has to match the entire value not just a subset.
    * aDocument must be a valid pointer (not null).
    *
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1238,17 +1238,17 @@ nsExternalResourceMap::PendingLoad::Setu
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
     do_GetService(contractId);
   NS_ENSURE_TRUE(docLoaderFactory, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIContentViewer> viewer;
   nsCOMPtr<nsIStreamListener> listener;
   rv = docLoaderFactory->CreateInstance("external-resource", chan, newLoadGroup,
-                                        type.get(), nullptr, nullptr,
+                                        type, nullptr, nullptr,
                                         getter_AddRefs(listener),
                                         getter_AddRefs(viewer));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(viewer, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIParser> parser = do_QueryInterface(listener);
   if (!parser) {
     /// We don't want to deal with the various fake documents yet
--- a/image/src/SVGDocumentWrapper.cpp
+++ b/image/src/SVGDocumentWrapper.cpp
@@ -315,17 +315,18 @@ SVGDocumentWrapper::SetupViewer(nsIReque
   nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
     do_GetService(contractId);
   NS_ENSURE_TRUE(docLoaderFactory, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIContentViewer> viewer;
   nsCOMPtr<nsIStreamListener> listener;
   rv = docLoaderFactory->CreateInstance("external-resource", chan,
                                         newLoadGroup,
-                                        IMAGE_SVG_XML, nullptr, nullptr,
+                                        NS_LITERAL_CSTRING(IMAGE_SVG_XML),
+                                        nullptr, nullptr,
                                         getter_AddRefs(listener),
                                         getter_AddRefs(viewer));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_TRUE(viewer, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIParser> parser = do_QueryInterface(listener);
   NS_ENSURE_TRUE(parser, NS_ERROR_UNEXPECTED);
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -128,37 +128,36 @@ MayUseXULXBL(nsIChannel* aChannel)
 
   return nsContentUtils::AllowXULXBLForPrincipal(principal);
 }
 
 NS_IMETHODIMP
 nsContentDLF::CreateInstance(const char* aCommand,
                              nsIChannel* aChannel,
                              nsILoadGroup* aLoadGroup,
-                             const char* aContentType, 
+                             const nsACString& aContentType, 
                              nsIDocShell* aContainer,
                              nsISupports* aExtraInfo,
                              nsIStreamListener** aDocListener,
                              nsIContentViewer** aDocViewer)
 {
-  // Declare "type" here.  This is because although the variable itself only
-  // needs limited scope, we need to use the raw string memory -- as returned
-  // by "type.get()" farther down in the function.
-  nsAutoCString type;
+  // Make a copy of aContentType, because we're possibly going to change it.
+  nsAutoCString contentType(aContentType);
 
   // Are we viewing source?
   nsCOMPtr<nsIViewSourceChannel> viewSourceChannel = do_QueryInterface(aChannel);
   if (viewSourceChannel)
   {
     aCommand = "view-source";
 
     // The parser freaks out when it sees the content-type that a
     // view-source channel normally returns.  Get the actual content
     // type of the data.  If it's known, use it; otherwise use
     // text/plain.
+    nsAutoCString type;
     viewSourceChannel->GetOriginalContentType(type);
     bool knownType = false;
     int32_t typeIndex;
     for (typeIndex = 0; gHTMLTypes[typeIndex] && !knownType; ++typeIndex) {
       if (type.Equals(gHTMLTypes[typeIndex]) &&
           !type.EqualsLiteral(VIEWSOURCE_CONTENT_TYPE)) {
         knownType = true;
       }
@@ -182,91 +181,89 @@ nsContentDLF::CreateInstance(const char*
       }
     }
 
     if (knownType) {
       viewSourceChannel->SetContentType(type);
     } else if (IsImageContentType(type.get())) {
       // If it's an image, we want to display it the same way we normally would.
       // Also note the lifetime of "type" allows us to safely use "get()" here.
-      aContentType = type.get();
+      contentType = type;
     } else {
       viewSourceChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN));
     }
-  } else if (0 == PL_strcmp(VIEWSOURCE_CONTENT_TYPE, aContentType)) {
+  } else if (aContentType.EqualsLiteral(VIEWSOURCE_CONTENT_TYPE)) {
     aChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN));
-    aContentType = TEXT_PLAIN;
+    contentType = TEXT_PLAIN;
   }
   // Try html
   int typeIndex=0;
   while(gHTMLTypes[typeIndex]) {
-    if (0 == PL_strcmp(gHTMLTypes[typeIndex++], aContentType)) {
+    if (contentType.EqualsASCII(gHTMLTypes[typeIndex++])) {
       return CreateDocument(aCommand, 
                             aChannel, aLoadGroup,
                             aContainer, kHTMLDocumentCID,
                             aDocListener, aDocViewer);
     }
   }
 
   // Try XML
   typeIndex = 0;
   while(gXMLTypes[typeIndex]) {
-    if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) {
+    if (contentType.EqualsASCII(gXMLTypes[typeIndex++])) {
       return CreateDocument(aCommand, 
                             aChannel, aLoadGroup,
                             aContainer, kXMLDocumentCID,
                             aDocListener, aDocViewer);
     }
   }
 
   // Try SVG
   typeIndex = 0;
   while(gSVGTypes[typeIndex]) {
-    if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
+    if (contentType.EqualsASCII(gSVGTypes[typeIndex++])) {
       return CreateDocument(aCommand,
                             aChannel, aLoadGroup,
                             aContainer, kSVGDocumentCID,
                             aDocListener, aDocViewer);
     }
   }
 
   // Try XUL
   typeIndex = 0;
   while (gXULTypes[typeIndex]) {
-    if (0 == PL_strcmp(gXULTypes[typeIndex++], aContentType)) {
+    if (contentType.EqualsASCII(gXULTypes[typeIndex++])) {
       if (!MayUseXULXBL(aChannel)) {
         return NS_ERROR_REMOTE_XUL;
       }
 
-      return CreateXULDocument(aCommand,
-                               aChannel, aLoadGroup,
-                               aContentType, aContainer,
+      return CreateXULDocument(aCommand, aChannel, aLoadGroup, aContainer,
                                aExtraInfo, aDocListener, aDocViewer);
     }
   }
 
-  if (mozilla::DecoderTraits::ShouldHandleMediaType(aContentType)) {
+  if (mozilla::DecoderTraits::ShouldHandleMediaType(contentType.get())) {
     return CreateDocument(aCommand, 
                           aChannel, aLoadGroup,
                           aContainer, kVideoDocumentCID,
                           aDocListener, aDocViewer);
   }  
 
   // Try image types
-  if (IsImageContentType(aContentType)) {
+  if (IsImageContentType(contentType.get())) {
     return CreateDocument(aCommand, 
                           aChannel, aLoadGroup,
                           aContainer, kImageDocumentCID,
                           aDocListener, aDocViewer);
   }
 
   nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
   nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
   if(pluginHost &&
-     pluginHost->PluginExistsForType(aContentType)) {
+     pluginHost->PluginExistsForType(contentType.get())) {
     return CreateDocument(aCommand,
                           aChannel, aLoadGroup,
                           aContainer, kPluginDocumentCID,
                           aDocListener, aDocViewer);
   }
 
   // If we get here, then we weren't able to create anything. Sorry!
   return NS_ERROR_FAILURE;
@@ -409,17 +406,16 @@ nsContentDLF::CreateDocument(const char*
   contentViewer.forget(aContentViewer);
   return NS_OK;
 }
 
 nsresult
 nsContentDLF::CreateXULDocument(const char* aCommand,
                                 nsIChannel* aChannel,
                                 nsILoadGroup* aLoadGroup,
-                                const char* aContentType,
                                 nsIDocShell* aContainer,
                                 nsISupports* aExtraInfo,
                                 nsIStreamListener** aDocListener,
                                 nsIContentViewer** aContentViewer)
 {
   nsresult rv;
   nsCOMPtr<nsIDocument> doc = do_CreateInstance(kXULDocumentCID, &rv);
   if (NS_FAILED(rv)) return rv;
--- a/layout/build/nsContentDLF.h
+++ b/layout/build/nsContentDLF.h
@@ -38,17 +38,16 @@ public:
                           nsIDocShell* aContainer,
                           const nsCID& aDocumentCID,
                           nsIStreamListener** aDocListener,
                           nsIContentViewer** aContentViewer);
 
   nsresult CreateXULDocument(const char* aCommand,
                              nsIChannel* aChannel,
                              nsILoadGroup* aLoadGroup,
-                             const char* aContentType,
                              nsIDocShell* aContainer,
                              nsISupports* aExtraInfo,
                              nsIStreamListener** aDocListener,
                              nsIContentViewer** aContentViewer);
 
 private:
   static nsresult EnsureUAStyleSheet();
   static bool IsImageContentType(const char* aContentType);
--- a/security/manager/ssl/src/PSMContentListener.cpp
+++ b/security/manager/ssl/src/PSMContentListener.cpp
@@ -259,25 +259,25 @@ PSMContentListener::CanHandleContent(con
     *aCanHandleContent = false;
   } else {
     *aCanHandleContent = true;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PSMContentListener::DoContent(const char * aContentType,
+PSMContentListener::DoContent(const nsACString & aContentType,
                                bool aIsContentPreferred,
                                nsIRequest * aRequest,
                                nsIStreamListener ** aContentHandler,
                                bool * aAbortProcess)
 {
   PSMContentDownloader *downLoader;
   uint32_t type;
-  type = getPSMContentType(aContentType);
+  type = getPSMContentType(PromiseFlatCString(aContentType).get());
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("PSMContentListener::DoContent\n"));
   if (type != PSMContentDownloader::UNKNOWN_TYPE) {
     downLoader = new PSMContentDownloader(type);
     if (downLoader) {
       downLoader->QueryInterface(NS_GET_IID(nsIStreamListener), 
                                             (void **)aContentHandler);
       return NS_OK;
     }
--- a/uriloader/base/nsIURIContentListener.idl
+++ b/uriloader/base/nsIURIContentListener.idl
@@ -11,17 +11,17 @@ interface nsIURI;
 
 /**
  * nsIURIContentListener is an interface used by components which
  * want to know (and have a chance to handle) a particular content type.
  * Typical usage scenarios will include running applications which register
  * a nsIURIContentListener for each of its content windows with the uri
  * dispatcher service. 
  */
-[scriptable, uuid(94928AB3-8B63-11d3-989D-001083010E9B)]
+[scriptable, uuid(10a28f38-32e8-4c63-8aa1-12eaaebc369a)]
 interface nsIURIContentListener : nsISupports
 {
  /**
   * Gives the original content listener first crack at stopping a load before
   * it happens.
   *
   * @param aURI   URI that is being opened.
   *
@@ -47,17 +47,17 @@ interface nsIURIContentListener : nsISup
   * @return                     <code>true</code> if the load should
   *                             be aborted and consumer wants to
   *                             handle the load completely by itself.  This
   *                             causes the URI Loader do nothing else...
   *                             <code>false</code> if the URI Loader should
   *                             continue handling the load and call the
   *                             returned streamlistener's methods. 
   */
-  boolean doContent(in string aContentType,
+  boolean doContent(in ACString aContentType,
                     in boolean aIsContentPreferred,
                     in nsIRequest aRequest,
                     out nsIStreamListener aContentHandler);
 
  /**
   * When given a uri to dispatch, if the URI is specified as 'preferred 
   * content' then the uri loader tries to find a preferred content handler
   * for the content type. The thought is that many content listeners may
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -718,17 +718,17 @@ nsDocumentOpenInfo::TryContentListener(n
     do_GetInterface(m_originalContext);
   if (originalListener != aListener) {
     newLoadFlags |= nsIChannel::LOAD_RETARGETED_DOCUMENT_URI;
   }
   aChannel->SetLoadFlags(loadFlags | newLoadFlags);
   
   bool abort = false;
   bool isPreferred = (mFlags & nsIURILoader::IS_CONTENT_PREFERRED) != 0;
-  nsresult rv = aListener->DoContent(mContentType.get(),
+  nsresult rv = aListener->DoContent(mContentType,
                                      isPreferred,
                                      aChannel,
                                      getter_AddRefs(m_targetStreamListener),
                                      &abort);
     
   if (NS_FAILED(rv)) {
     LOG_ERROR(("  DoContent failed"));
     
--- a/xpfe/components/directory/nsDirectoryViewer.cpp
+++ b/xpfe/components/directory/nsDirectoryViewer.cpp
@@ -1258,25 +1258,26 @@ nsDirectoryViewerFactory::~nsDirectoryVi
 NS_IMPL_ISUPPORTS(nsDirectoryViewerFactory, nsIDocumentLoaderFactory)
 
 
 
 NS_IMETHODIMP
 nsDirectoryViewerFactory::CreateInstance(const char *aCommand,
                                          nsIChannel* aChannel,
                                          nsILoadGroup* aLoadGroup,
-                                         const char* aContentType, 
+                                         const nsACString& aContentType, 
                                          nsIDocShell* aContainer,
                                          nsISupports* aExtraInfo,
                                          nsIStreamListener** aDocListenerResult,
                                          nsIContentViewer** aDocViewerResult)
 {
   nsresult rv;
 
-  bool viewSource = aContentType && strstr(aContentType, "view-source");
+  bool viewSource = FindInReadable(NS_LITERAL_CSTRING("view-source"),
+                                   aContentType);
 
   if (!viewSource &&
       Preferences::GetInt("network.dir.format", FORMAT_XUL) == FORMAT_XUL) {
     // ... and setup the original channel's content type
     (void)aChannel->SetContentType(NS_LITERAL_CSTRING("application/vnd.mozilla.xul+xml"));
 
     // This is where we shunt the HTTP/Index stream into our datasource,
     // and open the directory viewer XUL file as the content stream to
@@ -1304,17 +1305,18 @@ nsDirectoryViewerFactory::CreateInstance
                        uri,
                        nsContentUtils::GetSystemPrincipal(),
                        nsILoadInfo::SEC_NORMAL,
                        nsIContentPolicy::TYPE_OTHER,
                        aLoadGroup);
     if (NS_FAILED(rv)) return rv;
     
     nsCOMPtr<nsIStreamListener> listener;
-    rv = factory->CreateInstance(aCommand, channel, aLoadGroup, "application/vnd.mozilla.xul+xml",
+    rv = factory->CreateInstance(aCommand, channel, aLoadGroup,
+                                 NS_LITERAL_CSTRING("application/vnd.mozilla.xul+xml"),
                                  aContainer, aExtraInfo, getter_AddRefs(listener),
                                  aDocViewerResult);
     if (NS_FAILED(rv)) return rv;
 
     rv = channel->AsyncOpen(listener, nullptr);
     if (NS_FAILED(rv)) return rv;
     
     // Create an HTTPIndex object so that we can stuff it into the script context
@@ -1352,21 +1354,23 @@ nsDirectoryViewerFactory::CreateInstance
     return rv;
 
   nsCOMPtr<nsIDocumentLoaderFactory> factory(do_GetService(contractID, &rv));
   if (NS_FAILED(rv)) return rv;
   
   nsCOMPtr<nsIStreamListener> listener;
 
   if (viewSource) {
-    rv = factory->CreateInstance("view-source", aChannel, aLoadGroup, "text/html; x-view-type=view-source",
+    rv = factory->CreateInstance("view-source", aChannel, aLoadGroup,
+                                 NS_LITERAL_CSTRING("text/html; x-view-type=view-source"),
                                  aContainer, aExtraInfo, getter_AddRefs(listener),
                                  aDocViewerResult);
   } else {
-    rv = factory->CreateInstance("view", aChannel, aLoadGroup, "text/html",
+    rv = factory->CreateInstance("view", aChannel, aLoadGroup,
+                                 NS_LITERAL_CSTRING("text/html"),
                                  aContainer, aExtraInfo, getter_AddRefs(listener),
                                  aDocViewerResult);
   }
 
   if (NS_FAILED(rv)) return rv;
 
   nsCOMPtr<nsIStreamConverterService> scs = do_GetService("@mozilla.org/streamConverters;1", &rv);
   if (NS_FAILED(rv)) return rv;