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 #ifndef IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ |
6 #define IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ | 6 #define IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include "base/ios/block_types.h" | 11 #include "base/ios/block_types.h" |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 13 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
14 #import "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions.h" | 14 #import "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions.h" |
15 #import "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions_bridge.h" | 15 #import "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions_bridge.h" |
16 #import "ios/chrome/browser/ui/tab_switcher/tab_model_snapshot.h" | 16 #import "ios/chrome/browser/ui/tab_switcher/tab_model_snapshot.h" |
17 | 17 |
| 18 class ChromeBrowserState; |
18 @class TabModel; | 19 @class TabModel; |
19 @class TabSwitcherCache; | 20 @class TabSwitcherCache; |
20 | 21 |
21 enum class TabSwitcherSignInPanelsType { | 22 enum class TabSwitcherSignInPanelsType { |
22 PANEL_USER_SIGNED_OUT, | 23 PANEL_USER_SIGNED_OUT, |
23 PANEL_USER_SIGNED_IN_SYNC_OFF, | 24 PANEL_USER_SIGNED_IN_SYNC_OFF, |
24 PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS, | 25 PANEL_USER_SIGNED_IN_SYNC_IN_PROGRESS, |
25 PANEL_USER_SIGNED_IN_SYNC_ON_NO_SESSIONS, | 26 PANEL_USER_SIGNED_IN_SYNC_ON_NO_SESSIONS, |
26 NO_PANEL, | 27 NO_PANEL, |
27 }; | 28 }; |
28 | 29 |
29 namespace ios_internal { | 30 enum class TabSwitcherSessionType { |
30 | |
31 enum class SessionType { | |
32 OFF_THE_RECORD_SESSION, | 31 OFF_THE_RECORD_SESSION, |
33 REGULAR_SESSION, | 32 REGULAR_SESSION, |
34 DISTANT_SESSION | 33 DISTANT_SESSION |
35 }; | 34 }; |
36 | 35 |
37 class ChromeBrowserState; | |
38 | |
39 // Returns true if the session type is a local session. A local session is a | 36 // Returns true if the session type is a local session. A local session is a |
40 // "regular session" or an "off the record" session. | 37 // "regular session" or an "off the record" session. |
41 bool IsLocalSession(SessionType sessionType); | 38 bool TabSwitcherSessionTypeIsLocalSession(TabSwitcherSessionType sessionType); |
42 | |
43 } // namespace ios_internal | |
44 | 39 |
45 // Protocol to observe changes to the TabSwitcherModel. | 40 // Protocol to observe changes to the TabSwitcherModel. |
46 @protocol TabSwitcherModelDelegate<NSObject> | 41 @protocol TabSwitcherModelDelegate<NSObject> |
47 // Called when distant sessions were removed or inserted. |removedIndexes| and | 42 // Called when distant sessions were removed or inserted. |removedIndexes| and |
48 // |insertedIndexes| contains indexes in ascending order. | 43 // |insertedIndexes| contains indexes in ascending order. |
49 - (void)distantSessionsRemovedAtSortedIndexes:(NSArray*)removedIndexes | 44 - (void)distantSessionsRemovedAtSortedIndexes:(NSArray*)removedIndexes |
50 insertedAtSortedIndexes:(NSArray*)insertedIndexes; | 45 insertedAtSortedIndexes:(NSArray*)insertedIndexes; |
51 // Called when the distant session with the tag |tag| may need to be updated. | 46 // Called when the distant session with the tag |tag| may need to be updated. |
52 - (void)distantSessionMayNeedUpdate:(std::string const&)tag; | 47 - (void)distantSessionMayNeedUpdate:(std::string const&)tag; |
53 // Called when a local session of type |type| needs to be updated. | 48 // Called when a local session of type |type| needs to be updated. |
54 - (void)localSessionMayNeedUpdate:(ios_internal::SessionType)type; | 49 - (void)localSessionMayNeedUpdate:(TabSwitcherSessionType)type; |
55 // Called when the signed-in panel (if any) must change. | 50 // Called when the signed-in panel (if any) must change. |
56 - (void)signInPanelChangedTo:(TabSwitcherSignInPanelsType)panelType; | 51 - (void)signInPanelChangedTo:(TabSwitcherSignInPanelsType)panelType; |
57 // Called to retrieve the size of the item at the |index| in |session|. | 52 // Called to retrieve the size of the item at the |index| in |session|. |
58 - (CGSize)sizeForItemAtIndex:(NSUInteger)index | 53 - (CGSize)sizeForItemAtIndex:(NSUInteger)index |
59 inSession:(ios_internal::SessionType)session; | 54 inSession:(TabSwitcherSessionType)session; |
60 @end | 55 @end |
61 | 56 |
62 // This class serves as a bridge between Chrome-level data (CLD), and what is | 57 // This class serves as a bridge between Chrome-level data (CLD), and what is |
63 // presented on screen in the Tab Switcher. | 58 // presented on screen in the Tab Switcher. |
64 // The CLD is: | 59 // The CLD is: |
65 // -The "distant sessions", i.e. the list of Chrome instances the user is | 60 // -The "distant sessions", i.e. the list of Chrome instances the user is |
66 // signed-in, and the tabs each of the session contains. | 61 // signed-in, and the tabs each of the session contains. |
67 // -The non incognito/incognito tab models. Also known as the "local sessions". | 62 // -The non incognito/incognito tab models. Also known as the "local sessions". |
68 // | 63 // |
69 // The TabSwitcher observes changes in the CLD, and takes snapshots of its | 64 // The TabSwitcher observes changes in the CLD, and takes snapshots of its |
(...skipping 13 matching lines...) Expand all Loading... |
83 otrTabModel:(TabModel*)otrTabModel | 78 otrTabModel:(TabModel*)otrTabModel |
84 withCache:(TabSwitcherCache*)cache; | 79 withCache:(TabSwitcherCache*)cache; |
85 // Sets the main and incognito tab models, and notify the delegate of changes, | 80 // Sets the main and incognito tab models, and notify the delegate of changes, |
86 // if any. |mainTabModel| and |otrTabModel| can be nil. | 81 // if any. |mainTabModel| and |otrTabModel| can be nil. |
87 - (void)setMainTabModel:(TabModel*)mainTabModel | 82 - (void)setMainTabModel:(TabModel*)mainTabModel |
88 otrTabModel:(TabModel*)otrTabModel; | 83 otrTabModel:(TabModel*)otrTabModel; |
89 // Returns the browserState. | 84 // Returns the browserState. |
90 - (ios::ChromeBrowserState*)browserState; | 85 - (ios::ChromeBrowserState*)browserState; |
91 // Returns the latest data for the local session of type |type|. | 86 // Returns the latest data for the local session of type |type|. |
92 - (std::unique_ptr<TabModelSnapshot>)tabModelSnapshotForLocalSession: | 87 - (std::unique_ptr<TabModelSnapshot>)tabModelSnapshotForLocalSession: |
93 (ios_internal::SessionType)type; | 88 (TabSwitcherSessionType)type; |
94 // Returns the latest data for the distant session of tag |tag|. | 89 // Returns the latest data for the distant session of tag |tag|. |
95 - (std::unique_ptr<const synced_sessions::DistantSession>)distantSessionForTag: | 90 - (std::unique_ptr<const synced_sessions::DistantSession>)distantSessionForTag: |
96 (std::string const&)tag; | 91 (std::string const&)tag; |
97 | 92 |
98 // Returns the current count of sessions including main and incognito. | 93 // Returns the current count of sessions including main and incognito. |
99 - (NSInteger)sessionCount; | 94 - (NSInteger)sessionCount; |
100 // Returns the current count of distant sessions. | 95 // Returns the current count of distant sessions. |
101 - (NSInteger)distantSessionCount; | 96 - (NSInteger)distantSessionCount; |
102 // Returns the type of the sign in panel. | 97 // Returns the type of the sign in panel. |
103 - (TabSwitcherSignInPanelsType)signInPanelType; | 98 - (TabSwitcherSignInPanelsType)signInPanelType; |
104 // Returns the tag of the session at index |index|. | 99 // Returns the tag of the session at index |index|. |
105 - (std::string const&)tagOfDistantSessionAtIndex:(int)index; | 100 - (std::string const&)tagOfDistantSessionAtIndex:(int)index; |
106 // Notifies the delegate that changes occured for the distant sessions. | 101 // Notifies the delegate that changes occured for the distant sessions. |
107 - (void)syncedSessionsChanged; | 102 - (void)syncedSessionsChanged; |
108 @end | 103 @end |
109 | 104 |
110 #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ | 105 #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ |
OLD | NEW |