| 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 3325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3336 // application? For example, only allow it for TYPED and LINK transitions. | 3336 // application? For example, only allow it for TYPED and LINK transitions. |
| 3337 if (![CRWWebController webControllerCanShow:requestURL]) { | 3337 if (![CRWWebController webControllerCanShow:requestURL]) { |
| 3338 if (![self shouldOpenExternalURLForNavigationAction:action]) { | 3338 if (![self shouldOpenExternalURLForNavigationAction:action]) { |
| 3339 return NO; | 3339 return NO; |
| 3340 } | 3340 } |
| 3341 | 3341 |
| 3342 // Stop load if navigation is believed to be happening on the main frame. | 3342 // Stop load if navigation is believed to be happening on the main frame. |
| 3343 if ([self isMainFrameNavigationAction:action]) | 3343 if ([self isMainFrameNavigationAction:action]) |
| 3344 [self stopLoading]; | 3344 [self stopLoading]; |
| 3345 | 3345 |
| 3346 // Purge web view if last committed URL is different from the document URL. |
| 3347 // This can happen if external URL was added to the navigation stack and was |
| 3348 // loaded using Go Back or Go Forward navigation (in which case document URL |
| 3349 // will point to the previous page). |
| 3350 GURL lastCommittedURL = |
| 3351 self.webState->GetNavigationManager()->GetLastCommittedItem()->GetURL(); |
| 3352 if (lastCommittedURL != _documentURL) { |
| 3353 [self requirePageReconstruction]; |
| 3354 [self setDocumentURL:lastCommittedURL]; |
| 3355 } |
| 3356 |
| 3346 if ([_delegate openExternalURL:requestURL | 3357 if ([_delegate openExternalURL:requestURL |
| 3347 linkClicked:isNavigationTypeLinkActivated]) { | 3358 linkClicked:isNavigationTypeLinkActivated]) { |
| 3348 // Record the URL so that errors reported following the 'NO' reply can be | 3359 // Record the URL so that errors reported following the 'NO' reply can be |
| 3349 // safely ignored. | 3360 // safely ignored. |
| 3350 [_openedApplicationURL addObject:request.URL]; | 3361 [_openedApplicationURL addObject:request.URL]; |
| 3351 if ([self shouldClosePageOnNativeApplicationLoad]) | 3362 if ([self shouldClosePageOnNativeApplicationLoad]) |
| 3352 [_delegate webPageOrderedClose]; | 3363 [_delegate webPageOrderedClose]; |
| 3353 } | 3364 } |
| 3354 return NO; | 3365 return NO; |
| 3355 } | 3366 } |
| (...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5634 } | 5645 } |
| 5635 | 5646 |
| 5636 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5647 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5637 } | 5648 } |
| 5638 | 5649 |
| 5639 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5650 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5640 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5651 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5641 } | 5652 } |
| 5642 | 5653 |
| 5643 @end | 5654 @end |
| OLD | NEW |