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

Unified Diff: ios/web/navigation/navigation_manager_impl.mm

Issue 2766453002: Implement Reload for ORIGINAL_REQUEST_URL in NavigationManagerImpl. (Closed)
Patch Set: Addressed comments Created 3 years, 9 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/navigation/navigation_manager_impl.mm
diff --git a/ios/web/navigation/navigation_manager_impl.mm b/ios/web/navigation/navigation_manager_impl.mm
index a059c1d0e3c19f4421442ccc06de66ddcc44dd38..9da7c359e28a7a235767a27a34d14d9578fc40be 100644
--- a/ios/web/navigation/navigation_manager_impl.mm
+++ b/ios/web/navigation/navigation_manager_impl.mm
@@ -339,6 +339,27 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
void NavigationManagerImpl::Reload(ReloadType reload_type,
bool check_for_reposts) {
+ // Reload with ORIGINAL_REQUEST_URL type should reload with the original
+ // request url of the transient item, or pending item if transient doesn't
+ // exist, or last committed item if both of them don't exist. The reason is
+ // that a server side redirect may change the item's url.
+ // For example, an user visits www.chromium.org and is then redirected
Eugene But (OOO till 7-30) 2017/03/28 01:52:56 s/an/the ?
liaoyuke 2017/03/28 16:22:48 Done.
+ // to m.chromium.org, when the user wants to refresh the page with a different
+ // configuration (e.g. user agent), the user would be expecting to visit
+ // www.chromium.org instead of m.chromium.org.
+ if (reload_type == web::ReloadType::ORIGINAL_REQUEST_URL) {
+ NavigationItem* reload_item = nullptr;
+ if (GetTransientItem())
+ reload_item = GetTransientItem();
+ else if (GetPendingItem())
+ reload_item = GetPendingItem();
+ else
+ reload_item = GetLastCommittedItem();
+ DCHECK(reload_item);
+
+ reload_item->SetURL(reload_item->GetOriginalRequestURL());
+ }
+
delegate_->Reload();
}
@@ -434,7 +455,7 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
}
bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const {
- DCHECK_GT(index, 0);
+ DCHECK_GE(index, 0);
DCHECK_LT(index, GetItemCount());
ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType();
return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK;

Powered by Google App Engine
This is Rietveld 408576698