| 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 3128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3139 const GURL currentNavigationURL = | 3139 const GURL currentNavigationURL = |
| 3140 item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 3140 item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
| 3141 // Check If the URL is handled by a native app. | 3141 // Check If the URL is handled by a native app. |
| 3142 if ([self urlTriggersNativeAppLaunch:requestURL | 3142 if ([self urlTriggersNativeAppLaunch:requestURL |
| 3143 sourceURL:currentNavigationURL | 3143 sourceURL:currentNavigationURL |
| 3144 linkActivatedNavigation:isNavigationTypeLinkActivated]) { | 3144 linkActivatedNavigation:isNavigationTypeLinkActivated]) { |
| 3145 // External app has been launched successfully. Stop the current page | 3145 // External app has been launched successfully. Stop the current page |
| 3146 // load operation (e.g. notifying all observers) and record the URL so | 3146 // load operation (e.g. notifying all observers) and record the URL so |
| 3147 // that errors reported following the 'NO' reply can be safely ignored. | 3147 // that errors reported following the 'NO' reply can be safely ignored. |
| 3148 if ([self shouldClosePageOnNativeApplicationLoad]) | 3148 if ([self shouldClosePageOnNativeApplicationLoad]) |
| 3149 [_delegate webPageOrderedClose]; | 3149 _webStateImpl->CloseWebState(); |
| 3150 [self stopLoading]; | 3150 [self stopLoading]; |
| 3151 [_openedApplicationURL addObject:request.URL]; | 3151 [_openedApplicationURL addObject:request.URL]; |
| 3152 return NO; | 3152 return NO; |
| 3153 } | 3153 } |
| 3154 } | 3154 } |
| 3155 | 3155 |
| 3156 // The WebDelegate may instruct the CRWWebController to stop loading, and | 3156 // The WebDelegate may instruct the CRWWebController to stop loading, and |
| 3157 // instead instruct the next page to be loaded in an animation. | 3157 // instead instruct the next page to be loaded in an animation. |
| 3158 GURL mainDocumentURL = net::GURLWithNSURL(request.mainDocumentURL); | 3158 GURL mainDocumentURL = net::GURLWithNSURL(request.mainDocumentURL); |
| 3159 DCHECK(_webView); | 3159 DCHECK(_webView); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3190 [self setDocumentURL:lastCommittedURL]; | 3190 [self setDocumentURL:lastCommittedURL]; |
| 3191 } | 3191 } |
| 3192 } | 3192 } |
| 3193 | 3193 |
| 3194 if ([_delegate openExternalURL:requestURL | 3194 if ([_delegate openExternalURL:requestURL |
| 3195 linkClicked:isNavigationTypeLinkActivated]) { | 3195 linkClicked:isNavigationTypeLinkActivated]) { |
| 3196 // Record the URL so that errors reported following the 'NO' reply can be | 3196 // Record the URL so that errors reported following the 'NO' reply can be |
| 3197 // safely ignored. | 3197 // safely ignored. |
| 3198 [_openedApplicationURL addObject:request.URL]; | 3198 [_openedApplicationURL addObject:request.URL]; |
| 3199 if ([self shouldClosePageOnNativeApplicationLoad]) | 3199 if ([self shouldClosePageOnNativeApplicationLoad]) |
| 3200 [_delegate webPageOrderedClose]; | 3200 _webStateImpl->CloseWebState(); |
| 3201 } | 3201 } |
| 3202 return NO; | 3202 return NO; |
| 3203 } | 3203 } |
| 3204 | 3204 |
| 3205 if ([[request HTTPMethod] isEqualToString:@"POST"]) { | 3205 if ([[request HTTPMethod] isEqualToString:@"POST"]) { |
| 3206 web::NavigationItemImpl* item = self.currentNavItem; | 3206 web::NavigationItemImpl* item = self.currentNavItem; |
| 3207 // TODO(crbug.com/570699): Remove this check once it's no longer possible to | 3207 // TODO(crbug.com/570699): Remove this check once it's no longer possible to |
| 3208 // have no current entries. | 3208 // have no current entries. |
| 3209 if (item) | 3209 if (item) |
| 3210 [self cachePOSTDataForRequest:request inNavigationItem:item]; | 3210 [self cachePOSTDataForRequest:request inNavigationItem:item]; |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4358 // different). |configuration| param and config returned by | 4358 // different). |configuration| param and config returned by |
| 4359 // WKWebViewConfigurationProvider are different objects because WKWebView | 4359 // WKWebViewConfigurationProvider are different objects because WKWebView |
| 4360 // makes a shallow copy of the config inside init, so every WKWebView | 4360 // makes a shallow copy of the config inside init, so every WKWebView |
| 4361 // owns a separate shallow copy of WKWebViewConfiguration. | 4361 // owns a separate shallow copy of WKWebViewConfiguration. |
| 4362 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; | 4362 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; |
| 4363 return childWebController.webView; | 4363 return childWebController.webView; |
| 4364 } | 4364 } |
| 4365 | 4365 |
| 4366 - (void)webViewDidClose:(WKWebView*)webView { | 4366 - (void)webViewDidClose:(WKWebView*)webView { |
| 4367 if (self.sessionController.openedByDOM) { | 4367 if (self.sessionController.openedByDOM) { |
| 4368 [self.delegate webPageOrderedClose]; | 4368 _webStateImpl->CloseWebState(); |
| 4369 } | 4369 } |
| 4370 } | 4370 } |
| 4371 | 4371 |
| 4372 - (void)webView:(WKWebView*)webView | 4372 - (void)webView:(WKWebView*)webView |
| 4373 runJavaScriptAlertPanelWithMessage:(NSString*)message | 4373 runJavaScriptAlertPanelWithMessage:(NSString*)message |
| 4374 initiatedByFrame:(WKFrameInfo*)frame | 4374 initiatedByFrame:(WKFrameInfo*)frame |
| 4375 completionHandler:(void (^)())completionHandler { | 4375 completionHandler:(void (^)())completionHandler { |
| 4376 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT | 4376 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT |
| 4377 initiatedByFrame:frame | 4377 initiatedByFrame:frame |
| 4378 message:message | 4378 message:message |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5205 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5205 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5206 _lastRegisteredRequestURL = URL; | 5206 _lastRegisteredRequestURL = URL; |
| 5207 _loadPhase = web::LOAD_REQUESTED; | 5207 _loadPhase = web::LOAD_REQUESTED; |
| 5208 } | 5208 } |
| 5209 | 5209 |
| 5210 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5210 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5211 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5211 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5212 } | 5212 } |
| 5213 | 5213 |
| 5214 @end | 5214 @end |
| OLD | NEW |