commit e7b74ce6d0559f2a9d801b7dae1117fb8ead0212 Author: Hans-Christoph Steiner hans@eds.org Date: Sat Nov 21 00:24:09 2015 +0100
Orfox: hook up default panic trigger to "quit and clear"
Signed-off-by: Amogh Pradeep amoghbl1@gmail.com --- mobile/android/base/AndroidManifest.xml.in | 7 +++ .../base/java/org/mozilla/gecko/GeckoApp.java | 61 ++++++++++++---------- 2 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 4f626dcc2098..c4ea9a37683e 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -168,6 +168,13 @@ <data android:pathPattern=".*\\.xpi" /> </intent-filter>
+ <!-- receive triggers from panickit apps --> + <intent-filter> + <action android:name="info.guardianproject.panic.action.TRIGGER" /> + + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + #ifdef MOZ_ANDROID_BEAM <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED"/> diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java index ada3e5fa5b0c..63a136541970 100644 --- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java @@ -129,6 +129,7 @@ public abstract class GeckoApp extends GeckoActivity public static final String ACTION_INIT_PW = "org.mozilla.gecko.INIT_PW"; public static final String ACTION_SWITCH_TAB = "org.mozilla.gecko.SWITCH_TAB"; public static final String ACTION_SHUTDOWN = "org.mozilla.gecko.SHUTDOWN"; + public static final String ACTION_PANIC_TRIGGER = "info.guardianproject.panic.action.TRIGGER";
public static final String INTENT_REGISTER_STUMBLER_LISTENER = "org.mozilla.gecko.STUMBLER_REGISTER_LOCAL_LISTENER";
@@ -554,42 +555,46 @@ public abstract class GeckoApp extends GeckoActivity @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.quit) { - // Make sure the Guest Browsing notification goes away when we quit. - GuestSession.hideNotification(this); + quitAndClear(); + return true; + }
- final SharedPreferences prefs = getSharedPreferencesForProfile(); - final Set<String> clearSet = PrefUtils.getStringSet( - prefs, ClearOnShutdownPref.PREF, new HashSet<String>()); + return super.onOptionsItemSelected(item); + }
- final GeckoBundle clearObj = new GeckoBundle(clearSet.size()); - for (final String clear : clearSet) { - clearObj.putBoolean(clear, true); - } + private void quitAndClear() { + // Make sure the Guest Browsing notification goes away when we quit. + GuestSession.hideNotification(this);
- final GeckoBundle res = new GeckoBundle(2); - res.putBundle("sanitize", clearObj); + final SharedPreferences prefs = getSharedPreferencesForProfile(); + final Set<String> clearSet = PrefUtils.getStringSet( + prefs, ClearOnShutdownPref.PREF, new HashSet<String>());
- // If the user wants to clear open tabs, or else has opted out of session - // restore and does want to clear history, we also want to prevent the current - // session info from being saved. - if (clearObj.containsKey("private.data.openTabs")) { - res.putBoolean("dontSaveSession", true); - } else if (clearObj.containsKey("private.data.history")) { + final GeckoBundle clearObj = new GeckoBundle(clearSet.size()); + for (final String clear : clearSet) { + clearObj.putBoolean(clear, true); + }
- final String sessionRestore = - getSessionRestorePreference(getSharedPreferences()); - res.putBoolean("dontSaveSession", "quit".equals(sessionRestore)); - } + final GeckoBundle res = new GeckoBundle(2); + res.putBundle("sanitize", clearObj);
- EventDispatcher.getInstance().dispatch("Browser:Quit", res); + // If the user wants to clear open tabs, or else has opted out of session + // restore and does want to clear history, we also want to prevent the current + // session info from being saved. + if (clearObj.containsKey("private.data.openTabs")) { + res.putBoolean("dontSaveSession", true); + } else if (clearObj.containsKey("private.data.history")) {
- // We don't call shutdown here because this creates a race condition which - // can cause the clearing of private data to fail. Instead, we shut down the - // UI only after we're done sanitizing. - return true; + final String sessionRestore = + getSessionRestorePreference(getSharedPreferences()); + res.putBoolean("dontSaveSession", "quit".equals(sessionRestore)); }
- return super.onOptionsItemSelected(item); + EventDispatcher.getInstance().dispatch("Browser:Quit", res); + + // We don't call shutdown here because this creates a race condition which + // can cause the clearing of private data to fail. Instead, we shut down the + // UI only after we're done sanitizing. }
@Override @@ -1531,6 +1536,8 @@ public abstract class GeckoApp extends GeckoActivity // Copy extras. settingsIntent.putExtras(intent.getUnsafe()); startActivity(settingsIntent); + } else if (ACTION_PANIC_TRIGGER.equals(action)) { + quitAndClear(); }
mPromptService = new PromptService(this, getAppEventDispatcher());
tbb-commits@lists.torproject.org