[tbb-commits] [tor-browser/tor-browser-52.7.2esr-8.0-1] Orfox: hook up default panic trigger to "quit and clear"
gk at torproject.org
gk at torproject.org
Tue Mar 20 11:26:34 UTC 2018
commit 4f8bad4120d0d20148840adae41ad712812c4ddc
Author: Hans-Christoph Steiner <hans at 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 at gmail.com>
---
mobile/android/base/AndroidManifest.xml.in | 7 ++
.../base/java/org/mozilla/gecko/GeckoApp.java | 76 ++++++++++++----------
2 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in
index 2ec98c35ab54..1aa50a08463d 100644
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -155,6 +155,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 2f989576c1a9..1bf4f1d77de5 100644
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -152,6 +152,8 @@ public abstract class GeckoApp
public static final String INTENT_REGISTER_STUMBLER_LISTENER = "org.mozilla.gecko.STUMBLER_REGISTER_LOCAL_LISTENER";
+ public static final String ACTION_PANIC_TRIGGER = "info.guardianproject.panic.action.TRIGGER";
+
public static final String EXTRA_STATE_BUNDLE = "stateBundle";
public static final String LAST_SELECTED_TAB = "lastSelectedTab";
@@ -520,48 +522,52 @@ public abstract class GeckoApp
@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 = GeckoSharedPrefs.forProfile(this);
- final Set<String> clearSet =
- PrefUtils.getStringSet(prefs, ClearOnShutdownPref.PREF, new HashSet<String>());
+ return super.onOptionsItemSelected(item);
+ }
- final JSONObject clearObj = new JSONObject();
- for (String clear : clearSet) {
- try {
- clearObj.put(clear, true);
- } catch (JSONException ex) {
- Log.e(LOGTAG, "Error adding clear object " + clear, ex);
- }
- }
+ private void quitAndClear() {
+ // Make sure the Guest Browsing notification goes away when we quit.
+ GuestSession.hideNotification(this);
- final JSONObject res = new JSONObject();
- try {
- res.put("sanitize", clearObj);
- } catch (JSONException ex) {
- Log.e(LOGTAG, "Error adding sanitize object", ex);
- }
+ final SharedPreferences prefs = GeckoSharedPrefs.forProfile(this);
+ final Set<String> clearSet =
+ PrefUtils.getStringSet(prefs, ClearOnShutdownPref.PREF, new HashSet<String>());
- // If the user 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.has("private.data.history")) {
- final String sessionRestore = getSessionRestorePreference(getSharedPreferences());
- try {
- res.put("dontSaveSession", "quit".equals(sessionRestore));
- } catch (JSONException ex) {
- Log.e(LOGTAG, "Error adding session restore data", ex);
- }
+ final JSONObject clearObj = new JSONObject();
+ for (String clear : clearSet) {
+ try {
+ clearObj.put(clear, true);
+ } catch(JSONException ex) {
+ Log.e(LOGTAG, "Error adding clear object " + clear, ex);
}
+ }
- GeckoAppShell.notifyObservers("Browser:Quit", res.toString());
- // We don't call doShutdown() 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 JSONObject res = new JSONObject();
+ try {
+ res.put("sanitize", clearObj);
+ } catch(JSONException ex) {
+ Log.e(LOGTAG, "Error adding sanitize object", ex);
}
- return super.onOptionsItemSelected(item);
+ // If the user 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.has("private.data.history")) {
+ final String sessionRestore = getSessionRestorePreference(getSharedPreferences());
+ try {
+ res.put("dontSaveSession", "quit".equals(sessionRestore));
+ } catch(JSONException ex) {
+ Log.e(LOGTAG, "Error adding session restore data", ex);
+ }
+ }
+
+ GeckoAppShell.notifyObservers("Browser:Quit", res.toString());
+ // We don't call doShutdown() 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
@@ -1625,6 +1631,8 @@ public abstract class GeckoApp
// Copy extras.
settingsIntent.putExtras(intent.getUnsafe());
startActivity(settingsIntent);
+ } else if (ACTION_PANIC_TRIGGER.equals(action)) {
+ quitAndClear();
}
//app state callbacks
More information about the tbb-commits
mailing list