| 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_header_view.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_header_view.h" |
| 6 | 6 |
| 7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 327 } |
| 328 | 328 |
| 329 - (void)setPanelSelectorAccessibility { | 329 - (void)setPanelSelectorAccessibility { |
| 330 NSInteger index = [self selectedIndex]; | 330 NSInteger index = [self selectedIndex]; |
| 331 if (index != NSNotFound) | 331 if (index != NSNotFound) |
| 332 [_accessibilityView setAccessibilityLabel:[self panelTitleAtIndex:index]]; | 332 [_accessibilityView setAccessibilityLabel:[self panelTitleAtIndex:index]]; |
| 333 } | 333 } |
| 334 | 334 |
| 335 - (NSString*)panelTitleAtIndex:(NSInteger)index { | 335 - (NSString*)panelTitleAtIndex:(NSInteger)index { |
| 336 NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; | 336 NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; |
| 337 SessionCellData* sessionCellData = | 337 TabSwitcherSessionCellData* sessionCellData = |
| 338 [[self dataSource] sessionCellDataAtIndex:indexPath.row]; | 338 [[self dataSource] sessionCellDataAtIndex:indexPath.row]; |
| 339 return sessionCellData.title; | 339 return sessionCellData.title; |
| 340 } | 340 } |
| 341 | 341 |
| 342 #pragma mark - AccessiblePanelSelectorDelegate | 342 #pragma mark - AccessiblePanelSelectorDelegate |
| 343 | 343 |
| 344 - (void)moveToPanelInDirection:(PanelSelectionChangeDirection)direction { | 344 - (void)moveToPanelInDirection:(PanelSelectionChangeDirection)direction { |
| 345 NSInteger indexDelta = direction == RIGHT ? 1 : -1; | 345 NSInteger indexDelta = direction == RIGHT ? 1 : -1; |
| 346 NSInteger newIndex = [self selectedIndex] + indexDelta; | 346 NSInteger newIndex = [self selectedIndex] + indexDelta; |
| 347 newIndex = std::max<NSInteger>(newIndex, 0); | 347 newIndex = std::max<NSInteger>(newIndex, 0); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 366 DCHECK([self dataSource]); | 366 DCHECK([self dataSource]); |
| 367 DCHECK(section == 0); | 367 DCHECK(section == 0); |
| 368 return [[self dataSource] tabSwitcherHeaderViewSessionCount]; | 368 return [[self dataSource] tabSwitcherHeaderViewSessionCount]; |
| 369 } | 369 } |
| 370 | 370 |
| 371 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView | 371 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView |
| 372 cellForItemAtIndexPath:(NSIndexPath*)indexPath { | 372 cellForItemAtIndexPath:(NSIndexPath*)indexPath { |
| 373 TabSwitcherHeaderCell* headerCell = [collectionView | 373 TabSwitcherHeaderCell* headerCell = [collectionView |
| 374 dequeueReusableCellWithReuseIdentifier:[TabSwitcherHeaderCell identifier] | 374 dequeueReusableCellWithReuseIdentifier:[TabSwitcherHeaderCell identifier] |
| 375 forIndexPath:indexPath]; | 375 forIndexPath:indexPath]; |
| 376 SessionCellData* sessionCellData = | 376 TabSwitcherSessionCellData* sessionCellData = |
| 377 [[self dataSource] sessionCellDataAtIndex:indexPath.row]; | 377 [[self dataSource] sessionCellDataAtIndex:indexPath.row]; |
| 378 [headerCell loadSessionCellData:sessionCellData]; | 378 [headerCell loadSessionCellData:sessionCellData]; |
| 379 return headerCell; | 379 return headerCell; |
| 380 } | 380 } |
| 381 | 381 |
| 382 #pragma mark - UICollectionViewDelegate | 382 #pragma mark - UICollectionViewDelegate |
| 383 | 383 |
| 384 - (void)collectionView:(UICollectionView*)collectionView | 384 - (void)collectionView:(UICollectionView*)collectionView |
| 385 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 385 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
| 386 [self updateSelectionAtIndex:indexPath.item animated:YES]; | 386 [self updateSelectionAtIndex:indexPath.item animated:YES]; |
| 387 [[self delegate] tabSwitcherHeaderViewDidSelectSessionAtIndex:indexPath.item]; | 387 [[self delegate] tabSwitcherHeaderViewDidSelectSessionAtIndex:indexPath.item]; |
| 388 } | 388 } |
| 389 | 389 |
| 390 #pragma mark - UIScrollViewDelegate | 390 #pragma mark - UIScrollViewDelegate |
| 391 | 391 |
| 392 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { | 392 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { |
| 393 [self layoutActiveSpaceIndicatorAnimated:NO]; | 393 [self layoutActiveSpaceIndicatorAnimated:NO]; |
| 394 } | 394 } |
| 395 | 395 |
| 396 @end | 396 @end |
| OLD | NEW |