Commit 52f7e12e authored by Yi Su's avatar Yi Su Committed by Commit Bot

Move CRWWebController.removeAllWebFrames into CRWWKNavigationHandler.

This CL moves CRWWebController.removeAllWebFrames into
CRWWKNavigationHandler.

Bug: 956511
Change-Id: I645d20a59c237f99edb474720dc96f8e8d15d392
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1645352Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666433}
parent d1e8057e
...@@ -93,10 +93,6 @@ class WKBackForwardListItemHolder; ...@@ -93,10 +93,6 @@ class WKBackForwardListItemHolder;
rendererInitiated:(BOOL)renderedInitiated rendererInitiated:(BOOL)renderedInitiated
placeholderNavigation:(BOOL)placeholderNavigation; placeholderNavigation:(BOOL)placeholderNavigation;
// Instructs the delegate to clear the web frames list.
- (void)navigationHandlerRemoveAllWebFrames:
(CRWWKNavigationHandler*)navigationHandler;
// Instructs the delegate to display the webView. // Instructs the delegate to display the webView.
- (void)navigationHandlerDisplayWebView: - (void)navigationHandlerDisplayWebView:
(CRWWKNavigationHandler*)navigationHandler; (CRWWKNavigationHandler*)navigationHandler;
......
...@@ -698,7 +698,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -698,7 +698,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
} }
} }
[self.delegate navigationHandlerRemoveAllWebFrames:self]; [self removeAllWebFrames];
// This must be reset at the end, since code above may need information about // This must be reset at the end, since code above may need information about
// the pending load. // the pending load.
self.pendingNavigationInfo = nil; self.pendingNavigationInfo = nil;
...@@ -831,7 +831,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -831,7 +831,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
[self commitPendingNavigationInfoInWebView:webView]; [self commitPendingNavigationInfoInWebView:webView];
[self.delegate navigationHandlerRemoveAllWebFrames:self]; [self removeAllWebFrames];
// This point should closely approximate the document object change, so reset // This point should closely approximate the document object change, so reset
// the list of injected scripts to those that are automatically injected. // the list of injected scripts to those that are automatically injected.
...@@ -1091,7 +1091,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -1091,7 +1091,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
forNavigation:navigation forNavigation:navigation
webView:webView webView:webView
provisionalLoad:NO]; provisionalLoad:NO];
[self.delegate navigationHandlerRemoveAllWebFrames:self]; [self removeAllWebFrames];
_certVerificationErrors->Clear(); _certVerificationErrors->Clear();
[self forgetNullWKNavigation:navigation]; [self forgetNullWKNavigation:navigation];
} }
...@@ -1144,6 +1144,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -1144,6 +1144,7 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
_certVerificationErrors->Clear(); _certVerificationErrors->Clear();
self.webProcessCrashed = YES; self.webProcessCrashed = YES;
[self removeAllWebFrames];
[self.delegate navigationHandlerWebProcessDidCrash:self]; [self.delegate navigationHandlerWebProcessDidCrash:self];
} }
...@@ -1968,6 +1969,16 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -1968,6 +1969,16 @@ const web::CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
self.webStateImpl->OnPageLoaded(failingURL, NO); self.webStateImpl->OnPageLoaded(failingURL, NO);
} }
// Clears the frames list.
- (void)removeAllWebFrames {
web::WebFramesManagerImpl* framesManager =
web::WebFramesManagerImpl::FromWebState(self.webStateImpl);
for (auto* frame : framesManager->GetAllWebFrames()) {
self.webStateImpl->OnWebFrameUnavailable(frame);
}
framesManager->RemoveAllWebFrames();
}
#pragma mark - Public methods #pragma mark - Public methods
- (void)stopLoading { - (void)stopLoading {
......
...@@ -354,8 +354,6 @@ GURL URLEscapedForHistory(const GURL& url) { ...@@ -354,8 +354,6 @@ GURL URLEscapedForHistory(const GURL& url) {
- (void)frameBecameAvailableWithMessage:(WKScriptMessage*)message; - (void)frameBecameAvailableWithMessage:(WKScriptMessage*)message;
// Handles frame became unavailable message. // Handles frame became unavailable message.
- (void)frameBecameUnavailableWithMessage:(WKScriptMessage*)message; - (void)frameBecameUnavailableWithMessage:(WKScriptMessage*)message;
// Clears the frames list.
- (void)removeAllWebFrames;
// Restores the state for this page from session history. // Restores the state for this page from session history.
- (void)restoreStateFromHistory; - (void)restoreStateFromHistory;
...@@ -2243,15 +2241,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -2243,15 +2241,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
} }
} }
- (void)removeAllWebFrames {
web::WebFramesManagerImpl* framesManager =
web::WebFramesManagerImpl::FromWebState([self webState]);
for (auto* frame : framesManager->GetAllWebFrames()) {
self.webStateImpl->OnWebFrameUnavailable(frame);
}
framesManager->RemoveAllWebFrames();
}
#pragma mark - JavaScript message handlers #pragma mark - JavaScript message handlers
// Handlers for JavaScript messages. |message| contains a JavaScript command and // Handlers for JavaScript messages. |message| contains a JavaScript command and
// data relevant to the message, and |context| contains contextual information // data relevant to the message, and |context| contains contextual information
...@@ -3695,11 +3684,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -3695,11 +3684,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
placeholderNavigation:placeholderNavigation]; placeholderNavigation:placeholderNavigation];
} }
- (void)navigationHandlerRemoveAllWebFrames:
(CRWWKNavigationHandler*)navigationHandler {
[self removeAllWebFrames];
}
- (void)navigationHandlerDisplayWebView: - (void)navigationHandlerDisplayWebView:
(CRWWKNavigationHandler*)navigationHandler { (CRWWKNavigationHandler*)navigationHandler {
[self displayWebView]; [self displayWebView];
...@@ -3737,7 +3721,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -3737,7 +3721,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
- (void)navigationHandlerWebProcessDidCrash: - (void)navigationHandlerWebProcessDidCrash:
(CRWWKNavigationHandler*)navigationHandler { (CRWWKNavigationHandler*)navigationHandler {
[self removeAllWebFrames];
// On iOS 11 WKWebView does not repaint after crash and reload. Recreating // On iOS 11 WKWebView does not repaint after crash and reload. Recreating
// web view fixes the issue. TODO(crbug.com/770914): Remove this workaround // web view fixes the issue. TODO(crbug.com/770914): Remove this workaround
// once rdar://35063950 is fixed. // once rdar://35063950 is fixed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment