| 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 4323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4334 GURL requestURL = net::GURLWithNSURL(action.request.URL); | 4334 GURL requestURL = net::GURLWithNSURL(action.request.URL); |
| 4335 if (!requestURL.is_empty() && !requestURL.is_valid()) { | 4335 if (!requestURL.is_empty() && !requestURL.is_valid()) { |
| 4336 DLOG(WARNING) << "Unable to open a window with invalid URL: " | 4336 DLOG(WARNING) << "Unable to open a window with invalid URL: " |
| 4337 << requestURL.spec(); | 4337 << requestURL.spec(); |
| 4338 return nil; | 4338 return nil; |
| 4339 } | 4339 } |
| 4340 | 4340 |
| 4341 NSString* referrer = [self referrerFromNavigationAction:action]; | 4341 NSString* referrer = [self referrerFromNavigationAction:action]; |
| 4342 GURL openerURL = | 4342 GURL openerURL = |
| 4343 referrer ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; | 4343 referrer ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; |
| 4344 CRWWebController* child = [_delegate webController:self | 4344 |
| 4345 createWebControllerForURL:requestURL | 4345 WebState* childWebState = _webStateImpl->CreateNewWebState( |
| 4346 openerURL:openerURL | 4346 requestURL, openerURL, [self userIsInteracting]); |
| 4347 initiatedByUser:[self userIsInteracting]]; | 4347 if (!childWebState) |
| 4348 DCHECK(!child || child.sessionController.openedByDOM); | 4348 return nil; |
| 4349 |
| 4350 CRWWebController* childWebController = |
| 4351 static_cast<WebStateImpl*>(childWebState)->GetWebController(); |
| 4352 |
| 4353 DCHECK(!childWebController || |
| 4354 childWebController.sessionController.openedByDOM); |
| 4349 | 4355 |
| 4350 // WKWebView requires WKUIDelegate to return a child view created with | 4356 // WKWebView requires WKUIDelegate to return a child view created with |
| 4351 // exactly the same |configuration| object (exception is raised if config is | 4357 // exactly the same |configuration| object (exception is raised if config is |
| 4352 // different). |configuration| param and config returned by | 4358 // different). |configuration| param and config returned by |
| 4353 // WKWebViewConfigurationProvider are different objects because WKWebView | 4359 // WKWebViewConfigurationProvider are different objects because WKWebView |
| 4354 // 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 |
| 4355 // owns a separate shallow copy of WKWebViewConfiguration. | 4361 // owns a separate shallow copy of WKWebViewConfiguration. |
| 4356 [child ensureWebViewCreatedWithConfiguration:configuration]; | 4362 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; |
| 4357 return child.webView; | 4363 return childWebController.webView; |
| 4358 } | 4364 } |
| 4359 | 4365 |
| 4360 - (void)webViewDidClose:(WKWebView*)webView { | 4366 - (void)webViewDidClose:(WKWebView*)webView { |
| 4361 if (self.sessionController.openedByDOM) { | 4367 if (self.sessionController.openedByDOM) { |
| 4362 [self.delegate webPageOrderedClose]; | 4368 [self.delegate webPageOrderedClose]; |
| 4363 } | 4369 } |
| 4364 } | 4370 } |
| 4365 | 4371 |
| 4366 - (void)webView:(WKWebView*)webView | 4372 - (void)webView:(WKWebView*)webView |
| 4367 runJavaScriptAlertPanelWithMessage:(NSString*)message | 4373 runJavaScriptAlertPanelWithMessage:(NSString*)message |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5199 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5205 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5200 _lastRegisteredRequestURL = URL; | 5206 _lastRegisteredRequestURL = URL; |
| 5201 _loadPhase = web::LOAD_REQUESTED; | 5207 _loadPhase = web::LOAD_REQUESTED; |
| 5202 } | 5208 } |
| 5203 | 5209 |
| 5204 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5210 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5205 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5211 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5206 } | 5212 } |
| 5207 | 5213 |
| 5208 @end | 5214 @end |
| OLD | NEW |