Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2737353006: Replaced webPageOrderedClose with WebStateDelegate API. (Closed)
Patch Set: Addressed review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 const GURL currentNavigationURL = 3153 const GURL currentNavigationURL =
3154 item ? item->GetVirtualURL() : GURL::EmptyGURL(); 3154 item ? item->GetVirtualURL() : GURL::EmptyGURL();
3155 // Check If the URL is handled by a native app. 3155 // Check If the URL is handled by a native app.
3156 if ([self urlTriggersNativeAppLaunch:requestURL 3156 if ([self urlTriggersNativeAppLaunch:requestURL
3157 sourceURL:currentNavigationURL 3157 sourceURL:currentNavigationURL
3158 linkActivatedNavigation:isNavigationTypeLinkActivated]) { 3158 linkActivatedNavigation:isNavigationTypeLinkActivated]) {
3159 // External app has been launched successfully. Stop the current page 3159 // External app has been launched successfully. Stop the current page
3160 // load operation (e.g. notifying all observers) and record the URL so 3160 // load operation (e.g. notifying all observers) and record the URL so
3161 // that errors reported following the 'NO' reply can be safely ignored. 3161 // that errors reported following the 'NO' reply can be safely ignored.
3162 if ([self shouldClosePageOnNativeApplicationLoad]) 3162 if ([self shouldClosePageOnNativeApplicationLoad])
3163 [_delegate webPageOrderedClose]; 3163 _webStateImpl->CloseWebState();
3164 [self stopLoading]; 3164 [self stopLoading];
3165 [_openedApplicationURL addObject:request.URL]; 3165 [_openedApplicationURL addObject:request.URL];
3166 return NO; 3166 return NO;
3167 } 3167 }
3168 } 3168 }
3169 3169
3170 // The WebDelegate may instruct the CRWWebController to stop loading, and 3170 // The WebDelegate may instruct the CRWWebController to stop loading, and
3171 // instead instruct the next page to be loaded in an animation. 3171 // instead instruct the next page to be loaded in an animation.
3172 GURL mainDocumentURL = net::GURLWithNSURL(request.mainDocumentURL); 3172 GURL mainDocumentURL = net::GURLWithNSURL(request.mainDocumentURL);
3173 DCHECK(_webView); 3173 DCHECK(_webView);
(...skipping 30 matching lines...) Expand all
3204 [self setDocumentURL:lastCommittedURL]; 3204 [self setDocumentURL:lastCommittedURL];
3205 } 3205 }
3206 } 3206 }
3207 3207
3208 if ([_delegate openExternalURL:requestURL 3208 if ([_delegate openExternalURL:requestURL
3209 linkClicked:isNavigationTypeLinkActivated]) { 3209 linkClicked:isNavigationTypeLinkActivated]) {
3210 // Record the URL so that errors reported following the 'NO' reply can be 3210 // Record the URL so that errors reported following the 'NO' reply can be
3211 // safely ignored. 3211 // safely ignored.
3212 [_openedApplicationURL addObject:request.URL]; 3212 [_openedApplicationURL addObject:request.URL];
3213 if ([self shouldClosePageOnNativeApplicationLoad]) 3213 if ([self shouldClosePageOnNativeApplicationLoad])
3214 [_delegate webPageOrderedClose]; 3214 _webStateImpl->CloseWebState();
3215 } 3215 }
3216 return NO; 3216 return NO;
3217 } 3217 }
3218 3218
3219 if ([[request HTTPMethod] isEqualToString:@"POST"]) { 3219 if ([[request HTTPMethod] isEqualToString:@"POST"]) {
3220 web::NavigationItemImpl* item = self.currentNavItem; 3220 web::NavigationItemImpl* item = self.currentNavItem;
3221 // TODO(crbug.com/570699): Remove this check once it's no longer possible to 3221 // TODO(crbug.com/570699): Remove this check once it's no longer possible to
3222 // have no current entries. 3222 // have no current entries.
3223 if (item) 3223 if (item)
3224 [self cachePOSTDataForRequest:request inNavigationItem:item]; 3224 [self cachePOSTDataForRequest:request inNavigationItem:item];
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
4372 // different). |configuration| param and config returned by 4372 // different). |configuration| param and config returned by
4373 // WKWebViewConfigurationProvider are different objects because WKWebView 4373 // WKWebViewConfigurationProvider are different objects because WKWebView
4374 // makes a shallow copy of the config inside init, so every WKWebView 4374 // makes a shallow copy of the config inside init, so every WKWebView
4375 // owns a separate shallow copy of WKWebViewConfiguration. 4375 // owns a separate shallow copy of WKWebViewConfiguration.
4376 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; 4376 [childWebController ensureWebViewCreatedWithConfiguration:configuration];
4377 return childWebController.webView; 4377 return childWebController.webView;
4378 } 4378 }
4379 4379
4380 - (void)webViewDidClose:(WKWebView*)webView { 4380 - (void)webViewDidClose:(WKWebView*)webView {
4381 if (self.sessionController.openedByDOM) { 4381 if (self.sessionController.openedByDOM) {
4382 [self.delegate webPageOrderedClose]; 4382 _webStateImpl->CloseWebState();
4383 } 4383 }
4384 } 4384 }
4385 4385
4386 - (void)webView:(WKWebView*)webView 4386 - (void)webView:(WKWebView*)webView
4387 runJavaScriptAlertPanelWithMessage:(NSString*)message 4387 runJavaScriptAlertPanelWithMessage:(NSString*)message
4388 initiatedByFrame:(WKFrameInfo*)frame 4388 initiatedByFrame:(WKFrameInfo*)frame
4389 completionHandler:(void (^)())completionHandler { 4389 completionHandler:(void (^)())completionHandler {
4390 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT 4390 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT
4391 initiatedByFrame:frame 4391 initiatedByFrame:frame
4392 message:message 4392 message:message
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
5219 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5219 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5220 _lastRegisteredRequestURL = URL; 5220 _lastRegisteredRequestURL = URL;
5221 _loadPhase = web::LOAD_REQUESTED; 5221 _loadPhase = web::LOAD_REQUESTED;
5222 } 5222 }
5223 5223
5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5226 } 5226 }
5227 5227
5228 @end 5228 @end
OLDNEW
« no previous file with comments | « ios/web/public/web_state/web_state_delegate_bridge.h ('k') | ios/web/web_state/ui/crw_web_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698