From 221a346fdfeb5f960cf3e1e8c0ade76d84354f3d Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Fri, 28 Oct 2011 00:55:15 -0400 Subject: [PATCH] Bug 697720 - Add 'Clear private data' preference [r=blassey] --- embedding/android/ConfirmPreference.java | 49 +++++++++++-------- .../android/locales/en-US/android_strings.dtd | 8 +-- .../android/resources/xml/preferences.xml | 17 ++++--- embedding/android/strings.xml.in | 8 +-- mobile/chrome/content/browser.js | 5 +- mobile/chrome/content/browser.xul | 1 + mobile/chrome/content/sanitize.js | 15 ------ 7 files changed, 53 insertions(+), 50 deletions(-) diff --git a/embedding/android/ConfirmPreference.java b/embedding/android/ConfirmPreference.java index a5cebe1c40a4..4328bc3f2e8d 100644 --- a/embedding/android/ConfirmPreference.java +++ b/embedding/android/ConfirmPreference.java @@ -36,33 +36,42 @@ * ***** END LICENSE BLOCK ***** */ package org.mozilla.gecko; -import android.preference.*; -import android.content.*; -import android.util.*; + +import android.content.Context; +import android.preference.DialogPreference; import android.provider.Browser; +import android.util.AttributeSet; +import android.util.Log; class ConfirmPreference extends DialogPreference { - String mAction = null; - Context mContext = null; + private String mAction = null; + private Context mContext = null; public ConfirmPreference(Context context, AttributeSet attrs) { - super(context, attrs); - mAction = attrs.getAttributeValue(null, "action"); - mContext = context; + super(context, attrs); + mAction = attrs.getAttributeValue(null, "action"); + mContext = context; } public ConfirmPreference(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mAction = attrs.getAttributeValue(null, "action"); - mContext = context; + super(context, attrs, defStyle); + mAction = attrs.getAttributeValue(null, "action"); + mContext = context; } protected void onDialogClosed(boolean positiveResult) { - if (!positiveResult) - return; - if ("clear_history".equalsIgnoreCase(mAction)) { - GeckoAppShell.getHandler().post(new Runnable(){ - public void run() { - Browser.clearHistory(mContext.getContentResolver()); - }}); - } - Log.i("GeckoPref", "action: " + mAction); + if (!positiveResult) + return; + if ("clear_history".equalsIgnoreCase(mAction)) { + GeckoAppShell.getHandler().post(new Runnable(){ + public void run() { + Browser.clearHistory(mContext.getContentResolver()); + } + }); + } else if ("clear_private_data".equalsIgnoreCase(mAction)) { + GeckoAppShell.getHandler().post(new Runnable(){ + public void run() { + GeckoAppShell.sendEventToGecko(new GeckoEvent("Sanitize:ClearAll", null)); + } + }); + } + Log.i("GeckoPref", "action: " + mAction); } } diff --git a/embedding/android/locales/en-US/android_strings.dtd b/embedding/android/locales/en-US/android_strings.dtd index 21bf4a3924ce..5f7b5fa6d134 100644 --- a/embedding/android/locales/en-US/android_strings.dtd +++ b/embedding/android/locales/en-US/android_strings.dtd @@ -54,6 +54,10 @@ + + + + @@ -61,7 +65,3 @@ - - - - diff --git a/embedding/android/resources/xml/preferences.xml b/embedding/android/resources/xml/preferences.xml index bf55fb98aed5..5b028f02ec5c 100644 --- a/embedding/android/resources/xml/preferences.xml +++ b/embedding/android/resources/xml/preferences.xml @@ -37,12 +37,17 @@ - + + + &pref_show_images; &pref_enable_js; &pref_char_encoding; + &pref_clear_history; + &pref_clear_history_confirm; + &pref_clear_private_data; + &pref_clear_private_data_confirm; &reload; &new_tab; - &pref_category_history; - &pref_clear_history; - &pref_clear_history_confirm; - &addons; diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index 89e732123a72..700eeff3cac2 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -132,6 +132,7 @@ var BrowserApp = { Services.obs.addObserver(this, "Preferences:Get", false); Services.obs.addObserver(this, "Preferences:Set", false); Services.obs.addObserver(this, "ScrollTo:FocusedInput", false); + Services.obs.addObserver(this, "Sanitize:ClearAll", false); Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false); Services.obs.addObserver(XPInstallObserver, "addon-install-started", false); @@ -467,7 +468,7 @@ var BrowserApp = { this.selectTab(this.getTabForId(parseInt(aData))); } else if (aTopic == "Tab:Close") { this.closeTab(this.getTabForId(parseInt(aData))); - } else if (aTopic == "SaveAs:PDF") { + } else if (aTopic == "SaveAs:PDF") { this.saveAsPDF(browser); } else if (aTopic == "Preferences:Get") { this.getPreferences(aData); @@ -475,6 +476,8 @@ var BrowserApp = { this.setPreferences(aData); } else if (aTopic == "ScrollTo:FocusedInput") { this.scrollToFocusedInput(browser); + } else if (aTopic == "Sanitize:ClearAll") { + Sanitizer.sanitize(); } } } diff --git a/mobile/chrome/content/browser.xul b/mobile/chrome/content/browser.xul index 4bbe7d34c63d..30aa819f16ec 100644 --- a/mobile/chrome/content/browser.xul +++ b/mobile/chrome/content/browser.xul @@ -8,6 +8,7 @@