Commit 81321bf5 authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[ios] Remove |loadNativeViewWithSuccess| and inline its content.

This makes it more clear which WebStateObserver callbacks are called
when. This change does not contain any function changes.

Bug: 903497
Change-Id: Ie774c191ffc2681a7cf1df90089ea25e90a381ac
Reviewed-on: https://chromium-review.googlesource.com/c/1359296Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Danyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613265}
parent 642abc60
...@@ -552,7 +552,7 @@ const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -552,7 +552,7 @@ const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
// to notify WebStateObservers. // to notify WebStateObservers.
- (void)presentNativeContentForNavigationItem:(web::NavigationItem*)item; - (void)presentNativeContentForNavigationItem:(web::NavigationItem*)item;
// Notifies WebStateObservers the completion of this navigation. // Notifies WebStateObservers the completion of this navigation.
- (void)didLoadNativeContentForNavigationItem:(web::NavigationItem*)item; - (void)didLoadNativeContentForNavigationItem:(web::NavigationItemImpl*)item;
// Loads a blank page directly into WKWebView as a placeholder for a Native View // Loads a blank page directly into WKWebView as a placeholder for a Native View
// or WebUI URL. This page has the URL about:blank?for=<encoded original URL>. // or WebUI URL. This page has the URL about:blank?for=<encoded original URL>.
// The completion handler is called in the |webView:didFinishNavigation| // The completion handler is called in the |webView:didFinishNavigation|
...@@ -564,11 +564,6 @@ const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100; ...@@ -564,11 +564,6 @@ const CertVerificationErrorsCacheType::size_type kMaxCertErrorsCount = 100;
- (void)handleErrorRetryCommand:(web::ErrorRetryCommand)command - (void)handleErrorRetryCommand:(web::ErrorRetryCommand)command
navigationItem:(web::NavigationItemImpl*)item navigationItem:(web::NavigationItemImpl*)item
navigationContext:(web::NavigationContextImpl*)context; navigationContext:(web::NavigationContextImpl*)context;
// Loads the current nativeController in a native view. If a web view is
// present, removes it and swaps in the native view in its place. |context| can
// not be null.
- (void)loadNativeViewWithSuccess:(BOOL)loadSuccess
navigationContext:(web::NavigationContextImpl*)context;
// Loads the error page. // Loads the error page.
- (void)loadErrorPageForNavigationItem:(web::NavigationItemImpl*)item - (void)loadErrorPageForNavigationItem:(web::NavigationItemImpl*)item
navigationContext:(web::NavigationContextImpl*)context; navigationContext:(web::NavigationContextImpl*)context;
...@@ -1722,38 +1717,6 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1722,38 +1717,6 @@ registerLoadRequestForURL:(const GURL&)requestURL
holder->set_mime_type([_pendingNavigationInfo MIMEType]); holder->set_mime_type([_pendingNavigationInfo MIMEType]);
} }
- (void)loadNativeViewWithSuccess:(BOOL)loadSuccess
navigationContext:(web::NavigationContextImpl*)context {
if (loadSuccess) {
// No DidStartNavigation callback for displaying error page.
_webStateImpl->OnNavigationStarted(context);
}
[self didStartLoading];
self.navigationManagerImpl->CommitPendingItem();
if (loadSuccess) {
// No DidFinishNavigation callback for displaying error page.
context->SetHasCommitted(true);
_webStateImpl->OnNavigationFinished(context);
web::NavigationItemImpl* item =
context ? web::GetItemWithUniqueID(self.navigationManagerImpl,
context->GetNavigationItemUniqueID())
: nullptr;
if (item && web::GetWebClient()->IsAppSpecificURL(item->GetURL())) {
// Reports the successful navigation to the ErrorRetryStateMachine.
item->error_retry_state_machine().SetNoNavigationError();
}
}
NSString* title = [self.nativeController title];
if (title) {
[self setNavigationItemTitle:title];
}
if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) {
[self.nativeController setDelegate:self];
}
}
- (void)loadErrorPageForNavigationItem:(web::NavigationItemImpl*)item - (void)loadErrorPageForNavigationItem:(web::NavigationItemImpl*)item
navigationContext:(web::NavigationContextImpl*)context { navigationContext:(web::NavigationContextImpl*)context {
const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL();
...@@ -1794,15 +1757,20 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1794,15 +1757,20 @@ registerLoadRequestForURL:(const GURL&)requestURL
[_navigationStates setState:web::WKNavigationState::REQUESTED [_navigationStates setState:web::WKNavigationState::REQUESTED
forNavigation:navigation]; forNavigation:navigation];
// If |context| has placeholder URL, this is the second part of a native error // TODO(crbug.com/803503): only call these for placeholder navigation because
// load for a provisional load failure. Rewrite the context URL to actual URL // they should have already been triggered during navigation commit for
// so the navigation event is broadcasted. // failures that happen after commit.
// TODO(crbug.com/803503) Clean up callbcks for native error. [self didStartLoading];
self.navigationManagerImpl->CommitPendingItem();
// If |context| is a placeholder navigation, this is the second part of the
// error page load for a provisional load failure. Rewrite the context URL to
// actual URL so the navigation event is broadcasted.
if (context->IsPlaceholderNavigation()) { if (context->IsPlaceholderNavigation()) {
context->SetUrl(item->GetURL()); context->SetUrl(item->GetURL());
context->SetPlaceholderNavigation(false); context->SetPlaceholderNavigation(false);
} }
[self loadNativeViewWithSuccess:NO navigationContext:context];
_webStateImpl->SetIsLoading(false); _webStateImpl->SetIsLoading(false);
_webStateImpl->OnPageLoaded(currentURL, NO); _webStateImpl->OnPageLoaded(currentURL, NO);
} }
...@@ -1845,22 +1813,39 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1845,22 +1813,39 @@ registerLoadRequestForURL:(const GURL&)requestURL
} }
} }
- (void)didLoadNativeContentForNavigationItem:(web::NavigationItem*)item { - (void)didLoadNativeContentForNavigationItem:(web::NavigationItemImpl*)item {
const GURL targetURL = item ? item->GetURL() : GURL::EmptyGURL(); const GURL targetURL = item ? item->GetURL() : GURL::EmptyGURL();
const web::Referrer referrer; const web::Referrer referrer;
std::unique_ptr<web::NavigationContextImpl> navigationContext = std::unique_ptr<web::NavigationContextImpl> context =
[self registerLoadRequestForURL:targetURL [self registerLoadRequestForURL:targetURL
referrer:referrer referrer:referrer
transition:self.currentTransition transition:self.currentTransition
sameDocumentNavigation:NO sameDocumentNavigation:NO
hasUserGesture:YES hasUserGesture:YES
placeholderNavigation:NO]; placeholderNavigation:NO];
[self loadNativeViewWithSuccess:YES
navigationContext:navigationContext.get()]; _webStateImpl->OnNavigationStarted(context.get());
[self didStartLoading];
self.navigationManagerImpl->CommitPendingItem();
context->SetHasCommitted(true);
_webStateImpl->OnNavigationFinished(context.get());
if (item && web::GetWebClient()->IsAppSpecificURL(item->GetURL())) {
// Report the successful navigation to the ErrorRetryStateMachine.
item->error_retry_state_machine().SetNoNavigationError();
}
NSString* title = [self.nativeController title];
if (title) {
[self setNavigationItemTitle:title];
}
if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) {
[self.nativeController setDelegate:self];
}
_loadPhase = web::PAGE_LOADED; _loadPhase = web::PAGE_LOADED;
[self didFinishWithURL:targetURL [self didFinishWithURL:targetURL loadSuccess:YES context:context.get()];
loadSuccess:YES
context:navigationContext.get()];
} }
- (web::NavigationContextImpl*)loadPlaceholderInWebViewForURL: - (web::NavigationContextImpl*)loadPlaceholderInWebViewForURL:
......
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