Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller.mm

Issue 2971093002: [ios] Take snapshot for tab grid. (Closed)
Patch Set: Update unit test. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/clean/chrome/browser/ui/tab_collection/tab_collection_view_controll er.h" 5 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controll er.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h" 10 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 DCHECK_LE(item, INT_MAX); 150 DCHECK_LE(item, INT_MAX);
151 int index = static_cast<int>(item); 151 int index = static_cast<int>(item);
152 [self closeTabAtIndex:index]; 152 [self closeTabAtIndex:index];
153 } 153 }
154 154
155 #pragma mark - TabCollectionConsumer methods 155 #pragma mark - TabCollectionConsumer methods
156 156
157 - (void)insertItem:(TabCollectionItem*)item 157 - (void)insertItem:(TabCollectionItem*)item
158 atIndex:(int)index 158 atIndex:(int)index
159 selectedIndex:(int)selectedIndex { 159 selectedIndex:(int)selectedIndex {
160 DCHECK(item);
160 DCHECK_GE(index, 0); 161 DCHECK_GE(index, 0);
161 DCHECK_LE(static_cast<NSUInteger>(index), self.items.count); 162 DCHECK_LE(static_cast<NSUInteger>(index), self.items.count);
162 [self.items insertObject:item atIndex:index]; 163 [self.items insertObject:item atIndex:index];
163 [self.tabs insertItemsAtIndexPaths:@[ [NSIndexPath indexPathForItem:index 164 [self.tabs insertItemsAtIndexPaths:@[ [NSIndexPath indexPathForItem:index
164 inSection:0] ]]; 165 inSection:0] ]];
165 self.selectedIndex = selectedIndex; 166 self.selectedIndex = selectedIndex;
166 } 167 }
167 168
168 - (void)deleteItemAtIndex:(int)index selectedIndex:(int)selectedIndex { 169 - (void)deleteItemAtIndex:(int)index selectedIndex:(int)selectedIndex {
169 DCHECK_GE(index, 0); 170 DCHECK_GE(index, 0);
(...skipping 27 matching lines...) Expand all
197 [cell configureCell:self.items[index] snapshotCache:self.snapshotCache]; 198 [cell configureCell:self.items[index] snapshotCache:self.snapshotCache];
198 } 199 }
199 200
200 - (void)populateItems:(NSArray<TabCollectionItem*>*)items 201 - (void)populateItems:(NSArray<TabCollectionItem*>*)items
201 selectedIndex:(int)selectedIndex { 202 selectedIndex:(int)selectedIndex {
202 self.items = [items mutableCopy]; 203 self.items = [items mutableCopy];
203 [self.tabs reloadItemsAtIndexPaths:[self.tabs indexPathsForVisibleItems]]; 204 [self.tabs reloadItemsAtIndexPaths:[self.tabs indexPathsForVisibleItems]];
204 self.selectedIndex = selectedIndex; 205 self.selectedIndex = selectedIndex;
205 } 206 }
206 207
208 - (void)updateSnapshotAtIndex:(int)index {
209 DCHECK_GE(index, 0);
210 DCHECK_LT(static_cast<NSUInteger>(index), self.items.count);
211 TabCollectionTabCell* cell = base::mac::ObjCCastStrict<TabCollectionTabCell>(
212 [self.tabs cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index
213 inSection:0]]);
214 [cell configureCell:self.items[index] snapshotCache:self.snapshotCache];
215 }
216
207 @end 217 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698