OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/tab_switcher/tab_switcher_panel_controller.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #import "ios/chrome/browser/tabs/tab.h" | 10 #import "ios/chrome/browser/tabs/tab.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 #pragma mark - SessionCellDelegate | 255 #pragma mark - SessionCellDelegate |
256 | 256 |
257 - (TabSwitcherCache*)tabSwitcherCache { | 257 - (TabSwitcherCache*)tabSwitcherCache { |
258 return _cache; | 258 return _cache; |
259 } | 259 } |
260 | 260 |
261 - (void)cellPressed:(UICollectionViewCell*)cell { | 261 - (void)cellPressed:(UICollectionViewCell*)cell { |
262 const NSInteger tabIndex = | 262 const NSInteger tabIndex = |
263 [[_panelView collectionView] indexPathForCell:cell].item; | 263 [[_panelView collectionView] indexPathForCell:cell].item; |
264 | 264 |
265 if (_sessionType == TabSwitcherSessionType::DISTANT_SESSION) { | 265 if (TabSwitcherSessionTypeIsLocalSession(_sessionType)) { |
| 266 Tab* tab = _localSession->tabs()[tabIndex]; |
| 267 if (tab) |
| 268 [self.delegate tabSwitcherPanelController:self didSelectLocalTab:tab]; |
| 269 } else { |
266 synced_sessions::DistantTab* tab = _distantSession->tabs[tabIndex].get(); | 270 synced_sessions::DistantTab* tab = _distantSession->tabs[tabIndex].get(); |
267 if (tab) | 271 if (tab) |
268 [self.delegate tabSwitcherPanelController:self didSelectDistantTab:tab]; | 272 [self.delegate tabSwitcherPanelController:self didSelectDistantTab:tab]; |
269 } else { | |
270 Tab* tab = _localSession->tabs()[tabIndex]; | |
271 if (tab) | |
272 [self.delegate tabSwitcherPanelController:self didSelectLocalTab:tab]; | |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 - (void)deleteButtonPressedForCell:(UICollectionViewCell*)cell { | 276 - (void)deleteButtonPressedForCell:(UICollectionViewCell*)cell { |
277 DCHECK(_sessionType != TabSwitcherSessionType::DISTANT_SESSION); | 277 DCHECK(TabSwitcherSessionTypeIsLocalSession(_sessionType)); |
278 const NSInteger tabIndex = | 278 const NSInteger tabIndex = |
279 [[_panelView collectionView] indexPathForCell:cell].item; | 279 [[_panelView collectionView] indexPathForCell:cell].item; |
280 Tab* tab = _localSession->tabs()[tabIndex]; | 280 Tab* tab = _localSession->tabs()[tabIndex]; |
281 if (tab) | 281 if (tab) |
282 [self.delegate tabSwitcherPanelController:self didCloseLocalTab:tab]; | 282 [self.delegate tabSwitcherPanelController:self didCloseLocalTab:tab]; |
283 } | 283 } |
284 | 284 |
285 #pragma mark - Private | 285 #pragma mark - Private |
286 | 286 |
287 - (BOOL)isOverlayVisible { | 287 - (BOOL)isOverlayVisible { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 _panelView.reset( | 326 _panelView.reset( |
327 [[TabSwitcherPanelView alloc] initWithSessionType:_sessionType]); | 327 [[TabSwitcherPanelView alloc] initWithSessionType:_sessionType]); |
328 _panelView.get().collectionView.dataSource = self; | 328 _panelView.get().collectionView.dataSource = self; |
329 } | 329 } |
330 | 330 |
331 - (synced_sessions::DistantSession const*)distantSession { | 331 - (synced_sessions::DistantSession const*)distantSession { |
332 return _distantSession.get(); | 332 return _distantSession.get(); |
333 } | 333 } |
334 | 334 |
335 @end | 335 @end |
OLD | NEW |