Bug 822846 - Use nsMimeTypes.h instead of working with literal strings in imagelib. r=joe
authorSeth Fowler <seth@mozilla.com>
Tue, 08 Jan 2013 13:40:47 -0800
changeset 118537 1b5445f3ff22e1f64ac68d3e64937caa9dd32508
parent 118536 47260562baa510ef8f0a48c8d60eef2a231b4bf9
child 118538 d30114b63097b1505982944025c1ccd1b05a3c2b
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjoe
bugs822846
milestone21.0a1
Bug 822846 - Use nsMimeTypes.h instead of working with literal strings in imagelib. r=joe
image/build/nsImageModule.cpp
image/decoders/icon/android/nsIconChannel.cpp
image/decoders/icon/gtk/nsIconChannel.cpp
image/decoders/icon/mac/nsIconChannelCocoa.mm
image/decoders/icon/os2/nsIconChannel.cpp
image/decoders/icon/qt/nsIconChannel.cpp
image/decoders/icon/win/nsIconChannel.cpp
image/src/Image.cpp
image/src/ImageFactory.cpp
image/src/ImageFactory.h
image/src/SVGDocumentWrapper.cpp
image/src/SVGDocumentWrapper.h
image/src/VectorImage.cpp
image/src/imgLoader.cpp
image/src/imgRequest.cpp
netwerk/mime/nsMimeTypes.h
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/image/build/nsImageModule.cpp
+++ b/image/build/nsImageModule.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ModuleUtils.h"
+#include "nsMimeTypes.h"
 
 #include "RasterImage.h"
 
 /* We end up pulling in windows.h because we eventually hit gfxWindowsSurface;
  * windows.h defines LoadImage, so we have to #undef it or imgLoader::LoadImage
  * gets changed.
  * This #undef needs to be in multiple places because we don't always pull
  * headers in in the same order.
@@ -56,35 +57,35 @@ static const mozilla::Module::CIDEntry k
   { NULL }
 };
 
 static const mozilla::Module::ContractIDEntry kImageContracts[] = {
   { "@mozilla.org/image/cache;1", &kNS_IMGLOADER_CID },
   { "@mozilla.org/image/loader;1", &kNS_IMGLOADER_CID },
   { "@mozilla.org/image/request;1", &kNS_IMGREQUESTPROXY_CID },
   { "@mozilla.org/image/tools;1", &kNS_IMGTOOLS_CID },
-  { "@mozilla.org/image/encoder;2?type=image/vnd.microsoft.icon", &kNS_ICOENCODER_CID },
-  { "@mozilla.org/image/encoder;2?type=image/jpeg", &kNS_JPEGENCODER_CID },
-  { "@mozilla.org/image/encoder;2?type=image/png", &kNS_PNGENCODER_CID },
-  { "@mozilla.org/image/encoder;2?type=image/bmp", &kNS_BMPENCODER_CID },
+  { "@mozilla.org/image/encoder;2?type=" IMAGE_ICO_MS, &kNS_ICOENCODER_CID },
+  { "@mozilla.org/image/encoder;2?type=" IMAGE_JPEG, &kNS_JPEGENCODER_CID },
+  { "@mozilla.org/image/encoder;2?type=" IMAGE_PNG, &kNS_PNGENCODER_CID },
+  { "@mozilla.org/image/encoder;2?type=" IMAGE_BMP, &kNS_BMPENCODER_CID },
   { NULL }
 };
 
 static const mozilla::Module::CategoryEntry kImageCategories[] = {
-  { "Gecko-Content-Viewers", "image/gif", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/jpeg", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/pjpeg", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/jpg", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/x-icon", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/vnd.microsoft.icon", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/bmp", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/x-ms-bmp", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/icon", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/png", "@mozilla.org/content/document-loader-factory;1" },
-  { "Gecko-Content-Viewers", "image/x-png", "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_GIF, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_JPEG, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_PJPEG, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_JPG, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_ICO, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_ICO_MS, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_BMP, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_BMP_MS, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_ICON_MS, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_PNG, "@mozilla.org/content/document-loader-factory;1" },
+  { "Gecko-Content-Viewers", IMAGE_X_PNG, "@mozilla.org/content/document-loader-factory;1" },
   { "content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1" },
   { NULL }
 };
 
 static nsresult
 imglib_Initialize()
 {
   mozilla::image::DiscardTracker::Initialize();
--- a/image/decoders/icon/android/nsIconChannel.cpp
+++ b/image/decoders/icon/android/nsIconChannel.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdlib.h>
 #include "mozilla/dom/ContentChild.h"
+#include "nsMimeTypes.h"
 #include "nsIURL.h"
 #include "nsXULAppAPI.h"
 #include "AndroidBridge.h"
 #include "nsIconChannel.h"
 #include "nsIStringStream.h"
 #include "nsNetUtil.h"
 
 NS_IMPL_ISUPPORTS2(nsIconChannel,
@@ -97,17 +98,17 @@ moz_icon_to_channel(nsIURI *aURI, const 
   nsCOMPtr<nsIStringInputStream> stream =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stream->AdoptData((char*)buf, buf_size);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_NewInputStreamChannel(aChannel, aURI, stream,
-                                  NS_LITERAL_CSTRING("image/icon"));
+                                  NS_LITERAL_CSTRING(IMAGE_ICON_MS));
 }
 
 nsresult
 nsIconChannel::Init(nsIURI* aURI)
 {
   nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI);
   NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI");
 
--- a/image/decoders/icon/gtk/nsIconChannel.cpp
+++ b/image/decoders/icon/gtk/nsIconChannel.cpp
@@ -20,16 +20,17 @@ extern "C" {
 }
 #endif
 #ifdef MOZ_ENABLE_GIO
 #include <gio/gio.h>
 #endif
 
 #include <gtk/gtk.h>
 
+#include "nsMimeTypes.h"
 #include "nsIMIMEService.h"
 
 #include "nsIStringBundle.h"
 
 #include "nsNetUtil.h"
 #include "nsIURL.h"
 #include "prlink.h"
 
@@ -120,17 +121,17 @@ moz_gdk_pixbuf_to_channel(GdkPixbuf* aPi
   nsCOMPtr<nsIStringInputStream> stream =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stream->AdoptData((char*)buf, buf_size);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = NS_NewInputStreamChannel(aChannel, aURI, stream,
-                                NS_LITERAL_CSTRING("image/icon"));
+                                NS_LITERAL_CSTRING(IMAGE_ICON_MS));
   return rv;
 }
 
 static GtkWidget *gProtoWindow = nullptr;
 static GtkWidget *gStockImageWidget = nullptr;
 #ifdef MOZ_ENABLE_GNOMEUI
 static GnomeIconTheme *gIconTheme = nullptr;
 #endif //MOZ_ENABLE_GNOMEUI
--- a/image/decoders/icon/mac/nsIconChannelCocoa.mm
+++ b/image/decoders/icon/mac/nsIconChannelCocoa.mm
@@ -340,31 +340,31 @@ NS_IMETHODIMP nsIconChannel::GetLoadFlag
 
 NS_IMETHODIMP nsIconChannel::SetLoadFlags(uint32_t aLoadAttributes)
 {
   return mPump->SetLoadFlags(aLoadAttributes);
 }
 
 NS_IMETHODIMP nsIconChannel::GetContentType(nsACString &aContentType) 
 {
-  aContentType.AssignLiteral("image/icon");
+  aContentType.AssignLiteral(IMAGE_ICON_MS);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIconChannel::SetContentType(const nsACString &aContentType)
 {
   //It doesn't make sense to set the content-type on this type
   // of channel...
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP nsIconChannel::GetContentCharset(nsACString &aContentCharset) 
 {
-  aContentCharset.AssignLiteral("image/icon");
+  aContentCharset.AssignLiteral(IMAGE_ICON_MS);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
 {
   //It doesn't make sense to set the content-type on this type
   // of channel...
--- a/image/decoders/icon/os2/nsIconChannel.cpp
+++ b/image/decoders/icon/os2/nsIconChannel.cpp
@@ -6,16 +6,17 @@
 
 //------------------------------------------------------------------------
 
 #include "nsIconChannel.h"
 #include "nsIIconURI.h"
 #include "nsReadableUtils.h"
 #include "nsMemory.h"
 #include "nsNetUtil.h"
+#include "nsMimeTypes.h"
 #include "nsIFile.h"
 #include "nsIFileURL.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIRwsService.h"
 
 #define INCL_PM
 #include <os2.h>
 
@@ -568,17 +569,17 @@ void ConvertMaskBitMap(uint8_t *inBuf, P
     pIn -= ((next + 1) * bprIn) - padIn;
   }
 }
 
 //------------------------------------------------------------------------
 
 NS_IMETHODIMP nsIconChannel::GetContentType(nsACString &aContentType) 
 {
-  aContentType.AssignLiteral("image/icon");
+  aContentType.AssignLiteral(IMAGE_ICON_MS);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIconChannel::SetContentType(const nsACString &aContentType)
 {
   // It doesn't make sense to set the content-type on this type
   // of channel...
--- a/image/decoders/icon/qt/nsIconChannel.cpp
+++ b/image/decoders/icon/qt/nsIconChannel.cpp
@@ -5,16 +5,17 @@
 
 #include <QIcon>
 #include <QStyle>
 #include <QApplication>
 
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "nsMimeTypes.h"
 #include "nsIMIMEService.h"
 
 #include "nsIStringBundle.h"
 
 #include "nsNetUtil.h"
 #include "nsIURL.h"
 #include "prlink.h"
 
@@ -79,17 +80,17 @@ moz_qicon_to_channel(QImage *image, nsIU
   nsCOMPtr<nsIStringInputStream> stream =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stream->AdoptData((char*)buf, buf_size);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_NewInputStreamChannel(aChannel, aURI, stream,
-                                  NS_LITERAL_CSTRING("image/icon"));
+                                  NS_LITERAL_CSTRING(IMAGE_ICON_MS));
 }
 
 nsresult
 nsIconChannel::Init(nsIURI* aURI)
 {
 
   nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI);
   NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI");
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -582,17 +582,17 @@ nsresult nsIconChannel::MakeInputStream(
   // If we didn't make a stream, then fail.
   if (!*_retval && NS_SUCCEEDED(rv))
     rv = NS_ERROR_NOT_AVAILABLE;
   return rv;
 }
 
 NS_IMETHODIMP nsIconChannel::GetContentType(nsACString &aContentType) 
 {
-  aContentType.AssignLiteral("image/x-icon");
+  aContentType.AssignLiteral(IMAGE_ICO);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIconChannel::SetContentType(const nsACString &aContentType)
 {
   // It doesn't make sense to set the content-type on this type
   // of channel...
--- a/image/src/Image.cpp
+++ b/image/src/Image.cpp
@@ -1,13 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsMimeTypes.h"
+
 #include "Image.h"
 
 namespace mozilla {
 namespace image {
 
 // Constructor
 ImageResource::ImageResource(imgStatusTracker* aStatusTracker, nsIURI* aURI) :
   mURI(aURI),
@@ -44,49 +46,49 @@ ImageResource::SizeOfData()
 // Translates a mimetype into a concrete decoder
 Image::eDecoderType
 Image::GetDecoderType(const char *aMimeType)
 {
   // By default we don't know
   eDecoderType rv = eDecoderType_unknown;
 
   // PNG
-  if (!strcmp(aMimeType, "image/png"))
+  if (!strcmp(aMimeType, IMAGE_PNG))
     rv = eDecoderType_png;
-  else if (!strcmp(aMimeType, "image/x-png"))
+  else if (!strcmp(aMimeType, IMAGE_X_PNG))
     rv = eDecoderType_png;
 
   // GIF
-  else if (!strcmp(aMimeType, "image/gif"))
+  else if (!strcmp(aMimeType, IMAGE_GIF))
     rv = eDecoderType_gif;
 
 
   // JPEG
-  else if (!strcmp(aMimeType, "image/jpeg"))
+  else if (!strcmp(aMimeType, IMAGE_JPEG))
     rv = eDecoderType_jpeg;
-  else if (!strcmp(aMimeType, "image/pjpeg"))
+  else if (!strcmp(aMimeType, IMAGE_PJPEG))
     rv = eDecoderType_jpeg;
-  else if (!strcmp(aMimeType, "image/jpg"))
+  else if (!strcmp(aMimeType, IMAGE_JPG))
     rv = eDecoderType_jpeg;
 
   // BMP
-  else if (!strcmp(aMimeType, "image/bmp"))
+  else if (!strcmp(aMimeType, IMAGE_BMP))
     rv = eDecoderType_bmp;
-  else if (!strcmp(aMimeType, "image/x-ms-bmp"))
+  else if (!strcmp(aMimeType, IMAGE_BMP_MS))
     rv = eDecoderType_bmp;
 
 
   // ICO
-  else if (!strcmp(aMimeType, "image/x-icon"))
+  else if (!strcmp(aMimeType, IMAGE_ICO))
     rv = eDecoderType_ico;
-  else if (!strcmp(aMimeType, "image/vnd.microsoft.icon"))
+  else if (!strcmp(aMimeType, IMAGE_ICO_MS))
     rv = eDecoderType_ico;
 
   // Icon
-  else if (!strcmp(aMimeType, "image/icon"))
+  else if (!strcmp(aMimeType, IMAGE_ICON_MS))
     rv = eDecoderType_icon;
 
   return rv;
 }
 
 void
 ImageResource::IncrementAnimationConsumers()
 {
--- a/image/src/ImageFactory.cpp
+++ b/image/src/ImageFactory.cpp
@@ -4,27 +4,26 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Likely.h"
 
 #include "nsIHttpChannel.h"
 #include "nsSimpleURI.h"
+#include "nsMimeTypes.h"
 
 #include "RasterImage.h"
 #include "VectorImage.h"
 
 #include "ImageFactory.h"
 
 namespace mozilla {
 namespace image {
 
-const char* SVG_MIMETYPE = "image/svg+xml";
-
 // Global preferences related to image containers.
 static bool gInitializedPrefCaches = false;
 static bool gDecodeOnDraw = false;
 static bool gDiscardable = false;
 
 static void
 InitPrefCaches()
 {
@@ -84,17 +83,17 @@ ImageFactory::CreateImage(nsIRequest* aR
   // Register our pref observers if we haven't yet.
   if (MOZ_UNLIKELY(!gInitializedPrefCaches))
     InitPrefCaches();
 
   // Compute the image's initialization flags.
   uint32_t imageFlags = ComputeImageFlags(aURI, aIsMultiPart);
 
   // Select the type of image to create based on MIME type.
-  if (aMimeType.Equals(SVG_MIMETYPE)) {
+  if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) {
     return CreateVectorImage(aRequest, aStatusTracker, aMimeType,
                              aURI, imageFlags, aInnerWindowId);
   } else {
     return CreateRasterImage(aRequest, aStatusTracker, aMimeType,
                              aURI, imageFlags, aInnerWindowId);
   }
 }
 
--- a/image/src/ImageFactory.h
+++ b/image/src/ImageFactory.h
@@ -10,18 +10,16 @@
 #include "imgIContainer.h"
 #include "imgStatusTracker.h"
 
 #include "Image.h"
 
 namespace mozilla {
 namespace image {
 
-extern const char* SVG_MIMETYPE;
-
 class ImageFactory
 {
 public:
   /**
    * Creates a new image with the given properties.
    *
    * @param aRequest       The associated request.
    * @param aStatusTracker A status tracker for the image to use.
--- a/image/src/SVGDocumentWrapper.cpp
+++ b/image/src/SVGDocumentWrapper.cpp
@@ -338,28 +338,28 @@ SVGDocumentWrapper::SetupViewer(nsIReque
         do_CreateInstance(NS_LOADGROUP_CONTRACTID);
   NS_ENSURE_TRUE(newLoadGroup, NS_ERROR_OUT_OF_MEMORY);
   newLoadGroup->SetLoadGroup(loadGroup);
 
   nsCOMPtr<nsICategoryManager> catMan =
     do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
   NS_ENSURE_TRUE(catMan, NS_ERROR_NOT_AVAILABLE);
   nsXPIDLCString contractId;
-  nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", SVG_MIMETYPE,
+  nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", IMAGE_SVG_XML,
                                          getter_Copies(contractId));
   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,
-                                        SVG_MIMETYPE, nullptr, nullptr,
+                                        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/image/src/SVGDocumentWrapper.h
+++ b/image/src/SVGDocumentWrapper.h
@@ -10,26 +10,26 @@
 
 #include "mozilla/Attributes.h"
 
 #include "nsCOMPtr.h"
 #include "nsIStreamListener.h"
 #include "nsIObserver.h"
 #include "nsIContentViewer.h"
 #include "nsWeakReference.h"
+#include "nsMimeTypes.h"
 
 class nsIAtom;
 class nsIPresShell;
 class nsIRequest;
 class nsILoadGroup;
 class nsIFrame;
 struct nsIntSize;
 class nsSVGSVGElement;
 
-#define SVG_MIMETYPE     "image/svg+xml"
 #define OBSERVER_SVC_CID "@mozilla.org/observer-service;1"
 
 
 namespace mozilla {
 namespace image {
 
 class SVGDocumentWrapper MOZ_FINAL : public nsIStreamListener,
                                      public nsIObserver,
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -9,16 +9,17 @@
 #include "SVGDocumentWrapper.h"
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "nsPresContext.h"
 #include "nsRect.h"
 #include "nsIObserverService.h"
 #include "nsIPresShell.h"
 #include "nsIStreamListener.h"
+#include "nsMimeTypes.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsSVGUtils.h"  // for nsSVGUtils::ConvertToSurfaceSize
 #include "nsSVGEffects.h" // for nsSVGRenderingObserver
 #include "gfxDrawable.h"
 #include "gfxUtils.h"
 #include "nsSVGSVGElement.h"
 
@@ -199,17 +200,17 @@ VectorImage::Init(imgDecoderObserver* aO
 
   NS_ABORT_IF_FALSE(!mIsFullyLoaded && !mHaveAnimations &&
                     !mHaveRestrictedRegion && !mError,
                     "Flags unexpectedly set before initialization");
 
   if (aObserver) {
     mObserver = aObserver->asWeakPtr();
   }
-  NS_ABORT_IF_FALSE(!strcmp(aMimeType, SVG_MIMETYPE), "Unexpected mimetype");
+  NS_ABORT_IF_FALSE(!strcmp(aMimeType, IMAGE_SVG_XML), "Unexpected mimetype");
 
   mIsInitialized = true;
 
   return NS_OK;
 }
 
 void
 VectorImage::GetCurrentFrameRect(nsIntRect& aRect)
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -20,16 +20,17 @@
  */
 #undef LoadImage
 
 #include "nsCOMPtr.h"
 
 #include "nsContentUtils.h"
 #include "nsCrossSiteListenerProxy.h"
 #include "nsNetUtil.h"
