| OLD | NEW |
| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 Tab* current = [self tabAtIndex:i]; | 404 Tab* current = [self tabAtIndex:i]; |
| 405 DCHECK([current navigationManager]); | 405 DCHECK([current navigationManager]); |
| 406 CRWSessionController* sessionController = | 406 CRWSessionController* sessionController = |
| 407 [current navigationManager]->GetSessionController(); | 407 [current navigationManager]->GetSessionController(); |
| 408 if ([sessionController.openerId isEqualToString:parentID]) | 408 if ([sessionController.openerId isEqualToString:parentID]) |
| 409 return current; | 409 return current; |
| 410 } | 410 } |
| 411 return nil; | 411 return nil; |
| 412 } | 412 } |
| 413 | 413 |
| 414 - (Tab*)firstTabWithOpener:(Tab*)tab { | |
| 415 if (!tab) | |
| 416 return nil; | |
| 417 NSUInteger stopIndex = [self indexOfTab:tab]; | |
| 418 if (stopIndex == NSNotFound) | |
| 419 return nil; | |
| 420 NSString* parentID = tab.tabId; | |
| 421 // Match the navigation index as well as the session id, to better match the | |
| 422 // state of the tab. I.e. two tabs are opened via a link from tab A, and then | |
| 423 // a new url is loaded into tab A, and more tabs opened from that url, the | |
| 424 // latter two tabs should not be grouped with the former two. The navigation | |
| 425 // index is the simplest way to detect navigation changes. | |
| 426 DCHECK([tab navigationManager]); | |
| 427 NSInteger parentNavIndex = [tab navigationManager]->GetCurrentItemIndex(); | |
| 428 for (NSUInteger i = 0; i < stopIndex; ++i) { | |
| 429 Tab* tabToCheck = [self tabAtIndex:i]; | |
| 430 DCHECK([tabToCheck navigationManager]); | |
| 431 CRWSessionController* sessionController = | |
| 432 [tabToCheck navigationManager]->GetSessionController(); | |
| 433 if ([sessionController.openerId isEqualToString:parentID] && | |
| 434 sessionController.openerNavigationIndex == parentNavIndex) { | |
| 435 return tabToCheck; | |
| 436 } | |
| 437 } | |
| 438 return nil; | |
| 439 } | |
| 440 | |
| 441 - (Tab*)lastTabWithOpener:(Tab*)tab { | 414 - (Tab*)lastTabWithOpener:(Tab*)tab { |
| 442 NSUInteger startIndex = [self indexOfTab:tab]; | 415 NSUInteger startIndex = [self indexOfTab:tab]; |
| 443 if (startIndex == NSNotFound) | 416 if (startIndex == NSNotFound) |
| 444 return nil; | 417 return nil; |
| 445 // There is at least one tab in the model, because otherwise the above check | 418 // There is at least one tab in the model, because otherwise the above check |
| 446 // would have returned. | 419 // would have returned. |
| 447 NSString* parentID = tab.tabId; | 420 NSString* parentID = tab.tabId; |
| 448 DCHECK([tab navigationManager]); | 421 DCHECK([tab navigationManager]); |
| 449 NSInteger parentNavIndex = [tab navigationManager]->GetCurrentItemIndex(); | 422 NSInteger parentNavIndex = [tab navigationManager]->GetCurrentItemIndex(); |
| 450 | 423 |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 web::NavigationManager::WebLoadParams params(URL); | 1086 web::NavigationManager::WebLoadParams params(URL); |
| 1114 params.referrer = referrer; | 1087 params.referrer = referrer; |
| 1115 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 1088 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| 1116 [[tab webController] loadWithParams:params]; | 1089 [[tab webController] loadWithParams:params]; |
| 1117 [tab webController].webUsageEnabled = webUsageEnabled_; | 1090 [tab webController].webUsageEnabled = webUsageEnabled_; |
| 1118 [self insertTab:tab atIndex:index]; | 1091 [self insertTab:tab atIndex:index]; |
| 1119 return tab; | 1092 return tab; |
| 1120 } | 1093 } |
| 1121 | 1094 |
| 1122 @end | 1095 @end |
| OLD | NEW |