Bug 1352997 - Part 1 - Register GeckoApp's onTabsChangedListener earlier. r=sebastian,walkingice

For BrowserApp we want to switch the last selected tab tracking to use tab selection events instead, so we need to register the listener earlier in order to catch the initial selection of the startup tab as well.

MozReview-Commit-ID: F7luIE6oNK

--HG--
extra : rebase_source : d08216a7a73b2f372b2357326e5c9d6de622c4d9
This commit is contained in:
Jan Henning 2017-04-08 11:16:13 +02:00
Родитель 0fcae12707
Коммит 8467f9e026
2 изменённых файлов: 27 добавлений и 9 удалений

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

@ -353,6 +353,11 @@ public class BrowserApp extends GeckoApp
@Override
public void onTabChanged(Tab tab, TabEvents msg, String data) {
if (!mInitialized) {
super.onTabChanged(tab, msg, data);
return;
}
if (tab == null) {
// Only RESTORED is allowed a null tab: it's the only event that
// isn't tied to a specific tab.

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

@ -418,22 +418,36 @@ public abstract class GeckoApp
case LOCATION_CHANGE:
// We only care about location change for the selected tab.
if (!Tabs.getInstance().isSelectedTab(tab))
break;
// Fall through...
if (Tabs.getInstance().isSelectedTab(tab)) {
resetOptionsMenu();
resetFormAssistPopup();
}
break;
case SELECTED:
invalidateOptionsMenu();
if (mFormAssistPopup != null)
mFormAssistPopup.hide();
resetOptionsMenu();
resetFormAssistPopup();
break;
case DESKTOP_MODE_CHANGE:
if (Tabs.getInstance().isSelectedTab(tab))
invalidateOptionsMenu();
resetOptionsMenu();
break;
}
}
private void resetOptionsMenu() {
if (mInitialized) {
invalidateOptionsMenu();
}
}
private void resetFormAssistPopup() {
if (mInitialized && mFormAssistPopup != null) {
mFormAssistPopup.hide();
}
}
public void refreshChrome() { }
@Override
@ -1343,6 +1357,7 @@ public abstract class GeckoApp
null);
Tabs.getInstance().attachToContext(this, mLayerView);
Tabs.registerOnTabsChangedListener(this);
// Use global layout state change to kick off additional initialization
mMainLayout.getViewTreeObserver().addOnGlobalLayoutListener(this);
@ -1703,8 +1718,6 @@ public abstract class GeckoApp
// parallel with Gecko load.
checkMigrateProfile();
Tabs.registerOnTabsChangedListener(this);
initializeChrome();
// We need to wait here because mShouldRestore can revert back to