| 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_controller.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h" |
| 6 | 6 |
| 7 #include "base/ios/block_types.h" | 7 #include "base/ios/block_types.h" |
| 8 #include "base/ios/weak_nsobject.h" | 8 #include "base/ios/weak_nsobject.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #import "ios/chrome/browser/tabs/tab.h" | 24 #import "ios/chrome/browser/tabs/tab.h" |
| 25 #import "ios/chrome/browser/tabs/tab_model.h" | 25 #import "ios/chrome/browser/tabs/tab_model.h" |
| 26 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 26 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 27 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 27 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 28 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 28 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 29 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" | 29 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" |
| 30 #include "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions.h" | 30 #include "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions.h" |
| 31 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_in_sync_off_view.h" | 31 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_in_sync_off_view.h" |
| 32 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_in_sync_on_no_sessio
ns_view.h" | 32 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_in_sync_on_no_sessio
ns_view.h" |
| 33 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_out_view.h" | 33 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_out_view.h" |
| 34 #import "ios/chrome/browser/ui/tab_switcher/session_changes.h" | |
| 35 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_cache.h" | 34 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_cache.h" |
| 36 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_header_view.h" | 35 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_header_view.h" |
| 37 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_model.h" | 36 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_model.h" |
| 38 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" | 37 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
| 39 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_controller.h" | 38 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_controller.h" |
| 40 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" | 39 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" |
| 41 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_view.h" | 40 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_view.h" |
| 42 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_session_cell_data.h" | 41 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_session_cell_data.h" |
| 43 #include "ios/chrome/browser/ui/tab_switcher/tab_switcher_transition_context.h" | 42 #include "ios/chrome/browser/ui/tab_switcher/tab_switcher_transition_context.h" |
| 44 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_view.h" | 43 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_view.h" |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 [_tabSwitcherView selectPanelAtIndex:index]; | 1077 [_tabSwitcherView selectPanelAtIndex:index]; |
| 1079 } | 1078 } |
| 1080 | 1079 |
| 1081 #pragma mark - TabSwitcherHeaderViewDataSource | 1080 #pragma mark - TabSwitcherHeaderViewDataSource |
| 1082 | 1081 |
| 1083 - (NSInteger)tabSwitcherHeaderViewSessionCount { | 1082 - (NSInteger)tabSwitcherHeaderViewSessionCount { |
| 1084 NSInteger promoPanel = (![_tabSwitcherModel distantSessionCount]) ? 1 : 0; | 1083 NSInteger promoPanel = (![_tabSwitcherModel distantSessionCount]) ? 1 : 0; |
| 1085 return [_tabSwitcherModel sessionCount] + promoPanel; | 1084 return [_tabSwitcherModel sessionCount] + promoPanel; |
| 1086 } | 1085 } |
| 1087 | 1086 |
| 1088 - (SessionCellData*)sessionCellDataAtIndex:(NSUInteger)index { | 1087 - (TabSwitcherSessionCellData*)sessionCellDataAtIndex:(NSUInteger)index { |
| 1089 if (index == kLocalTabsOffTheRecordPanelIndex) { | 1088 if (index == kLocalTabsOffTheRecordPanelIndex) { |
| 1090 // If has incognito tabs return incognito cell data. | 1089 // If has incognito tabs return incognito cell data. |
| 1091 return [SessionCellData incognitoSessionCellData]; | 1090 return [TabSwitcherSessionCellData incognitoSessionCellData]; |
| 1092 } else if (index == kLocalTabsOnTheRecordPanelIndex) { | 1091 } else if (index == kLocalTabsOnTheRecordPanelIndex) { |
| 1093 return [SessionCellData openTabSessionCellData]; | 1092 return [TabSwitcherSessionCellData openTabSessionCellData]; |
| 1094 } else { | 1093 } else { |
| 1095 if (![_tabSwitcherModel distantSessionCount]) { | 1094 if (![_tabSwitcherModel distantSessionCount]) { |
| 1096 // Display promo panel cell if there is no distant sessions. | 1095 // Display promo panel cell if there is no distant sessions. |
| 1097 return [SessionCellData otherDevicesSessionCellData]; | 1096 return [TabSwitcherSessionCellData otherDevicesSessionCellData]; |
| 1098 } else { | 1097 } else { |
| 1099 index -= kHeaderDistantSessionIndexOffset; | 1098 index -= kHeaderDistantSessionIndexOffset; |
| 1100 | 1099 |
| 1101 sync_sessions::SyncedSession::DeviceType deviceType = | 1100 sync_sessions::SyncedSession::DeviceType deviceType = |
| 1102 sync_sessions::SyncedSession::TYPE_UNSET; | 1101 sync_sessions::SyncedSession::TYPE_UNSET; |
| 1103 NSString* cellTitle = nil; | 1102 NSString* cellTitle = nil; |
| 1104 | 1103 |
| 1105 if (index < _controllersOfDistantSessions.get().count) { | 1104 if (index < _controllersOfDistantSessions.get().count) { |
| 1106 TabSwitcherPanelController* panel = | 1105 TabSwitcherPanelController* panel = |
| 1107 [_controllersOfDistantSessions objectAtIndex:index]; | 1106 [_controllersOfDistantSessions objectAtIndex:index]; |
| 1108 const synced_sessions::DistantSession* distantSession = | 1107 const synced_sessions::DistantSession* distantSession = |
| 1109 [panel distantSession]; | 1108 [panel distantSession]; |
| 1110 deviceType = distantSession->device_type; | 1109 deviceType = distantSession->device_type; |
| 1111 cellTitle = base::SysUTF8ToNSString(distantSession->name); | 1110 cellTitle = base::SysUTF8ToNSString(distantSession->name); |
| 1112 } | 1111 } |
| 1113 TabSwitcherSessionCellType cellType; | 1112 TabSwitcherSessionCellType cellType; |
| 1114 switch (deviceType) { | 1113 switch (deviceType) { |
| 1115 case sync_sessions::SyncedSession::TYPE_PHONE: | 1114 case sync_sessions::SyncedSession::TYPE_PHONE: |
| 1116 cellType = kPhoneRemoteSessionCell; | 1115 cellType = kPhoneRemoteSessionCell; |
| 1117 break; | 1116 break; |
| 1118 case sync_sessions::SyncedSession::TYPE_TABLET: | 1117 case sync_sessions::SyncedSession::TYPE_TABLET: |
| 1119 cellType = kTabletRemoteSessionCell; | 1118 cellType = kTabletRemoteSessionCell; |
| 1120 break; | 1119 break; |
| 1121 default: | 1120 default: |
| 1122 cellType = kLaptopRemoteSessionCell; | 1121 cellType = kLaptopRemoteSessionCell; |
| 1123 break; | 1122 break; |
| 1124 } | 1123 } |
| 1125 SessionCellData* sessionData = [[[SessionCellData alloc] | 1124 TabSwitcherSessionCellData* sessionData = |
| 1126 initWithSessionCellType:cellType] autorelease]; | 1125 [[[TabSwitcherSessionCellData alloc] initWithSessionCellType:cellType] |
| 1126 autorelease]; |
| 1127 sessionData.title = cellTitle; | 1127 sessionData.title = cellTitle; |
| 1128 return sessionData; | 1128 return sessionData; |
| 1129 } | 1129 } |
| 1130 } | 1130 } |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 - (NSInteger)tabSwitcherHeaderViewSelectedPanelIndex { | 1133 - (NSInteger)tabSwitcherHeaderViewSelectedPanelIndex { |
| 1134 return [_tabSwitcherView currentPanelIndex]; | 1134 return [_tabSwitcherView currentPanelIndex]; |
| 1135 } | 1135 } |
| 1136 | 1136 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); | 1238 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); |
| 1239 } | 1239 } |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: | 1242 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: |
| 1243 (TabSwitcherPanelController*)tabSwitcherPanelController { | 1243 (TabSwitcherPanelController*)tabSwitcherPanelController { |
| 1244 [_tabSwitcherView updateOverlayButtonState]; | 1244 [_tabSwitcherView updateOverlayButtonState]; |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 @end | 1247 @end |
| OLD | NEW |