| 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 4343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4354 GURL requestURL = net::GURLWithNSURL(action.request.URL); | 4354 GURL requestURL = net::GURLWithNSURL(action.request.URL); |
| 4355 if (!requestURL.is_empty() && !requestURL.is_valid()) { | 4355 if (!requestURL.is_empty() && !requestURL.is_valid()) { |
| 4356 DLOG(WARNING) << "Unable to open a window with invalid URL: " | 4356 DLOG(WARNING) << "Unable to open a window with invalid URL: " |
| 4357 << requestURL.spec(); | 4357 << requestURL.spec(); |
| 4358 return nil; | 4358 return nil; |
| 4359 } | 4359 } |
| 4360 | 4360 |
| 4361 NSString* referrer = [self referrerFromNavigationAction:action]; | 4361 NSString* referrer = [self referrerFromNavigationAction:action]; |
| 4362 GURL openerURL = | 4362 GURL openerURL = |
| 4363 referrer ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; | 4363 referrer ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; |
| 4364 CRWWebController* child = [_delegate webController:self | 4364 |
| 4365 createWebControllerForURL:requestURL | 4365 WebState* childWebState = _webStateImpl->CreateNewWebState( |
| 4366 openerURL:openerURL | 4366 requestURL, openerURL, [self userIsInteracting]); |
| 4367 initiatedByUser:[self userIsInteracting]]; | 4367 if (!childWebState) |
| 4368 DCHECK(!child || child.sessionController.openedByDOM); | 4368 return nil; |
| 4369 |
| 4370 CRWWebController* childWebController = |
| 4371 static_cast<WebStateImpl*>(childWebState)->GetWebController(); |
| 4372 |
| 4373 DCHECK(!childWebController || |
| 4374 childWebController.sessionController.openedByDOM); |
| 4369 | 4375 |
| 4370 // WKWebView requires WKUIDelegate to return a child view created with | 4376 // WKWebView requires WKUIDelegate to return a child view created with |
| 4371 // exactly the same |configuration| object (exception is raised if config is | 4377 // exactly the same |configuration| object (exception is raised if config is |
| 4372 // different). |configuration| param and config returned by | 4378 // different). |configuration| param and config returned by |
| 4373 // WKWebViewConfigurationProvider are different objects because WKWebView | 4379 // WKWebViewConfigurationProvider are different objects because WKWebView |
| 4374 // makes a shallow copy of the config inside init, so every WKWebView | 4380 // makes a shallow copy of the config inside init, so every WKWebView |
| 4375 // owns a separate shallow copy of WKWebViewConfiguration. | 4381 // owns a separate shallow copy of WKWebViewConfiguration. |
| 4376 [child ensureWebViewCreatedWithConfiguration:configuration]; | 4382 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; |
| 4377 return child.webView; | 4383 return childWebController.webView; |
| 4378 } | 4384 } |
| 4379 | 4385 |
| 4380 - (void)webViewDidClose:(WKWebView*)webView { | 4386 - (void)webViewDidClose:(WKWebView*)webView { |
| 4381 if (self.sessionController.openedByDOM) { | 4387 if (self.sessionController.openedByDOM) { |
| 4382 [self.delegate webPageOrderedClose]; | 4388 [self.delegate webPageOrderedClose]; |
| 4383 } | 4389 } |
| 4384 } | 4390 } |
| 4385 | 4391 |
| 4386 - (void)webView:(WKWebView*)webView | 4392 - (void)webView:(WKWebView*)webView |
| 4387 runJavaScriptAlertPanelWithMessage:(NSString*)message | 4393 runJavaScriptAlertPanelWithMessage:(NSString*)message |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5219 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5225 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5220 _lastRegisteredRequestURL = URL; | 5226 _lastRegisteredRequestURL = URL; |
| 5221 _loadPhase = web::LOAD_REQUESTED; | 5227 _loadPhase = web::LOAD_REQUESTED; |
| 5222 } | 5228 } |
| 5223 | 5229 |
| 5224 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5230 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5225 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5231 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5226 } | 5232 } |
| 5227 | 5233 |
| 5228 @end | 5234 @end |
| OLD | NEW |