summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2010-11-19 14:49:34 -0800
committerMichael Kolb <kolby@google.com>2010-11-22 09:13:50 -0800
commit77df4568331d527f993f4d69168218ddf5acddda (patch)
tree2cdef545065beb3a3b319978f901e8f7160289e9
parente8a28338fcd94ef17506b14fed9ebed7dec1124a (diff)
downloadpackages_apps_Browser-77df4568331d527f993f4d69168218ddf5acddda.zip
packages_apps_Browser-77df4568331d527f993f4d69168218ddf5acddda.tar.gz
packages_apps_Browser-77df4568331d527f993f4d69168218ddf5acddda.tar.bz2
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
-rw-r--r--src/com/android/browser/BaseUi.java16
-rw-r--r--src/com/android/browser/Controller.java5
2 files changed, 14 insertions, 7 deletions
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 @@ public class BaseUi implements UI, WebViewFactory {
Activity mActivity;
UiController mUiController;
TabControl mTabControl;
+ private Tab mActiveTab;
private Drawable mSecLockIcon;
private Drawable mMixLockIcon;
@@ -295,14 +296,20 @@ public class BaseUi implements UI, WebViewFactory {
@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 @@ public class BaseUi implements UI, WebViewFactory {
@Override
public void removeTab(Tab tab) {
- if (mTabControl.getCurrentTab() == tab) {
+ if (mActiveTab == tab) {
removeTabFromContentView(tab);
+ mActiveTab = null;
}
if (mXLargeScreenSize) {
mTabBar.onRemoveTab(tab);
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 79fff3d..aabdb26 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1903,10 +1903,9 @@ public class Controller
}
protected void setActiveTab(Tab tab) {
- // Update the UI before setting the current tab in TabControl
- // so the UI can access the old tab to switch over from
- mUi.setActiveTab(tab);
mTabControl.setCurrentTab(tab);
+ // the tab is guaranteed to have a webview after setCurrentTab
+ mUi.setActiveTab(tab);
}
protected void closeEmptyChildTab() {