From 0e0121f2cba63e8021d247101047abaa82beee0e Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Thu, 24 Sep 2015 15:27:56 +0200 Subject: [PATCH] Bug 1202052 - Bypass cache on reload button long press. r=margaret --HG-- extra : commitid : Jqr0id1curC extra : rebase_source : c1b541e4295f0b516f01d2cb8884cecd9be5f337 --- mobile/android/base/BrowserApp.java | 19 +++++++++++++++++-- mobile/android/base/GeckoView.java | 2 +- mobile/android/base/Tab.java | 4 ++-- mobile/android/base/menu/GeckoMenu.java | 24 ++++++++++++++++++------ mobile/android/chrome/content/browser.js | 5 +++++ 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 6950bb388f0d..b4312c97728c 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -669,7 +669,7 @@ public class BrowserApp extends GeckoApp return true; case KeyEvent.KEYCODE_R: - tab.doReload(); + tab.doReload(false); return true; case KeyEvent.KEYCODE_PERIOD: @@ -3410,7 +3410,7 @@ public class BrowserApp extends GeckoApp if (itemId == R.id.reload) { tab = Tabs.getInstance().getSelectedTab(); if (tab != null) - tab.doReload(); + tab.doReload(false); return true; } @@ -3527,6 +3527,21 @@ public class BrowserApp extends GeckoApp 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 diff --git a/mobile/android/base/GeckoView.java b/mobile/android/base/GeckoView.java index 704bcd28bbea..238ebb9991d1 100644 --- a/mobile/android/base/GeckoView.java +++ b/mobile/android/base/GeckoView.java @@ -465,7 +465,7 @@ public class GeckoView extends LayerView public void reload() { Tab tab = Tabs.getInstance().getTab(mId); if (tab != null) { - tab.doReload(); + tab.doReload(true); } } diff --git a/mobile/android/base/Tab.java b/mobile/android/base/Tab.java index 9baca0ae757c..4b36bc672878 100644 --- a/mobile/android/base/Tab.java +++ b/mobile/android/base/Tab.java @@ -614,8 +614,8 @@ public class Tab { 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); } diff --git a/mobile/android/base/menu/GeckoMenu.java b/mobile/android/base/menu/GeckoMenu.java index f8b6b076014b..6029c2e2d78a 100644 --- a/mobile/android/base/menu/GeckoMenu.java +++ b/mobile/android/base/menu/GeckoMenu.java @@ -5,6 +5,7 @@ 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; @@ -256,8 +257,12 @@ public class GeckoMenu extends ListView }); ((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) { @@ -270,7 +275,11 @@ public class GeckoMenu extends ListView ((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; } }); } @@ -644,12 +653,15 @@ public class GeckoMenu extends ListView } 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; } diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 23f807f7e3ff..fb9917b8a83f 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -1727,6 +1727,11 @@ var BrowserApp = { // 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