summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorRussell Brenner <russellbrenner@google.com>2011-01-07 11:09:36 -0800
committerRussell Brenner <russellbrenner@google.com>2011-01-07 11:09:36 -0800
commitd4afde1bf98cef79d00edc67c1b218105c0954fe (patch)
tree970bec141de5f20a61cf76afbd62d47bdf5b2d83 /src/com/android/browser
parentff18134fa8c3cc6a20e75b58b19274d7f0019eb9 (diff)
downloadpackages_apps_Browser-d4afde1bf98cef79d00edc67c1b218105c0954fe.tar.gz
packages_apps_Browser-d4afde1bf98cef79d00edc67c1b218105c0954fe.tar.bz2
packages_apps_Browser-d4afde1bf98cef79d00edc67c1b218105c0954fe.zip
Fix 3296929 to show available actions
RLZ handling was causing links for google properties to bypass the Activity Manager. Refactored the relevant code as startActivityForUrl() so that it could be used for both RLZ and non-RLZ links. Change-Id: Icdacdaafe92671767397fe8cba3503636072eabf
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/UrlHandler.java102
1 files changed, 56 insertions, 46 deletions
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java
index 6cdd071c8..cd0afeb3c 100644
--- a/src/com/android/browser/UrlHandler.java
+++ b/src/com/android/browser/UrlHandler.java
@@ -133,51 +133,8 @@ public class UrlHandler {
}
}
- Intent intent;
- // perform generic parsing of the URI to turn it into an Intent.
- try {
- intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
- } catch (URISyntaxException ex) {
- Log.w("Browser", "Bad URI " + url + ": " + ex.getMessage());
- return false;
- }
-
- // check whether the intent can be resolved. If not, we will see
- // whether we can download it from the Market.
- if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) {
- String packagename = intent.getPackage();
- if (packagename != null) {
- intent = new Intent(Intent.ACTION_VIEW, Uri
- .parse("market://search?q=pname:" + packagename));
- intent.addCategory(Intent.CATEGORY_BROWSABLE);
- mActivity.startActivity(intent);
- // before leaving BrowserActivity, close the empty child tab.
- // 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();
- return true;
- } else {
- return false;
- }
- }
-
- // sanitize the Intent, ensuring web pages can not bypass browser
- // security (only access to BROWSABLE activities).
- intent.addCategory(Intent.CATEGORY_BROWSABLE);
- intent.setComponent(null);
- try {
- if (mActivity.startActivityIfNeeded(intent, -1)) {
- // before leaving BrowserActivity, close the empty child tab.
- // 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();
- return true;
- }
- } catch (ActivityNotFoundException ex) {
- // ignore the error. If no application can handle the URL,
- // eg about:blank, assume the browser can handle it.
+ if (startActivityForUrl(url)) {
+ return true;
}
if (mController.isMenuDown()) {
@@ -185,9 +142,62 @@ public class UrlHandler {
mActivity.closeOptionsMenu();
return true;
}
+
return false;
}
+ boolean startActivityForUrl(String url)
+ {
+ Intent intent;
+ // perform generic parsing of the URI to turn it into an Intent.
+ try {
+ intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
+ } catch (URISyntaxException ex) {
+ Log.w("Browser", "Bad URI " + url + ": " + ex.getMessage());
+ return false;
+ }
+
+ // check whether the intent can be resolved. If not, we will see
+ // whether we can download it from the Market.
+ if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) {
+ String packagename = intent.getPackage();
+ if (packagename != null) {
+ intent = new Intent(Intent.ACTION_VIEW, Uri
+ .parse("market://search?q=pname:" + packagename));
+ intent.addCategory(Intent.CATEGORY_BROWSABLE);
+ mActivity.startActivity(intent);
+ // before leaving BrowserActivity, close the empty child tab.
+ // 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();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ // sanitize the Intent, ensuring web pages can not bypass browser
+ // security (only access to BROWSABLE activities).
+ intent.addCategory(Intent.CATEGORY_BROWSABLE);
+ intent.setComponent(null);
+ try {
+ if (mActivity.startActivityIfNeeded(intent, -1)) {
+ // before leaving BrowserActivity, close the empty child tab.
+ // 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();
+ return true;
+ }
+ } catch (ActivityNotFoundException ex) {
+ // ignore the error. If no application can handle the URL,
+ // eg about:blank, assume the browser can handle it.
+ }
+
+ return false;
+ }
+
// Url for issuing the uber token.
private final static Uri ISSUE_AUTH_TOKEN_URL = Uri.parse(
"https://www.google.com/accounts/IssueAuthToken?service=gaia&Session=false");
@@ -373,7 +383,7 @@ public class UrlHandler {
}
protected void onPostExecute(String result) {
- mController.loadUrl(mWebView, result);
+ startActivityForUrl(result);
}
}