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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // to Chrome. This check should happen for reloads, navigations, etc...
, which is why | 200 // to Chrome. This check should happen for reloads, navigations, etc...
, which is why |
201 // it occurs before the subsequent blocks. | 201 // it occurs before the subsequent blocks. |
202 if (params.getUrl().startsWith("file:") | 202 if (params.getUrl().startsWith("file:") |
203 && mDelegate.shouldRequestFileAccess(params.getUrl(), params.get
Tab())) { | 203 && mDelegate.shouldRequestFileAccess(params.getUrl(), params.get
Tab())) { |
204 mDelegate.startFileIntent( | 204 mDelegate.startFileIntent( |
205 intent, params.getReferrerUrl(), params.getTab(), | 205 intent, params.getReferrerUrl(), params.getTab(), |
206 params.shouldCloseContentsOnOverrideUrlLoadingAndLaunchInten
t()); | 206 params.shouldCloseContentsOnOverrideUrlLoadingAndLaunchInten
t()); |
207 return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION; | 207 return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION; |
208 } | 208 } |
209 | 209 |
| 210 // http://crbug.com/149218: We want to show the intent picker for ordina
ry links, providing |
| 211 // the link is not an incoming intent from another application, unless i
t's a redirect (see |
| 212 // below). |
| 213 boolean linkNotFromIntent = isLink && !isFromIntent; |
| 214 |
| 215 boolean isOnEffectiveIntentRedirect = params.getRedirectHandler() == nul
l ? false |
| 216 : params.getRedirectHandler().isOnEffectiveIntentRedirectChain()
; |
| 217 |
| 218 // http://crbug.com/170925: We need to show the intent picker when we re
ceive an intent from |
| 219 // another app that 30x redirects to a YouTube/Google Maps/Play Store/Go
ogle+ URL etc. |
| 220 boolean incomingIntentRedirect = (isLink && isFromIntent && params.isRed
irect()) |
| 221 || isOnEffectiveIntentRedirect; |
| 222 |
| 223 |
210 // http://crbug/331571 : Do not override a navigation started from user
typing. | 224 // http://crbug/331571 : Do not override a navigation started from user
typing. |
211 // http://crbug/424029 : Need to stay in Chrome for an intent heading ex
plicitly to Chrome. | 225 // http://crbug/424029 : Need to stay in Chrome for an intent heading ex
plicitly to Chrome. |
212 if (params.getRedirectHandler() != null) { | 226 if (params.getRedirectHandler() != null) { |
213 TabRedirectHandler handler = params.getRedirectHandler(); | 227 TabRedirectHandler handler = params.getRedirectHandler(); |
214 if (handler.shouldStayInChrome(isExternalProtocol) | 228 if (handler.shouldStayInChrome(isExternalProtocol) |
215 || handler.shouldNotOverrideUrlLoading()) { | 229 || handler.shouldNotOverrideUrlLoading()) { |
| 230 // http://crbug.com/659301: Handle redirects to Instant Apps out
of Custom Tabs. |
| 231 if (handler.isFromCustomTabIntent() |
| 232 && !isExternalProtocol |
| 233 && incomingIntentRedirect |
| 234 && !handler.shouldNavigationTypeStayInChrome() |
| 235 && mDelegate.maybeLaunchInstantApp(params.getTab(), para
ms.getUrl(), |
| 236 params.getReferrerUrl(), true)) { |
| 237 return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTEN
T; |
| 238 } |
216 return OverrideUrlLoadingResult.NO_OVERRIDE; | 239 return OverrideUrlLoadingResult.NO_OVERRIDE; |
217 } | 240 } |
218 } | 241 } |
219 | 242 |
220 // http://crbug.com/647569 : Stay in a PWA window for a URL within the s
ame scope. | 243 // http://crbug.com/647569 : Stay in a PWA window for a URL within the s
ame scope. |
221 if (mDelegate.isWithinCurrentWebappScope(params.getUrl())) { | 244 if (mDelegate.isWithinCurrentWebappScope(params.getUrl())) { |
222 return OverrideUrlLoadingResult.NO_OVERRIDE; | 245 return OverrideUrlLoadingResult.NO_OVERRIDE; |
223 } | 246 } |
224 | 247 |
225 // http://crbug.com/149218: We want to show the intent picker for ordina
ry links, providing | |
226 // the link is not an incoming intent from another application, unless i
t's a redirect (see | |
227 // below). | |
228 boolean linkNotFromIntent = isLink && !isFromIntent; | |
229 | |
230 boolean isOnEffectiveIntentRedirect = params.getRedirectHandler() == nul
l ? false | |
231 : params.getRedirectHandler().isOnEffectiveIntentRedirectChain()
; | |
232 | |
233 // http://crbug.com/170925: We need to show the intent picker when we re
ceive an intent from | |
234 // another app that 30x redirects to a YouTube/Google Maps/Play Store/Go
ogle+ URL etc. | |
235 boolean incomingIntentRedirect = (isLink && isFromIntent && params.isRed
irect()) | |
236 || isOnEffectiveIntentRedirect; | |
237 | |
238 // http://crbug.com/181186: We need to show the intent picker when we re
ceive a redirect | 248 // http://crbug.com/181186: We need to show the intent picker when we re
ceive a redirect |
239 // following a form submit. | 249 // following a form submit. |
240 boolean isRedirectFromFormSubmit = isFormSubmit && params.isRedirect(); | 250 boolean isRedirectFromFormSubmit = isFormSubmit && params.isRedirect(); |
241 | 251 |
242 if (!typedRedirectToExternalProtocol) { | 252 if (!typedRedirectToExternalProtocol) { |
243 if (!linkNotFromIntent && !incomingIntentRedirect && !isRedirectFrom
FormSubmit) { | 253 if (!linkNotFromIntent && !incomingIntentRedirect && !isRedirectFrom
FormSubmit) { |
244 return OverrideUrlLoadingResult.NO_OVERRIDE; | 254 return OverrideUrlLoadingResult.NO_OVERRIDE; |
245 } | 255 } |
246 if (params.getRedirectHandler() != null | 256 if (params.getRedirectHandler() != null |
247 && params.getRedirectHandler().isNavigationFromUserTyping())
{ | 257 && params.getRedirectHandler().isNavigationFromUserTyping())
{ |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 if (defaultSmsPackageName == null) return null; | 589 if (defaultSmsPackageName == null) return null; |
580 // Makes sure that the default SMS app actually resolves the intent. | 590 // Makes sure that the default SMS app actually resolves the intent. |
581 for (ResolveInfo resolveInfo : resolvingComponentNames) { | 591 for (ResolveInfo resolveInfo : resolvingComponentNames) { |
582 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam
e)) { | 592 if (defaultSmsPackageName.equals(resolveInfo.activityInfo.packageNam
e)) { |
583 return defaultSmsPackageName; | 593 return defaultSmsPackageName; |
584 } | 594 } |
585 } | 595 } |
586 return null; | 596 return null; |
587 } | 597 } |
588 } | 598 } |
OLD | NEW |