summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-08-29 16:43:02 -0700
committerJohn Reck <jreck@google.com>2011-08-29 16:48:09 -0700
commit8bcafc149bc49b84c8dfbaacf88c178d8bc9eda6 (patch)
tree22fbd2191f8d23233fa7aef98cfef50767aa74bd
parent88956b9456a6c8396dc966e6bfb61e45287569a5 (diff)
downloadpackages_apps_Browser-8bcafc149bc49b84c8dfbaacf88c178d8bc9eda6.tar.gz
packages_apps_Browser-8bcafc149bc49b84c8dfbaacf88c178d8bc9eda6.tar.bz2
packages_apps_Browser-8bcafc149bc49b84c8dfbaacf88c178d8bc9eda6.zip
Fix blank page activity selection bug
Bug: 5191031 Sets an app id on the tab so that if the intent comes back to us, it is opened in the current tab. Close empty tabs correctly if the intent goes elsewhere Fix Tab.syncCurrentState to deal with WebView.getUrl() == null correctly Change-Id: I31e1e1f6688fb5c5c31ba07dde4e6b3bad34fb13
-rw-r--r--src/com/android/browser/Controller.java8
-rw-r--r--src/com/android/browser/Tab.java2
-rw-r--r--src/com/android/browser/UrlHandler.java20
3 files changed, 17 insertions, 13 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 92cb743b7..58edd2305 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -2098,15 +2098,11 @@ public class Controller
}
}
- protected void closeEmptyChildTab() {
+ protected void closeEmptyTab() {
Tab current = mTabControl.getCurrentTab();
if (current != null
&& current.getWebView().copyBackForwardList().getSize() == 0) {
- Tab parent = current.getParent();
- if (parent != null) {
- switchToTab(parent);
- closeTab(current);
- }
+ closeCurrentTab();
}
}
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index c519c910d..ecd4a80f2 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -877,7 +877,7 @@ class Tab implements PictureListener {
// Sync state (in case of stop/timeout)
mCurrentState.mUrl = view.getUrl();
if (mCurrentState.mUrl == null) {
- mCurrentState.mUrl = url != null ? url : "";
+ mCurrentState.mUrl = "";
}
mCurrentState.mOriginalUrl = view.getOriginalUrl();
mCurrentState.mTitle = view.getTitle();
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java
index 74a58f30f..73b265d4d 100644
--- a/src/com/android/browser/UrlHandler.java
+++ b/src/com/android/browser/UrlHandler.java
@@ -25,6 +25,7 @@ import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
+import android.provider.Browser;
import android.util.Log;
import android.webkit.WebView;
@@ -76,7 +77,7 @@ public class UrlHandler {
// If a new tab is created through JavaScript open to load this
// url, we would like to close it as we will load this url in a
// different Activity.
- mController.closeEmptyChildTab();
+ mController.closeEmptyTab();
return true;
}
// wtai://wp/sd;dtmf
@@ -114,7 +115,7 @@ public class UrlHandler {
}
}
- if (startActivityForUrl(url)) {
+ if (startActivityForUrl(tab, url)) {
return true;
}
@@ -125,7 +126,7 @@ public class UrlHandler {
return false;
}
- boolean startActivityForUrl(String url) {
+ boolean startActivityForUrl(Tab tab, String url) {
Intent intent;
// perform generic parsing of the URI to turn it into an Intent.
try {
@@ -148,7 +149,7 @@ public class UrlHandler {
// If a new tab is created through JavaScript open to load this
// url, we would like to close it as we will load this url in a
// different Activity.
- mController.closeEmptyChildTab();
+ mController.closeEmptyTab();
return true;
} else {
return false;
@@ -159,6 +160,13 @@ public class UrlHandler {
// security (only access to BROWSABLE activities).
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setComponent(null);
+ // Re-use the existing tab if the intent comes back to us
+ if (tab != null) {
+ if (tab.getAppId() == null) {
+ tab.setAppId("com.android.browser-" + tab.getId());
+ }
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, tab.getAppId());
+ }
// Make sure webkit can handle it internally before checking for specialized
// handlers. If webkit can't handle it internally, we need to call
// startActivityIfNeeded
@@ -172,7 +180,7 @@ public class UrlHandler {
// If a new tab is created through JavaScript open to load this
// url, we would like to close it as we will load this url in a
// different Activity.
- mController.closeEmptyChildTab();
+ mController.closeEmptyTab();
return true;
}
} catch (ActivityNotFoundException ex) {
@@ -262,7 +270,7 @@ public class UrlHandler {
// Make sure the Tab was not closed while handling the task
if (mController.getTabControl().getTabPosition(mTab) != -1) {
// If the Activity Manager is not invoked, load the URL directly
- if (!startActivityForUrl(result)) {
+ if (!startActivityForUrl(mTab, result)) {
if (!handleMenuClick(mTab, result)) {
mController.loadUrl(mTab, result);
}