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 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1857 // Remove the transient content view. | 1857 // Remove the transient content view. |
1858 [self clearTransientContentView]; | 1858 [self clearTransientContentView]; |
1859 | 1859 |
1860 web::NavigationItem* item = self.currentNavItem; | 1860 web::NavigationItem* item = self.currentNavItem; |
1861 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL(); | 1861 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL(); |
1862 // If it's a chrome URL, but not a native one, create the WebUI instance. | 1862 // If it's a chrome URL, but not a native one, create the WebUI instance. |
1863 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && | 1863 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && |
1864 ![_nativeProvider hasControllerForURL:currentURL]) { | 1864 ![_nativeProvider hasControllerForURL:currentURL]) { |
1865 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || | 1865 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || |
1866 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && | 1866 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && |
1867 self.sessionController.openedByDOM) { | 1867 self.webState && self.webState->HasOpener()) { |
1868 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as | 1868 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as |
1869 // they have increased power. WebUI URLs may only be opened when the user | 1869 // they have increased power. WebUI URLs may only be opened when the user |
1870 // types in the URL or use bookmarks. | 1870 // types in the URL or use bookmarks. |
1871 [[self sessionController] discardNonCommittedItems]; | 1871 [[self sessionController] discardNonCommittedItems]; |
1872 return; | 1872 return; |
1873 } else { | 1873 } else { |
1874 [self createWebUIForURL:currentURL]; | 1874 [self createWebUIForURL:currentURL]; |
1875 } | 1875 } |
1876 } | 1876 } |
1877 | 1877 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2188 | 2188 |
2189 - (CRWJSInjectionReceiver*)jsInjectionReceiver { | 2189 - (CRWJSInjectionReceiver*)jsInjectionReceiver { |
2190 return _jsInjectionReceiver; | 2190 return _jsInjectionReceiver; |
2191 } | 2191 } |
2192 | 2192 |
2193 - (BOOL)shouldClosePageOnNativeApplicationLoad { | 2193 - (BOOL)shouldClosePageOnNativeApplicationLoad { |
2194 // The page should be closed if it was initiated by the DOM and there has been | 2194 // The page should be closed if it was initiated by the DOM and there has been |
2195 // no user interaction with the page since the web view was created, or if | 2195 // no user interaction with the page since the web view was created, or if |
2196 // the page has no navigation items, as occurs when an App Store link is | 2196 // the page has no navigation items, as occurs when an App Store link is |
2197 // opened from another application. | 2197 // opened from another application. |
2198 BOOL rendererInitiatedWithoutInteraction = | 2198 BOOL rendererInitiatedWithoutInteraction = self.webState && |
2199 self.sessionController.openedByDOM && !_userInteractedWithWebController; | 2199 self.webState->HasOpener() && |
2200 !_userInteractedWithWebController; | |
2200 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); | 2201 BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount()); |
2201 return rendererInitiatedWithoutInteraction || noNavigationItems; | 2202 return rendererInitiatedWithoutInteraction || noNavigationItems; |
2202 } | 2203 } |
2203 | 2204 |
2204 - (BOOL)usesDesktopUserAgent { | 2205 - (BOOL)usesDesktopUserAgent { |
2205 web::NavigationItem* item = self.currentNavItem; | 2206 web::NavigationItem* item = self.currentNavItem; |
2206 return item && item->GetUserAgentType() == web::UserAgentType::DESKTOP; | 2207 return item && item->GetUserAgentType() == web::UserAgentType::DESKTOP; |
2207 } | 2208 } |
2208 | 2209 |
2209 - (web::MojoFacade*)mojoFacade { | 2210 - (web::MojoFacade*)mojoFacade { |
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4209 referrer.length ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; | 4210 referrer.length ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; |
4210 | 4211 |
4211 WebState* childWebState = _webStateImpl->CreateNewWebState( | 4212 WebState* childWebState = _webStateImpl->CreateNewWebState( |
4212 requestURL, openerURL, [self userIsInteracting]); | 4213 requestURL, openerURL, [self userIsInteracting]); |
4213 if (!childWebState) | 4214 if (!childWebState) |
4214 return nil; | 4215 return nil; |
4215 | 4216 |
4216 CRWWebController* childWebController = | 4217 CRWWebController* childWebController = |
4217 static_cast<WebStateImpl*>(childWebState)->GetWebController(); | 4218 static_cast<WebStateImpl*>(childWebState)->GetWebController(); |
4218 | 4219 |
4219 DCHECK(!childWebController || | 4220 DCHECK(!childWebController || (childWebController.webState && |
4220 childWebController.sessionController.openedByDOM); | 4221 childWebController.webState->HasOpener())); |
4221 | 4222 |
4222 // WKWebView requires WKUIDelegate to return a child view created with | 4223 // WKWebView requires WKUIDelegate to return a child view created with |
4223 // exactly the same |configuration| object (exception is raised if config is | 4224 // exactly the same |configuration| object (exception is raised if config is |
4224 // different). |configuration| param and config returned by | 4225 // different). |configuration| param and config returned by |
4225 // WKWebViewConfigurationProvider are different objects because WKWebView | 4226 // WKWebViewConfigurationProvider are different objects because WKWebView |
4226 // makes a shallow copy of the config inside init, so every WKWebView | 4227 // makes a shallow copy of the config inside init, so every WKWebView |
4227 // owns a separate shallow copy of WKWebViewConfiguration. | 4228 // owns a separate shallow copy of WKWebViewConfiguration. |
4228 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; | 4229 [childWebController ensureWebViewCreatedWithConfiguration:configuration]; |
4229 return childWebController.webView; | 4230 return childWebController.webView; |
4230 } | 4231 } |
4231 | 4232 |
4232 - (void)webViewDidClose:(WKWebView*)webView { | 4233 - (void)webViewDidClose:(WKWebView*)webView { |
4233 if (self.sessionController.openedByDOM) { | 4234 if (self.webState && self.webState->HasOpener()) |
Eugene But (OOO till 7-30)
2017/03/18 00:33:30
|self.webState && self.webState->HasOpener()| is q
kkhorimoto
2017/03/20 22:39:20
Done.
| |
4234 _webStateImpl->CloseWebState(); | 4235 _webStateImpl->CloseWebState(); |
4235 } | |
4236 } | 4236 } |
4237 | 4237 |
4238 - (void)webView:(WKWebView*)webView | 4238 - (void)webView:(WKWebView*)webView |
4239 runJavaScriptAlertPanelWithMessage:(NSString*)message | 4239 runJavaScriptAlertPanelWithMessage:(NSString*)message |
4240 initiatedByFrame:(WKFrameInfo*)frame | 4240 initiatedByFrame:(WKFrameInfo*)frame |
4241 completionHandler:(void (^)())completionHandler { | 4241 completionHandler:(void (^)())completionHandler { |
4242 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT | 4242 [self runJavaScriptDialogOfType:web::JAVASCRIPT_DIALOG_TYPE_ALERT |
4243 initiatedByFrame:frame | 4243 initiatedByFrame:frame |
4244 message:message | 4244 message:message |
4245 defaultText:nil | 4245 defaultText:nil |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5071 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5071 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
5072 _lastRegisteredRequestURL = URL; | 5072 _lastRegisteredRequestURL = URL; |
5073 _loadPhase = web::LOAD_REQUESTED; | 5073 _loadPhase = web::LOAD_REQUESTED; |
5074 } | 5074 } |
5075 | 5075 |
5076 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5076 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5077 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5077 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5078 } | 5078 } |
5079 | 5079 |
5080 @end | 5080 @end |
OLD | NEW |