+#include "nsMimeTypes.h"
 #include "nsStreamUtils.h"
 #include "nsIHttpChannel.h"
 #include "nsICachingChannel.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIProgressEventSink.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIServiceManager.h"
@@ -952,17 +953,17 @@ imgLoader::Observe(nsISupports* aSubject
 }
 
 void imgLoader::ReadAcceptHeaderPref()
 {
   nsAdoptingCString accept = Preferences::GetCString("image.http.accept");
   if (accept)
     mAcceptHeader = accept;
   else
-    mAcceptHeader = "image/png,image/*;q=0.8,*/*;q=0.5";
+    mAcceptHeader = IMAGE_PNG "," IMAGE_WILDCARD ";q=0.8," ANY_WILDCARD ";q=0.5";
 }
 
 /* void clearCache (in boolean chrome); */
 NS_IMETHODIMP imgLoader::ClearCache(bool chrome)
 {
   if (chrome)
     return ClearChromeImageCache();
   else
@@ -1986,68 +1987,68 @@ NS_IMETHODIMP imgLoader::GetMIMETypeFrom
 
 /* static */
 nsresult imgLoader::GetMimeTypeFromContent(const char* aContents, uint32_t aLength, nsACString& aContentType)
 {
   /* Is it a GIF? */
   if (aLength >= 6 && (!nsCRT::strncmp(aContents, "GIF87a", 6) ||
                        !nsCRT::strncmp(aContents, "GIF89a", 6)))
   {
-    aContentType.AssignLiteral("image/gif");
+    aContentType.AssignLiteral(IMAGE_GIF);
   }
 
   /* or a PNG? */
   else if (aLength >= 8 && ((unsigned char)aContents[0]==0x89 &&
                    (unsigned char)aContents[1]==0x50 &&
                    (unsigned char)aContents[2]==0x4E &&
                    (unsigned char)aContents[3]==0x47 &&
                    (unsigned char)aContents[4]==0x0D &&
                    (unsigned char)aContents[5]==0x0A &&
                    (unsigned char)aContents[6]==0x1A &&
                    (unsigned char)aContents[7]==0x0A))
   { 
-    aContentType.AssignLiteral("image/png");
+    aContentType.AssignLiteral(IMAGE_PNG);
   }
 
   /* maybe a JPEG (JFIF)? */
   /* JFIF files start with SOI APP0 but older files can start with SOI DQT
    * so we test for SOI followed by any marker, i.e. FF D8 FF
    * this will also work for SPIFF JPEG files if they appear in the future.
    *
    * (JFIF is 0XFF 0XD8 0XFF 0XE0 <skip 2> 0X4A 0X46 0X49 0X46 0X00)
    */
   else if (aLength >= 3 &&
      ((unsigned char)aContents[0])==0xFF &&
      ((unsigned char)aContents[1])==0xD8 &&
      ((unsigned char)aContents[2])==0xFF)
   {
-    aContentType.AssignLiteral("image/jpeg");
+    aContentType.AssignLiteral(IMAGE_JPEG);
   }
 
   /* or how about ART? */
   /* ART begins with JG (4A 47). Major version offset 2.
    * Minor version offset 3. Offset 4 must be NULL.
    */
   else if (aLength >= 5 &&
    ((unsigned char) aContents[0])==0x4a &&
    ((unsigned char) aContents[1])==0x47 &&
    ((unsigned char) aContents[4])==0x00 )
   {
-    aContentType.AssignLiteral("image/x-jg");
+    aContentType.AssignLiteral(IMAGE_ART);
   }
 
   else if (aLength >= 2 && !nsCRT::strncmp(aContents, "BM", 2)) {
-    aContentType.AssignLiteral("image/bmp");
+    aContentType.AssignLiteral(IMAGE_BMP);
   }
 
   // ICOs always begin with a 2-byte 0 followed by a 2-byte 1.
   // CURs begin with 2-byte 0 followed by 2-byte 2.
   else if (aLength >= 4 && (!memcmp(aContents, "\000\000\001\000", 4) ||
                             !memcmp(aContents, "\000\000\002\000", 4))) {
-    aContentType.AssignLiteral("image/x-icon");
+    aContentType.AssignLiteral(IMAGE_ICO);
   }
 
   else {
     /* none of the above?  I give up */
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return NS_OK;
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -26,16 +26,17 @@
 #include "nsIChannel.h"
 #include "nsICachingChannel.h"
 #include "nsILoadGroup.h"
 #include "nsIInputStream.h"
 #include "nsIMultiPartChannel.h"
 #include "nsIHttpChannel.h"
 #include "nsIApplicationCache.h"
 #include "nsIApplicationCacheChannel.h"
+#include "nsMimeTypes.h"
 
 #include "nsIComponentManager.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIServiceManager.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIScriptSecurityManager.h"
 
 #include "nsICacheVisitor.h"
@@ -721,17 +722,17 @@ imgRequest::OnDataAvailable(nsIRequest *
     }
 
     // If we're a regular image and this is the first call to OnDataAvailable,
     // this will always be true. If we've resniffed our MIME type (i.e. we're a
     // multipart/x-mixed-replace image), we have to be able to switch our image
     // type and decoder.
     // We always reinitialize for SVGs, because they have no way of
     // reinitializing themselves.
-    if (mContentType != newType || newType.Equals(SVG_MIMETYPE)) {
+    if (mContentType != newType || newType.EqualsLiteral(IMAGE_SVG_XML)) {
       mContentType = newType;
 
       // If we've resniffed our MIME type and it changed, we need to create a
       // new status tracker to give to the image, because we don't have one of
       // our own any more.
       if (mResniffMimeType) {
         NS_ABORT_IF_FALSE(mIsMultiPartChannel, "Resniffing a non-multipart image");
 
--- a/netwerk/mime/nsMimeTypes.h
+++ b/netwerk/mime/nsMimeTypes.h
@@ -11,16 +11,17 @@
 #ifndef nsMimeTypes_h_
 #define nsMimeTypes_h_
 
 /* Defines for various MIME content-types and encodings.
    Whenever you type in a content-type, you should use one of these defines
    instead, to help catch typos, and make central management of them easier.
  */
 
+#define ANY_WILDCARD                        "*/*"
 #define AUDIO_WILDCARD                      "audio/*"
 #define IMAGE_WILDCARD                      "image/*"
 
 #define APPLICATION_APPLEFILE               "application/applefile"
 #define APPLICATION_BINHEX                  "application/mac-binhex40"
 #define APPLICATION_MACBINARY               "application/x-macbinary"
 #define APPLICATION_COMPRESS                "application/x-compress"
 #define APPLICATION_COMPRESS2               "application/compress"
@@ -76,27 +77,32 @@
 #define AUDIO_WAV                           "audio/x-wav"
 #define AUDIO_WEBM                          "audio/webm"
 #define AUDIO_MP3                           "audio/mpeg"
 #define AUDIO_MP4                           "audio/mp4"
 
 #define BINARY_OCTET_STREAM                 "binary/octet-stream"
 
 #define IMAGE_GIF                           "image/gif"
-#define IMAGE_JPG                           "image/jpeg"
-#define IMAGE_PJPG                          "image/pjpeg"
+#define IMAGE_JPEG                          "image/jpeg"
+#define IMAGE_JPG                           "image/jpg"
+#define IMAGE_PJPEG                         "image/pjpeg"
 #define IMAGE_PNG                           "image/png"
+#define IMAGE_X_PNG                         "image/x-png"
 #define IMAGE_PPM                           "image/x-portable-pixmap"
 #define IMAGE_XBM                           "image/x-xbitmap"
 #define IMAGE_XBM2                          "image/x-xbm"
 #define IMAGE_XBM3                          "image/xbm"
 #define IMAGE_ART                           "image/x-jg"
 #define IMAGE_TIFF                          "image/tiff"
 #define IMAGE_BMP                           "image/bmp"
+#define IMAGE_BMP_MS                        "image/x-ms-bmp"
 #define IMAGE_ICO                           "image/x-icon"
+#define IMAGE_ICO_MS                        "image/vnd.microsoft.icon"
+#define IMAGE_ICON_MS                       "image/icon"
 #define IMAGE_MNG                           "video/x-mng"
 #define IMAGE_JNG                           "image/x-jng"
 #define IMAGE_SVG_XML                       "image/svg+xml"
 
 #define MESSAGE_EXTERNAL_BODY               "message/external-body"
 #define MESSAGE_NEWS                        "message/news"
 #define MESSAGE_RFC822                      "message/rfc822"
 
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -376,18 +376,18 @@ static nsDefaultMimeTypeEntry defaultMim
   // sorted by order used
   { IMAGE_GIF, "gif" },
   { TEXT_XML, "xml" },
   { APPLICATION_RDF, "rdf" },
   { TEXT_XUL, "xul" },
   { IMAGE_PNG, "png" },
   // -- end extensions used during startup
   { TEXT_CSS, "css" },
-  { IMAGE_JPG, "jpeg" },
-  { IMAGE_JPG, "jpg" },
+  { IMAGE_JPEG, "jpeg" },
+  { IMAGE_JPEG, "jpg" },
   { TEXT_HTML, "html" },
   { TEXT_HTML, "htm" },
   { APPLICATION_XPINSTALL, "xpi" },
   { "application/xhtml+xml", "xhtml" },
   { "application/xhtml+xml", "xht" },
   { TEXT_PLAIN, "txt" },
 #ifdef MOZ_OGG
   { VIDEO_OGG, "ogv" },
@@ -455,17 +455,17 @@ static nsExtraMimeTypeEntry extraMimeEnt
   { APPLICATION_XJAVASCRIPT, "js", "Javascript Source File" },
 #ifdef MOZ_WIDGET_ANDROID
   { "application/vnd.android.package-archive", "apk", "Android Package" },
 #endif
   { IMAGE_ART, "art", "ART Image" },
   { IMAGE_BMP, "bmp", "BMP Image" },
   { IMAGE_GIF, "gif", "GIF Image" },
   { IMAGE_ICO, "ico,cur", "ICO Image" },
-  { IMAGE_JPG, "jpeg,jpg,jfif,pjpeg,pjp", "JPEG Image" },
+  { IMAGE_JPEG, "jpeg,jpg,jfif,pjpeg,pjp", "JPEG Image" },
   { IMAGE_PNG, "png", "PNG Image" },
   { IMAGE_TIFF, "tiff,tif", "TIFF Image" },
   { IMAGE_XBM, "xbm", "XBM Image" },
   { "image/svg+xml", "svg", "Scalable Vector Graphics" },
   { MESSAGE_RFC822, "eml", "RFC-822 data" },
   { TEXT_PLAIN, "txt,text", "Text File" },
   { TEXT_HTML, "html,htm,shtml,ehtml", "HyperText Markup Language" },
   { "application/xhtml+xml", "xhtml,xht", "Extensible HyperText Markup Language" },