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

Side by Side Diff: ios/chrome/browser/tabs/tab_model.mm

Issue 2690893003: Remove obsolete code in TabModelOrderController. (Closed)
Patch Set: Rebase on origin/master. Created 3 years, 10 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/chrome/browser/tabs/tab_model.h" 5 #import "ios/chrome/browser/tabs/tab_model.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 Tab* current = [_tabs objectAtIndex:i]; 357 Tab* current = [_tabs objectAtIndex:i];
358 DCHECK([current navigationManager]); 358 DCHECK([current navigationManager]);
359 CRWSessionController* sessionController = 359 CRWSessionController* sessionController =
360 [current navigationManager]->GetSessionController(); 360 [current navigationManager]->GetSessionController();
361 if ([sessionController.openerId isEqualToString:parentID]) 361 if ([sessionController.openerId isEqualToString:parentID])
362 return current; 362 return current;
363 } 363 }
364 return nil; 364 return nil;
365 } 365 }
366 366
367 - (Tab*)firstTabWithOpener:(Tab*)tab {
368 if (!tab)
369 return nil;
370 NSUInteger stopIndex = [self indexOfTab:tab];
371 if (stopIndex == NSNotFound)
372 return nil;
373 NSString* parentID = tab.tabId;
374 // Match the navigation index as well as the session id, to better match the
375 // state of the tab. I.e. two tabs are opened via a link from tab A, and then
376 // a new url is loaded into tab A, and more tabs opened from that url, the
377 // latter two tabs should not be grouped with the former two. The navigation
378 // index is the simplest way to detect navigation changes.
379 DCHECK([tab navigationManager]);
380 NSInteger parentNavIndex = [tab navigationManager]->GetCurrentItemIndex();
381 for (NSUInteger i = 0; i < stopIndex; ++i) {
382 Tab* tabToCheck = [_tabs objectAtIndex:i];
383 DCHECK([tabToCheck navigationManager]);
384 CRWSessionController* sessionController =
385 [tabToCheck navigationManager]->GetSessionController();
386 if ([sessionController.openerId isEqualToString:parentID] &&
387 sessionController.openerNavigationIndex == parentNavIndex) {
388 return tabToCheck;
389 }
390 }
391 return nil;
392 }
393
394 - (Tab*)lastTabWithOpener:(Tab*)tab { 367 - (Tab*)lastTabWithOpener:(Tab*)tab {
395 NSUInteger startIndex = [self indexOfTab:tab]; 368 NSUInteger startIndex = [self indexOfTab:tab];
396 if (startIndex == NSNotFound) 369 if (startIndex == NSNotFound)
397 return nil; 370 return nil;
398 // There is at least one tab in the model, because otherwise the above check 371 // There is at least one tab in the model, because otherwise the above check
399 // would have returned. 372 // would have returned.
400 NSString* parentID = tab.tabId; 373 NSString* parentID = tab.tabId;
401 DCHECK([tab navigationManager]); 374 DCHECK([tab navigationManager]);
402 NSInteger parentNavIndex = [tab navigationManager]->GetCurrentItemIndex(); 375 NSInteger parentNavIndex = [tab navigationManager]->GetCurrentItemIndex();
403 376
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 web::NavigationManager::WebLoadParams params(URL); 1044 web::NavigationManager::WebLoadParams params(URL);
1072 params.referrer = referrer; 1045 params.referrer = referrer;
1073 params.transition_type = ui::PAGE_TRANSITION_TYPED; 1046 params.transition_type = ui::PAGE_TRANSITION_TYPED;
1074 [[tab webController] loadWithParams:params]; 1047 [[tab webController] loadWithParams:params];
1075 [tab webController].webUsageEnabled = webUsageEnabled_; 1048 [tab webController].webUsageEnabled = webUsageEnabled_;
1076 [self insertTab:tab atIndex:index]; 1049 [self insertTab:tab atIndex:index];
1077 return tab; 1050 return tab;
1078 } 1051 }
1079 1052
1080 @end 1053 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_model.h ('k') | ios/chrome/browser/tabs/tab_model_order_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698