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

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

Issue 2766453002: Implement Reload for ORIGINAL_REQUEST_URL in NavigationManagerImpl. (Closed)
Patch Set: Rebase 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..a9e42e85157e6e0aab693ee103ae6ee809afc2b3 100644
--- a/ios/web/navigation/navigation_manager_impl.mm
+++ b/ios/web/navigation/navigation_manager_impl.mm
@@ -339,6 +339,30 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
void NavigationManagerImpl::Reload(ReloadType reload_type,
bool check_for_reposts) {
+ if (!GetTransientItem() && !GetPendingItem() && !GetLastCommittedItem())
+ return;
+
+ // 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, the user visits www.chromium.org and is then redirected
+ // 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();
kkhorimoto 2017/03/28 18:10:17 So are we no longer using the last user item logic
+ DCHECK(reload_item);
+
+ reload_item->SetURL(reload_item->GetOriginalRequestURL());
+ }
+
delegate_->Reload();
}
@@ -434,7 +458,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;
« no previous file with comments | « ios/web/navigation/crw_session_controller.mm ('k') | ios/web/navigation/navigation_manager_impl_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698