Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2896623003: Added web::NavigationContext::GetPageTransition. (Closed)
Patch Set: Fixed condition for SetIsCreatedFromHashChange call Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 afdb77c98861e546d87dddd7d88a9c488cd20ee7..8ad7ba1ec6b6aeb6fefd17451e40ac83adfb4b1b 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -1340,7 +1340,7 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
transition:(ui::PageTransition)transition {
std::unique_ptr<web::NavigationContextImpl> context =
web::NavigationContextImpl::CreateNavigationContext(_webStateImpl,
- pageURL);
+ pageURL, transition);
_webStateImpl->OnNavigationStarted(context.get());
[[self sessionController] pushNewItemWithURL:pageURL
stateObject:stateObject
@@ -1353,8 +1353,9 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
- (void)replaceStateWithPageURL:(const GURL&)pageURL
stateObject:(NSString*)stateObject {
std::unique_ptr<web::NavigationContextImpl> context =
- web::NavigationContextImpl::CreateNavigationContext(_webStateImpl,
- pageURL);
+ web::NavigationContextImpl::CreateNavigationContext(
+ _webStateImpl, pageURL,
+ ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT);
_webStateImpl->OnNavigationStarted(context.get());
[[self sessionController] updateCurrentItemWithURL:pageURL
stateObject:stateObject];
@@ -1529,8 +1530,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
web::NavigationManager::UserAgentOverrideOption::INHERIT);
}
std::unique_ptr<web::NavigationContextImpl> context =
- web::NavigationContextImpl::CreateNavigationContext(_webStateImpl,
- requestURL);
+ web::NavigationContextImpl::CreateNavigationContext(
+ _webStateImpl, requestURL, transition);
web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem();
// TODO(crbug.com/676129): AddPendingItem does not always create a pending
@@ -1862,6 +1863,18 @@ registerLoadRequestForURL:(const GURL&)requestURL
params.url, params.referrer, params.transition_type,
navigationInitiationType, params.user_agent_override_option);
+ // Mark pending item as created from hash change if necessary. This is needed
+ // because window.hashchange message may not arrive on time.
+ web::NavigationItemImpl* pendingItem = self.sessionController.pendingItem;
+ if (pendingItem) {
+ GURL lastCommittedURL = _webStateImpl->GetLastCommittedURL();
+ GURL pendingURL = pendingItem->GetURL();
+ if (lastCommittedURL != pendingURL &&
+ lastCommittedURL.EqualsIgnoringRef(pendingURL)) {
+ pendingItem->SetIsCreatedFromHashChange(true);
+ }
+ }
kkhorimoto 2017/05/22 21:13:56 This change seems to be unrelated to the page tran
Eugene But (OOO till 7-30) 2017/05/22 22:04:28 This was needed to make sure that hash change navi
+
web::NavigationItemImpl* addedItem = self.currentNavItem;
DCHECK(addedItem);
if (params.extra_headers)
@@ -4164,17 +4177,18 @@ registerLoadRequestForURL:(const GURL&)requestURL
[_navigationStates setState:web::WKNavigationState::REQUESTED
forNavigation:navigation];
std::unique_ptr<web::NavigationContextImpl> context;
+ const ui::PageTransition loadHTMLTransition =
+ ui::PageTransition::PAGE_TRANSITION_TYPED;
if (_webStateImpl->HasWebUI()) {
// WebUI uses |loadHTML:forURL:| to feed the content to web view. This
// should not be treated as a navigation, but WKNavigationDelegate callbacks
// still expect a valid context.
- context =
- web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, URL);
+ context = web::NavigationContextImpl::CreateNavigationContext(
+ _webStateImpl, URL, loadHTMLTransition);
} else {
- context = [self
- registerLoadRequestForURL:URL
- referrer:web::Referrer()
- transition:ui::PageTransition::PAGE_TRANSITION_TYPED];
+ context = [self registerLoadRequestForURL:URL
+ referrer:web::Referrer()
+ transition:loadHTMLTransition];
}
[_navigationStates setContext:std::move(context) forNavigation:navigation];
}
« no previous file with comments | « ios/web/web_state/navigation_context_impl_unittest.mm ('k') | ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698