Bug 826063 - Part 1: Add and implement nsIPrivateBrowsingChannel::isChannelPrivate; r=ehsan
authorNils Maier <maierman@web.de>
Thu, 03 Jan 2013 19:40:48 -0500
changeset 123105 4b6bc165770f1a88413b3dcc56f19aadf90dc103
parent 123104 2b45a99e0108a674965d33ba8c4d83ed603cc32d
child 123106 fc816bcb876c37a4d47e912304aa7b362c48a7d2
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs826063
milestone20.0a1
Bug 826063 - Part 1: Add and implement nsIPrivateBrowsingChannel::isChannelPrivate; r=ehsan
netwerk/base/public/nsIPrivateBrowsingChannel.idl
netwerk/base/src/PrivateBrowsingChannel.h
--- a/netwerk/base/public/nsIPrivateBrowsingChannel.idl
+++ b/netwerk/base/public/nsIPrivateBrowsingChannel.idl
@@ -6,17 +6,17 @@
 #include "nsISupports.idl"
 
 /**
  * This interface is implemented by channels which support overriding the
  * privacy state of the channel.
  *
  * This interface must be used only from the XPCOM main thread.
  */
-[scriptable, uuid(424b7efc-5d56-4717-9a71-8db9dcaaa618)]
+[scriptable, uuid(df702bb0-55b8-11e2-bcfd-0800200c9a66)]
 interface nsIPrivateBrowsingChannel : nsISupports
 {
     /**
      * Determine whether the channel is tied to a private browsing window.
      *
      * This value can be set only before the channel is opened.  Setting it
      * after that does not have any effect.  This value overrides the privacy
      * state of the channel, which means that if you call this method, then
@@ -32,16 +32,25 @@ interface nsIPrivateBrowsingChannel : ns
      * raising errors if setPrivate is called on a channel which has a loadGroup
      * and/or callbacks that implement nsILoadContext, or if the loadGroup
      * or notificationCallbacks are set after setPrivate has been called.
      *
      * @param aPrivate whether the channel should be opened in private mode.
      */
     void setPrivate(in boolean aPrivate);
 
+    /**
+     * States whether the channel is in private browsing mode. This may either
+     * happen because the channel is opened from a private mode context or
+     * when the mode is explicitly set with ::setPrivate().
+     *
+     * This attribute is equivalent to NS_UsePrivateBrowsing(), but scriptable.
+     */
+    readonly attribute boolean isChannelPrivate;
+
     /*
      * This function is used to determine whether the channel's private mode
      * has been overridden by a call to setPrivate.  It is intended to be used
      * by NS_UsePrivateBrowsing(), and you should not call it directly.
      *
      * @param aValue the overridden value.  This will only be set if the function
      *               returns true.
      */
--- a/netwerk/base/src/PrivateBrowsingChannel.h
+++ b/netwerk/base/src/PrivateBrowsingChannel.h
@@ -42,16 +42,23 @@ public:
         return NS_ERROR_FAILURE;
       }
 
       mPrivateBrowsingOverriden = true;
       mPrivateBrowsing = aPrivate;
       return NS_OK;
   }
 
+  NS_IMETHOD GetIsChannelPrivate(bool *aResult)
+  {
+      NS_ENSURE_ARG_POINTER(aResult);
+      *aResult = NS_UsePrivateBrowsing(static_cast<Channel*>(this));
+      return NS_OK;
+  }
+
   NS_IMETHOD IsPrivateModeOverriden(bool* aValue, bool *aResult)
   {
       NS_ENSURE_ARG_POINTER(aValue);
       NS_ENSURE_ARG_POINTER(aResult);
       *aResult = mPrivateBrowsingOverriden;
       if (mPrivateBrowsingOverriden) {
           *aValue = mPrivateBrowsing;
       }