Bug 902156 - Persist 'disable protection' option for Mixed Content Blocker. r=smaug, r=tanvi, a=bajaj
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Mon, 19 Aug 2013 10:20:20 -0700
changeset 153856 688e49041611991e439709952c17516ce88a456b
parent 153855 561f74e56882a28dc701d555ce2fa5000c51c1a1
child 153857 8dbe776a3ebcacc59a67028347ba62ed7f761317
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, tanvi, bajaj
bugs902156
milestone25.0a2
Bug 902156 - Persist 'disable protection' option for Mixed Content Blocker. r=smaug, r=tanvi, a=bajaj
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -9546,19 +9546,30 @@ nsDocShell::DoURILoad(nsIURI * aURI,
             rv = channel->SetContentDispositionFilename(aFileName);
             NS_ENSURE_SUCCESS(rv, rv);
         }
     }
 
     if (mLoadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
           rv = SetMixedContentChannel(channel);
           NS_ENSURE_SUCCESS(rv, rv);
-    } else {
-          rv = SetMixedContentChannel(nullptr);
-          NS_ENSURE_SUCCESS(rv, rv);
+    } else if (mMixedContentChannel) {
+      /*
+       * If the user "Disables Protection on This Page", we call
+       * SetMixedContentChannel for the first time, otherwise
+       * mMixedContentChannel is still null.
+       * Later, if the new channel passes a same orign check, we remember the
+       * users decision by calling SetMixedContentChannel using the new channel.
+       * This way, the user does not have to click the disable protection button
+       * over and over for browsing the same site.
+       */
+      rv = nsContentUtils::CheckSameOrigin(mMixedContentChannel, channel);
+      if (NS_FAILED(rv) || NS_FAILED(SetMixedContentChannel(channel))) {
+        SetMixedContentChannel(nullptr);
+      }
     }
 
     //hack
     nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
     nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal(do_QueryInterface(channel));
     if (httpChannelInternal) {
       if (aForceAllowCookies) {
         httpChannelInternal->SetForceAllowThirdPartyCookie(true);