Commit c956417e authored by Yi Su's avatar Yi Su Committed by Commit Bot

Set CRWWKNavigationHandler as delegate in CRWWebController.

This CL sets the CRWWKNavigationHandler as the navigation handler of
WKWebView in CRWWebController. Unused public @property and methods of
CRWWKNavigationHandler are also cleaned up.

Bug: 956511
Change-Id: I1306d080c57872d4d5b293393b31d20f0bc81716
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634865
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665522}
parent 7fd2894a
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
@class CRWLegacyNativeContentController; @class CRWLegacyNativeContentController;
@class CRWCertVerificationController; @class CRWCertVerificationController;
class GURL; class GURL;
namespace base {
class RepeatingTimer;
}
namespace web { namespace web {
enum class WKNavigationState; enum class WKNavigationState;
enum class ErrorRetryCommand; enum class ErrorRetryCommand;
...@@ -205,11 +202,6 @@ class WKBackForwardListItemHolder; ...@@ -205,11 +202,6 @@ class WKBackForwardListItemHolder;
// TODO(crbug.com/956511): Remove this once refactor is done. // TODO(crbug.com/956511): Remove this once refactor is done.
@property(nonatomic, readwrite, assign) web::WKNavigationState navigationState; @property(nonatomic, readwrite, assign) web::WKNavigationState navigationState;
// The SafeBrowsingDetection timer.
// TODO(crbug.com/956511): Remove this once refactor is done.
@property(nonatomic, readonly, assign)
base::RepeatingTimer* safeBrowsingWarningDetectionTimer;
// Returns the WKBackForwardlistItemHolder of current navigation item. // Returns the WKBackForwardlistItemHolder of current navigation item.
@property(nonatomic, readonly, assign) @property(nonatomic, readonly, assign)
web::WKBackForwardListItemHolder* currentBackForwardListItemHolder; web::WKBackForwardListItemHolder* currentBackForwardListItemHolder;
...@@ -217,11 +209,6 @@ class WKBackForwardListItemHolder; ...@@ -217,11 +209,6 @@ class WKBackForwardListItemHolder;
// Returns the referrer for the current page. // Returns the referrer for the current page.
@property(nonatomic, readonly, assign) web::Referrer currentReferrer; @property(nonatomic, readonly, assign) web::Referrer currentReferrer;
// Discards non committed items, only if the last committed URL was not loaded
// in native view. But if it was a native view, no discard will happen to avoid
// an ugly animation where the web view is inserted and quickly removed.
- (void)discardNonCommittedItemsIfLastCommittedWasNotNativeView;
// Instructs this handler to stop loading. // Instructs this handler to stop loading.
- (void)stopLoading; - (void)stopLoading;
...@@ -233,12 +220,6 @@ class WKBackForwardListItemHolder; ...@@ -233,12 +220,6 @@ class WKBackForwardListItemHolder;
- (web::NavigationContextImpl*)contextForPendingMainFrameNavigationWithURL: - (web::NavigationContextImpl*)contextForPendingMainFrameNavigationWithURL:
(const GURL&)URL; (const GURL&)URL;
// Notifies that server redirect has been received.
// TODO(crbug.com/956511): Remove this once "webView:didCommitNavigation" is
// moved into CRWWKNavigationHandler.
- (void)didReceiveRedirectForNavigation:(web::NavigationContextImpl*)context
withURL:(const GURL&)URL;
// Returns YES if current navigation item is WKNavigationTypeBackForward. // Returns YES if current navigation item is WKNavigationTypeBackForward.
- (BOOL)isCurrentNavigationBackForward; - (BOOL)isCurrentNavigationBackForward;
...@@ -246,12 +227,6 @@ class WKBackForwardListItemHolder; ...@@ -246,12 +227,6 @@ class WKBackForwardListItemHolder;
// loaded by a POST request. // loaded by a POST request.
- (BOOL)isCurrentNavigationItemPOST; - (BOOL)isCurrentNavigationItemPOST;
// Updates current state with any pending information. Should be called when a
// navigation is committed.
// TODO(crbug.com/956511): Make this private once "webView:didCommitNavigation"
// is moved into CRWWKNavigationHandler.
- (void)commitPendingNavigationInfoInWebView:(WKWebView*)webView;
// Sets last committed NavigationItem's title to the given |title|, which can // Sets last committed NavigationItem's title to the given |title|, which can
// not be nil. // not be nil.
- (void)setLastCommittedNavigationItemTitle:(NSString*)title; - (void)setLastCommittedNavigationItemTitle:(NSString*)title;
......
...@@ -1549,10 +1549,6 @@ using web::wk_navigation_util::IsWKInternalUrl; ...@@ -1549,10 +1549,6 @@ using web::wk_navigation_util::IsWKInternalUrl;
[self loadCancelled]; [self loadCancelled];
} }
- (base::RepeatingTimer*)safeBrowsingWarningDetectionTimer {
return &_safeBrowsingWarningDetectionTimer;
}
- (void)loadCancelled { - (void)loadCancelled {
// TODO(crbug.com/821995): Check if this function should be removed. // TODO(crbug.com/821995): Check if this function should be removed.
if (self.navigationState != web::WKNavigationState::FINISHED) { if (self.navigationState != web::WKNavigationState::FINISHED) {
...@@ -1619,6 +1615,8 @@ using web::wk_navigation_util::IsWKInternalUrl; ...@@ -1619,6 +1615,8 @@ using web::wk_navigation_util::IsWKInternalUrl;
return holder; return holder;
} }
// Updates current state with any pending information. Should be called when a
// navigation is committed.
- (void)commitPendingNavigationInfoInWebView:(WKWebView*)webView { - (void)commitPendingNavigationInfoInWebView:(WKWebView*)webView {
if (self.pendingNavigationInfo.referrer) { if (self.pendingNavigationInfo.referrer) {
_currentReferrerString = [self.pendingNavigationInfo.referrer copy]; _currentReferrerString = [self.pendingNavigationInfo.referrer copy];
......
...@@ -290,8 +290,6 @@ GURL URLEscapedForHistory(const GURL& url) { ...@@ -290,8 +290,6 @@ GURL URLEscapedForHistory(const GURL& url) {
// Note that this method is expensive, so it should always be cached locally if // Note that this method is expensive, so it should always be cached locally if
// it's needed multiple times in a method. // it's needed multiple times in a method.
@property(nonatomic, readonly) GURL currentURL; @property(nonatomic, readonly) GURL currentURL;
// Returns the referrer for the current page.
@property(nonatomic, readonly) web::Referrer currentReferrer;
// User agent type of the transient item if any, the pending item if a // User agent type of the transient item if any, the pending item if a
// navigation is in progress or the last committed item otherwise. // navigation is in progress or the last committed item otherwise.
...@@ -613,7 +611,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -613,7 +611,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
webView:webView]; webView:webView];
} }
[_jsInjector setWebView:webView]; [_jsInjector setWebView:webView];
[_webView setNavigationDelegate:self]; [_webView setNavigationDelegate:self.navigationHandler];
[_webView setUIDelegate:self.UIHandler]; [_webView setUIDelegate:self.UIHandler];
for (NSString* keyPath in self.WKWebViewObservers) { for (NSString* keyPath in self.WKWebViewObservers) {
[_webView addObserver:self forKeyPath:keyPath options:0 context:nullptr]; [_webView addObserver:self forKeyPath:keyPath options:0 context:nullptr];
...@@ -3386,78 +3384,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -3386,78 +3384,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
return self.webStateImpl; return self.webStateImpl;
} }
#pragma mark - WKNavigationDelegate Methods
- (void)webView:(WKWebView*)webView
decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction
decisionHandler:
(void (^)(WKNavigationActionPolicy))decisionHandler {
[self.navigationHandler webView:webView
decidePolicyForNavigationAction:navigationAction
decisionHandler:decisionHandler];
}
- (void)webView:(WKWebView*)webView
decidePolicyForNavigationResponse:(WKNavigationResponse*)WKResponse
decisionHandler:
(void (^)(WKNavigationResponsePolicy))handler {
[self.navigationHandler webView:webView
decidePolicyForNavigationResponse:WKResponse
decisionHandler:handler];
}
- (void)webView:(WKWebView*)webView
didStartProvisionalNavigation:(WKNavigation*)navigation {
[self.navigationHandler webView:webView
didStartProvisionalNavigation:navigation];
}
- (void)webView:(WKWebView*)webView
didReceiveServerRedirectForProvisionalNavigation:(WKNavigation*)navigation {
[self.navigationHandler webView:webView
didReceiveServerRedirectForProvisionalNavigation:navigation];
}
- (void)webView:(WKWebView*)webView
didFailProvisionalNavigation:(WKNavigation*)navigation
withError:(NSError*)error {
[self.navigationHandler webView:webView
didFailProvisionalNavigation:navigation
withError:error];
}
- (void)webView:(WKWebView*)webView
didCommitNavigation:(WKNavigation*)navigation {
[self.navigationHandler webView:webView didCommitNavigation:navigation];
}
- (void)webView:(WKWebView*)webView
didFinishNavigation:(WKNavigation*)navigation {
[self.navigationHandler webView:webView didFinishNavigation:navigation];
}
- (void)webView:(WKWebView*)webView
didFailNavigation:(WKNavigation*)navigation
withError:(NSError*)error {
[self.navigationHandler webView:webView
didFailNavigation:navigation
withError:error];
}
- (void)webView:(WKWebView*)webView
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
completionHandler:
(void (^)(NSURLSessionAuthChallengeDisposition,
NSURLCredential*))completionHandler {
[self.navigationHandler webView:webView
didReceiveAuthenticationChallenge:challenge
completionHandler:completionHandler];
}
- (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView {
[self.navigationHandler webViewWebContentProcessDidTerminate:webView];
}
#pragma mark - WKNavigationDelegate Helpers #pragma mark - WKNavigationDelegate Helpers
// Called when the web page has changed document and/or URL, and so the page // Called when the web page has changed document and/or URL, and so the page
......
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