Commit eaedf244 authored by edchin's avatar edchin Committed by Commit Bot

Reland "[ios] Hook up remote tabs in tab grid"

This reverts commit cd9fa081.

This CL fixes the reason that the DCHECK failed causing
the original revert.

Original change's description:
> Revert "[ios] Hook up remote tabs in tab grid"
>
> This reverts commit 5316b1cb.
>
> Reason for revert: breaking ios_chrome_settings_egtests
>
> Original change's description:
> > [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: Eugene But <eugenebut@chromium.org>
> > Reviewed-by: Sergio Collazos <sczs@chromium.org>
> > Reviewed-by: edchin <edchin@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#564684}
>
> TBR=rohitrao@chromium.org,eugenebut@chromium.org,edchin@chromium.org,sczs@chromium.org,javierrobles@chromium.org
>
> Change-Id: Idc0b0b2def356a173949298bc7f560ee4dad3744
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
> Reviewed-on: https://chromium-review.googlesource.com/1088566
> Reviewed-by: Olivier Robin <olivierrobin@chromium.org>
> Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#564828}

TBR=rohitrao@chromium.org,eugenebut@chromium.org,olivierrobin@chromium.org,edchin@chromium.org,sczs@chromium.org

Change-Id: I34dca3dadbe0d356aff881559353876736722224
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Reviewed-on: https://chromium-review.googlesource.com/1089251Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565045}
parent 5a9eebe5
...@@ -956,6 +956,8 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -956,6 +956,8 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[_browserViewWrangler shutdown]; [_browserViewWrangler shutdown];
_browserViewWrangler = nil; _browserViewWrangler = nil;
[_mainCoordinator stop];
_chromeMain.reset(); _chromeMain.reset();
} }
......
...@@ -354,25 +354,25 @@ const int kRelativeTimeMaxHours = 4; ...@@ -354,25 +354,25 @@ const int kRelativeTimeMaxHours = 4;
// called inside a [UITableView beginUpdates] block on iOS10, or // called inside a [UITableView beginUpdates] block on iOS10, or
// performBatchUpdates on iOS11+. // performBatchUpdates on iOS11+.
- (void)updateOtherDevicesSectionForState:(SessionsSyncUserState)newState { - (void)updateOtherDevicesSectionForState:(SessionsSyncUserState)newState {
DCHECK(newState != DCHECK_NE(newState,
SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS); SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS);
TableViewModel* model = self.tableViewModel; TableViewModel* model = self.tableViewModel;
SessionsSyncUserState previousState = self.sessionState; SessionsSyncUserState previousState = self.sessionState;
switch (previousState) { if (previousState ==
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_OFF: SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS) {
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_NO_SESSIONS: // There were previously one or more session sections, but now they will be
case SessionsSyncUserState::USER_SIGNED_OUT: // removed and replaced with a single OtherDevices section.
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_IN_PROGRESS: [self removeSessionSections];
// The OtherDevices section will be updated, remove it in order to clean [self addOtherDevicesSectionForState:newState];
// it up. // This is a special situation where the tableview operation is an insert
[model removeSectionWithIdentifier:SectionIdentifierOtherDevices]; // rather than reload because the section was deleted.
break; [self.tableView insertSections:[self otherDevicesSectionIndexSet]
case SessionsSyncUserState::USER_SIGNED_IN_SYNC_ON_WITH_SESSIONS: withRowAnimation:UITableViewRowAnimationNone];
// The Sessions Section exists, remove it. return;
[self removeSessionSections];
break;
} }
// 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 addOtherDevicesSectionForState:newState];
[self.tableView reloadSections:[self otherDevicesSectionIndexSet] [self.tableView reloadSections:[self otherDevicesSectionIndexSet]
withRowAnimation:UITableViewRowAnimationNone]; withRowAnimation:UITableViewRowAnimationNone];
...@@ -570,6 +570,7 @@ const int kRelativeTimeMaxHours = 4; ...@@ -570,6 +570,7 @@ const int kRelativeTimeMaxHours = 4;
self.sessionState = newSessionState; self.sessionState = newSessionState;
if (self.sessionState != SessionsSyncUserState::USER_SIGNED_OUT) { if (self.sessionState != SessionsSyncUserState::USER_SIGNED_OUT) {
[self.signinPromoViewMediator signinPromoViewRemoved]; [self.signinPromoViewMediator signinPromoViewRemoved];
self.signinPromoViewMediator.consumer = nil;
self.signinPromoViewMediator = nil; self.signinPromoViewMediator = nil;
} }
} }
......
...@@ -68,6 +68,12 @@ ...@@ -68,6 +68,12 @@
forProtocol:@protocol(BrowserCommands)]; forProtocol:@protocol(BrowserCommands)];
[_dispatcher startDispatchingToTarget:applicationCommandEndpoint [_dispatcher startDispatchingToTarget:applicationCommandEndpoint
forProtocol:@protocol(ApplicationCommands)]; 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; return self;
} }
...@@ -150,6 +156,21 @@ ...@@ -150,6 +156,21 @@
mainViewController.remoteTabsViewController.browserState = mainViewController.remoteTabsViewController.browserState =
_regularTabModel.browserState; _regularTabModel.browserState;
self.remoteTabsMediator = [[RecentTabsMediator alloc] init]; 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 // Once the mediators are set up, stop keeping pointers to the tab models used
// to initialize them. // to initialize them.
...@@ -162,6 +183,8 @@ ...@@ -162,6 +183,8 @@
- (void)stop { - (void)stop {
[self.dispatcher stopDispatchingForProtocol:@protocol(BrowserCommands)]; [self.dispatcher stopDispatchingForProtocol:@protocol(BrowserCommands)];
[self.dispatcher stopDispatchingForProtocol:@protocol(ApplicationCommands)]; [self.dispatcher stopDispatchingForProtocol:@protocol(ApplicationCommands)];
[self.dispatcher
stopDispatchingForProtocol:@protocol(ApplicationSettingsCommands)];
// TODO(crbug.com/845192) : RecentTabsTableViewController behaves like a // TODO(crbug.com/845192) : RecentTabsTableViewController behaves like a
// coordinator and that should be factored out. // 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