| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ | 7 // ============================================================================ |
| 8 | 8 |
| 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.h" | 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.h" |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 [[TabStripContainerCoordinator alloc] init]; | 101 [[TabStripContainerCoordinator alloc] init]; |
| 102 size_t index = static_cast<size_t>(indexPath.item); | 102 size_t index = static_cast<size_t>(indexPath.item); |
| 103 DCHECK(index < _webStates.size()); | 103 DCHECK(index < _webStates.size()); |
| 104 tabCoordinator.webState = _webStates[index].get(); | 104 tabCoordinator.webState = _webStates[index].get(); |
| 105 tabCoordinator.presentationKey = indexPath; | 105 tabCoordinator.presentationKey = indexPath; |
| 106 [self addChildCoordinator:tabCoordinator]; | 106 [self addChildCoordinator:tabCoordinator]; |
| 107 [tabCoordinator start]; | 107 [tabCoordinator start]; |
| 108 _activeWebStateIndex = index; | 108 _activeWebStateIndex = index; |
| 109 } | 109 } |
| 110 | 110 |
| 111 - (void)closeTabAtIndexPath:(NSIndexPath*)indexPath { |
| 112 size_t index = static_cast<size_t>(indexPath.item); |
| 113 DCHECK(index < _webStates.size()); |
| 114 _webStates.erase(_webStates.begin() + index); |
| 115 } |
| 116 |
| 111 #pragma mark - TabGridCommands | 117 #pragma mark - TabGridCommands |
| 112 | 118 |
| 113 - (void)showTabGrid { | 119 - (void)showTabGrid { |
| 114 // This object should only ever have at most one child. | 120 // This object should only ever have at most one child. |
| 115 DCHECK_LE(self.children.count, 1UL); | 121 DCHECK_LE(self.children.count, 1UL); |
| 116 BrowserCoordinator* child = [self.children anyObject]; | 122 BrowserCoordinator* child = [self.children anyObject]; |
| 117 [child stop]; | 123 [child stop]; |
| 118 [self removeChildCoordinator:child]; | 124 [self removeChildCoordinator:child]; |
| 119 } | 125 } |
| 120 | 126 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 146 activeWebState->GetNavigationManager()->LoadURLWithParams(params); | 152 activeWebState->GetNavigationManager()->LoadURLWithParams(params); |
| 147 if (!self.children.count) { | 153 if (!self.children.count) { |
| 148 [self showTabAtIndexPath:[NSIndexPath | 154 [self showTabAtIndexPath:[NSIndexPath |
| 149 indexPathForItem:static_cast<NSUInteger>( | 155 indexPathForItem:static_cast<NSUInteger>( |
| 150 _activeWebStateIndex) | 156 _activeWebStateIndex) |
| 151 inSection:0]]; | 157 inSection:0]]; |
| 152 } | 158 } |
| 153 } | 159 } |
| 154 | 160 |
| 155 @end | 161 @end |
| OLD | NEW |