OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_PANEL_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_PANEL_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #include "base/ios/block_types.h" |
| 11 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_model.h" |
| 12 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
| 13 |
| 14 namespace ios { |
| 15 class ChromeBrowserState; |
| 16 } |
| 17 |
| 18 @class TabSwitcherLocalSessionCell; |
| 19 @class TabSwitcherPanelController; |
| 20 |
| 21 @protocol TabSwitcherPanelControllerDelegate<NSObject> |
| 22 |
| 23 // Called when the user selects the cell representing the distant tab |tab|. |
| 24 - (void)tabSwitcherPanelController: |
| 25 (TabSwitcherPanelController*)tabSwitcherPanelController |
| 26 didSelectDistantTab:(synced_sessions::DistantTab*)tab; |
| 27 |
| 28 // Called when the user selects the cell representing the local tab |tab|. |
| 29 - (void)tabSwitcherPanelController: |
| 30 (TabSwitcherPanelController*)tabSwitcherPanelController |
| 31 didSelectLocalTab:(Tab*)tab; |
| 32 |
| 33 // Called when the user pressed the close button on the cell representing the |
| 34 // local tab |tab|. |
| 35 - (void)tabSwitcherPanelController: |
| 36 (TabSwitcherPanelController*)tabSwitcherPanelController |
| 37 didCloseLocalTab:(Tab*)tab; |
| 38 |
| 39 // Called when the overlay view visibility changed. |
| 40 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: |
| 41 (TabSwitcherPanelController*)tabSwitcherPanelController; |
| 42 |
| 43 @end |
| 44 |
| 45 @class TabSwitcherPanelView; |
| 46 // The tab switcher panel controller manages a panel view. |
| 47 // It can manage either distant or local sessions and uses a TabSwitcherModel |
| 48 // as its data source. |
| 49 @class TabSwitcherCache; |
| 50 |
| 51 @interface TabSwitcherPanelController : NSObject |
| 52 |
| 53 @property(nonatomic, readonly) TabSwitcherPanelView* view; |
| 54 @property(nonatomic, assign) id<TabSwitcherPanelControllerDelegate> delegate; |
| 55 @property(nonatomic, readonly) ios_internal::SessionType sessionType; |
| 56 |
| 57 // Initializes a controller for a view showing local tabs. |offTheRecord| |
| 58 // determines whether the tabs will be shown for the incognito browser state or |
| 59 // not. |model| is used to populate the view and must not be nil. |
| 60 - (instancetype)initWithModel:(TabSwitcherModel*)model |
| 61 forLocalSessionOfType:(ios_internal::SessionType)type |
| 62 withCache:(TabSwitcherCache*)cache |
| 63 browserState:(ios::ChromeBrowserState*)browserState; |
| 64 |
| 65 // Initializes a controller for a view showing the tabs of a distant session. |
| 66 // |model| is used to populate the view and must not be nil. |
| 67 - (instancetype)initWithModel:(TabSwitcherModel*)model |
| 68 forDistantSessionWithTag:(std::string const&)sessionTag |
| 69 browserState:(ios::ChromeBrowserState*)browserState; |
| 70 |
| 71 // Tells the controller that the collectionview's content may need to be |
| 72 // updated. |
| 73 - (void)updateCollectionViewIfNeeded; |
| 74 |
| 75 // Returns the tag of the distant session. |
| 76 - (std::string)sessionTag; |
| 77 |
| 78 // Returns true if the new tab button should be shown. |
| 79 - (BOOL)shouldShowNewTabButton; |
| 80 |
| 81 // Scrolls the collection view so that the tab cell at the given index is |
| 82 // visible. |
| 83 - (void)scrollTabIndexToVisible:(NSInteger)index triggerLayout:(BOOL)layout; |
| 84 |
| 85 // Returns the cell for the tab at the given index. |
| 86 // This methods should only be used for animation purpose. |
| 87 - (TabSwitcherLocalSessionCell*)localSessionCellForTabAtIndex:(NSInteger)index; |
| 88 |
| 89 - (CGRect)localSessionCellFrameForTabAtIndex:(NSInteger)index; |
| 90 |
| 91 // Reloads cells. |
| 92 - (void)reload; |
| 93 |
| 94 - (UICollectionView*)collectionView; |
| 95 |
| 96 // Returns the distantSession owned and displayed by this controller. |
| 97 - (const synced_sessions::DistantSession*)distantSession; |
| 98 |
| 99 @end |
| 100 |
| 101 #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_PANEL_CONTROLLER_H_ |
OLD | NEW |