diff options
author | John Reck <jreck@google.com> | 2011-05-27 09:52:29 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-05-27 09:52:29 -0700 |
commit | 5949c661b51295148706d53a03b41df2eb840ae3 (patch) | |
tree | ddd816e87c94282d51225e6b7fd3d327accd872e | |
parent | b9b2a8290874e447444c7791647cbade915bc47d (diff) | |
download | packages_apps_browser-5949c661b51295148706d53a03b41df2eb840ae3.zip packages_apps_browser-5949c661b51295148706d53a03b41df2eb840ae3.tar.gz packages_apps_browser-5949c661b51295148706d53a03b41df2eb840ae3.tar.bz2 |
Fix set parent race condition
Alter the openTab method to make sure that the parent is
always set before trying to load a url. This is done because
some web settings (useragent) are now inherited from the parent,
and we need to make sure those are applied before the UA is sent
to the server.
Change-Id: Ib33b75ac4648e8ba1ede9bb92406ea175aabb19d
-rw-r--r-- | src/com/android/browser/Controller.java | 38 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 6 | ||||
-rw-r--r-- | src/com/android/browser/WebViewController.java | 3 |
3 files changed, 24 insertions, 23 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index e20a876..5b259a9 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -480,15 +480,8 @@ public class Controller break; case R.id.open_newtab_context_menu_id: final Tab parent = mTabControl.getCurrentTab(); - final Tab newTab = - openTab(url, - (parent != null) - && parent.isPrivateBrowsingEnabled(), - !mSettings.openInBackground(), - true); - if (newTab != null && newTab != parent) { - parent.addChildTab(newTab); - } + openTab(url, parent, + !mSettings.openInBackground(), true); break; case R.id.copy_link_context_menu_id: copy(url); @@ -1392,15 +1385,9 @@ public class Controller @Override public boolean onMenuItemClick(MenuItem item) { final Tab parent = mTabControl.getCurrentTab(); - final Tab newTab = - openTab(extra, - (parent != null) - && parent.isPrivateBrowsingEnabled(), - !mSettings.openInBackground(), - true); - if (newTab != parent) { - parent.addChildTab(newTab); - } + openTab(extra, parent, + !mSettings.openInBackground(), + true); return true; } }); @@ -2225,8 +2212,23 @@ public class Controller @Override public Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent) { + return openTab(url, incognito, setActive, useCurrent, null); + } + + @Override + public Tab openTab(String url, Tab parent, boolean setActive, + boolean useCurrent) { + return openTab(url, (parent != null) && parent.isPrivateBrowsingEnabled(), + setActive, useCurrent, parent); + } + + public Tab openTab(String url, boolean incognito, boolean setActive, + boolean useCurrent, Tab parent) { Tab tab = createNewTab(incognito, setActive, useCurrent); if (tab != null) { + if (parent != null && parent != tab) { + parent.addChildTab(tab); + } WebView w = tab.getWebView(); if (url != null) { loadUrl(w, url); diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 8962475..4097334 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -855,11 +855,7 @@ class Tab { transport.setWebView(mSubView); } else { final Tab newTab = mWebViewController.openTab(null, - Tab.this.isPrivateBrowsingEnabled(), - true, true); - if (newTab != Tab.this) { - Tab.this.addChildTab(newTab); - } + Tab.this, true, true); transport.setWebView(newTab.getWebView()); } msg.sendToTarget(); diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java index bf3bdba..87703bd 100644 --- a/src/com/android/browser/WebViewController.java +++ b/src/com/android/browser/WebViewController.java @@ -104,6 +104,9 @@ public interface WebViewController { Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent); + Tab openTab(String url, Tab parent, boolean setActive, + boolean useCurrent); + boolean switchToTab(Tab tab); void closeTab(Tab tab); |