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

Side by Side Diff: ios/web/navigation/navigation_manager_impl.mm

Issue 2766063002: Remove the concept of currentItemIndex (Closed)
Patch Set: 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 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 int NavigationManagerImpl::GetItemCount() const { 270 int NavigationManagerImpl::GetItemCount() const {
271 return [session_controller_ items].size(); 271 return [session_controller_ items].size();
272 } 272 }
273 273
274 NavigationItem* NavigationManagerImpl::GetItemAtIndex(size_t index) const { 274 NavigationItem* NavigationManagerImpl::GetItemAtIndex(size_t index) const {
275 return [session_controller_ itemAtIndex:index]; 275 return [session_controller_ itemAtIndex:index];
276 } 276 }
277 277
278 int NavigationManagerImpl::GetCurrentItemIndex() const {
279 return [session_controller_ currentNavigationIndex];
280 }
281
282 int NavigationManagerImpl::GetPendingItemIndex() const { 278 int NavigationManagerImpl::GetPendingItemIndex() const {
283 if (GetPendingItem()) { 279 if (GetPendingItem()) {
284 if ([session_controller_ pendingItemIndex] != -1) { 280 if ([session_controller_ pendingItemIndex] != -1) {
285 return [session_controller_ pendingItemIndex]; 281 return [session_controller_ pendingItemIndex];
286 } 282 }
287 // TODO(crbug.com/665189): understand why current item index is 283 // TODO(crbug.com/665189): understand why last committed item index is
288 // returned here. 284 // returned here.
289 return GetCurrentItemIndex(); 285 return GetLastCommittedItemIndex();
290 } 286 }
291 return -1; 287 return -1;
292 } 288 }
293 289
294 int NavigationManagerImpl::GetLastCommittedItemIndex() const { 290 int NavigationManagerImpl::GetLastCommittedItemIndex() const {
295 if (GetItemCount() == 0) 291 if (GetItemCount() == 0)
296 return -1; 292 return -1;
297 return [session_controller_ currentNavigationIndex]; 293 return [session_controller_ currentNavigationIndex];
298 } 294 }
299 295
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 NavigationManagerImpl::GetTransientURLRewriters() { 358 NavigationManagerImpl::GetTransientURLRewriters() {
363 return std::move(transient_url_rewriters_); 359 return std::move(transient_url_rewriters_);
364 } 360 }
365 361
366 void NavigationManagerImpl::RemoveTransientURLRewriters() { 362 void NavigationManagerImpl::RemoveTransientURLRewriters() {
367 transient_url_rewriters_.reset(); 363 transient_url_rewriters_.reset();
368 } 364 }
369 365
370 int NavigationManagerImpl::GetIndexForOffset(int offset) const { 366 int NavigationManagerImpl::GetIndexForOffset(int offset) const {
371 int result = [session_controller_ pendingItemIndex] == -1 367 int result = [session_controller_ pendingItemIndex] == -1
372 ? GetCurrentItemIndex() 368 ? GetLastCommittedItemIndex()
373 : static_cast<int>([session_controller_ pendingItemIndex]); 369 : static_cast<int>([session_controller_ pendingItemIndex]);
374 370
375 if (offset < 0) { 371 if (offset < 0) {
376 if (GetTransientItem() && [session_controller_ pendingItemIndex] == -1) { 372 if (GetTransientItem() && [session_controller_ pendingItemIndex] == -1) {
377 // Going back from transient item that added to the end navigation stack 373 // Going back from transient item that added to the end navigation stack
378 // is a matter of discarding it as there is no need to move navigation 374 // is a matter of discarding it as there is no need to move navigation
379 // index back. 375 // index back.
380 offset++; 376 offset++;
381 } 377 }
382 378
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 435
440 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { 436 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const {
441 DCHECK_GT(index, 0); 437 DCHECK_GT(index, 0);
442 DCHECK_LT(index, GetItemCount()); 438 DCHECK_LT(index, GetItemCount());
443 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); 439 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType();
444 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; 440 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK;
445 } 441 }
446 442
447 NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem() 443 NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem()
448 const { 444 const {
449 int index = GetCurrentItemIndex(); 445 int index = GetLastCommittedItemIndex();
450 if (index == -1) 446 if (index == -1)
451 return nullptr; 447 return nullptr;
452 WebClient* client = GetWebClient(); 448 WebClient* client = GetWebClient();
453 const ScopedNavigationItemImplList& items = [session_controller_ items]; 449 const ScopedNavigationItemImplList& items = [session_controller_ items];
454 while (index >= 0) { 450 while (index >= 0) {
455 NavigationItem* item = items[index--].get(); 451 NavigationItem* item = items[index--].get();
456 if (!client->IsAppSpecificURL(item->GetVirtualURL())) 452 if (!client->IsAppSpecificURL(item->GetVirtualURL()))
457 return item; 453 return item;
458 } 454 }
459 return nullptr; 455 return nullptr;
460 } 456 }
461 457
462 } // namespace web 458 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698