Bug 1342820 - Reset navigation button state when clearing history. r=ahunt

Clearing history purges a tab's session history as well. Normally, we only update the navigation button state in the UI for a location change, so now we need to start listening for the appropriate message as well.

BrowserApp has already registered a background thread listener for "Sanitize:ClearHistory" - since this can be called during shutdown as well and their listener is more important (clearing the history DB), we defer to them and redispatch to the UI thread ourselves, so BrowserApp doesn't have to do this during shutdown.

MozReview-Commit-ID: C83mk6Z56Oq

--HG--
extra : rebase_source : 6dc40b1ff816b373783afa6bd34546a961e75571
This commit is contained in:
Jan Henning 2017-03-01 21:08:11 +01:00
Родитель 9e00ebc0fc
Коммит ef37784cd5
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -654,6 +654,11 @@ public class Tab {
mCanDoForward = message.getBoolean("canGoForward");
}
void handleButtonStateChange(boolean canGoBack, boolean canGoForward) {
mCanDoBack = canGoBack;
mCanDoForward = canGoForward;
}
private static boolean shouldShowProgress(final String url) {
return !AboutPages.isAboutPage(url);
}

Просмотреть файл

@ -136,6 +136,11 @@ public class Tabs implements BundleEventListener {
"Tab:SetParentId",
null);
EventDispatcher.getInstance().registerBackgroundThreadListener(this,
// BrowserApp already wants this on the background thread.
"Sanitize:ClearHistory",
null);
mPrivateClearColor = Color.RED;
}
@ -483,6 +488,21 @@ public class Tabs implements BundleEventListener {
@Override // BundleEventListener
public synchronized void handleMessage(final String event, final GeckoBundle message,
final EventCallback callback) {
if ("Sanitize:ClearHistory".equals(event)) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
// Tab session history will be cleared as well,
// so we need to reset the navigation buttons.
for (final Tab tab : mOrder) {
tab.handleButtonStateChange(false, false);
notifyListeners(tab, TabEvents.LOCATION_CHANGE, tab.getURL());
}
}
});
return;
}
// All other events handled below should contain a tabID property
final int id = message.getInt("tabID", -1);
Tab tab = getTab(id);