Bug 464222 - Add a baseURI attribute to nsIViewSourceChannel. r=bz
authorJames Kitchener <jkitch.bug@gmail.com>
Thu, 20 Feb 2014 08:43:53 -0500
changeset 169680 f0412d2e262c6d149b5ce95a02dc9c37f16387c6
parent 169679 3159065d1ceec2054a1451328226ecec650ee088
child 169681 af8283de5112a6505a7999a50bc081b0df71a0e3
push id26263
push userryanvm@gmail.com
push dateThu, 20 Feb 2014 20:12:54 +0000
treeherdermozilla-central@b89a9d7b4ca0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs464222
milestone30.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 464222 - Add a baseURI attribute to nsIViewSourceChannel. r=bz
netwerk/protocol/viewsource/nsIViewSourceChannel.idl
netwerk/protocol/viewsource/nsViewSourceChannel.cpp
netwerk/protocol/viewsource/nsViewSourceChannel.h
--- a/netwerk/protocol/viewsource/nsIViewSourceChannel.idl
+++ b/netwerk/protocol/viewsource/nsIViewSourceChannel.idl
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; 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 "nsIChannel.idl"
 
-[uuid(023782d2-3ec9-4bbc-8027-ec35e144fc96)]
+[uuid(0073d67c-a64f-4f45-8f36-02cd0abfeca1)]
 interface nsIViewSourceChannel : nsIChannel
 {
     /**
      * The actual (MIME) content type of the data.
      *
      * nsIViewSourceChannel returns a content type of
      * "application/x-view-source" if you ask it for the contentType
      * attribute.
@@ -21,17 +21,18 @@ interface nsIViewSourceChannel : nsIChan
     attribute ACString originalContentType;
 
     /**
      * Whether the channel was created to view the source of a srcdoc document.
      */
     readonly attribute boolean isSrcdocChannel;
 
     /**
-     * If this is a srcdoc channel, it returns the base URI provided by the
-     * embedded channel.  It is used to provide an indication of the base URI
-     * in circumstances where it isn't otherwise recoverable.  Returns a
-     * nullptr when it isn't set or isn't a srcdoc channel.
+     * Set to indicate the base URI.  If this channel is a srcdoc channel, it
+     * returns the base URI provided by the embedded channel.  It is used to
+     * provide an indication of the base URI in circumstances where it isn't
+     * otherwise recoverable.  Returns null when it isn't set and isn't a
+     * srcdoc channel.
      */
-    readonly attribute nsIURI baseURI;
+    attribute nsIURI baseURI;
 };
 
 
--- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
+++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
@@ -506,17 +506,25 @@ NS_IMETHODIMP
 nsViewSourceChannel::GetBaseURI(nsIURI** aBaseURI)
 {
   if (mIsSrcdocChannel) {
     nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(mChannel);
     if (isc) {
       return isc->GetBaseURI(aBaseURI);
     }
   }
-  *aBaseURI = nullptr;
+  *aBaseURI = mBaseURI;
+  NS_IF_ADDREF(*aBaseURI);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsViewSourceChannel::SetBaseURI(nsIURI* aBaseURI)
+{
+  mBaseURI = aBaseURI;
   return NS_OK;
 }
 
 // nsIRequestObserver methods
 NS_IMETHODIMP
 nsViewSourceChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
 {
     NS_ENSURE_TRUE(mListener, NS_ERROR_FAILURE);
--- a/netwerk/protocol/viewsource/nsViewSourceChannel.h
+++ b/netwerk/protocol/viewsource/nsViewSourceChannel.h
@@ -56,15 +56,16 @@ protected:
     nsCOMPtr<nsIChannel>        mChannel;
     nsCOMPtr<nsIHttpChannel>    mHttpChannel;
     nsCOMPtr<nsIHttpChannelInternal>    mHttpChannelInternal;
     nsCOMPtr<nsICachingChannel> mCachingChannel;
     nsCOMPtr<nsIApplicationCacheChannel> mApplicationCacheChannel;
     nsCOMPtr<nsIUploadChannel>  mUploadChannel;
     nsCOMPtr<nsIStreamListener> mListener;
     nsCOMPtr<nsIURI>            mOriginalURI;
+    nsCOMPtr<nsIURI>            mBaseURI;
     nsCString                   mContentType;
     bool                        mIsDocument; // keeps track of the LOAD_DOCUMENT_URI flag
     bool                        mOpened;
     bool                        mIsSrcdocChannel;
 };
 
 #endif /* nsViewSourceChannel_h___ */