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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/navigation/navigation_manager_impl.h" 5 #import "ios/web/navigation/navigation_manager_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 NavigationItemList NavigationManagerImpl::GetBackwardItems() const { 332 NavigationItemList NavigationManagerImpl::GetBackwardItems() const {
333 return [session_controller_ backwardItems]; 333 return [session_controller_ backwardItems];
334 } 334 }
335 335
336 NavigationItemList NavigationManagerImpl::GetForwardItems() const { 336 NavigationItemList NavigationManagerImpl::GetForwardItems() const {
337 return [session_controller_ forwardItems]; 337 return [session_controller_ forwardItems];
338 } 338 }
339 339
340 void NavigationManagerImpl::Reload(ReloadType reload_type, 340 void NavigationManagerImpl::Reload(ReloadType reload_type,
341 bool check_for_reposts) { 341 bool check_for_reposts) {
342 // Reload with ORIGINAL_REQUEST_URL type should reload with the original
343 // request url of the current item because a server side redirect may change
Eugene But (OOO till 7-30) 2017/03/27 17:15:47 Could you please avoid referring to "current item"
liaoyuke 2017/03/28 00:16:40 Done.
344 // its url. For example, an user visits www.youtube.com and is then redirected
Eugene But (OOO till 7-30) 2017/03/27 17:15:47 nit: s/www.youtube.com/www.chromium.org and s/m.yo
liaoyuke 2017/03/28 00:16:40 Done.
345 // to m.youtube.com, when the user wants to refresh the page with a different
346 // configuration (e.g. user agent), the user would be expecting to visit
347 // www.youtube.com instead of m.youtube.com.
348 // NOTE: this logic has the following two assumptions:
349 // 1. |-reload| in web controller always reloads the current item.
350 // 2. Generally, a website would not issue a client side redirect
351 // (e.g. window.location) to redirect an user to its mobile version.
352 if (reload_type == web::ReloadType::ORIGINAL_REQUEST_URL) {
353 NavigationItem* current_item = [session_controller_ currentItem];
Eugene But (OOO till 7-30) 2017/03/27 17:15:47 The end goal is to remove |currentItem|, so it wil
liaoyuke 2017/03/28 00:16:40 Addressed per offline discussion.
354 DCHECK(current_item);
355 current_item->SetURL(current_item->GetOriginalRequestURL());
Eugene But (OOO till 7-30) 2017/03/27 17:15:47 Should we crash if NM is empty? Does this code cra
liaoyuke 2017/03/28 00:16:40 This function should do nothing if NM is empty. Ad
356 }
357
342 delegate_->Reload(); 358 delegate_->Reload();
343 } 359 }
344 360
345 void NavigationManagerImpl::CopyStateFromAndPrune( 361 void NavigationManagerImpl::CopyStateFromAndPrune(
346 const NavigationManager* manager) { 362 const NavigationManager* manager) {
347 DCHECK(manager); 363 DCHECK(manager);
348 CRWSessionController* other_session = 364 CRWSessionController* other_session =
349 static_cast<const NavigationManagerImpl*>(manager)->session_controller_; 365 static_cast<const NavigationManagerImpl*>(manager)->session_controller_;
350 [session_controller_ copyStateFromSessionControllerAndPrune:other_session]; 366 [session_controller_ copyStateFromSessionControllerAndPrune:other_session];
351 } 367 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // The desktop user agent cannot be used for a pending navigation to an 443 // The desktop user agent cannot be used for a pending navigation to an
428 // app-specific URL. 444 // app-specific URL.
429 DCHECK_NE(pending_item->GetUserAgentType(), UserAgentType::NONE); 445 DCHECK_NE(pending_item->GetUserAgentType(), UserAgentType::NONE);
430 pending_item->SetUserAgentType(UserAgentType::DESKTOP); 446 pending_item->SetUserAgentType(UserAgentType::DESKTOP);
431 } else { 447 } else {
432 override_desktop_user_agent_for_next_pending_item_ = true; 448 override_desktop_user_agent_for_next_pending_item_ = true;
433 } 449 }
434 } 450 }
435 451
436 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { 452 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const {
437 DCHECK_GT(index, 0); 453 DCHECK_GE(index, 0);
438 DCHECK_LT(index, GetItemCount()); 454 DCHECK_LT(index, GetItemCount());
439 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); 455 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType();
440 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; 456 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK;
441 } 457 }
442 458
443 NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem() 459 NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem()
444 const { 460 const {
445 int index = GetLastCommittedItemIndex(); 461 int index = GetLastCommittedItemIndex();
446 if (index == -1) 462 if (index == -1)
447 return nullptr; 463 return nullptr;
448 WebClient* client = GetWebClient(); 464 WebClient* client = GetWebClient();
449 const ScopedNavigationItemImplList& items = [session_controller_ items]; 465 const ScopedNavigationItemImplList& items = [session_controller_ items];
450 while (index >= 0) { 466 while (index >= 0) {
451 NavigationItem* item = items[index--].get(); 467 NavigationItem* item = items[index--].get();
452 if (!client->IsAppSpecificURL(item->GetVirtualURL())) 468 if (!client->IsAppSpecificURL(item->GetVirtualURL()))
453 return item; 469 return item;
454 } 470 }
455 return nullptr; 471 return nullptr;
456 } 472 }
457 473
458 } // namespace web 474 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698