Commit 34992965 authored by Nazerke's avatar Nazerke Committed by Commit Bot

[ios] Refactoring the GridItem.

This CL is renaming the GridItem to be the TabSwitcherItem to make it
usable by the TabStrip as well as by the TabGrid.

Bug: 1128249
Change-Id: Ic7736156f9cff5b6218261ce29f047b37b37253f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536435Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#827832}
parent 62fe3e0e
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//ios/public/provider/chrome/browser/build_config.gni")
source_set("tab_switcher") {
sources = [
"tab_switcher_item.h",
"tab_switcher_item.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
"//base",
]
}
...@@ -45,6 +45,7 @@ source_set("tab_grid") { ...@@ -45,6 +45,7 @@ source_set("tab_grid") {
"//ios/chrome/browser/ui/recent_tabs", "//ios/chrome/browser/ui/recent_tabs",
"//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui", "//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui",
"//ios/chrome/browser/ui/sharing", "//ios/chrome/browser/ui/sharing",
"//ios/chrome/browser/ui/tab_switcher",
"//ios/chrome/browser/ui/tab_switcher/tab_grid/transitions", "//ios/chrome/browser/ui/tab_switcher/tab_grid/transitions",
"//ios/chrome/browser/ui/thumb_strip", "//ios/chrome/browser/ui/thumb_strip",
"//ios/chrome/browser/ui/thumb_strip:feature_flags", "//ios/chrome/browser/ui/thumb_strip:feature_flags",
...@@ -163,6 +164,7 @@ source_set("unit_tests") { ...@@ -163,6 +164,7 @@ source_set("unit_tests") {
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/tabs:tabs_internal", "//ios/chrome/browser/tabs:tabs_internal",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/tab_switcher",
"//ios/chrome/browser/web", "//ios/chrome/browser/web",
"//ios/chrome/browser/web:page_placeholder", "//ios/chrome/browser/web:page_placeholder",
"//ios/chrome/browser/web:test_support", "//ios/chrome/browser/web:test_support",
......
...@@ -23,8 +23,6 @@ source_set("grid_ui") { ...@@ -23,8 +23,6 @@ source_set("grid_ui") {
"grid_drag_drop_handler.h", "grid_drag_drop_handler.h",
"grid_empty_view.h", "grid_empty_view.h",
"grid_image_data_source.h", "grid_image_data_source.h",
"grid_item.h",
"grid_item.mm",
"grid_layout.h", "grid_layout.h",
"grid_layout.mm", "grid_layout.mm",
"grid_theme.h", "grid_theme.h",
...@@ -55,6 +53,7 @@ source_set("grid_ui") { ...@@ -55,6 +53,7 @@ source_set("grid_ui") {
"//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/gestures", "//ios/chrome/browser/ui/gestures",
"//ios/chrome/browser/ui/tab_switcher",
"//ios/chrome/browser/ui/tab_switcher/tab_grid/transitions", "//ios/chrome/browser/ui/tab_switcher/tab_grid/transitions",
"//ios/chrome/browser/ui/thumb_strip:feature_flags", "//ios/chrome/browser/ui/thumb_strip:feature_flags",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
...@@ -75,6 +74,7 @@ source_set("unit_tests") { ...@@ -75,6 +74,7 @@ source_set("unit_tests") {
":grid_ui", ":grid_ui",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//ios/chrome/browser/ui/tab_switcher",
"//ios/chrome/test:test_support", "//ios/chrome/test:test_support",
"//testing/gtest", "//testing/gtest",
] ]
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class GridItem; @class TabSwitcherItem;
// Supports idempotent insert/delete/updates to a grid. // Supports idempotent insert/delete/updates to a grid.
@protocol GridConsumer @protocol GridConsumer
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
// Tells the consumer to replace its current set of items with |items| and // Tells the consumer to replace its current set of items with |items| and
// update the selected item ID to be |selectedItemID|. It's an error to pass // update the selected item ID to be |selectedItemID|. It's an error to pass
// an |items| array containing items without unique IDs. // an |items| array containing items without unique IDs.
- (void)populateItems:(NSArray<GridItem*>*)items - (void)populateItems:(NSArray<TabSwitcherItem*>*)items
selectedItemID:(NSString*)selectedItemID; selectedItemID:(NSString*)selectedItemID;
// Tells the consumer to insert |item| at |index| and update the selected item // Tells the consumer to insert |item| at |index| and update the selected item
// ID to be |selectedItemID|. It's an error if |item|'s ID duplicates an // ID to be |selectedItemID|. It's an error if |item|'s ID duplicates an
// ID already passed to the consumer (and not yet removed). // ID already passed to the consumer (and not yet removed).
- (void)insertItem:(GridItem*)item - (void)insertItem:(TabSwitcherItem*)item
atIndex:(NSUInteger)index atIndex:(NSUInteger)index
selectedItemID:(NSString*)selectedItemID; selectedItemID:(NSString*)selectedItemID;
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
// Tells the consumer to replace the item with ID |itemID| with |item|. // Tells the consumer to replace the item with ID |itemID| with |item|.
// It's an error if |item|'s ID duplicates any other item's ID besides |itemID|. // It's an error if |item|'s ID duplicates any other item's ID besides |itemID|.
// The consumer should ignore this call if |itemID| has not yet been inserted. // The consumer should ignore this call if |itemID| has not yet been inserted.
- (void)replaceItemID:(NSString*)itemID withItem:(GridItem*)item; - (void)replaceItemID:(NSString*)itemID withItem:(TabSwitcherItem*)item;
// Tells the consumer to move the item with id |itemID| to |toIndex|. Note that // Tells the consumer to move the item with id |itemID| to |toIndex|. Note that
// the ID of the selected item isn't changed by this method, although the index // the ID of the selected item isn't changed by this method, although the index
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_drag_drop_handler.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_drag_drop_handler.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_empty_view.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_empty_view.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_image_data_source.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_image_data_source.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_layout.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_layout.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/horizontal_layout.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/horizontal_layout.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/grid_transition_layout.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/grid_transition_layout.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h" #import "ios/chrome/browser/ui/thumb_strip/thumb_strip_feature.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h" #include "ios/chrome/browser/ui/util/rtl_geometry.h"
...@@ -57,7 +57,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -57,7 +57,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
// A collection view of items in a grid format. // A collection view of items in a grid format.
@property(nonatomic, weak) UICollectionView* collectionView; @property(nonatomic, weak) UICollectionView* collectionView;
// The local model backing the collection view. // The local model backing the collection view.
@property(nonatomic, strong) NSMutableArray<GridItem*>* items; @property(nonatomic, strong) NSMutableArray<TabSwitcherItem*>* items;
// Identifier of the selected item. This value is disregarded if |self.items| is // Identifier of the selected item. This value is disregarded if |self.items| is
// empty. This bookkeeping is done to set the correct selection on // empty. This bookkeeping is done to set the correct selection on
// |-viewWillAppear:|. // |-viewWillAppear:|.
...@@ -110,7 +110,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -110,7 +110,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
- (instancetype)init { - (instancetype)init {
if (self = [super init]) { if (self = [super init]) {
_items = [[NSMutableArray<GridItem*> alloc] init]; _items = [[NSMutableArray<TabSwitcherItem*> alloc] init];
_showsSelectionUpdates = YES; _showsSelectionUpdates = YES;
} }
return self; return self;
...@@ -351,7 +351,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -351,7 +351,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
if (itemIndex >= self.items.count) if (itemIndex >= self.items.count)
itemIndex = self.items.count - 1; itemIndex = self.items.count - 1;
GridItem* item = self.items[itemIndex]; TabSwitcherItem* item = self.items[itemIndex];
cell = cell =
[collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier
forIndexPath:indexPath]; forIndexPath:indexPath];
...@@ -397,7 +397,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -397,7 +397,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
base::checked_cast<NSUInteger>(destinationIndexPath.item); base::checked_cast<NSUInteger>(destinationIndexPath.item);
// Update |items| before informing the delegate, so the state of the UI // Update |items| before informing the delegate, so the state of the UI
// is correctly represented before any updates occur. // is correctly represented before any updates occur.
GridItem* item = self.items[source]; TabSwitcherItem* item = self.items[source];
[self.items removeObjectAtIndex:source]; [self.items removeObjectAtIndex:source];
[self.items insertObject:item atIndex:destination]; [self.items insertObject:item atIndex:destination];
self.hasChangedOrder = YES; self.hasChangedOrder = YES;
...@@ -466,7 +466,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -466,7 +466,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
// Return an empty array because the plus sign cell should not be dragged. // Return an empty array because the plus sign cell should not be dragged.
return @[]; return @[];
} }
GridItem* item = self.items[indexPath.item]; TabSwitcherItem* item = self.items[indexPath.item];
return @[ [self.dragDropHandler dragItemForItemWithID:item.identifier] ]; return @[ [self.dragDropHandler dragItemForItemWithID:item.identifier] ];
} }
...@@ -610,12 +610,12 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -610,12 +610,12 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
#pragma mark - GridConsumer #pragma mark - GridConsumer
- (void)populateItems:(NSArray<GridItem*>*)items - (void)populateItems:(NSArray<TabSwitcherItem*>*)items
selectedItemID:(NSString*)selectedItemID { selectedItemID:(NSString*)selectedItemID {
#ifndef NDEBUG #ifndef NDEBUG
// Consistency check: ensure no IDs are duplicated. // Consistency check: ensure no IDs are duplicated.
NSMutableSet<NSString*>* identifiers = [[NSMutableSet alloc] init]; NSMutableSet<NSString*>* identifiers = [[NSMutableSet alloc] init];
for (GridItem* item in items) { for (TabSwitcherItem* item in items) {
[identifiers addObject:item.identifier]; [identifiers addObject:item.identifier];
} }
CHECK_EQ(identifiers.count, items.count); CHECK_EQ(identifiers.count, items.count);
...@@ -637,7 +637,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -637,7 +637,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self updateFractionVisibleOfLastItem]; [self updateFractionVisibleOfLastItem];
} }
- (void)insertItem:(GridItem*)item - (void)insertItem:(TabSwitcherItem*)item
atIndex:(NSUInteger)index atIndex:(NSUInteger)index
selectedItemID:(NSString*)selectedItemID { selectedItemID:(NSString*)selectedItemID {
// Consistency check: |item|'s ID is not in |items|. // Consistency check: |item|'s ID is not in |items|.
...@@ -729,7 +729,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -729,7 +729,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
scrollPosition:UICollectionViewScrollPositionNone]; scrollPosition:UICollectionViewScrollPositionNone];
} }
- (void)replaceItemID:(NSString*)itemID withItem:(GridItem*)item { - (void)replaceItemID:(NSString*)itemID withItem:(TabSwitcherItem*)item {
if ([self indexOfItemWithID:itemID] == NSNotFound) if ([self indexOfItemWithID:itemID] == NSNotFound)
return; return;
// Consistency check: |item|'s ID is either |itemID| or not in |items|. // Consistency check: |item|'s ID is either |itemID| or not in |items|.
...@@ -750,7 +750,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -750,7 +750,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
if (fromIndex == toIndex) if (fromIndex == toIndex)
return; return;
auto modelUpdates = ^{ auto modelUpdates = ^{
GridItem* item = self.items[fromIndex]; TabSwitcherItem* item = self.items[fromIndex];
[self.items removeObjectAtIndex:fromIndex]; [self.items removeObjectAtIndex:fromIndex];
[self.items insertObject:item atIndex:toIndex]; [self.items insertObject:item atIndex:toIndex];
}; };
...@@ -881,7 +881,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -881,7 +881,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
// Returns the index in |self.items| of the first item whose identifier is // Returns the index in |self.items| of the first item whose identifier is
// |identifier|. // |identifier|.
- (NSUInteger)indexOfItemWithID:(NSString*)identifier { - (NSUInteger)indexOfItemWithID:(NSString*)identifier {
auto selectedTest = ^BOOL(GridItem* item, NSUInteger index, BOOL* stop) { auto selectedTest =
^BOOL(TabSwitcherItem* item, NSUInteger index, BOOL* stop) {
return [item.identifier isEqualToString:identifier]; return [item.identifier isEqualToString:identifier];
}; };
return [self.items indexOfObjectPassingTest:selectedTest]; return [self.items indexOfObjectPassingTest:selectedTest];
...@@ -891,7 +892,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -891,7 +892,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
// asynchronously with information from |item|. Updates the |cell|'s theme to // asynchronously with information from |item|. Updates the |cell|'s theme to
// this view controller's theme. This view controller becomes the delegate for // this view controller's theme. This view controller becomes the delegate for
// the cell. // the cell.
- (void)configureCell:(GridCell*)cell withItem:(GridItem*)item { - (void)configureCell:(GridCell*)cell withItem:(TabSwitcherItem*)item {
DCHECK(cell); DCHECK(cell);
DCHECK(item); DCHECK(item);
cell.delegate = self; cell.delegate = self;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#import "base/numerics/safe_conversions.h" #import "base/numerics/safe_conversions.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/chrome/test/root_view_controller_test.h" #import "ios/chrome/test/root_view_controller_test.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h" #import "testing/gtest_mac.h"
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// Test object that exposes the inner state for test verification. // Test object that exposes the inner state for test verification.
@interface GridViewController (Testing) @interface GridViewController (Testing)
@property(nonatomic, readonly) NSMutableArray<GridItem*>* items; @property(nonatomic, readonly) NSMutableArray<TabSwitcherItem*>* items;
@property(nonatomic, readonly) NSUInteger selectedIndex; @property(nonatomic, readonly) NSUInteger selectedIndex;
@property(nonatomic, readonly) UICollectionView* collectionView; @property(nonatomic, readonly) UICollectionView* collectionView;
@property(nonatomic, assign, getter=isViewAppeared) BOOL viewAppeared; @property(nonatomic, assign, getter=isViewAppeared) BOOL viewAppeared;
...@@ -68,8 +68,8 @@ class GridViewControllerTest : public RootViewControllerTest { ...@@ -68,8 +68,8 @@ class GridViewControllerTest : public RootViewControllerTest {
view_controller_ = [[GridViewController alloc] init]; view_controller_ = [[GridViewController alloc] init];
[view_controller_ loadView]; [view_controller_ loadView];
NSArray* items = @[ NSArray* items = @[
[[GridItem alloc] initWithIdentifier:@"A"], [[TabSwitcherItem alloc] initWithIdentifier:@"A"],
[[GridItem alloc] initWithIdentifier:@"B"] [[TabSwitcherItem alloc] initWithIdentifier:@"B"]
]; ];
[view_controller_ populateItems:items selectedItemID:@"A"]; [view_controller_ populateItems:items selectedItemID:@"A"];
delegate_ = [[FakeGridViewControllerDelegate alloc] init]; delegate_ = [[FakeGridViewControllerDelegate alloc] init];
...@@ -87,7 +87,8 @@ class GridViewControllerTest : public RootViewControllerTest { ...@@ -87,7 +87,8 @@ class GridViewControllerTest : public RootViewControllerTest {
TEST_F(GridViewControllerTest, InitializeItems) { TEST_F(GridViewControllerTest, InitializeItems) {
// Previously: The grid had 2 items and selectedIndex was 0. The delegate had // Previously: The grid had 2 items and selectedIndex was 0. The delegate had
// an itemCount of 2. // an itemCount of 2.
GridItem* item = [[GridItem alloc] initWithIdentifier:@"NEW-ITEM"]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:@"NEW-ITEM"];
[view_controller_ populateItems:@[ item ] selectedItemID:@"NEW-ITEM"]; [view_controller_ populateItems:@[ item ] selectedItemID:@"NEW-ITEM"];
EXPECT_NSEQ(@"NEW-ITEM", view_controller_.items[0].identifier); EXPECT_NSEQ(@"NEW-ITEM", view_controller_.items[0].identifier);
EXPECT_EQ(1U, view_controller_.items.count); EXPECT_EQ(1U, view_controller_.items.count);
...@@ -99,7 +100,8 @@ TEST_F(GridViewControllerTest, InitializeItems) { ...@@ -99,7 +100,8 @@ TEST_F(GridViewControllerTest, InitializeItems) {
TEST_F(GridViewControllerTest, InsertItem) { TEST_F(GridViewControllerTest, InsertItem) {
// Previously: The grid had 2 items and selectedIndex was 0. The delegate had // Previously: The grid had 2 items and selectedIndex was 0. The delegate had
// an itemCount of 2. // an itemCount of 2.
[view_controller_ insertItem:[[GridItem alloc] initWithIdentifier:@"NEW-ITEM"] [view_controller_
insertItem:[[TabSwitcherItem alloc] initWithIdentifier:@"NEW-ITEM"]
atIndex:2 atIndex:2
selectedItemID:@"NEW-ITEM"]; selectedItemID:@"NEW-ITEM"];
EXPECT_EQ(3U, view_controller_.items.count); EXPECT_EQ(3U, view_controller_.items.count);
...@@ -141,7 +143,8 @@ TEST_F(GridViewControllerTest, SelectNonexistentItem) { ...@@ -141,7 +143,8 @@ TEST_F(GridViewControllerTest, SelectNonexistentItem) {
TEST_F(GridViewControllerTest, ReplaceItem) { TEST_F(GridViewControllerTest, ReplaceItem) {
// Previously: The grid had 2 items and selectedIndex was 0. The delegate had // Previously: The grid had 2 items and selectedIndex was 0. The delegate had
// an itemCount of 2. // an itemCount of 2.
GridItem* item = [[GridItem alloc] initWithIdentifier:@"NEW-ITEM"]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:@"NEW-ITEM"];
[view_controller_ replaceItemID:@"A" withItem:item]; [view_controller_ replaceItemID:@"A" withItem:item];
EXPECT_NSEQ(@"NEW-ITEM", view_controller_.items[0].identifier); EXPECT_NSEQ(@"NEW-ITEM", view_controller_.items[0].identifier);
EXPECT_EQ(2U, delegate_.itemCount); EXPECT_EQ(2U, delegate_.itemCount);
...@@ -151,7 +154,7 @@ TEST_F(GridViewControllerTest, ReplaceItem) { ...@@ -151,7 +154,7 @@ TEST_F(GridViewControllerTest, ReplaceItem) {
TEST_F(GridViewControllerTest, ReplaceItemSameIdentifier) { TEST_F(GridViewControllerTest, ReplaceItemSameIdentifier) {
// Previously: The grid had 2 items and selectedIndex was 0. The delegate had // Previously: The grid had 2 items and selectedIndex was 0. The delegate had
// an itemCount of 2. // an itemCount of 2.
GridItem* item = [[GridItem alloc] initWithIdentifier:@"A"]; TabSwitcherItem* item = [[TabSwitcherItem alloc] initWithIdentifier:@"A"];
item.title = @"NEW-ITEM-TITLE"; item.title = @"NEW-ITEM-TITLE";
[view_controller_ replaceItemID:@"A" withItem:item]; [view_controller_ replaceItemID:@"A" withItem:item];
EXPECT_NSEQ(@"A", view_controller_.items[0].identifier); EXPECT_NSEQ(@"A", view_controller_.items[0].identifier);
...@@ -163,7 +166,8 @@ TEST_F(GridViewControllerTest, ReplaceItemSameIdentifier) { ...@@ -163,7 +166,8 @@ TEST_F(GridViewControllerTest, ReplaceItemSameIdentifier) {
TEST_F(GridViewControllerTest, ReplaceItemNotFound) { TEST_F(GridViewControllerTest, ReplaceItemNotFound) {
// Previously: The grid had 2 items and selectedIndex was 0. The delegate had // Previously: The grid had 2 items and selectedIndex was 0. The delegate had
// an itemCount of 2. // an itemCount of 2.
GridItem* item = [[GridItem alloc] initWithIdentifier:@"NOT-FOUND"]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:@"NOT-FOUND"];
[view_controller_ replaceItemID:@"NOT-FOUND" withItem:item]; [view_controller_ replaceItemID:@"NOT-FOUND" withItem:item];
EXPECT_NSNE(@"NOT-FOUND", view_controller_.items[0].identifier); EXPECT_NSNE(@"NOT-FOUND", view_controller_.items[0].identifier);
EXPECT_NSNE(@"NOT-FOUND", view_controller_.items[1].identifier); EXPECT_NSNE(@"NOT-FOUND", view_controller_.items[1].identifier);
...@@ -215,12 +219,14 @@ TEST_F(GridViewControllerTest, DISABLED_ReplaceScrolledOffScreenCell) { ...@@ -215,12 +219,14 @@ TEST_F(GridViewControllerTest, DISABLED_ReplaceScrolledOffScreenCell) {
while (visibleCellsCount >= items.count) { while (visibleCellsCount >= items.count) {
NSString* uniqueID = NSString* uniqueID =
[NSString stringWithFormat:@"%d", base::checked_cast<int>(items.count)]; [NSString stringWithFormat:@"%d", base::checked_cast<int>(items.count)];
GridItem* item = [[GridItem alloc] initWithIdentifier:uniqueID]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:uniqueID];
[view_controller_ insertItem:item atIndex:0 selectedItemID:@"A"]; [view_controller_ insertItem:item atIndex:0 selectedItemID:@"A"];
visibleCellsCount = view_controller_.collectionView.visibleCells.count; visibleCellsCount = view_controller_.collectionView.visibleCells.count;
} }
// The last item ("B") is scrolled off screen. // The last item ("B") is scrolled off screen.
GridItem* item = [[GridItem alloc] initWithIdentifier:@"NEW-ITEM"]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:@"NEW-ITEM"];
// Do not crash due to cell being nil. // Do not crash due to cell being nil.
[view_controller_ replaceItemID:@"B" withItem:item]; [view_controller_ replaceItemID:@"B" withItem:item];
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/tabs/tab_title_util.h" #import "ios/chrome/browser/tabs/tab_title_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_consumer.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_consumer.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/chrome/browser/web/tab_id_tab_helper.h" #import "ios/chrome/browser/web/tab_id_tab_helper.h"
#include "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h"
...@@ -46,10 +46,11 @@ ...@@ -46,10 +46,11 @@
#endif #endif
namespace { namespace {
// Constructs a GridItem from a |web_state|. // Constructs a TabSwitcherItem from a |web_state|.
GridItem* CreateItem(web::WebState* web_state) { TabSwitcherItem* CreateItem(web::WebState* web_state) {
TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state); TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state);
GridItem* item = [[GridItem alloc] initWithIdentifier:tab_helper->tab_id()]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:tab_helper->tab_id()];
// chrome://newtab (NTP) tabs have no title. // chrome://newtab (NTP) tabs have no title.
if (IsURLNtp(web_state->GetVisibleURL())) { if (IsURLNtp(web_state->GetVisibleURL())) {
item.hidesTitle = YES; item.hidesTitle = YES;
...@@ -58,7 +59,7 @@ GridItem* CreateItem(web::WebState* web_state) { ...@@ -58,7 +59,7 @@ GridItem* CreateItem(web::WebState* web_state) {
return item; return item;
} }
// Constructs an array of GridItems from a |web_state_list|. // Constructs an array of TabSwitcherItems from a |web_state_list|.
NSArray* CreateItems(WebStateList* web_state_list) { NSArray* CreateItems(WebStateList* web_state_list) {
NSMutableArray* items = [[NSMutableArray alloc] init]; NSMutableArray* items = [[NSMutableArray alloc] init];
for (int i = 0; i < web_state_list->count(); i++) { for (int i = 0; i < web_state_list->count(); i++) {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#import "ios/chrome/browser/tabs/closing_web_state_observer_browser_agent.h" #import "ios/chrome/browser/tabs/closing_web_state_observer_browser_agent.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_commands.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_commands.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_consumer.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_consumer.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/chrome/browser/web/page_placeholder_tab_helper.h" #import "ios/chrome/browser/web/page_placeholder_tab_helper.h"
#import "ios/chrome/browser/web/tab_id_tab_helper.h" #import "ios/chrome/browser/web/tab_id_tab_helper.h"
#include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
...@@ -161,16 +161,16 @@ std::unique_ptr<KeyedService> BuildFakeTabRestoreService( ...@@ -161,16 +161,16 @@ std::unique_ptr<KeyedService> BuildFakeTabRestoreService(
@synthesize items = _items; @synthesize items = _items;
@synthesize selectedItemID = _selectedItemID; @synthesize selectedItemID = _selectedItemID;
- (void)populateItems:(NSArray<GridItem*>*)items - (void)populateItems:(NSArray<TabSwitcherItem*>*)items
selectedItemID:(NSString*)selectedItemID { selectedItemID:(NSString*)selectedItemID {
self.selectedItemID = selectedItemID; self.selectedItemID = selectedItemID;
self.items = [NSMutableArray array]; self.items = [NSMutableArray array];
for (GridItem* item in items) { for (TabSwitcherItem* item in items) {
[self.items addObject:item.identifier]; [self.items addObject:item.identifier];
} }
} }
- (void)insertItem:(GridItem*)item - (void)insertItem:(TabSwitcherItem*)item
atIndex:(NSUInteger)index atIndex:(NSUInteger)index
selectedItemID:(NSString*)selectedItemID { selectedItemID:(NSString*)selectedItemID {
[self.items insertObject:item.identifier atIndex:index]; [self.items insertObject:item.identifier atIndex:index];
...@@ -187,7 +187,7 @@ std::unique_ptr<KeyedService> BuildFakeTabRestoreService( ...@@ -187,7 +187,7 @@ std::unique_ptr<KeyedService> BuildFakeTabRestoreService(
self.selectedItemID = selectedItemID; self.selectedItemID = selectedItemID;
} }
- (void)replaceItemID:(NSString*)itemID withItem:(GridItem*)item { - (void)replaceItemID:(NSString*)itemID withItem:(TabSwitcherItem*)item {
NSUInteger index = [self.items indexOfObject:itemID]; NSUInteger index = [self.items indexOfObject:itemID];
self.items[index] = item.identifier; self.items[index] = item.identifier;
} }
......
...@@ -38,7 +38,7 @@ source_set("tab_strip_ui") { ...@@ -38,7 +38,7 @@ source_set("tab_strip_ui") {
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui/tab_switcher/tab_grid/grid:grid_ui", "//ios/chrome/browser/ui/tab_switcher",
"//ios/chrome/browser/web:tab_id_tab_helper", "//ios/chrome/browser/web:tab_id_tab_helper",
"//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list",
"//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/colors",
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class GridItem; @class TabSwitcherItem;
// TabStripConsumer sets the current appearance of the TabStrip. // TabStripConsumer sets the current appearance of the TabStrip.
@protocol TabStripConsumer @protocol TabStripConsumer
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
// Tells the consumer to replace its current set of items with |items| and // Tells the consumer to replace its current set of items with |items| and
// update the selected item ID to be |selectedItemID|. It's an error to pass // update the selected item ID to be |selectedItemID|. It's an error to pass
// an |items| array containing items without unique IDs. // an |items| array containing items without unique IDs.
- (void)populateItems:(NSArray<GridItem*>*)items - (void)populateItems:(NSArray<TabSwitcherItem*>*)items
selectedItemID:(NSString*)selectedItemID; selectedItemID:(NSString*)selectedItemID;
// Tells the consumer to replace the item with ID |itemID| with |item|. // Tells the consumer to replace the item with ID |itemID| with |item|.
// It's an error if |item|'s ID duplicates any other item's ID besides |itemID|. // It's an error if |item|'s ID duplicates any other item's ID besides |itemID|.
// The consumer should ignore this call if |itemID| has not yet been inserted. // The consumer should ignore this call if |itemID| has not yet been inserted.
- (void)replaceItemID:(NSString*)itemID withItem:(GridItem*)item; - (void)replaceItemID:(NSString*)itemID withItem:(TabSwitcherItem*)item;
@end @end
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#import "ios/chrome/browser/browser_state/chrome_browser_state.h" #import "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/chrome_url_util.h" #import "ios/chrome/browser/chrome_url_util.h"
#import "ios/chrome/browser/tabs/tab_title_util.h" #import "ios/chrome/browser/tabs/tab_title_util.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_consumer.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_consumer.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/chrome/browser/web/tab_id_tab_helper.h" #import "ios/chrome/browser/web/tab_id_tab_helper.h"
#import "ios/chrome/browser/web_state_list/all_web_state_observation_forwarder.h" #import "ios/chrome/browser/web_state_list/all_web_state_observation_forwarder.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list.h"
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
#endif #endif
namespace { namespace {
// Constructs a GridItem from a |web_state|. // Constructs a TabSwitcherItem from a |web_state|.
GridItem* CreateItem(web::WebState* web_state) { TabSwitcherItem* CreateItem(web::WebState* web_state) {
TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state); TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state);
GridItem* item = [[GridItem alloc] initWithIdentifier:tab_helper->tab_id()]; TabSwitcherItem* item =
[[TabSwitcherItem alloc] initWithIdentifier:tab_helper->tab_id()];
// chrome://newtab (NTP) tabs have no title. // chrome://newtab (NTP) tabs have no title.
if (IsURLNtp(web_state->GetVisibleURL())) { if (IsURLNtp(web_state->GetVisibleURL())) {
item.hidesTitle = YES; item.hidesTitle = YES;
...@@ -35,7 +36,7 @@ GridItem* CreateItem(web::WebState* web_state) { ...@@ -35,7 +36,7 @@ GridItem* CreateItem(web::WebState* web_state) {
return item; return item;
} }
// Constructs an array of GridItems from a |web_state_list|. // Constructs an array of TabSwitcherItems from a |web_state_list|.
NSArray* CreateItems(WebStateList* web_state_list) { NSArray* CreateItems(WebStateList* web_state_list) {
NSMutableArray* items = [[NSMutableArray alloc] init]; NSMutableArray* items = [[NSMutableArray alloc] init];
for (int i = 0; i < web_state_list->count(); i++) { for (int i = 0; i < web_state_list->count(); i++) {
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_view_controller.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_view_controller.h"
#import "base/allocator/partition_allocator/partition_alloc.h" #import "base/allocator/partition_allocator/partition_alloc.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_cell.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_cell.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_mediator.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_mediator.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_view_layout.h" #import "ios/chrome/browser/ui/tab_switcher/tab_strip/tab_strip_view_layout.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -24,7 +24,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -24,7 +24,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
@interface TabStripViewController () @interface TabStripViewController ()
// The local model backing the collection view. // The local model backing the collection view.
@property(nonatomic, strong) NSMutableArray<GridItem*>* items; @property(nonatomic, strong) NSMutableArray<TabSwitcherItem*>* items;
// Identifier of the selected item. This value is disregarded if |self.items| is // Identifier of the selected item. This value is disregarded if |self.items| is
// empty. // empty.
@property(nonatomic, copy) NSString* selectedItemID; @property(nonatomic, copy) NSString* selectedItemID;
...@@ -66,7 +66,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -66,7 +66,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
if (itemIndex >= self.items.count) if (itemIndex >= self.items.count)
itemIndex = self.items.count - 1; itemIndex = self.items.count - 1;
GridItem* item = self.items[itemIndex]; TabSwitcherItem* item = self.items[itemIndex];
TabStripCell* cell = (TabStripCell*)[collectionView TabStripCell* cell = (TabStripCell*)[collectionView
dequeueReusableCellWithReuseIdentifier:kReuseIdentifier dequeueReusableCellWithReuseIdentifier:kReuseIdentifier
forIndexPath:indexPath]; forIndexPath:indexPath];
...@@ -77,12 +77,12 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -77,12 +77,12 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
#pragma mark - TabStripConsumer #pragma mark - TabStripConsumer
- (void)populateItems:(NSArray<GridItem*>*)items - (void)populateItems:(NSArray<TabSwitcherItem*>*)items
selectedItemID:(NSString*)selectedItemID { selectedItemID:(NSString*)selectedItemID {
#ifndef NDEBUG #ifndef NDEBUG
// Consistency check: ensure no IDs are duplicated. // Consistency check: ensure no IDs are duplicated.
NSMutableSet<NSString*>* identifiers = [[NSMutableSet alloc] init]; NSMutableSet<NSString*>* identifiers = [[NSMutableSet alloc] init];
for (GridItem* item in items) { for (TabSwitcherItem* item in items) {
[identifiers addObject:item.identifier]; [identifiers addObject:item.identifier];
} }
CHECK_EQ(identifiers.count, items.count); CHECK_EQ(identifiers.count, items.count);
...@@ -93,7 +93,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -93,7 +93,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self.collectionView reloadData]; [self.collectionView reloadData];
} }
- (void)replaceItemID:(NSString*)itemID withItem:(GridItem*)item { - (void)replaceItemID:(NSString*)itemID withItem:(TabSwitcherItem*)item {
if ([self indexOfItemWithID:itemID] == NSNotFound) if ([self indexOfItemWithID:itemID] == NSNotFound)
return; return;
// Consistency check: |item|'s ID is either |itemID| or not in |items|. // Consistency check: |item|'s ID is either |itemID| or not in |items|.
...@@ -113,7 +113,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -113,7 +113,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
// Configures |cell|'s title synchronously, and favicon asynchronously with // Configures |cell|'s title synchronously, and favicon asynchronously with
// information from |item|. Updates the |cell|'s theme to this view controller's // information from |item|. Updates the |cell|'s theme to this view controller's
// theme. // theme.
- (void)configureCell:(TabStripCell*)cell withItem:(GridItem*)item { - (void)configureCell:(TabStripCell*)cell withItem:(TabSwitcherItem*)item {
if (item) { if (item) {
cell.itemIdentifier = item.identifier; cell.itemIdentifier = item.identifier;
cell.titleLabel.text = item.title; cell.titleLabel.text = item.title;
...@@ -132,7 +132,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -132,7 +132,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
// Returns the index in |self.items| of the first item whose identifier is // Returns the index in |self.items| of the first item whose identifier is
// |identifier|. // |identifier|.
- (NSUInteger)indexOfItemWithID:(NSString*)identifier { - (NSUInteger)indexOfItemWithID:(NSString*)identifier {
auto selectedTest = ^BOOL(GridItem* item, NSUInteger index, BOOL* stop) { auto selectedTest =
^BOOL(TabSwitcherItem* item, NSUInteger index, BOOL* stop) {
return [item.identifier isEqualToString:identifier]; return [item.identifier isEqualToString:identifier];
}; };
return [self.items indexOfObjectPassingTest:selectedTest]; return [self.items indexOfObjectPassingTest:selectedTest];
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_GRID_GRID_GRID_ITEM_H_ #ifndef IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_ITEM_H_
#define IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_GRID_GRID_GRID_ITEM_H_ #define IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_ITEM_H_
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// Model object representing an item in a grid. // Model object representing an item in the tab switchers.
@interface GridItem : NSObject @interface TabSwitcherItem : NSObject
// Create an item with |identifier|, which cannot be nil. // Create an item with |identifier|, which cannot be nil.
- (instancetype)initWithIdentifier:(NSString*)identifier - (instancetype)initWithIdentifier:(NSString*)identifier
...@@ -21,4 +21,4 @@ ...@@ -21,4 +21,4 @@
@property(nonatomic, assign) BOOL hidesTitle; @property(nonatomic, assign) BOOL hidesTitle;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_GRID_GRID_GRID_ITEM_H_ #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_ITEM_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/check.h" #include "base/check.h"
@implementation GridItem @implementation TabSwitcherItem
- (instancetype)initWithIdentifier:(NSString*)identifier { - (instancetype)initWithIdentifier:(NSString*)identifier {
DCHECK(identifier); DCHECK(identifier);
......
...@@ -18,6 +18,7 @@ source_set("tab_grid") { ...@@ -18,6 +18,7 @@ source_set("tab_grid") {
deps = [ deps = [
"//base", "//base",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/tab_switcher/",
"//ios/chrome/browser/ui/tab_switcher/tab_grid:tab_grid_ui", "//ios/chrome/browser/ui/tab_switcher/tab_grid:tab_grid_ui",
"//ios/chrome/browser/ui/tab_switcher/tab_grid/grid:grid_ui", "//ios/chrome/browser/ui/tab_switcher/tab_grid/grid:grid_ui",
"//ios/showcase/common", "//ios/showcase/common",
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_drag_drop_handler.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_drag_drop_handler.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_image_data_source.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_image_data_source.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_view_controller.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_view_controller.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/showcase/common/protocol_alerter.h" #import "ios/showcase/common/protocol_alerter.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
gridViewController.imageDataSource = self; gridViewController.imageDataSource = self;
self.alerter.baseViewController = gridViewController; self.alerter.baseViewController = gridViewController;
NSMutableArray<GridItem*>* items = [[NSMutableArray alloc] init]; NSMutableArray<TabSwitcherItem*>* items = [[NSMutableArray alloc] init];
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
GridItem* item = [[GridItem alloc] TabSwitcherItem* item = [[TabSwitcherItem alloc]
initWithIdentifier:[NSString stringWithFormat:@"item%d", i]]; initWithIdentifier:[NSString stringWithFormat:@"item%d", i]];
item.title = @"The New York Times - Breaking News"; item.title = @"The New York Times - Breaking News";
[items addObject:item]; [items addObject:item];
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_commands.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_commands.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_consumer.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_consumer.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_drag_drop_handler.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_drag_drop_handler.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_item.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_item.h"
#import "ios/showcase/common/protocol_alerter.h" #import "ios/showcase/common/protocol_alerter.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
self.baseViewController.hidesBarsOnSwipe = YES; self.baseViewController.hidesBarsOnSwipe = YES;
[self.baseViewController pushViewController:self.viewController animated:YES]; [self.baseViewController pushViewController:self.viewController animated:YES];
NSMutableArray<GridItem*>* items = [[NSMutableArray alloc] init]; NSMutableArray<TabSwitcherItem*>* items = [[NSMutableArray alloc] init];
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
GridItem* item = [[GridItem alloc] TabSwitcherItem* item = [[TabSwitcherItem alloc]
initWithIdentifier:[NSString stringWithFormat:@"incogitem%d", i]]; initWithIdentifier:[NSString stringWithFormat:@"incogitem%d", i]];
item.title = @"YouTube - Cat Videos"; item.title = @"YouTube - Cat Videos";
[items addObject:item]; [items addObject:item];
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
selectedItemID:items[0].identifier]; selectedItemID:items[0].identifier];
items = [[NSMutableArray alloc] init]; items = [[NSMutableArray alloc] init];
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
GridItem* item = [[GridItem alloc] TabSwitcherItem* item = [[TabSwitcherItem alloc]
initWithIdentifier:[NSString stringWithFormat:@"item%d", i]]; initWithIdentifier:[NSString stringWithFormat:@"item%d", i]];
item.title = @"The New York Times - Breaking News"; item.title = @"The New York Times - Breaking News";
[items addObject:item]; [items addObject:item];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment