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