Bug 1202052 - Bypass cache on reload button long press. r=margaret
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 24 Sep 2015 15:27:56 +0200
changeset 264702 631931fb26588ddfcca4a0932ebe6f48702a4699
parent 264701 3581bfec80da83d207d55dda976087afce57a27e
child 264703 43af8bb24e9abd1fff0fd7ba41c459043d305cac
push id29445
push userkwierso@gmail.com
push dateMon, 28 Sep 2015 22:09:05 +0000
treeherdermozilla-central@fd551ed64296 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1202052
milestone44.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 1202052 - Bypass cache on reload button long press. r=margaret
mobile/android/base/BrowserApp.java
mobile/android/base/GeckoView.java
mobile/android/base/Tab.java
mobile/android/base/menu/GeckoMenu.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -664,17 +664,17 @@ public class BrowserApp extends GeckoApp
                     tab.doBack();
                     return true;
 
                 case KeyEvent.KEYCODE_RIGHT_BRACKET:
                     tab.doForward();
                     return true;
 
                 case KeyEvent.KEYCODE_R:
-                    tab.doReload();
+                    tab.doReload(false);
                     return true;
 
                 case KeyEvent.KEYCODE_PERIOD:
                     tab.doStop();
                     return true;
 
                 case KeyEvent.KEYCODE_T:
                     addTab();
@@ -3405,17 +3405,17 @@ public class BrowserApp extends GeckoApp
         if (itemId == R.id.share) {
             shareCurrentUrl();
             return true;
         }
 
         if (itemId == R.id.reload) {
             tab = Tabs.getInstance().getSelectedTab();
             if (tab != null)
-                tab.doReload();
+                tab.doReload(false);
             return true;
         }
 
         if (itemId == R.id.back) {
             tab = Tabs.getInstance().getSelectedTab();
             if (tab != null)
                 tab.doBack();
             return true;
@@ -3522,16 +3522,31 @@ public class BrowserApp extends GeckoApp
         // a chance.
         if (onContextItemSelected(item)) {
             return true;
         }
 
         return super.onOptionsItemSelected(item);
     }
 
+    @Override
+    public boolean onMenuItemLongClick(MenuItem item) {
+        if (item.getItemId() == R.id.reload) {
+            Tab tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null) {
+                tab.doReload(true);
+
+                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.MENU, "reload_force");
+            }
+            return true;
+        }
+
+        return super.onMenuItemLongClick(item);
+    }
+
     public void showGuestModeDialog(final GuestModeDialog type) {
         final Prompt ps = new Prompt(this, new Prompt.PromptCallback() {
             @Override
             public void onPromptFinished(String result) {
                 try {
                     int itemId = new JSONObject(result).getInt("button");
                     if (itemId == 0) {
                         String args = "";
--- a/mobile/android/base/GeckoView.java
+++ b/mobile/android/base/GeckoView.java
@@ -460,17 +460,17 @@ public class GeckoView extends LayerView
 
         /**
         * Reload the current URL resource into the Browser. The URL is force loaded from the
         * network and is not pulled from cache.
         */
         public void reload() {
             Tab tab = Tabs.getInstance().getTab(mId);
             if (tab != null) {
-                tab.doReload();
+                tab.doReload(true);
             }
         }
 
         /**
         * Stop the current loading operation.
         */
         public void stop() {
             Tab tab = Tabs.getInstance().getTab(mId);
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -609,18 +609,18 @@ public class Tab {
             }
         });
     }
 
     public boolean isEnteringReaderMode() {
         return mEnteringReaderMode;
     }
 
-    public void doReload() {
-        GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", "");
+    public void doReload(boolean bypassCache) {
+        GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", "{\"bypassCache\":" + String.valueOf(bypassCache) + "}");
         GeckoAppShell.sendEventToGecko(e);
     }
 
     // Our version of nsSHistory::GetCanGoBack
     public boolean canDoBack() {
         return mCanDoBack;
     }
 
--- a/mobile/android/base/menu/GeckoMenu.java
+++ b/mobile/android/base/menu/GeckoMenu.java
@@ -1,15 +1,16 @@
 /* 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/. */
 
 package org.mozilla.gecko.menu;
 
 import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.util.ThreadUtils.AssertBehavior;
 import org.mozilla.gecko.widget.GeckoActionProvider;
 
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -251,31 +252,39 @@ public class GeckoMenu extends ListView
             ((MenuItemActionBar) actionView).setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     handleMenuItemClick(menuItem);
                 }
             });
             ((MenuItemActionBar) actionView).setOnLongClickListener(new View.OnLongClickListener() {
                 @Override
-                public boolean onLongClick(View v) {
-                    return handleMenuItemLongClick(menuItem);
+                public boolean onLongClick(View view) {
+                    if (handleMenuItemLongClick(menuItem)) {
+                        GeckoAppShell.vibrateOnHapticFeedbackEnabled(getResources().getIntArray(R.array.long_press_vibrate_msec));
+                        return true;
+                    }
+                    return false;
                 }
             });
         } else if (actionView instanceof MenuItemActionView) {
             ((MenuItemActionView) actionView).setMenuItemClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     handleMenuItemClick(menuItem);
                 }
             });
             ((MenuItemActionView) actionView).setMenuItemLongClickListener(new View.OnLongClickListener() {
                 @Override
                 public boolean onLongClick(View view) {
-                    return handleMenuItemLongClick(menuItem);
+                    if (handleMenuItemLongClick(menuItem)) {
+                        GeckoAppShell.vibrateOnHapticFeedbackEnabled(getResources().getIntArray(R.array.long_press_vibrate_msec));
+                        return true;
+                    }
+                    return false;
                 }
             });
         }
 
         return added;
     }
 
     @Override
@@ -639,22 +648,25 @@ public class GeckoMenu extends ListView
             showMenu(subMenu);
         } else {
             close();
             mCallback.onMenuItemClick(item);
         }
     }
 
     boolean handleMenuItemLongClick(GeckoMenuItem item) {
-        if(!item.isEnabled()) {
+        if (!item.isEnabled()) {
             return false;
         }
 
-        if(mCallback != null) {
-            return mCallback.onMenuItemLongClick(item);
+        if (mCallback != null) {
+            if (mCallback.onMenuItemLongClick(item)) {
+                close();
+                return true;
+            }
         }
         return false;
     }
 
     public Callback getCallback() {
         return mCallback;
     }
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1722,16 +1722,21 @@ var BrowserApp = {
           break;
 
       case "Session:Reload": {
         let flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY;
 
         // Check to see if this is a message to enable/disable mixed content blocking.
         if (aData) {
           let data = JSON.parse(aData);
+
+          if (data.bypassCache) {
+            flags |= Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
+          }
+
           if (data.contentType === "tracking") {
             // Convert document URI into the format used by
             // nsChannelClassifier::ShouldEnableTrackingProtection
             // (any scheme turned into https is correct)
             let normalizedUrl = Services.io.newURI("https://" + browser.currentURI.hostPort, null, null);
             if (data.allowContent) {
               // Add the current host in the 'trackingprotection' consumer of
               // the permission manager using a normalized URI. This effectively