Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java

Issue 1282063003: Allow intent picker for external schemes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java
index 46e084a3683853f2db6d9227809cbc807bfe5137..d59b5563251dcd38d00e61240b581e929969aa5a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java
@@ -250,18 +250,16 @@ public class CustomTab extends ChromeTab {
@Override
public boolean startActivityIfNeeded(Intent intent) {
+ boolean isExternalProtocol = !UrlUtilities.isAcceptedScheme(intent.getDataString());
+ boolean hasDefaultHandler = hasDefaultHandler(intent);
try {
- if (resolveDefaultHandlerForIntent(intent)) {
- if (getActivity().startActivityIfNeeded(intent, -1)) {
- mHasActivityStarted = true;
- return true;
- } else {
- return false;
- }
- } else {
- // If we failed to find the default handler of the intent, fall back to chrome.
- return false;
- }
+ // For a url chrome can handle and there is no default set, handle it ourselves.
+ if (!hasDefaultHandler && !isExternalProtocol) return false;
+ // If android fails to find a handler, handle it ourselves.
+ if (!getActivity().startActivityIfNeeded(intent, -1)) return false;
+
+ mHasActivityStarted = true;
+ return true;
} catch (RuntimeException e) {
logTransactionTooLargeOrRethrow(e, intent);
return false;
@@ -273,7 +271,7 @@ public class CustomTab extends ChromeTab {
* @return Whether the default external handler is found: if chrome turns out to be the
* default handler, this method will return false.
*/
- private boolean resolveDefaultHandlerForIntent(Intent intent) {
+ private boolean hasDefaultHandler(Intent intent) {
try {
ResolveInfo info = getActivity().getPackageManager().resolveActivity(intent, 0);
if (info != null) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698