fix current tab has no webview bug
http://b/issue?id=3214823
setCurrentTab is called before setting the active tab in the UI
this guarantees the active tab has a webview
Change-Id: I5d56c42be5a19389d7bc2cc0c41039bb90cc8478
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 832b0b3..2a23bb1 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -66,6 +66,7 @@
Activity mActivity;
UiController mUiController;
TabControl mTabControl;
+ private Tab mActiveTab;
private Drawable mSecLockIcon;
private Drawable mMixLockIcon;
@@ -295,14 +296,20 @@
@Override
public void setActiveTab(Tab tab) {
- Tab current = mTabControl.getCurrentTab();
- if ((tab != current) && (current != null)) {
- removeTabFromContentView(current);
+ if ((tab != mActiveTab) && (mActiveTab != null)) {
+ removeTabFromContentView(mActiveTab);
}
+ mActiveTab = tab;
attachTabToContentView(tab);
setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole());
WebView view = tab.getWebView();
+ // TabControl.setCurrentTab has been called before this,
+ // so the tab is guaranteed to have a webview
+ if (view == null) {
+ Log.e(LOGTAG, "active tab with no webview detected");
+ return;
+ }
view.setEmbeddedTitleBar(mTitleBar);
if (tab.isInVoiceSearchMode()) {
showVoiceTitleBar(tab.getVoiceDisplayTitle());
@@ -328,8 +335,9 @@
@Override
public void removeTab(Tab tab) {
- if (mTabControl.getCurrentTab() == tab) {
+ if (mActiveTab == tab) {
removeTabFromContentView(tab);
+ mActiveTab = null;
}
if (mXLargeScreenSize) {
mTabBar.onRemoveTab(tab);