| Index: ios/web/web_state/ui/crw_web_controller.mm
|
| diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
|
| index e23141e1fb0ba7a4916fff43a41a8033ca04ef90..c15eb0c28b87b3c90437e3146c956e359006209b 100644
|
| --- a/ios/web/web_state/ui/crw_web_controller.mm
|
| +++ b/ios/web/web_state/ui/crw_web_controller.mm
|
| @@ -436,6 +436,8 @@ @interface CRWWebController ()<CRWContextMenuDelegate,
|
| @property(nonatomic, readonly) CRWSessionController* sessionController;
|
| // The associated NavigationManagerImpl.
|
| @property(nonatomic, readonly) NavigationManagerImpl* navigationManagerImpl;
|
| +// Whether the associated WebState has an opener.
|
| +@property(nonatomic, readonly) BOOL hasOpener;
|
| // Dictionary where keys are the names of WKWebView properties and values are
|
| // selector names which should be called when a corresponding property has
|
| // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that
|
| @@ -1864,7 +1866,7 @@ - (void)loadCurrentURL {
|
| ![_nativeProvider hasControllerForURL:currentURL]) {
|
| if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED ||
|
| item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) &&
|
| - self.sessionController.openedByDOM) {
|
| + self.hasOpener) {
|
| // WebUI URLs can not be opened by DOM to prevent cross-site scripting as
|
| // they have increased power. WebUI URLs may only be opened when the user
|
| // types in the URL or use bookmarks.
|
| @@ -2196,7 +2198,7 @@ - (BOOL)shouldClosePageOnNativeApplicationLoad {
|
| // the page has no navigation items, as occurs when an App Store link is
|
| // opened from another application.
|
| BOOL rendererInitiatedWithoutInteraction =
|
| - self.sessionController.openedByDOM && !_userInteractedWithWebController;
|
| + self.hasOpener && !_userInteractedWithWebController;
|
| BOOL noNavigationItems = !(self.navigationManagerImpl->GetItemCount());
|
| return rendererInitiatedWithoutInteraction || noNavigationItems;
|
| }
|
| @@ -3473,6 +3475,10 @@ - (NavigationManagerImpl*)navigationManagerImpl {
|
| return _webStateImpl ? &(_webStateImpl->GetNavigationManagerImpl()) : nil;
|
| }
|
|
|
| +- (BOOL)hasOpener {
|
| + return _webStateImpl ? _webStateImpl->HasOpener() : NO;
|
| +}
|
| +
|
| - (web::NavigationItemImpl*)currentNavItem {
|
| // This goes through the legacy Session* interface rather than Navigation*
|
| // because it is itself a legacy method that should not exist, and this
|
| @@ -4216,8 +4222,7 @@ - (WKWebView*)webView:(WKWebView*)webView
|
| CRWWebController* childWebController =
|
| static_cast<WebStateImpl*>(childWebState)->GetWebController();
|
|
|
| - DCHECK(!childWebController ||
|
| - childWebController.sessionController.openedByDOM);
|
| + DCHECK(!childWebController || childWebController.hasOpener);
|
|
|
| // WKWebView requires WKUIDelegate to return a child view created with
|
| // exactly the same |configuration| object (exception is raised if config is
|
| @@ -4230,9 +4235,8 @@ - (WKWebView*)webView:(WKWebView*)webView
|
| }
|
|
|
| - (void)webViewDidClose:(WKWebView*)webView {
|
| - if (self.sessionController.openedByDOM) {
|
| + if (self.hasOpener)
|
| _webStateImpl->CloseWebState();
|
| - }
|
| }
|
|
|
| - (void)webView:(WKWebView*)webView
|
|
|