Commit 5316b1cb authored by edchin's avatar edchin Committed by Commit Bot

[ios] Hook up remote tabs in tab grid

This CL hooks up the remote tabs in the tab grid.

A user can sign in from the remote tabs page in the tab grid. The
transition animation that displays the signin interaction controller
looks bad (and we are investigating the cause). If the user is signed
in but does not have sync enabled, the user can enable sync from here.

Currently, tapping on a tab does nothing. This will be enabled in a
future CL.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ifba06919e1fb496917254a0da7e5462a4b854d79
Reviewed-on: https://chromium-review.googlesource.com/1084080
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564684}
parent 04284098
......@@ -956,6 +956,8 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[_browserViewWrangler shutdown];
_browserViewWrangler = nil;
[_mainCoordinator stop];
_chromeMain.reset();
}
......
......@@ -354,25 +354,25 @@ const int kRelativeTimeMaxHours = 4;
// called inside a [UITableView beginUpdates] block on iOS10, or
// performBatchUpdates on iOS11+.
- (void)updateOtherDevicesSectionForState:(SessionsSyncUserState)newState {
DCHECK(newState !=
SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS);
DCHECK_NE(newState,
SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS);
TableViewModel* model = self.tableViewModel;
SessionsSyncUserState previousState = self.sessionState;
switch (previousState) {
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_OFF:
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_NO_SESSIONS:
case SessionsSyncUserState::USER_SIGNED_OUT:
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_IN_PROGRESS:
// The OtherDevices section will be updated, remove it in order to clean
// it up.
[model removeSectionWithIdentifier:SectionIdentifierOtherDevices];
break;
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS:
// The Sessions Section exists, remove it.
[self removeSessionSections];
break;
if (previousState ==
SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS) {
// There were previously one or more session sections, but now they will be
// removed and replaced with a single OtherDevices section.
[self removeSessionSections];
[self addOtherDevicesSectionForState:newState];
// This is a special situation where the tableview operation is an insert
// rather than reload because the section was deleted.
[self.tableView insertSections:[self otherDevicesSectionIndexSet]
withRowAnimation:UITableViewRowAnimationNone];
return;
}
// Add an updated OtherDevices Section and then reload the TableView section.
// For all other previous states, the tableview operation is a reload since
// there is already an OtherDevices section that can be updated.
[model removeSectionWithIdentifier:SectionIdentifierOtherDevices];
[self addOtherDevicesSectionForState:newState];
[self.tableView reloadSections:[self otherDevicesSectionIndexSet]
withRowAnimation:UITableViewRowAnimationNone];
......
......@@ -68,6 +68,12 @@
forProtocol:@protocol(BrowserCommands)];
[_dispatcher startDispatchingToTarget:applicationCommandEndpoint
forProtocol:@protocol(ApplicationCommands)];
// -startDispatchingToTarget:forProtocol: doesn't pick up protocols the
// passed protocol conforms to, so ApplicationSettingsCommands is explicitly
// dispatched to the endpoint as well.
[_dispatcher
startDispatchingToTarget:applicationCommandEndpoint
forProtocol:@protocol(ApplicationSettingsCommands)];
}
return self;
}
......@@ -150,6 +156,21 @@
mainViewController.remoteTabsViewController.browserState =
_regularTabModel.browserState;
self.remoteTabsMediator = [[RecentTabsMediator alloc] init];
self.remoteTabsMediator.browserState = _regularTabModel.browserState;
self.remoteTabsMediator.consumer = mainViewController.remoteTabsConsumer;
// TODO(crbug.com/845636) : Currently, the image data source must be set
// before the mediator starts updating its consumer. Fix this so that order of
// calls does not matter.
mainViewController.remoteTabsViewController.imageDataSource =
self.remoteTabsMediator;
mainViewController.remoteTabsViewController.delegate =
self.remoteTabsMediator;
mainViewController.remoteTabsViewController.dispatcher =
static_cast<id<ApplicationCommands>>(self.dispatcher);
if (self.remoteTabsMediator.browserState) {
[self.remoteTabsMediator initObservers];
[self.remoteTabsMediator refreshSessionsView];
}
// Once the mediators are set up, stop keeping pointers to the tab models used
// to initialize them.
......@@ -162,6 +183,8 @@
- (void)stop {
[self.dispatcher stopDispatchingForProtocol:@protocol(BrowserCommands)];
[self.dispatcher stopDispatchingForProtocol:@protocol(ApplicationCommands)];
[self.dispatcher
stopDispatchingForProtocol:@protocol(ApplicationSettingsCommands)];
// TODO(crbug.com/845192) : RecentTabsTableViewController behaves like a
// coordinator and that should be factored out.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment