| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ntp/recent_tabs/recent_tabs_table_view_controller
.h" | 5 #import "ios/chrome/browser/ui/ntp/recent_tabs/recent_tabs_table_view_controller
.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/mac/scoped_nsobject.h" | |
| 12 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| 13 #include "base/metrics/user_metrics_action.h" | 11 #include "base/metrics/user_metrics_action.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 15 #include "components/browser_sync/profile_sync_service.h" | 13 #include "components/browser_sync/profile_sync_service.h" |
| 16 #include "components/sync/driver/sync_service.h" | 14 #include "components/sync/driver/sync_service.h" |
| 17 #include "components/sync_sessions/open_tabs_ui_delegate.h" | 15 #include "components/sync_sessions/open_tabs_ui_delegate.h" |
| 18 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 19 #import "ios/chrome/browser/metrics/new_tab_page_uma.h" | 17 #import "ios/chrome/browser/metrics/new_tab_page_uma.h" |
| 20 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.h" | 18 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.h" |
| 21 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios_fact
ory.h" | 19 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios_fact
ory.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_out_view.h" | 34 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_out_view.h" |
| 37 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/spacers_view.h" | 35 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/spacers_view.h" |
| 38 #include "ios/chrome/browser/ui/ui_util.h" | 36 #include "ios/chrome/browser/ui/ui_util.h" |
| 39 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 37 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 40 #import "ios/chrome/browser/ui/url_loader.h" | 38 #import "ios/chrome/browser/ui/url_loader.h" |
| 41 #include "ios/chrome/grit/ios_strings.h" | 39 #include "ios/chrome/grit/ios_strings.h" |
| 42 #include "ios/web/public/referrer.h" | 40 #include "ios/web/public/referrer.h" |
| 43 #import "ios/web/public/web_state/context_menu_params.h" | 41 #import "ios/web/public/web_state/context_menu_params.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 45 | 43 |
| 44 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 45 #error "This file requires ARC support." |
| 46 #endif |
| 47 |
| 46 namespace { | 48 namespace { |
| 47 | 49 |
| 48 // Key for saving collapsed session state in the UserDefaults. | 50 // Key for saving collapsed session state in the UserDefaults. |
| 49 NSString* const kCollapsedSectionsKey = @"ChromeRecentTabsCollapsedSections"; | 51 NSString* const kCollapsedSectionsKey = @"ChromeRecentTabsCollapsedSections"; |
| 50 | 52 |
| 51 // Key for saving whether the Other Device section is collapsed. | 53 // Key for saving whether the Other Device section is collapsed. |
| 52 NSString* const kOtherDeviceCollapsedKey = @"OtherDevicesCollapsed"; | 54 NSString* const kOtherDeviceCollapsedKey = @"OtherDevicesCollapsed"; |
| 53 | 55 |
| 54 // Key for saving whether the Recently Closed section is collapsed. | 56 // Key for saving whether the Recently Closed section is collapsed. |
| 55 NSString* const kRecentlyClosedCollapsedKey = @"RecentlyClosedCollapsed"; | 57 NSString* const kRecentlyClosedCollapsedKey = @"RecentlyClosedCollapsed"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 80 CELL_SESSION_TAB_DATA, | 82 CELL_SESSION_TAB_DATA, |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 } // namespace | 85 } // namespace |
| 84 | 86 |
| 85 @interface RecentTabsTableViewController () { | 87 @interface RecentTabsTableViewController () { |
| 86 ios::ChromeBrowserState* _browserState; // weak | 88 ios::ChromeBrowserState* _browserState; // weak |
| 87 // The service that manages the recently closed tabs. | 89 // The service that manages the recently closed tabs. |
| 88 sessions::TabRestoreService* _tabRestoreService; // weak | 90 sessions::TabRestoreService* _tabRestoreService; // weak |
| 89 // Loader used to open new tabs. | 91 // Loader used to open new tabs. |
| 90 id<UrlLoader> _loader; // weak | 92 __weak id<UrlLoader> _loader; |
| 91 // The sync state. | 93 // The sync state. |
| 92 SessionsSyncUserState _sessionState; | 94 SessionsSyncUserState _sessionState; |
| 93 // The synced sessions. | 95 // The synced sessions. |
| 94 std::unique_ptr<synced_sessions::SyncedSessions> _syncedSessions; | 96 std::unique_ptr<synced_sessions::SyncedSessions> _syncedSessions; |
| 95 // Handles displaying the context menu for all form factors. | 97 // Handles displaying the context menu for all form factors. |
| 96 base::scoped_nsobject<ContextMenuCoordinator> _contextMenuCoordinator; | 98 ContextMenuCoordinator* _contextMenuCoordinator; |
| 97 } | 99 } |
| 98 // Returns the type of the section at index |section|. | 100 // Returns the type of the section at index |section|. |
| 99 - (SectionType)sectionType:(NSInteger)section; | 101 - (SectionType)sectionType:(NSInteger)section; |
| 100 // Returns the type of the cell at the path |indexPath|. | 102 // Returns the type of the cell at the path |indexPath|. |
| 101 - (CellType)cellType:(NSIndexPath*)indexPath; | 103 - (CellType)cellType:(NSIndexPath*)indexPath; |
| 102 // Returns the number of sections before the other devices or session sections. | 104 // Returns the number of sections before the other devices or session sections. |
| 103 - (NSInteger)numberOfSectionsBeforeSessionOrOtherDevicesSections; | 105 - (NSInteger)numberOfSectionsBeforeSessionOrOtherDevicesSections; |
| 104 // Dismisses the modal containing the Recent Tabs panel (iPhone only). | 106 // Dismisses the modal containing the Recent Tabs panel (iPhone only). |
| 105 - (void)dismissRecentTabsModal; | 107 - (void)dismissRecentTabsModal; |
| 106 // Dismisses the modal containing the Recent Tabs panel, with completion | 108 // Dismisses the modal containing the Recent Tabs panel, with completion |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 _browserState = browserState; | 163 _browserState = browserState; |
| 162 _loader = loader; | 164 _loader = loader; |
| 163 _sessionState = SessionsSyncUserState::USER_SIGNED_OUT; | 165 _sessionState = SessionsSyncUserState::USER_SIGNED_OUT; |
| 164 _syncedSessions.reset(new synced_sessions::SyncedSessions()); | 166 _syncedSessions.reset(new synced_sessions::SyncedSessions()); |
| 165 } | 167 } |
| 166 return self; | 168 return self; |
| 167 } | 169 } |
| 168 | 170 |
| 169 - (void)dealloc { | 171 - (void)dealloc { |
| 170 [self.tableView removeObserver:self forKeyPath:@"contentSize"]; | 172 [self.tableView removeObserver:self forKeyPath:@"contentSize"]; |
| 171 [super dealloc]; | |
| 172 } | 173 } |
| 173 | 174 |
| 174 - (void)viewDidLoad { | 175 - (void)viewDidLoad { |
| 175 [super viewDidLoad]; | 176 [super viewDidLoad]; |
| 176 self.view.accessibilityIdentifier = @"recent_tabs_view_controller"; | 177 self.view.accessibilityIdentifier = @"recent_tabs_view_controller"; |
| 177 [self.tableView setSeparatorColor:[UIColor clearColor]]; | 178 [self.tableView setSeparatorColor:[UIColor clearColor]]; |
| 178 [self.tableView setDataSource:self]; | 179 [self.tableView setDataSource:self]; |
| 179 [self.tableView setDelegate:self]; | 180 [self.tableView setDelegate:self]; |
| 180 base::scoped_nsobject<UILongPressGestureRecognizer> longPress( | 181 UILongPressGestureRecognizer* longPress = |
| 181 [[UILongPressGestureRecognizer alloc] | 182 [[UILongPressGestureRecognizer alloc] |
| 182 initWithTarget:self | 183 initWithTarget:self |
| 183 action:@selector(handleLongPress:)]); | 184 action:@selector(handleLongPress:)]; |
| 184 longPress.get().delegate = self; | 185 longPress.delegate = self; |
| 185 [self.tableView addGestureRecognizer:longPress]; | 186 [self.tableView addGestureRecognizer:longPress]; |
| 186 | 187 |
| 187 [self.tableView addObserver:self | 188 [self.tableView addObserver:self |
| 188 forKeyPath:@"contentSize" | 189 forKeyPath:@"contentSize" |
| 189 options:0 | 190 options:0 |
| 190 context:NULL]; | 191 context:NULL]; |
| 191 } | 192 } |
| 192 | 193 |
| 193 - (void)observeValueForKeyPath:(NSString*)keyPath | 194 - (void)observeValueForKeyPath:(NSString*)keyPath |
| 194 ofObject:(id)object | 195 ofObject:(id)object |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 referrer:web::Referrer() | 378 referrer:web::Referrer() |
| 378 transition:ui::PAGE_TRANSITION_TYPED | 379 transition:ui::PAGE_TRANSITION_TYPED |
| 379 rendererInitiated:NO]; | 380 rendererInitiated:NO]; |
| 380 } | 381 } |
| 381 } | 382 } |
| 382 | 383 |
| 383 - (void)showFullHistory { | 384 - (void)showFullHistory { |
| 384 UIViewController* rootViewController = | 385 UIViewController* rootViewController = |
| 385 self.tableView.window.rootViewController; | 386 self.tableView.window.rootViewController; |
| 386 ProceduralBlock openHistory = ^{ | 387 ProceduralBlock openHistory = ^{ |
| 387 base::scoped_nsobject<GenericChromeCommand> openHistory( | 388 GenericChromeCommand* openHistory = |
| 388 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_HISTORY]); | 389 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_HISTORY]; |
| 389 [rootViewController chromeExecuteCommand:openHistory]; | 390 [rootViewController chromeExecuteCommand:openHistory]; |
| 390 }; | 391 }; |
| 391 // Dismiss modal, if shown, and open history. | 392 // Dismiss modal, if shown, and open history. |
| 392 if (IsIPadIdiom()) { | 393 if (IsIPadIdiom()) { |
| 393 openHistory(); | 394 openHistory(); |
| 394 } else { | 395 } else { |
| 395 [self dismissRecentTabsModalWithCompletion:openHistory]; | 396 [self dismissRecentTabsModalWithCompletion:openHistory]; |
| 396 } | 397 } |
| 397 } | 398 } |
| 398 | 399 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 CellType cellType = [self cellType:indexPath]; | 593 CellType cellType = [self cellType:indexPath]; |
| 593 if (cellType != CELL_SESSION_SECTION_HEADER) { | 594 if (cellType != CELL_SESSION_SECTION_HEADER) { |
| 594 NOTREACHED(); | 595 NOTREACHED(); |
| 595 return; | 596 return; |
| 596 } | 597 } |
| 597 | 598 |
| 598 web::ContextMenuParams params; | 599 web::ContextMenuParams params; |
| 599 // Get view coordinates in local space. | 600 // Get view coordinates in local space. |
| 600 CGPoint viewCoordinate = [longPressGesture locationInView:self.tableView]; | 601 CGPoint viewCoordinate = [longPressGesture locationInView:self.tableView]; |
| 601 params.location = viewCoordinate; | 602 params.location = viewCoordinate; |
| 602 params.view.reset([self.tableView retain]); | 603 params.view.reset(self.tableView); |
| 603 | 604 |
| 604 // Present sheet/popover using controller that is added to view hierarchy. | 605 // Present sheet/popover using controller that is added to view hierarchy. |
| 605 UIViewController* topController = [params.view window].rootViewController; | 606 UIViewController* topController = [params.view window].rootViewController; |
| 606 while (topController.presentedViewController) | 607 while (topController.presentedViewController) |
| 607 topController = topController.presentedViewController; | 608 topController = topController.presentedViewController; |
| 608 | 609 |
| 609 _contextMenuCoordinator.reset([[ContextMenuCoordinator alloc] | 610 _contextMenuCoordinator = |
| 610 initWithBaseViewController:topController | 611 [[ContextMenuCoordinator alloc] initWithBaseViewController:topController |
| 611 params:params]); | 612 params:params]; |
| 612 | 613 |
| 613 // Fill the sheet/popover with buttons. | 614 // Fill the sheet/popover with buttons. |
| 614 base::WeakNSObject<RecentTabsTableViewController> weakSelf(self); | 615 __weak RecentTabsTableViewController* weakSelf = self; |
| 615 | 616 |
| 616 // "Open all tabs" button. | 617 // "Open all tabs" button. |
| 617 NSString* openAllButtonLabel = | 618 NSString* openAllButtonLabel = |
| 618 l10n_util::GetNSString(IDS_IOS_RECENT_TABS_OPEN_ALL_MENU_OPTION); | 619 l10n_util::GetNSString(IDS_IOS_RECENT_TABS_OPEN_ALL_MENU_OPTION); |
| 619 [_contextMenuCoordinator | 620 [_contextMenuCoordinator |
| 620 addItemWithTitle:openAllButtonLabel | 621 addItemWithTitle:openAllButtonLabel |
| 621 action:^{ | 622 action:^{ |
| 622 [weakSelf openTabsFromSessionAtIndexPath:indexPath]; | 623 [weakSelf openTabsFromSessionAtIndexPath:indexPath]; |
| 623 }]; | 624 }]; |
| 624 | 625 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 return 1; | 726 return 1; |
| 726 else | 727 else |
| 727 return distantSession->tabs.size() + 1; | 728 return distantSession->tabs.size() + 1; |
| 728 } | 729 } |
| 729 } | 730 } |
| 730 } | 731 } |
| 731 | 732 |
| 732 - (UITableViewCell*)tableView:(UITableView*)tableView | 733 - (UITableViewCell*)tableView:(UITableView*)tableView |
| 733 cellForRowAtIndexPath:(NSIndexPath*)indexPath { | 734 cellForRowAtIndexPath:(NSIndexPath*)indexPath { |
| 734 UITableViewCell* cell = | 735 UITableViewCell* cell = |
| 735 [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault | 736 [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
| 736 reuseIdentifier:nil] autorelease]; | 737 reuseIdentifier:nil]; |
| 737 UIView* contentView = cell.contentView; | 738 UIView* contentView = cell.contentView; |
| 738 | 739 |
| 739 base::scoped_nsobject<UIView> subview; | 740 UIView* subview; |
| 740 CellType cellType = [self cellType:indexPath]; | 741 CellType cellType = [self cellType:indexPath]; |
| 741 switch (cellType) { | 742 switch (cellType) { |
| 742 case CELL_CLOSED_TAB_SECTION_HEADER: { | 743 case CELL_CLOSED_TAB_SECTION_HEADER: { |
| 743 BOOL collapsed = [self sectionIsCollapsed:kRecentlyClosedCollapsedKey]; | 744 BOOL collapsed = [self sectionIsCollapsed:kRecentlyClosedCollapsedKey]; |
| 744 subview.reset([[GenericSectionHeaderView alloc] | 745 subview = [[GenericSectionHeaderView alloc] |
| 745 initWithType:recent_tabs::RECENTLY_CLOSED_TABS_SECTION_HEADER | 746 initWithType:recent_tabs::RECENTLY_CLOSED_TABS_SECTION_HEADER |
| 746 sectionIsCollapsed:collapsed]); | 747 sectionIsCollapsed:collapsed]; |
| 747 [subview setTag:kSectionHeader]; | 748 [subview setTag:kSectionHeader]; |
| 748 break; | 749 break; |
| 749 } | 750 } |
| 750 case CELL_CLOSED_TAB_DATA: { | 751 case CELL_CLOSED_TAB_DATA: { |
| 751 base::scoped_nsobject<SessionTabDataView> genericTabData( | 752 SessionTabDataView* genericTabData = |
| 752 [[SessionTabDataView alloc] initWithFrame:CGRectZero]); | 753 [[SessionTabDataView alloc] initWithFrame:CGRectZero]; |
| 753 [genericTabData | 754 [genericTabData |
| 754 updateWithTabRestoreEntry:[self tabRestoreEntryAtIndex:indexPath] | 755 updateWithTabRestoreEntry:[self tabRestoreEntryAtIndex:indexPath] |
| 755 browserState:_browserState]; | 756 browserState:_browserState]; |
| 756 subview.reset([genericTabData.get() retain]); | 757 subview = genericTabData; |
| 757 break; | 758 break; |
| 758 } | 759 } |
| 759 case CELL_SHOW_FULL_HISTORY: | 760 case CELL_SHOW_FULL_HISTORY: |
| 760 subview.reset([[ShowFullHistoryView alloc] initWithFrame:CGRectZero]); | 761 subview = [[ShowFullHistoryView alloc] initWithFrame:CGRectZero]; |
| 761 break; | 762 break; |
| 762 case CELL_SEPARATOR: | 763 case CELL_SEPARATOR: |
| 763 subview.reset( | 764 subview = [[RecentlyClosedSectionFooter alloc] initWithFrame:CGRectZero]; |
| 764 [[RecentlyClosedSectionFooter alloc] initWithFrame:CGRectZero]); | |
| 765 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; | 765 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; |
| 766 break; | 766 break; |
| 767 case CELL_OTHER_DEVICES_SECTION_HEADER: { | 767 case CELL_OTHER_DEVICES_SECTION_HEADER: { |
| 768 BOOL collapsed = [self sectionIsCollapsed:kOtherDeviceCollapsedKey]; | 768 BOOL collapsed = [self sectionIsCollapsed:kOtherDeviceCollapsedKey]; |
| 769 subview.reset([[GenericSectionHeaderView alloc] | 769 subview = [[GenericSectionHeaderView alloc] |
| 770 initWithType:recent_tabs::OTHER_DEVICES_SECTION_HEADER | 770 initWithType:recent_tabs::OTHER_DEVICES_SECTION_HEADER |
| 771 sectionIsCollapsed:collapsed]); | 771 sectionIsCollapsed:collapsed]; |
| 772 [subview setTag:kSectionHeader]; | 772 [subview setTag:kSectionHeader]; |
| 773 break; | 773 break; |
| 774 } | 774 } |
| 775 case CELL_OTHER_DEVICES_SIGNED_OUT: | 775 case CELL_OTHER_DEVICES_SIGNED_OUT: |
| 776 subview.reset([[SignedOutView alloc] initWithFrame:CGRectZero]); | 776 subview = [[SignedOutView alloc] initWithFrame:CGRectZero]; |
| 777 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; | 777 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; |
| 778 break; | 778 break; |
| 779 case CELL_OTHER_DEVICES_SIGNED_IN_SYNC_OFF: | 779 case CELL_OTHER_DEVICES_SIGNED_IN_SYNC_OFF: |
| 780 subview.reset([[SignedInSyncOffView alloc] initWithFrame:CGRectZero | 780 subview = [[SignedInSyncOffView alloc] initWithFrame:CGRectZero |
| 781 browserState:_browserState]); | 781 browserState:_browserState]; |
| 782 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; | 782 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; |
| 783 break; | 783 break; |
| 784 case CELL_OTHER_DEVICES_SIGNED_IN_SYNC_ON_NO_SESSIONS: | 784 case CELL_OTHER_DEVICES_SIGNED_IN_SYNC_ON_NO_SESSIONS: |
| 785 subview.reset( | 785 subview = [[SignedInSyncOnNoSessionsView alloc] initWithFrame:CGRectZero]; |
| 786 [[SignedInSyncOnNoSessionsView alloc] initWithFrame:CGRectZero]); | |
| 787 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; | 786 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; |
| 788 break; | 787 break; |
| 789 case CELL_OTHER_DEVICES_SYNC_IN_PROGRESS: | 788 case CELL_OTHER_DEVICES_SYNC_IN_PROGRESS: |
| 790 subview.reset( | 789 subview = [[SignedInSyncInProgressView alloc] initWithFrame:CGRectZero]; |
| 791 [[SignedInSyncInProgressView alloc] initWithFrame:CGRectZero]); | |
| 792 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; | 790 [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; |
| 793 break; | 791 break; |
| 794 case CELL_SESSION_SECTION_HEADER: { | 792 case CELL_SESSION_SECTION_HEADER: { |
| 795 synced_sessions::DistantSession const* distantSession = | 793 synced_sessions::DistantSession const* distantSession = |
| 796 [self sessionAtIndexPath:indexPath]; | 794 [self sessionAtIndexPath:indexPath]; |
| 797 NSString* key = [self keyForDistantSession:distantSession]; | 795 NSString* key = [self keyForDistantSession:distantSession]; |
| 798 BOOL collapsed = [self sectionIsCollapsed:key]; | 796 BOOL collapsed = [self sectionIsCollapsed:key]; |
| 799 base::scoped_nsobject<SessionSectionHeaderView> sessionSectionHeader( | 797 SessionSectionHeaderView* sessionSectionHeader = |
| 800 [[SessionSectionHeaderView alloc] initWithFrame:CGRectZero | 798 [[SessionSectionHeaderView alloc] initWithFrame:CGRectZero |
| 801 sectionIsCollapsed:collapsed]); | 799 sectionIsCollapsed:collapsed]; |
| 802 [sessionSectionHeader updateWithSession:distantSession]; | 800 [sessionSectionHeader updateWithSession:distantSession]; |
| 803 subview.reset(sessionSectionHeader.release()); | 801 subview = sessionSectionHeader; |
| 804 [subview setTag:kSectionHeader]; | 802 [subview setTag:kSectionHeader]; |
| 805 break; | 803 break; |
| 806 } | 804 } |
| 807 case CELL_SESSION_TAB_DATA: { | 805 case CELL_SESSION_TAB_DATA: { |
| 808 base::scoped_nsobject<SessionTabDataView> genericTabData( | 806 SessionTabDataView* genericTabData = |
| 809 [[SessionTabDataView alloc] initWithFrame:CGRectZero]); | 807 [[SessionTabDataView alloc] initWithFrame:CGRectZero]; |
| 810 [genericTabData updateWithDistantTab:[self distantTabAtIndex:indexPath] | 808 [genericTabData updateWithDistantTab:[self distantTabAtIndex:indexPath] |
| 811 browserState:_browserState]; | 809 browserState:_browserState]; |
| 812 subview.reset([genericTabData.get() retain]); | 810 subview = genericTabData; |
| 813 break; | 811 break; |
| 814 } | 812 } |
| 815 } | 813 } |
| 816 | 814 |
| 817 DCHECK(subview); | 815 DCHECK(subview); |
| 818 [contentView addSubview:subview]; | 816 [contentView addSubview:subview]; |
| 819 | 817 |
| 820 // Sets constraints on the subview. | 818 // Sets constraints on the subview. |
| 821 [subview setTranslatesAutoresizingMaskIntoConstraints:NO]; | 819 [subview setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 822 | 820 |
| 823 NSDictionary* viewsDictionary = @{ @"view" : subview.get() }; | 821 NSDictionary* viewsDictionary = @{ @"view" : subview }; |
| 824 // This set of constraints should match the constraints set on the | 822 // This set of constraints should match the constraints set on the |
| 825 // RecentlyClosedSectionFooter. | 823 // RecentlyClosedSectionFooter. |
| 826 // clang-format off | 824 // clang-format off |
| 827 NSArray* constraints = @[ | 825 NSArray* constraints = @[ |
| 828 @"V:|-0-[view]-0-|", | 826 @"V:|-0-[view]-0-|", |
| 829 @"H:|-(>=0)-[view(<=548)]-(>=0)-|", | 827 @"H:|-(>=0)-[view(<=548)]-(>=0)-|", |
| 830 @"H:[view(==548@500)]" | 828 @"H:[view(==548@500)]" |
| 831 ]; | 829 ]; |
| 832 // clang-format on | 830 // clang-format on |
| 833 [contentView addConstraint:[NSLayoutConstraint | 831 [contentView addConstraint:[NSLayoutConstraint |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 case CELL_OTHER_DEVICES_SECTION_HEADER: | 921 case CELL_OTHER_DEVICES_SECTION_HEADER: |
| 924 return [GenericSectionHeaderView desiredHeightInUITableViewCell]; | 922 return [GenericSectionHeaderView desiredHeightInUITableViewCell]; |
| 925 case CELL_OTHER_DEVICES_SYNC_IN_PROGRESS: | 923 case CELL_OTHER_DEVICES_SYNC_IN_PROGRESS: |
| 926 return [SignedInSyncInProgressView desiredHeightInUITableViewCell]; | 924 return [SignedInSyncInProgressView desiredHeightInUITableViewCell]; |
| 927 } | 925 } |
| 928 } | 926 } |
| 929 | 927 |
| 930 - (UIView*)tableView:(UITableView*)tableView | 928 - (UIView*)tableView:(UITableView*)tableView |
| 931 viewForHeaderInSection:(NSInteger)section { | 929 viewForHeaderInSection:(NSInteger)section { |
| 932 if ([self sectionType:section] == CLOSED_TAB_SECTION) { | 930 if ([self sectionType:section] == CLOSED_TAB_SECTION) { |
| 933 return [[[RecentlyTabsTopSpacingHeader alloc] initWithFrame:CGRectZero] | 931 return [[RecentlyTabsTopSpacingHeader alloc] initWithFrame:CGRectZero]; |
| 934 autorelease]; | |
| 935 } | 932 } |
| 936 return nil; | 933 return nil; |
| 937 } | 934 } |
| 938 | 935 |
| 939 - (CGFloat)tableView:(UITableView*)tableView | 936 - (CGFloat)tableView:(UITableView*)tableView |
| 940 heightForHeaderInSection:(NSInteger)section { | 937 heightForHeaderInSection:(NSInteger)section { |
| 941 if ([self sectionType:section] == CLOSED_TAB_SECTION) { | 938 if ([self sectionType:section] == CLOSED_TAB_SECTION) { |
| 942 return [RecentlyTabsTopSpacingHeader desiredHeightInUITableViewCell]; | 939 return [RecentlyTabsTopSpacingHeader desiredHeightInUITableViewCell]; |
| 943 } | 940 } |
| 944 return 0; | 941 return 0; |
| 945 } | 942 } |
| 946 | 943 |
| 947 #pragma mark - UIScrollViewDelegate | 944 #pragma mark - UIScrollViewDelegate |
| 948 | 945 |
| 949 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { | 946 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { |
| 950 [delegate_ recentTabsTableViewContentMoved:self.tableView]; | 947 [delegate_ recentTabsTableViewContentMoved:self.tableView]; |
| 951 } | 948 } |
| 952 | 949 |
| 953 @end | 950 @end |
| OLD | NEW |