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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java

Issue 1956403002: Re-submit of AppLink implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lock it and throw away the key Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.externalnav; 5 package org.chromium.chrome.browser.externalnav;
6 6
7 import android.content.ActivityNotFoundException; 7 import android.content.ActivityNotFoundException;
8 import android.content.ComponentName; 8 import android.content.ComponentName;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.pm.ResolveInfo; 10 import android.content.pm.ResolveInfo;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // as the app. This will make sure the link is opened in the same tab 328 // as the app. This will make sure the link is opened in the same tab
329 // instead of making a new one. 329 // instead of making a new one.
330 intent.putExtra(Browser.EXTRA_APPLICATION_ID, mDelegate.getPackageName() ); 330 intent.putExtra(Browser.EXTRA_APPLICATION_ID, mDelegate.getPackageName() );
331 if (params.isOpenInNewTab()) intent.putExtra(Browser.EXTRA_CREATE_NEW_TA B, true); 331 if (params.isOpenInNewTab()) intent.putExtra(Browser.EXTRA_CREATE_NEW_TA B, true);
332 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 332 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
333 333
334 if (params.getReferrerUrl() != null) { 334 if (params.getReferrerUrl() != null) {
335 IntentHandler.setPendingReferrer(intent, params.getReferrerUrl()); 335 IntentHandler.setPendingReferrer(intent, params.getReferrerUrl());
336 } 336 }
337 337
338 if (!params.isIncognito() && mDelegate.maybeDelegateToAppLink(intent)) {
339 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT;
340 }
341
338 // Make sure webkit can handle it internally before checking for special ized 342 // Make sure webkit can handle it internally before checking for special ized
339 // handlers. If webkit can't handle it internally, we need to call 343 // handlers. If webkit can't handle it internally, we need to call
340 // startActivityIfNeeded or startActivity. 344 // startActivityIfNeeded or startActivity.
341 if (!isExternalProtocol) { 345 if (!isExternalProtocol) {
342 if (!mDelegate.isSpecializedHandlerAvailable(resolvingInfos)) { 346 if (!mDelegate.isSpecializedHandlerAvailable(resolvingInfos)) {
343 return OverrideUrlLoadingResult.NO_OVERRIDE; 347 return OverrideUrlLoadingResult.NO_OVERRIDE;
344 } else if (params.getReferrerUrl() != null && (isLink || isFormSubmi t)) { 348 } else if (params.getReferrerUrl() != null && (isLink || isFormSubmi t)) {
345 // Current URL has at least one specialized handler available. F or navigations 349 // Current URL has at least one specialized handler available. F or navigations
346 // within the same host, keep the navigation inside the browser unless the set of 350 // within the same host, keep the navigation inside the browser unless the set of
347 // available apps to handle the new navigation is different. htt p://crbug.com/463138 351 // available apps to handle the new navigation is different. htt p://crbug.com/463138
(...skipping 28 matching lines...) Expand all
376 380
377 try { 381 try {
378 if (params.isIncognito() && !mDelegate.willChromeHandleIntent(intent )) { 382 if (params.isIncognito() && !mDelegate.willChromeHandleIntent(intent )) {
379 // This intent may leave Chrome. Warn the user that incognito d oes not carry over 383 // This intent may leave Chrome. Warn the user that incognito d oes not carry over
380 // to apps out side of Chrome. 384 // to apps out side of Chrome.
381 mDelegate.startIncognitoIntent(intent, params.getReferrerUrl(), 385 mDelegate.startIncognitoIntent(intent, params.getReferrerUrl(),
382 hasBrowserFallbackUrl ? browserFallbackUrl : null, param s.getTab(), 386 hasBrowserFallbackUrl ? browserFallbackUrl : null, param s.getTab(),
383 params.shouldCloseContentsOnOverrideUrlLoadingAndLaunchI ntent()); 387 params.shouldCloseContentsOnOverrideUrlLoadingAndLaunchI ntent());
384 return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION; 388 return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION;
385 } else { 389 } else {
390
386 // Some third-party app launched Chrome with an intent, and the URL got redirected. 391 // Some third-party app launched Chrome with an intent, and the URL got redirected.
387 // The user has explicitly chosen Chrome over other intent handl ers, so stay in 392 // The user has explicitly chosen Chrome over other intent handl ers, so stay in
388 // Chrome unless there was a new intent handler after redirectio n or Chrome cannot 393 // Chrome unless there was a new intent handler after redirectio n or Chrome cannot
389 // handle it any more. 394 // handle it any more.
390 if (params.getRedirectHandler() != null && incomingIntentRedirec t) { 395 if (params.getRedirectHandler() != null && incomingIntentRedirec t) {
391 if (!isExternalProtocol 396 if (!isExternalProtocol
392 && !params.getRedirectHandler().hasNewResolver(inten t)) { 397 && !params.getRedirectHandler().hasNewResolver(inten t)) {
393 return OverrideUrlLoadingResult.NO_OVERRIDE; 398 return OverrideUrlLoadingResult.NO_OVERRIDE;
394 } 399 }
395 } 400 }
396 // The intent can be used to launch Chrome itself, record the us er 401 // The intent can be used to launch Chrome itself, record the us er
397 // gesture here so that it can be used later. 402 // gesture here so that it can be used later.
398 if (params.hasUserGesture()) { 403 if (params.hasUserGesture()) {
399 IntentWithGesturesHandler.getInstance().onNewIntentWithGestu re(intent); 404 IntentWithGesturesHandler.getInstance().onNewIntentWithGestu re(intent);
400 } 405 }
406
401 if (mDelegate.startActivityIfNeeded(intent)) { 407 if (mDelegate.startActivityIfNeeded(intent)) {
402 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN T; 408 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN T;
403 } else { 409 } else {
404 return OverrideUrlLoadingResult.NO_OVERRIDE; 410 return OverrideUrlLoadingResult.NO_OVERRIDE;
405 } 411 }
406 } 412 }
407 } catch (ActivityNotFoundException ex) { 413 } catch (ActivityNotFoundException ex) {
408 // Ignore the error. If no application can handle the URL, 414 // Ignore the error. If no application can handle the URL,
409 // assume the browser can handle it. 415 // assume the browser can handle it.
410 } 416 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 if (defaultSmsPackageName == null) return null; 471 if (defaultSmsPackageName == null) return null;
466 // Makes sure that the default SMS app actually resolves the intent. 472 // Makes sure that the default SMS app actually resolves the intent.
467 for (ResolveInfo resolveInfo : resolvingComponentNames) { 473 for (ResolveInfo resolveInfo : resolvingComponentNames) {
468 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam e)) { 474 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam e)) {
469 return defaultSmsPackageName; 475 return defaultSmsPackageName;
470 } 476 }
471 } 477 }
472 return null; 478 return null;
473 } 479 }
474 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698