Chromium Code Reviews| 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 | |
| 31 enum class SessionType { | 30 enum class SessionType { |
|
sdefresne
2017/01/03 16:04:30
nit: maybe rename TabSwitcherSessionType?
rohitrao (ping after 24h)
2017/01/04 13:36:37
Done.
| |
| 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 SessionTypeIsLocalSession(SessionType 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:(SessionType)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 inSession:(SessionType)session; |
| 59 inSession:(ios_internal::SessionType)session; | |
| 60 @end | 54 @end |
| 61 | 55 |
| 62 // This class serves as a bridge between Chrome-level data (CLD), and what is | 56 // This class serves as a bridge between Chrome-level data (CLD), and what is |
| 63 // presented on screen in the Tab Switcher. | 57 // presented on screen in the Tab Switcher. |
| 64 // The CLD is: | 58 // The CLD is: |
| 65 // -The "distant sessions", i.e. the list of Chrome instances the user is | 59 // -The "distant sessions", i.e. the list of Chrome instances the user is |
| 66 // signed-in, and the tabs each of the session contains. | 60 // signed-in, and the tabs each of the session contains. |
| 67 // -The non incognito/incognito tab models. Also known as the "local sessions". | 61 // -The non incognito/incognito tab models. Also known as the "local sessions". |
| 68 // | 62 // |
| 69 // The TabSwitcher observes changes in the CLD, and takes snapshots of its | 63 // The TabSwitcher observes changes in the CLD, and takes snapshots of its |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 83 otrTabModel:(TabModel*)otrTabModel | 77 otrTabModel:(TabModel*)otrTabModel |
| 84 withCache:(TabSwitcherCache*)cache; | 78 withCache:(TabSwitcherCache*)cache; |
| 85 // Sets the main and incognito tab models, and notify the delegate of changes, | 79 // Sets the main and incognito tab models, and notify the delegate of changes, |
| 86 // if any. |mainTabModel| and |otrTabModel| can be nil. | 80 // if any. |mainTabModel| and |otrTabModel| can be nil. |
| 87 - (void)setMainTabModel:(TabModel*)mainTabModel | 81 - (void)setMainTabModel:(TabModel*)mainTabModel |
| 88 otrTabModel:(TabModel*)otrTabModel; | 82 otrTabModel:(TabModel*)otrTabModel; |
| 89 // Returns the browserState. | 83 // Returns the browserState. |
| 90 - (ios::ChromeBrowserState*)browserState; | 84 - (ios::ChromeBrowserState*)browserState; |
| 91 // Returns the latest data for the local session of type |type|. | 85 // Returns the latest data for the local session of type |type|. |
| 92 - (std::unique_ptr<TabModelSnapshot>)tabModelSnapshotForLocalSession: | 86 - (std::unique_ptr<TabModelSnapshot>)tabModelSnapshotForLocalSession: |
| 93 (ios_internal::SessionType)type; | 87 (SessionType)type; |
| 94 // Returns the latest data for the distant session of tag |tag|. | 88 // Returns the latest data for the distant session of tag |tag|. |
| 95 - (std::unique_ptr<const synced_sessions::DistantSession>)distantSessionForTag: | 89 - (std::unique_ptr<const synced_sessions::DistantSession>)distantSessionForTag: |
| 96 (std::string const&)tag; | 90 (std::string const&)tag; |
| 97 | 91 |
| 98 // Returns the current count of sessions including main and incognito. | 92 // Returns the current count of sessions including main and incognito. |
| 99 - (NSInteger)sessionCount; | 93 - (NSInteger)sessionCount; |
| 100 // Returns the current count of distant sessions. | 94 // Returns the current count of distant sessions. |
| 101 - (NSInteger)distantSessionCount; | 95 - (NSInteger)distantSessionCount; |
| 102 // Returns the type of the sign in panel. | 96 // Returns the type of the sign in panel. |
| 103 - (TabSwitcherSignInPanelsType)signInPanelType; | 97 - (TabSwitcherSignInPanelsType)signInPanelType; |
| 104 // Returns the tag of the session at index |index|. | 98 // Returns the tag of the session at index |index|. |
| 105 - (std::string const&)tagOfDistantSessionAtIndex:(int)index; | 99 - (std::string const&)tagOfDistantSessionAtIndex:(int)index; |
| 106 // Notifies the delegate that changes occured for the distant sessions. | 100 // Notifies the delegate that changes occured for the distant sessions. |
| 107 - (void)syncedSessionsChanged; | 101 - (void)syncedSessionsChanged; |
| 108 @end | 102 @end |
| 109 | 103 |
| 110 #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ | 104 #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_SWITCHER_MODEL_H_ |
| OLD | NEW |