Chromium Code Reviews| Index: ios/chrome/browser/ui/tab_switcher/tab_switcher_model.mm |
| diff --git a/ios/chrome/browser/ui/tab_switcher/tab_switcher_model.mm b/ios/chrome/browser/ui/tab_switcher/tab_switcher_model.mm |
| index 6f1a4e5df90d59c11346724d2d7f21dbb88f08ed..902f906b55f58d485f95b3292c5ee4c6393bbcce 100644 |
| --- a/ios/chrome/browser/ui/tab_switcher/tab_switcher_model.mm |
| +++ b/ios/chrome/browser/ui/tab_switcher/tab_switcher_model.mm |
| @@ -24,15 +24,11 @@ |
| #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_model_private.h" |
| #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
| -namespace ios_internal { |
| - |
| -bool IsLocalSession(SessionType sessionType) { |
| +bool SessionTypeIsLocalSession(SessionType sessionType) { |
| return sessionType == SessionType::OFF_THE_RECORD_SESSION || |
| sessionType == SessionType::REGULAR_SESSION; |
| } |
| -} // namespace ios_internal |
| - |
| namespace { |
| class TagAndIndex { |
| @@ -77,7 +73,7 @@ void FillSetUsingSessions(synced_sessions::SyncedSessions const& sessions, |
| // Returns the type of the local session corresponding to the given |tabModel|. |
| // |tabModel| MUST be equal to either |_mainTabModel|, or |_otrTabModel|. |
| -- (ios_internal::SessionType)typeOfLocalSessionForTabModel:(TabModel*)tabModel; |
| +- (SessionType)typeOfLocalSessionForTabModel:(TabModel*)tabModel; |
| @end |
| @implementation TabSwitcherModel |
| @@ -153,33 +149,31 @@ void FillSetUsingSessions(synced_sessions::SyncedSessions const& sessions, |
| return _browserState; |
| } |
| -- (TabModel*)tabModelForSessionOfType:(ios_internal::SessionType)type { |
| - DCHECK(type == ios_internal::SessionType::OFF_THE_RECORD_SESSION || |
| - type == ios_internal::SessionType::REGULAR_SESSION); |
| - return type == ios_internal::SessionType::OFF_THE_RECORD_SESSION |
| - ? _otrTabModel |
| - : _mainTabModel; |
| +- (TabModel*)tabModelForSessionOfType:(SessionType)type { |
| + DCHECK(type == SessionType::OFF_THE_RECORD_SESSION || |
|
sdefresne
2017/01/03 16:04:30
nit: this could be rewritten like this
DCHECK(S
rohitrao (ping after 24h)
2017/01/04 13:36:37
Acknowledged.
|
| + type == SessionType::REGULAR_SESSION); |
| + return type == SessionType::OFF_THE_RECORD_SESSION ? _otrTabModel |
| + : _mainTabModel; |
| } |
| -- (NSInteger)numberOfTabsInLocalSessionOfType:(ios_internal::SessionType)type { |
| +- (NSInteger)numberOfTabsInLocalSessionOfType:(SessionType)type { |
| TabModelSnapshot* tabModelSnapshot = [self tabModelSnapshotForSession:type]; |
| return tabModelSnapshot->tabs().size(); |
| } |
| -- (Tab*)tabAtIndex:(NSUInteger)index |
| - inLocalSessionOfType:(ios_internal::SessionType)type { |
| +- (Tab*)tabAtIndex:(NSUInteger)index inLocalSessionOfType:(SessionType)type { |
| TabModelSnapshot* tabModelSnapshot = [self tabModelSnapshotForSession:type]; |
| return tabModelSnapshot->tabs()[index]; |
| } |
| - (std::unique_ptr<TabModelSnapshot>)tabModelSnapshotForLocalSession: |
| - (ios_internal::SessionType)type { |
| + (SessionType)type { |
| TabModel* tm = nullptr; |
| switch (type) { |
| - case ios_internal::SessionType::OFF_THE_RECORD_SESSION: |
| + case SessionType::OFF_THE_RECORD_SESSION: |
| tm = _otrTabModel; |
| break; |
| - case ios_internal::SessionType::REGULAR_SESSION: |
| + case SessionType::REGULAR_SESSION: |
| tm = _mainTabModel; |
| break; |
| default: |
| @@ -316,19 +310,18 @@ void FillSetUsingSessions(synced_sessions::SyncedSessions const& sessions, |
| } |
| } |
| -- (ios_internal::SessionType)typeOfLocalSessionForTabModel:(TabModel*)tabModel { |
| +- (SessionType)typeOfLocalSessionForTabModel:(TabModel*)tabModel { |
| DCHECK(tabModel == _mainTabModel || tabModel == _otrTabModel); |
| if (tabModel == _otrTabModel) |
| - return ios_internal::SessionType::OFF_THE_RECORD_SESSION; |
| - return ios_internal::SessionType::REGULAR_SESSION; |
| + return SessionType::OFF_THE_RECORD_SESSION; |
| + return SessionType::REGULAR_SESSION; |
| } |
| -- (TabModelSnapshot*)tabModelSnapshotForSession: |
| - (ios_internal::SessionType)type { |
| +- (TabModelSnapshot*)tabModelSnapshotForSession:(SessionType)type { |
| switch (type) { |
| - case ios_internal::SessionType::OFF_THE_RECORD_SESSION: |
| + case SessionType::OFF_THE_RECORD_SESSION: |
| return _otrTabModelSnapshot.get(); |
| - case ios_internal::SessionType::REGULAR_SESSION: |
| + case SessionType::REGULAR_SESSION: |
| return _mainTabModelSnapshot.get(); |
| default: |
| NOTREACHED(); |
| @@ -338,12 +331,12 @@ void FillSetUsingSessions(synced_sessions::SyncedSessions const& sessions, |
| } |
| - (void)setTabModelSnapshot:(std::unique_ptr<TabModelSnapshot>)tabModelSnapshot |
| - forSession:(ios_internal::SessionType)type { |
| + forSession:(SessionType)type { |
| switch (type) { |
| - case ios_internal::SessionType::OFF_THE_RECORD_SESSION: |
| + case SessionType::OFF_THE_RECORD_SESSION: |
| _otrTabModelSnapshot = std::move(tabModelSnapshot); |
| break; |
| - case ios_internal::SessionType::REGULAR_SESSION: |
| + case SessionType::REGULAR_SESSION: |
| _mainTabModelSnapshot = std::move(tabModelSnapshot); |
| break; |
| default: |
| @@ -353,8 +346,7 @@ void FillSetUsingSessions(synced_sessions::SyncedSessions const& sessions, |
| } |
| - (void)tabModelChanged:(TabModel*)tabModel { |
| - ios_internal::SessionType sessionType = |
| - [self typeOfLocalSessionForTabModel:tabModel]; |
| + SessionType sessionType = [self typeOfLocalSessionForTabModel:tabModel]; |
| [_delegate localSessionMayNeedUpdate:sessionType]; |
| } |