Bug 921023 - Properly re-enable mixed content blocking. r=mfinkle, a=akeybl
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 01 Oct 2013 11:42:42 -0400
changeset 160556 f8a5867aef495ba18692885a6f90582858ccd48b
parent 160555 b3ca2e186bafef3186c2f66131dd3f34d4f04d86
child 160557 ca696fc3d418875b83a391a59f17b1d9fe276307
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, akeybl
bugs921023
milestone26.0a2
Bug 921023 - Properly re-enable mixed content blocking. r=mfinkle, a=akeybl
mobile/android/base/SiteIdentityPopup.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/SiteIdentityPopup.java
+++ b/mobile/android/base/SiteIdentityPopup.java
@@ -118,30 +118,23 @@ public class SiteIdentityPopup extends A
             // between the popup arrow and the mixed content notification.
             mContent.setPadding(0, (int) mResources.getDimension(R.dimen.identity_padding_top), 0, 0);
             mIdentity.setVisibility(View.GONE);
         }
     }
 
     @Override
     public void onButtonClick(DoorHanger dh, String tag) {
-        if (tag.equals("disable")) {
-            // To disable mixed content blocking, reload the page with a flag to load mixed content.
-            try {
-                JSONObject data = new JSONObject();
-                data.put("allowMixedContent", true);
-                GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", data.toString());
-                GeckoAppShell.sendEventToGecko(e);
-            } catch (JSONException e) {
-                Log.e(LOGTAG, "Exception creating message to allow mixed content", e);
-            }
-        } else if (tag.equals("enable")) {
-            // To enable mixed content blocking, reload the page without any flags.
-            GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", "");
+        try {
+            JSONObject data = new JSONObject();
+            data.put("allowMixedContent", tag.equals("disable"));
+            GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", data.toString());
             GeckoAppShell.sendEventToGecko(e);
+        } catch (JSONException e) {
+            Log.e(LOGTAG, "Exception creating message to enable/disable mixed content blocking", e);
         }
 
         dismiss();
     }
 
     private void addMixedContentNotification(boolean blocked) {
         // Remove any exixting mixed content notification.
         removeMixedContentNotification();
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1312,27 +1312,34 @@ var BrowserApp = {
         browser.goBack();
         break;
 
       case "Session:Forward":
         browser.goForward();
         break;
 
       case "Session:Reload": {
-        let allowMixedContent = false;
+        let flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
+
+        // Check to see if this is a message to enable/disable mixed content blocking.
         if (aData) {
-            let data = JSON.parse(aData);
-            allowMixedContent = data.allowMixedContent;
+          let allowMixedContent = JSON.parse(aData).allowMixedContent;
+          if (allowMixedContent) {
+            // Set a flag to disable mixed content blocking.
+            flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT;
+          } else {
+            // Set mixedContentChannel to null to re-enable mixed content blocking.
+            let docShell = browser.webNavigation.QueryInterface(Ci.nsIDocShell);
+            docShell.mixedContentChannel = null;
+          }
         }
 
         // Try to use the session history to reload so that framesets are
         // handled properly. If the window has no session history, fall back
         // to using the web navigation's reload method.
-        let flags = allowMixedContent ? Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT :
-                    Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
         let webNav = browser.webNavigation;
         try {
           let sh = webNav.sessionHistory;
           if (sh)
             webNav = sh.QueryInterface(Ci.nsIWebNavigation);
         } catch (e) {}
         webNav.reload(flags);
         break;