Bug 1150983 - Add "Synced Tabs" to Clear Private Data option list. r=nalexander

This commit is contained in:
Matt King 2015-05-04 14:08:31 +02:00
parent ad5c4dc545
commit c84b4da484
5 changed files with 41 additions and 0 deletions

View File

@ -49,6 +49,7 @@ import org.mozilla.gecko.preferences.ClearOnShutdownPref;
import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.prompts.Prompt;
import org.mozilla.gecko.prompts.PromptListItem;
import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository;
import org.mozilla.gecko.sync.setup.SyncAccounts;
import org.mozilla.gecko.tabqueue.TabQueueHelper;
import org.mozilla.gecko.tabqueue.TabQueuePrompt;
@ -784,6 +785,7 @@ public class BrowserApp extends GeckoApp
"Menu:Remove",
"Reader:Share",
"Sanitize:ClearHistory",
"Sanitize:ClearSyncedTabs",
"Settings:Show",
"Telemetry:Gather",
"Updater:Launch");
@ -1348,6 +1350,7 @@ public class BrowserApp extends GeckoApp
"Menu:Remove",
"Reader:Share",
"Sanitize:ClearHistory",
"Sanitize:ClearSyncedTabs",
"Settings:Show",
"Telemetry:Gather",
"Updater:Launch");
@ -1405,6 +1408,15 @@ public class BrowserApp extends GeckoApp
});
}
private void handleClearSyncedTabs() {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
FennecTabsRepository.deleteNonLocalClientsAndTabs(getContext());
}
});
}
private void shareCurrentUrl() {
Tab tab = Tabs.getInstance().getSelectedTab();
if (tab == null) {
@ -1685,6 +1697,9 @@ public class BrowserApp extends GeckoApp
} else if ("Sanitize:ClearHistory".equals(event)) {
handleClearHistory(message.optBoolean("clearSearchHistory", false));
callback.sendSuccess(true);
} else if ("Sanitize:ClearSyncedTabs".equals(event)) {
handleClearSyncedTabs();
callback.sendSuccess(true);
} else if ("Settings:Show".equals(event)) {
final String resource =
message.optString(GeckoPreferences.INTENT_EXTRA_RESOURCES, null);

View File

@ -260,6 +260,7 @@ size. -->
<!ENTITY pref_private_data_offlineApps "Offline website data">
<!ENTITY pref_private_data_siteSettings2 "Site settings">
<!ENTITY pref_private_data_downloadFiles2 "Downloads">
<!ENTITY pref_private_data_syncedTabs "Synced tabs">
<!ENTITY pref_about_firefox "About &brandShortName;">

View File

@ -81,6 +81,7 @@
<item>@string/pref_private_data_cache</item>
<item>@string/pref_private_data_offlineApps</item>
<item>@string/pref_private_data_siteSettings</item>
<item>@string/pref_private_data_syncedTabs</item>
</string-array>
<string-array name="pref_private_data_defaults">
<item>true</item>
@ -92,6 +93,7 @@
<item>true</item>
<item>true</item>
<item>true</item>
<item>true</item>
</string-array>
<string-array name="pref_private_data_values">
<item>private.data.history</item>
@ -103,6 +105,7 @@
<item>private.data.cache</item>
<item>private.data.offlineApps</item>
<item>private.data.siteSettings</item>
<item>private.data.syncedTabs</item>
</string-array>
<string-array name="pref_private_data_keys">
<item>private.data.history</item>
@ -114,6 +117,7 @@
<item>private.data.cache</item>
<item>private.data.offlineApps</item>
<item>private.data.siteSettings</item>
<item>private.data.syncedTabs</item>
</string-array>
<string-array name="pref_clear_on_exit_defaults">
<item>false</item>
@ -125,6 +129,7 @@
<item>false</item>
<item>false</item>
<item>false</item>
<item>false</item>
</string-array>
<string-array name="pref_restore_entries">
<item>@string/pref_restore_always</item>

View File

@ -229,6 +229,7 @@
<string name="pref_private_data_offlineApps">&pref_private_data_offlineApps;</string>
<string name="pref_private_data_siteSettings">&pref_private_data_siteSettings2;</string>
<string name="pref_private_data_downloadFiles2">&pref_private_data_downloadFiles2;</string>
<string name="pref_private_data_syncedTabs">&pref_private_data_syncedTabs;</string>
<string name="pref_import_android">&pref_import_android;</string>
<string name="pref_import_android_summary">&pref_import_android_summary;</string>
<string name="pref_update_autodownload">&pref_update_autodownload2;</string>

View File

@ -15,6 +15,7 @@ Cu.import("resource://gre/modules/Messaging.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/Downloads.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Accounts.jsm");
function dump(a) {
Services.console.logStringMessage(a);
@ -266,7 +267,25 @@ Sanitizer.prototype = {
{
return true;
}
},
syncedTabs: {
clear: function ()
{
return Messaging.sendRequestForResult({ type: "Sanitize:ClearSyncedTabs" })
.catch(e => Cu.reportError("Java-side synced tabs clearing failed: " + e));
},
canClear: function(aCallback)
{
Accounts.anySyncAccountsExist().then(aCallback)
.catch(function(err) {
Cu.reportError("Java-side synced tabs clearing failed: " + err)
aCallback(false);
});
}
}
}
};