diff options
author | Russell Brenner <russellbrenner@google.com> | 2011-01-21 13:34:02 -0800 |
---|---|---|
committer | Russell Brenner <russellbrenner@google.com> | 2011-01-21 13:34:02 -0800 |
commit | ca9898e114d8844a7eeb8fc5048f04ec2e13dd8e (patch) | |
tree | 4809178102d989430d13343dd0528ebf8de78c32 /src/com/android/browser/UrlHandler.java | |
parent | 0e64d3c230a0fafff311d39c52b043ef137bf318 (diff) | |
download | packages_apps_browser-ca9898e114d8844a7eeb8fc5048f04ec2e13dd8e.zip packages_apps_browser-ca9898e114d8844a7eeb8fc5048f04ec2e13dd8e.tar.gz packages_apps_browser-ca9898e114d8844a7eeb8fc5048f04ec2e13dd8e.tar.bz2 |
Fix 3373012, null pointer in WebView.loadUrl
UrlHandler can spawn a background RLZTask which will, upon completion,
load the url. This change checks with the controller to see that the
tab is still open before loading the url.
Change-Id: If756c1bc1f79b54878c7d03b5bc5f86b8ab07245
Diffstat (limited to 'src/com/android/browser/UrlHandler.java')
-rw-r--r-- | src/com/android/browser/UrlHandler.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java index 9e41990..f1d1c4c 100644 --- a/src/com/android/browser/UrlHandler.java +++ b/src/com/android/browser/UrlHandler.java @@ -119,8 +119,7 @@ public class UrlHandler { return false; } - boolean startActivityForUrl(String url) - { + boolean startActivityForUrl(String url) { Intent intent; // perform generic parsing of the URI to turn it into an Intent. try { @@ -173,8 +172,7 @@ public class UrlHandler { // In case a physical keyboard is attached, handle clicks with the menu key // depressed by opening in a new tab - boolean handleMenuClick(Tab tab, String url) - { + boolean handleMenuClick(Tab tab, String url) { if (mController.isMenuDown()) { mController.openTab(tab, url, false); mActivity.closeOptionsMenu(); @@ -184,6 +182,8 @@ public class UrlHandler { return false; } + // TODO: Move this class into Tab, where it can be properly stopped upon + // closure of the tab private class RLZTask extends AsyncTask<Void, Void, String> { private Tab mTab; private Uri mSiteUri; @@ -215,10 +215,13 @@ public class UrlHandler { } protected void onPostExecute(String result) { - // If the Activity Manager is not invoked, load the URL directly - if (!startActivityForUrl(result)) { - if (!handleMenuClick(mTab, result)) { - mController.loadUrl(mWebView, result); + // Make sure the Tab was not closed while handling the task + if (mController.getTabControl().getTabIndex(mTab) != -1) { + // If the Activity Manager is not invoked, load the URL directly + if (!startActivityForUrl(result)) { + if (!handleMenuClick(mTab, result)) { + mController.loadUrl(mWebView, result); + } } } } |