| 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 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 // If the URL doesn't look like one we can show, try to open the link with an | 3058 // If the URL doesn't look like one we can show, try to open the link with an |
| 3059 // external application. | 3059 // external application. |
| 3060 // TODO(droger): Check transition type before opening an external | 3060 // TODO(droger): Check transition type before opening an external |
| 3061 // application? For example, only allow it for TYPED and LINK transitions. | 3061 // application? For example, only allow it for TYPED and LINK transitions. |
| 3062 if (![CRWWebController webControllerCanShow:requestURL]) { | 3062 if (![CRWWebController webControllerCanShow:requestURL]) { |
| 3063 if (![self shouldOpenExternalURLForNavigationAction:action]) { | 3063 if (![self shouldOpenExternalURLForNavigationAction:action]) { |
| 3064 return NO; | 3064 return NO; |
| 3065 } | 3065 } |
| 3066 | 3066 |
| 3067 // Stop load if navigation is believed to be happening on the main frame. | 3067 // Stop load if navigation is believed to be happening on the main frame. |
| 3068 if ([self isMainFrameNavigationAction:action]) | 3068 if ([self isMainFrameNavigationAction:action]) { |
| 3069 [_delegate currentNavigationWillContinueInExternalApp]; |
| 3069 [self stopLoading]; | 3070 [self stopLoading]; |
| 3071 } |
| 3070 | 3072 |
| 3071 // Purge web view if last committed URL is different from the document URL. | 3073 // Purge web view if last committed URL is different from the document URL. |
| 3072 // This can happen if external URL was added to the navigation stack and was | 3074 // This can happen if external URL was added to the navigation stack and was |
| 3073 // loaded using Go Back or Go Forward navigation (in which case document URL | 3075 // loaded using Go Back or Go Forward navigation (in which case document URL |
| 3074 // will point to the previous page). If this is the first load for a | 3076 // will point to the previous page). If this is the first load for a |
| 3075 // NavigationManager, there will be no last committed item, so check here. | 3077 // NavigationManager, there will be no last committed item, so check here. |
| 3076 web::NavigationItem* lastCommittedItem = | 3078 web::NavigationItem* lastCommittedItem = |
| 3077 self.webState->GetNavigationManager()->GetLastCommittedItem(); | 3079 self.webState->GetNavigationManager()->GetLastCommittedItem(); |
| 3078 if (lastCommittedItem) { | 3080 if (lastCommittedItem) { |
| 3079 GURL lastCommittedURL = lastCommittedItem->GetURL(); | 3081 GURL lastCommittedURL = lastCommittedItem->GetURL(); |
| (...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5087 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5089 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5088 _lastRegisteredRequestURL = URL; | 5090 _lastRegisteredRequestURL = URL; |
| 5089 _loadPhase = web::LOAD_REQUESTED; | 5091 _loadPhase = web::LOAD_REQUESTED; |
| 5090 } | 5092 } |
| 5091 | 5093 |
| 5092 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5094 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5093 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5095 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5094 } | 5096 } |
| 5095 | 5097 |
| 5096 @end | 5098 @end |
| OLD | NEW |