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.app.Activity; | 7 import android.app.Activity; |
8 import android.content.ActivityNotFoundException; | 8 import android.content.ActivityNotFoundException; |
9 import android.content.ComponentName; | 9 import android.content.ComponentName; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 /** | 351 /** |
352 * Clobber the current tab with fallback URL. | 352 * Clobber the current tab with fallback URL. |
353 * | 353 * |
354 * @param browserFallbackUrl The fallback URL. | 354 * @param browserFallbackUrl The fallback URL. |
355 * @param params The external navigation params. | 355 * @param params The external navigation params. |
356 * @return {@link OverrideUrlLoadingResult} if the tab was clobbered, or we
launched an | 356 * @return {@link OverrideUrlLoadingResult} if the tab was clobbered, or we
launched an |
357 * intent. | 357 * intent. |
358 */ | 358 */ |
359 private OverrideUrlLoadingResult clobberCurrentTabWithFallbackUrl( | 359 private OverrideUrlLoadingResult clobberCurrentTabWithFallbackUrl( |
360 String browserFallbackUrl, ExternalNavigationParams params) { | 360 String browserFallbackUrl, ExternalNavigationParams params) { |
| 361 if (!params.isMainFrame()) { |
| 362 // For subframes, we don't support fallback url for now. |
| 363 // http://crbug.com/364522. |
| 364 return OverrideUrlLoadingResult.NO_OVERRIDE; |
| 365 } |
361 // NOTE: any further redirection from fall-back URL should not override
URL loading. | 366 // NOTE: any further redirection from fall-back URL should not override
URL loading. |
362 // Otherwise, it can be used in chain for fingerprinting multiple app in
stallation | 367 // Otherwise, it can be used in chain for fingerprinting multiple app in
stallation |
363 // status in one shot. In order to prevent this scenario, we notify redi
rection | 368 // status in one shot. In order to prevent this scenario, we notify redi
rection |
364 // handler that redirection from the current navigation should stay in C
hrome. | 369 // handler that redirection from the current navigation should stay in C
hrome. |
365 if (params.getRedirectHandler() != null) { | 370 if (params.getRedirectHandler() != null) { |
366 params.getRedirectHandler().setShouldNotOverrideUrlLoadingUntilNewUr
lLoading(); | 371 params.getRedirectHandler().setShouldNotOverrideUrlLoadingUntilNewUr
lLoading(); |
367 } | 372 } |
368 return mDelegate.clobberCurrentTab( | 373 return mDelegate.clobberCurrentTab( |
369 browserFallbackUrl, params.getReferrerUrl(), params.getTab()); | 374 browserFallbackUrl, params.getReferrerUrl(), params.getTab()); |
370 } | 375 } |
371 | 376 |
372 /** | 377 /** |
373 * @return Whether the |url| could be handled by an external application on
the system. | 378 * @return Whether the |url| could be handled by an external application on
the system. |
374 */ | 379 */ |
375 public boolean canExternalAppHandleUrl(String url) { | 380 public boolean canExternalAppHandleUrl(String url) { |
376 if (url.startsWith(SCHEME_WTAI_MC)) return true; | 381 if (url.startsWith(SCHEME_WTAI_MC)) return true; |
377 try { | 382 try { |
378 Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); | 383 Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); |
379 return intent.getPackage() != null || mDelegate.canResolveActivity(i
ntent); | 384 return intent.getPackage() != null || mDelegate.canResolveActivity(i
ntent); |
380 } catch (URISyntaxException ex) { | 385 } catch (URISyntaxException ex) { |
381 // Ignore the error. | 386 // Ignore the error. |
382 } | 387 } |
383 return false; | 388 return false; |
384 } | 389 } |
385 } | 390 } |
OLD | NEW |