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_view.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_view.h" |
6 | 6 |
7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" | 8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
9 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_l
ayout.h" | 9 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_l
ayout.h" |
10 | 10 |
11 @interface TabSwitcherPanelView () { | 11 @interface TabSwitcherPanelView () { |
12 base::scoped_nsobject<UICollectionView> _collectionView; | 12 base::scoped_nsobject<UICollectionView> _collectionView; |
13 base::scoped_nsobject<TabSwitcherPanelCollectionViewLayout> | 13 base::scoped_nsobject<TabSwitcherPanelCollectionViewLayout> |
14 _collectionViewLayout; | 14 _collectionViewLayout; |
15 ios_internal::SessionType _sessionType; | 15 TabSwitcherSessionType _sessionType; |
16 } | 16 } |
17 | 17 |
18 @end | 18 @end |
19 | 19 |
20 @implementation TabSwitcherPanelView | 20 @implementation TabSwitcherPanelView |
21 | 21 |
22 - (instancetype)initWithSessionType:(ios_internal::SessionType)sessionType { | 22 - (instancetype)initWithSessionType:(TabSwitcherSessionType)sessionType { |
23 self = [super initWithFrame:CGRectZero]; | 23 self = [super initWithFrame:CGRectZero]; |
24 if (self) { | 24 if (self) { |
25 _sessionType = sessionType; | 25 _sessionType = sessionType; |
26 [self loadSubviews]; | 26 [self loadSubviews]; |
27 } | 27 } |
28 return self; | 28 return self; |
29 } | 29 } |
30 | 30 |
31 - (instancetype)initWithFrame:(CGRect)frame { | 31 - (instancetype)initWithFrame:(CGRect)frame { |
32 NOTREACHED(); | 32 NOTREACHED(); |
(...skipping 22 matching lines...) Expand all Loading... |
55 } | 55 } |
56 | 56 |
57 #pragma mark - Private | 57 #pragma mark - Private |
58 | 58 |
59 - (void)loadSubviews { | 59 - (void)loadSubviews { |
60 _collectionViewLayout.reset( | 60 _collectionViewLayout.reset( |
61 [[TabSwitcherPanelCollectionViewLayout alloc] init]); | 61 [[TabSwitcherPanelCollectionViewLayout alloc] init]); |
62 _collectionView.reset([[UICollectionView alloc] | 62 _collectionView.reset([[UICollectionView alloc] |
63 initWithFrame:self.bounds | 63 initWithFrame:self.bounds |
64 collectionViewLayout:_collectionViewLayout.get()]); | 64 collectionViewLayout:_collectionViewLayout.get()]); |
65 if (_sessionType == ios_internal::SessionType::DISTANT_SESSION) { | 65 if (_sessionType == TabSwitcherSessionType::DISTANT_SESSION) { |
66 [_collectionView registerClass:[TabSwitcherDistantSessionCell class] | 66 [_collectionView registerClass:[TabSwitcherDistantSessionCell class] |
67 forCellWithReuseIdentifier:[TabSwitcherDistantSessionCell identifier]]; | 67 forCellWithReuseIdentifier:[TabSwitcherDistantSessionCell identifier]]; |
68 } else { | 68 } else { |
69 [_collectionView registerClass:[TabSwitcherLocalSessionCell class] | 69 [_collectionView registerClass:[TabSwitcherLocalSessionCell class] |
70 forCellWithReuseIdentifier:[TabSwitcherLocalSessionCell identifier]]; | 70 forCellWithReuseIdentifier:[TabSwitcherLocalSessionCell identifier]]; |
71 } | 71 } |
72 [_collectionView setBackgroundColor:[UIColor clearColor]]; | 72 [_collectionView setBackgroundColor:[UIColor clearColor]]; |
73 [self addSubview:_collectionView]; | 73 [self addSubview:_collectionView]; |
74 [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | | 74 [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
75 UIViewAutoresizingFlexibleWidth]; | 75 UIViewAutoresizingFlexibleWidth]; |
76 } | 76 } |
77 | 77 |
78 @end | 78 @end |
OLD | NEW |