| 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/foundation_util.h" | 8 #import "base/mac/foundation_util.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 CHECK(_distantSession); | 230 CHECK(_distantSession); |
| 231 const std::size_t distantSessionTabCount = _distantSession->tabs.size(); | 231 const std::size_t distantSessionTabCount = _distantSession->tabs.size(); |
| 232 LOG_ASSERT(tabIndex < distantSessionTabCount) | 232 LOG_ASSERT(tabIndex < distantSessionTabCount) |
| 233 << "tabIndex == " << tabIndex | 233 << "tabIndex == " << tabIndex |
| 234 << " _distantSession->tabs.size() == " << distantSessionTabCount; | 234 << " _distantSession->tabs.size() == " << distantSessionTabCount; |
| 235 synced_sessions::DistantTab* tab = _distantSession->tabs[tabIndex].get(); | 235 synced_sessions::DistantTab* tab = _distantSession->tabs[tabIndex].get(); |
| 236 CHECK(tab); | 236 CHECK(tab); |
| 237 [panelCell setTitle:SysUTF16ToNSString(tab->title)]; | 237 [panelCell setTitle:SysUTF16ToNSString(tab->title)]; |
| 238 [panelCell setSessionGURL:tab->virtual_url | 238 [panelCell setSessionGURL:tab->virtual_url |
| 239 withBrowserState:[_model browserState]]; | 239 withBrowserState:[_model browserState]]; |
| 240 [panelCell setDelegate:self]; |
| 240 } else { | 241 } else { |
| 241 NSString* identifier = [TabSwitcherLocalSessionCell identifier]; | 242 NSString* identifier = [TabSwitcherLocalSessionCell identifier]; |
| 242 TabSwitcherLocalSessionCell* panelCell = | 243 TabSwitcherLocalSessionCell* panelCell = |
| 243 base::mac::ObjCCastStrict<TabSwitcherLocalSessionCell>([collectionView | 244 base::mac::ObjCCastStrict<TabSwitcherLocalSessionCell>([collectionView |
| 244 dequeueReusableCellWithReuseIdentifier:identifier | 245 dequeueReusableCellWithReuseIdentifier:identifier |
| 245 forIndexPath:indexPath]); | 246 forIndexPath:indexPath]); |
| 246 cell = panelCell; | 247 cell = panelCell; |
| 247 | 248 |
| 248 Tab* tab = _localSession->tabs()[tabIndex]; | 249 Tab* tab = _localSession->tabs()[tabIndex]; |
| 249 [panelCell setSessionType:_sessionType]; | 250 [panelCell setSessionType:_sessionType]; |
| 251 [panelCell setDelegate:self]; |
| 250 [panelCell setAppearanceForTab:tab cellSize:[_panelView cellSize]]; | 252 [panelCell setAppearanceForTab:tab cellSize:[_panelView cellSize]]; |
| 251 } | 253 } |
| 252 DCHECK(cell); | 254 DCHECK(cell); |
| 253 cell.delegate = self; | |
| 254 return cell; | 255 return cell; |
| 255 } | 256 } |
| 256 | 257 |
| 257 - (void)collectionView:(UICollectionView*)collectionView | 258 - (void)collectionView:(UICollectionView*)collectionView |
| 258 didEndDisplayingCell:(UICollectionViewCell*)cell | 259 didEndDisplayingCell:(UICollectionViewCell*)cell |
| 259 forItemAtIndexPath:(NSIndexPath*)indexPath { | 260 forItemAtIndexPath:(NSIndexPath*)indexPath { |
| 260 // When closing the last tab, accessibility does not realize that there is no | 261 // When closing the last tab, accessibility does not realize that there is no |
| 261 // elements in the collection view and keep the custom action for the tab. So | 262 // elements in the collection view and keep the custom action for the tab. So |
| 262 // reset the delegate of the cell (to avoid crashing if the action is invoked) | 263 // reset the delegate of the cell (to avoid crashing if the action is invoked) |
| 263 // and post a notification that the screen changed to force accessibility to | 264 // and post a notification that the screen changed to force accessibility to |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 [[TabSwitcherPanelView alloc] initWithSessionType:_sessionType]); | 343 [[TabSwitcherPanelView alloc] initWithSessionType:_sessionType]); |
| 343 _panelView.get().collectionView.dataSource = self; | 344 _panelView.get().collectionView.dataSource = self; |
| 344 _panelView.get().collectionView.delegate = self; | 345 _panelView.get().collectionView.delegate = self; |
| 345 } | 346 } |
| 346 | 347 |
| 347 - (synced_sessions::DistantSession const*)distantSession { | 348 - (synced_sessions::DistantSession const*)distantSession { |
| 348 return _distantSession.get(); | 349 return _distantSession.get(); |
| 349 } | 350 } |
| 350 | 351 |
| 351 @end | 352 @end |
| OLD | NEW |