Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 if (!GetTransientItem() && !GetPendingItem() && !GetLastCommittedItem()) | |
| 343 return; | |
| 344 | |
| 345 // Reload with ORIGINAL_REQUEST_URL type should reload with the original | |
| 346 // request url of the transient item, or pending item if transient doesn't | |
| 347 // exist, or last committed item if both of them don't exist. The reason is | |
| 348 // that a server side redirect may change the item's url. | |
| 349 // For example, the user visits www.chromium.org and is then redirected | |
| 350 // to m.chromium.org, when the user wants to refresh the page with a different | |
| 351 // configuration (e.g. user agent), the user would be expecting to visit | |
| 352 // www.chromium.org instead of m.chromium.org. | |
| 353 if (reload_type == web::ReloadType::ORIGINAL_REQUEST_URL) { | |
| 354 NavigationItem* reload_item = nullptr; | |
| 355 if (GetTransientItem()) | |
| 356 reload_item = GetTransientItem(); | |
| 357 else if (GetPendingItem()) | |
| 358 reload_item = GetPendingItem(); | |
| 359 else | |
| 360 reload_item = GetLastCommittedItem(); | |
|
kkhorimoto
2017/03/28 18:10:17
So are we no longer using the last user item logic
| |
| 361 DCHECK(reload_item); | |
| 362 | |
| 363 reload_item->SetURL(reload_item->GetOriginalRequestURL()); | |
| 364 } | |
| 365 | |
| 342 delegate_->Reload(); | 366 delegate_->Reload(); |
| 343 } | 367 } |
| 344 | 368 |
| 345 void NavigationManagerImpl::CopyStateFromAndPrune( | 369 void NavigationManagerImpl::CopyStateFromAndPrune( |
| 346 const NavigationManager* manager) { | 370 const NavigationManager* manager) { |
| 347 DCHECK(manager); | 371 DCHECK(manager); |
| 348 CRWSessionController* other_session = | 372 CRWSessionController* other_session = |
| 349 static_cast<const NavigationManagerImpl*>(manager)->session_controller_; | 373 static_cast<const NavigationManagerImpl*>(manager)->session_controller_; |
| 350 [session_controller_ copyStateFromSessionControllerAndPrune:other_session]; | 374 [session_controller_ copyStateFromSessionControllerAndPrune:other_session]; |
| 351 } | 375 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 // The desktop user agent cannot be used for a pending navigation to an | 451 // The desktop user agent cannot be used for a pending navigation to an |
| 428 // app-specific URL. | 452 // app-specific URL. |
| 429 DCHECK_NE(pending_item->GetUserAgentType(), UserAgentType::NONE); | 453 DCHECK_NE(pending_item->GetUserAgentType(), UserAgentType::NONE); |
| 430 pending_item->SetUserAgentType(UserAgentType::DESKTOP); | 454 pending_item->SetUserAgentType(UserAgentType::DESKTOP); |
| 431 } else { | 455 } else { |
| 432 override_desktop_user_agent_for_next_pending_item_ = true; | 456 override_desktop_user_agent_for_next_pending_item_ = true; |
| 433 } | 457 } |
| 434 } | 458 } |
| 435 | 459 |
| 436 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { | 460 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { |
| 437 DCHECK_GT(index, 0); | 461 DCHECK_GE(index, 0); |
| 438 DCHECK_LT(index, GetItemCount()); | 462 DCHECK_LT(index, GetItemCount()); |
| 439 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); | 463 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); |
| 440 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; | 464 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; |
| 441 } | 465 } |
| 442 | 466 |
| 443 NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem() | 467 NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem() |
| 444 const { | 468 const { |
| 445 int index = GetLastCommittedItemIndex(); | 469 int index = GetLastCommittedItemIndex(); |
| 446 if (index == -1) | 470 if (index == -1) |
| 447 return nullptr; | 471 return nullptr; |
| 448 WebClient* client = GetWebClient(); | 472 WebClient* client = GetWebClient(); |
| 449 const ScopedNavigationItemImplList& items = [session_controller_ items]; | 473 const ScopedNavigationItemImplList& items = [session_controller_ items]; |
| 450 while (index >= 0) { | 474 while (index >= 0) { |
| 451 NavigationItem* item = items[index--].get(); | 475 NavigationItem* item = items[index--].get(); |
| 452 if (!client->IsAppSpecificURL(item->GetVirtualURL())) | 476 if (!client->IsAppSpecificURL(item->GetVirtualURL())) |
| 453 return item; | 477 return item; |
| 454 } | 478 } |
| 455 return nullptr; | 479 return nullptr; |
| 456 } | 480 } |
| 457 | 481 |
| 458 } // namespace web | 482 } // namespace web |
| OLD | NEW |