OLD | NEW |
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 340 |
341 if (params.getReferrerUrl() != null) { | 341 if (params.getReferrerUrl() != null) { |
342 IntentHandler.setPendingReferrer(intent, params.getReferrerUrl()); | 342 IntentHandler.setPendingReferrer(intent, params.getReferrerUrl()); |
343 } | 343 } |
344 | 344 |
345 // Make sure webkit can handle it internally before checking for special
ized | 345 // Make sure webkit can handle it internally before checking for special
ized |
346 // handlers. If webkit can't handle it internally, we need to call | 346 // handlers. If webkit can't handle it internally, we need to call |
347 // startActivityIfNeeded or startActivity. | 347 // startActivityIfNeeded or startActivity. |
348 if (!isExternalProtocol) { | 348 if (!isExternalProtocol) { |
349 if (!mDelegate.isSpecializedHandlerAvailable(resolvingInfos)) { | 349 if (!mDelegate.isSpecializedHandlerAvailable(resolvingInfos)) { |
350 if (params.isWebApk()) { | 350 if (params.webApkPackageName() != null) { |
351 intent.setPackage(mDelegate.getPackageName()); | 351 intent.setPackage(mDelegate.getPackageName()); |
352 mDelegate.startActivity(intent); | 352 mDelegate.startActivity(intent); |
353 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN
T; | 353 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN
T; |
354 } | 354 } |
355 return OverrideUrlLoadingResult.NO_OVERRIDE; | 355 return OverrideUrlLoadingResult.NO_OVERRIDE; |
356 } else if (params.getReferrerUrl() != null && (isLink || isFormSubmi
t)) { | 356 } else if (params.getReferrerUrl() != null && (isLink || isFormSubmi
t)) { |
357 // Current URL has at least one specialized handler available. F
or navigations | 357 // Current URL has at least one specialized handler available. F
or navigations |
358 // within the same host, keep the navigation inside the browser
unless the set of | 358 // within the same host, keep the navigation inside the browser
unless the set of |
359 // available apps to handle the new navigation is different. htt
p://crbug.com/463138 | 359 // available apps to handle the new navigation is different. htt
p://crbug.com/463138 |
360 URI currentUri; | 360 URI currentUri; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 && !params.getRedirectHandler().hasNewResolver(inten
t)) { | 405 && !params.getRedirectHandler().hasNewResolver(inten
t)) { |
406 return OverrideUrlLoadingResult.NO_OVERRIDE; | 406 return OverrideUrlLoadingResult.NO_OVERRIDE; |
407 } | 407 } |
408 } | 408 } |
409 // The intent can be used to launch Chrome itself, record the us
er | 409 // The intent can be used to launch Chrome itself, record the us
er |
410 // gesture here so that it can be used later. | 410 // gesture here so that it can be used later. |
411 if (params.hasUserGesture()) { | 411 if (params.hasUserGesture()) { |
412 IntentWithGesturesHandler.getInstance().onNewIntentWithGestu
re(intent); | 412 IntentWithGesturesHandler.getInstance().onNewIntentWithGestu
re(intent); |
413 } | 413 } |
414 | 414 |
| 415 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WE
BAPK)) { |
| 416 // If the only specialized intent handler is a WebAPK, set t
he intent's package |
| 417 // to launch the WebAPK without showing the intent picker. |
| 418 String targetWebApkPackageName = |
| 419 mDelegate.findValidWebApkPackageName(resolvingInfos)
; |
| 420 if (targetWebApkPackageName != null |
| 421 && mDelegate.countSpecializedHandlers(resolvingInfos
) == 1) { |
| 422 intent.setPackage(targetWebApkPackageName); |
| 423 } |
| 424 } |
| 425 |
415 if (mDelegate.startActivityIfNeeded(intent)) { | 426 if (mDelegate.startActivityIfNeeded(intent)) { |
416 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN
T; | 427 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN
T; |
417 } else { | 428 } else { |
418 return OverrideUrlLoadingResult.NO_OVERRIDE; | 429 return OverrideUrlLoadingResult.NO_OVERRIDE; |
419 } | 430 } |
420 } | 431 } |
421 } catch (ActivityNotFoundException ex) { | 432 } catch (ActivityNotFoundException ex) { |
422 // Ignore the error. If no application can handle the URL, | 433 // Ignore the error. If no application can handle the URL, |
423 // assume the browser can handle it. | 434 // assume the browser can handle it. |
424 } | 435 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 if (defaultSmsPackageName == null) return null; | 490 if (defaultSmsPackageName == null) return null; |
480 // Makes sure that the default SMS app actually resolves the intent. | 491 // Makes sure that the default SMS app actually resolves the intent. |
481 for (ResolveInfo resolveInfo : resolvingComponentNames) { | 492 for (ResolveInfo resolveInfo : resolvingComponentNames) { |
482 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam
e)) { | 493 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam
e)) { |
483 return defaultSmsPackageName; | 494 return defaultSmsPackageName; |
484 } | 495 } |
485 } | 496 } |
486 return null; | 497 return null; |
487 } | 498 } |
488 } | 499 } |
OLD | NEW |