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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 // Remove the transient content view. | 1922 // Remove the transient content view. |
1923 [self clearTransientContentView]; | 1923 [self clearTransientContentView]; |
1924 | 1924 |
1925 web::NavigationItem* item = self.currentNavItem; | 1925 web::NavigationItem* item = self.currentNavItem; |
1926 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL(); | 1926 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL(); |
1927 // If it's a chrome URL, but not a native one, create the WebUI instance. | 1927 // If it's a chrome URL, but not a native one, create the WebUI instance. |
1928 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && | 1928 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && |
1929 ![_nativeProvider hasControllerForURL:currentURL]) { | 1929 ![_nativeProvider hasControllerForURL:currentURL]) { |
1930 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || | 1930 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || |
1931 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && | 1931 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && |
1932 self.sessionController.openedByDOM) { | 1932 self.webState && self.webState->IsOpenedByDOM()) { |
1933 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as | 1933 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as |
1934 // they have increased power. WebUI URLs may only be opened when the user | 1934 // they have increased power. WebUI URLs may only be opened when the user |
1935 // types in the URL or use bookmarks. | 1935 // types in the URL or use bookmarks. |
1936 [[self sessionController] discardNonCommittedItems]; | 1936 [[self sessionController] discardNonCommittedItems]; |
1937 return; | 1937 return; |
1938 } else { | 1938 } else { |
1939 [self createWebUIForURL:currentURL]; | 1939 [self createWebUIForURL:currentURL]; |
1940 } | 1940 } |
1941 } | 1941 } |
1942 | 1942 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 | 2297 |
2298 - (CRWJSInjectionReceiver*)jsInjectionReceiver { | 2298 - (CRWJSInjectionReceiver*)jsInjectionReceiver { |
2299 return _jsInjectionReceiver; | 2299 return _jsInjectionReceiver; |
2300 } | 2300 } |
2301 | 2301 |
2302 - (BOOL)shouldClosePageOnNativeApplicationLoad { | 2302 - (BOOL)shouldClosePageOnNativeApplicationLoad { |
2303 // The page should be closed if it was initiated by the DOM and there has been | 2303 // The page should be closed if it was initiated by the DOM and there has been |
2304 // no user interaction with the page since the web view was created, or if | 2304 // no user interaction with the page since the web view was created, or if |
2305 // the page has no navigation items, as occurs when an App Store link is | 2305 // the page has no navigation items, as occurs when an App Store link is |
2306 // opened from another application. | 2306 // opened from another application. |
2307 BOOL rendererInitiatedWithoutInteraction = | 2307 BOOL rendererInitiatedWithoutInteraction = self.webState && |
2308 self.sessionController.openedByDOM && !_userInteractedWithWebController; | 2308 self.webState->IsOpenedByDOM() && |
| 2309 !_userInteractedWithWebController; |
2309 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); | 2310 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); |
2310 return rendererInitiatedWithoutInteraction || noNavigationItems; | 2311 return rendererInitiatedWithoutInteraction || noNavigationItems; |
2311 } | 2312 } |
2312 | 2313 |
2313 - (BOOL)usesDesktopUserAgent { | 2314 - (BOOL)usesDesktopUserAgent { |
2314 web::NavigationItem* item = self.currentNavItem; | 2315 web::NavigationItem* item = self.currentNavItem; |
2315 return item && item->GetUserAgentType() == web::UserAgentType::DESKTOP; | 2316 return item && item->GetUserAgentType() == web::UserAgentType::DESKTOP; |
2316 } | 2317 } |
2317 | 2318 |
2318 - (web::MojoFacade*)mojoFacade { | 2319 - (web::MojoFacade*)mojoFacade { |
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4328 referrer ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; | 4329 referrer ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; |
4329 | 4330 |
4330 WebState* childWebState = _webStateImpl->CreateNewWebState( | 4331 WebState* childWebState = _webStateImpl->CreateNewWebState( |
4331 requestURL, openerURL, [self userIsInteracting]); | 4332 requestURL, openerURL, [self userIsInteracting]); |
4332 if (!childWebState) | 4333 if (!childWebState) |
4333 return nil; | 4334 return nil; |
4334 | 4335 |
4335 CRWWebController* childWebController = | 4336 CRWWebController* childWebController = |
4336 static_cast<WebStateImpl*>(childWebState)->GetWebController(); | 4337 static_cast<WebStateImpl*>(childWebState)->GetWebController(); |
4337 | 4338 |
4338 DCHECK(!childWebController || | 4339 DCHECK(!childWebController || (childWebController.webState && |
4339 childWebController.sessionController.openedByDOM); | 4340 childWebController.webState->IsOpenedByDOM())); |
4340 | 4341 |
4341 // WKWebView requires WKUIDelegate to return a child view created with | 4342 // WKWebView requires WKUIDelegate to return a child view created with |
4342 // exactly the same |configuration| object (exception is raised if config is | 4343 // exactly the same |configuration| object (exception is raised if config is |
4343 // different). |configuration| param and config returned by | 4344 // different). |configuration| param and config returned by |
4344 // WKWebViewConfigurationProvider are different objects because WKWebView | 4345 // WKWebViewConfigurationProvider are different objects because WKWebView |
4345 // makes a shallow copy of the config inside init, so every WKWebView | 4346 // makes a shallow copy of the config inside init, so every WKWebView |
4346 // owns a separate shallow copy of WKWebViewConfiguration. | 4347 // owns a separate shallow copy of WKWebViewConfiguration. |
4347 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; | 4348 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; |
4348 return childWebController.webView; | 4349 return childWebController.webView; |
4349 } | 4350 } |
4350 | 4351 |
4351 - (void)webViewDidClose:(WKWebView*)webView { | 4352 - (void)webViewDidClose:(WKWebView*)webView { |
4352 if (self.sessionController.openedByDOM) { | 4353 if (self.webState && self.webState->IsOpenedByDOM()) |
4353 _webStateImpl->CloseWebState(); | 4354 _webStateImpl->CloseWebState(); |
4354 } | |
4355 } | 4355 } |
4356 | 4356 |
4357 - (void)webView:(WKWebView*)webView | 4357 - (void)webView:(WKWebView*)webView |
4358 runJavaScriptAlertPanelWithMessage:(NSString*)message | 4358 runJavaScriptAlertPanelWithMessage:(NSString*)message |
4359 initiatedByFrame:(WKFrameInfo*)frame | 4359 initiatedByFrame:(WKFrameInfo*)frame |
4360 completionHandler:(void (^)())completionHandler { | 4360 completionHandler:(void (^)())completionHandler { |
4361 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT | 4361 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT |
4362 initiatedByFrame:frame | 4362 initiatedByFrame:frame |
4363 message:message | 4363 message:message |
4364 defaultText:nil | 4364 defaultText:nil |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5190 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5190 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
5191 _lastRegisteredRequestURL = URL; | 5191 _lastRegisteredRequestURL = URL; |
5192 _loadPhase = web::LOAD_REQUESTED; | 5192 _loadPhase = web::LOAD_REQUESTED; |
5193 } | 5193 } |
5194 | 5194 |
5195 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5195 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5196 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5196 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5197 } | 5197 } |
5198 | 5198 |
5199 @end | 5199 @end |
OLD | NEW |