| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 2988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2999 // this for things that should be handled in the subclass instead. | 2999 // this for things that should be handled in the subclass instead. |
| 3000 - (BOOL)shouldAllowLoadWithNavigationAction:(WKNavigationAction*)action { | 3000 - (BOOL)shouldAllowLoadWithNavigationAction:(WKNavigationAction*)action { |
| 3001 NSURLRequest* request = action.request; | 3001 NSURLRequest* request = action.request; |
| 3002 GURL requestURL = net::GURLWithNSURL(request.URL); | 3002 GURL requestURL = net::GURLWithNSURL(request.URL); |
| 3003 | 3003 |
| 3004 // External application launcher needs |isNavigationTypeLinkActivated| to | 3004 // External application launcher needs |isNavigationTypeLinkActivated| to |
| 3005 // decide if the user intended to open the application by clicking on a link. | 3005 // decide if the user intended to open the application by clicking on a link. |
| 3006 BOOL isNavigationTypeLinkActivated = | 3006 BOOL isNavigationTypeLinkActivated = |
| 3007 action.navigationType == WKNavigationTypeLinkActivated; | 3007 action.navigationType == WKNavigationTypeLinkActivated; |
| 3008 | 3008 |
| 3009 // Check if the link navigation leads to a launch of an external app. | 3009 // Checks if the link navigation leads to a launch of an external app. |
| 3010 // TODO(crbug.com/704417): External apps will not be launched from clicking |
| 3011 // a Bookmarked URL or a Recently Closed URL. |
| 3010 // TODO(crbug.com/607780): Revise the logic of allowing external app launch | 3012 // TODO(crbug.com/607780): Revise the logic of allowing external app launch |
| 3011 // and move it to externalAppLauncher. | 3013 // and move it to externalAppLauncher. |
| 3012 BOOL isOpenInNewTabNavigation = !(self.navigationManagerImpl->GetItemCount()); | 3014 BOOL isOpenInNewTabNavigation = !(self.navigationManagerImpl->GetItemCount()); |
| 3013 BOOL isPossibleLinkClick = [self isLinkNavigation:action.navigationType]; | 3015 BOOL isPossibleLinkClick = [self isLinkNavigation:action.navigationType]; |
| 3014 if (isPossibleLinkClick || isOpenInNewTabNavigation || | 3016 if (isPossibleLinkClick || isOpenInNewTabNavigation) { |
| 3015 PageTransitionCoreTypeIs(self.currentTransition, | |
| 3016 ui::PAGE_TRANSITION_AUTO_BOOKMARK)) { | |
| 3017 web::NavigationItem* item = self.currentNavItem; | 3017 web::NavigationItem* item = self.currentNavItem; |
| 3018 const GURL currentNavigationURL = | 3018 const GURL currentNavigationURL = |
| 3019 item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 3019 item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
| 3020 // Check If the URL is handled by a native app. | 3020 // Check If the URL is handled by a native app. |
| 3021 if ([self urlTriggersNativeAppLaunch:requestURL | 3021 if ([self urlTriggersNativeAppLaunch:requestURL |
| 3022 sourceURL:currentNavigationURL | 3022 sourceURL:currentNavigationURL |
| 3023 linkActivatedNavigation:isNavigationTypeLinkActivated]) { | 3023 linkActivatedNavigation:isNavigationTypeLinkActivated]) { |
| 3024 // External app has been launched successfully. Stop the current page | 3024 // External app has been launched successfully. Stop the current page |
| 3025 // load operation (e.g. notifying all observers) and record the URL so | 3025 // load operation (e.g. notifying all observers) and record the URL so |
| 3026 // that errors reported following the 'NO' reply can be safely ignored. | 3026 // that errors reported following the 'NO' reply can be safely ignored. |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3375 // If page transfer started after last click, user is deemed to be no longer | 3375 // If page transfer started after last click, user is deemed to be no longer |
| 3376 // interacting. | 3376 // interacting. |
| 3377 if (!_lastUserInteraction || | 3377 if (!_lastUserInteraction || |
| 3378 _lastTransferTimeInSeconds > _lastUserInteraction->time) { | 3378 _lastTransferTimeInSeconds > _lastUserInteraction->time) { |
| 3379 return NO; | 3379 return NO; |
| 3380 } | 3380 } |
| 3381 return [self userClickedRecently]; | 3381 return [self userClickedRecently]; |
| 3382 } | 3382 } |
| 3383 | 3383 |
| 3384 - (BOOL)userClickedRecently { | 3384 - (BOOL)userClickedRecently { |
| 3385 // Scrolling generates a pair of touch on/off event which causes |
| 3386 // _lastUserInteraction to register that there was user interaction. |
| 3387 // Checks for scrolling first to override time-based click heuristics. |
| 3388 BOOL scrolling = [[self webScrollView] isDragging] || |
| 3389 [[self webScrollView] isDecelerating]; |
| 3390 if (scrolling) |
| 3391 return NO; |
| 3385 if (!_lastUserInteraction) | 3392 if (!_lastUserInteraction) |
| 3386 return NO; | 3393 return NO; |
| 3387 return _clickInProgress || | 3394 return _clickInProgress || |
| 3388 ((CFAbsoluteTimeGetCurrent() - _lastUserInteraction->time) < | 3395 ((CFAbsoluteTimeGetCurrent() - _lastUserInteraction->time) < |
| 3389 kMaximumDelayForUserInteractionInSeconds); | 3396 kMaximumDelayForUserInteractionInSeconds); |
| 3390 } | 3397 } |
| 3391 | 3398 |
| 3392 #pragma mark Placeholder Overlay Methods | 3399 #pragma mark Placeholder Overlay Methods |
| 3393 | 3400 |
| 3394 - (void)addPlaceholderOverlay { | 3401 - (void)addPlaceholderOverlay { |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5075 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5082 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5076 _lastRegisteredRequestURL = URL; | 5083 _lastRegisteredRequestURL = URL; |
| 5077 _loadPhase = web::LOAD_REQUESTED; | 5084 _loadPhase = web::LOAD_REQUESTED; |
| 5078 } | 5085 } |
| 5079 | 5086 |
| 5080 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5087 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5081 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5088 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5082 } | 5089 } |
| 5083 | 5090 |
| 5084 @end | 5091 @end |
| OLD | NEW |