Commit 977e468c authored by Igor Oliveira's avatar Igor Oliveira Committed by Georg Koppen
Browse files

Bug 28507: Implement fallback to delete private data in the browser startup

When the TBA is forcefully closed, its private data is not deleted,
even if the history.clear_on_exit is set.

As fallback, this patch calls the Sanitize:ClearData event in the
browser startup to clean the private data if needed.
parent 57ef4c82
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -564,10 +564,7 @@ public abstract class GeckoApp extends GeckoActivity
        return super.onOptionsItemSelected(item);
    }

    private void quitAndClear() {
        // Make sure the Guest Browsing notification goes away when we quit.
        GuestSession.hideNotification(this);

    private GeckoBundle createSanitizeData() {
        final SharedPreferences prefs = getSharedPreferencesForProfile();
        final Set<String> clearSet = PrefUtils.getStringSet(
            prefs, ClearOnShutdownPref.PREF, new HashSet<String>());
@@ -576,7 +573,14 @@ public abstract class GeckoApp extends GeckoActivity
        for (final String clear : clearSet) {
            clearObj.putBoolean(clear, true);
        }
        return clearObj;
    }

    private void quitAndClear() {
        // Make sure the Guest Browsing notification goes away when we quit.
        GuestSession.hideNotification(this);

        final GeckoBundle clearObj = createSanitizeData();
        final GeckoBundle res = new GeckoBundle(2);
        res.putBundle("sanitize", clearObj);

@@ -1135,6 +1139,13 @@ public abstract class GeckoApp extends GeckoActivity
        mTextSelection.create();

        final Bundle finalSavedInstanceState = savedInstanceState;

        // When the browser is forcefully closed, its private data is not
        // deleted, even if the history.clear_on_exit is set. Here we are calling
        // the Sanitize:ClearData in the startup to make sure the private
        // data was cleared.
        EventDispatcher.getInstance().dispatch("Sanitize:ClearData", createSanitizeData());

        ThreadUtils.postToBackgroundThread(new Runnable() {
            @Override
            public void run() {