Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm

Issue 2921833002: [iOS Clean] Created OverlayService.
Patch Set: self review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm
diff --git a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm
index 104978959777a314246cb43c5cda533d5725bd58..bd023408e105c898c63073d29d36a85dfa45456d 100644
--- a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm
+++ b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm
@@ -20,6 +20,7 @@
#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator.h"
#import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#import "ios/clean/chrome/browser/ui/tools/tools_coordinator.h"
+#import "ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_scheduler.h"
#import "ios/shared/chrome/browser/ui/browser_list/browser.h"
#import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.h"
@@ -43,6 +44,7 @@ @interface TabGridCoordinator ()<ContextMenuCommands,
@property(nonatomic, weak) TabCoordinator* activeTabCoordinator;
@property(nonatomic, readonly) WebStateList& webStateList;
@property(nonatomic, strong) TabGridMediator* mediator;
+@property(nonatomic, strong) WebOverlayScheduler* webOverlayScheduler;
@end
@implementation TabGridCoordinator
@@ -51,6 +53,7 @@ @implementation TabGridCoordinator
@synthesize toolsMenuCoordinator = _toolsMenuCoordinator;
@synthesize activeTabCoordinator = _activeTabCoordinator;
@synthesize mediator = _mediator;
+@synthesize webOverlayScheduler = _webOverlayScheduler;
#pragma mark - Properties
@@ -74,12 +77,23 @@ - (void)start {
self.mediator.consumer = self.viewController;
+ id<TabGridCommands, WebOverlayPresentationCommands> schedulerDispatcher =
+ static_cast<id<TabGridCommands, WebOverlayPresentationCommands>>(
+ self.browser->dispatcher());
+ self.webOverlayScheduler =
+ [[WebOverlayScheduler alloc] initWithDispatcher:schedulerDispatcher];
+ [self.browser->dispatcher()
+ startDispatchingToTarget:self.webOverlayScheduler
+ forProtocol:@protocol(WebOverlaySchedulerCommands)];
+
[super start];
}
- (void)stop {
[super stop];
[self.browser->dispatcher() stopDispatchingToTarget:self];
+ [self.browser->dispatcher() stopDispatchingToTarget:self.webOverlayScheduler];
+ self.webOverlayScheduler = nil;
[self.mediator disconnect];
// PLACEHOLDER: Remove child coordinators here for now. This might be handled
// differently later on.
@@ -146,6 +160,8 @@ - (void)closeSettings {
#pragma mark - TabGridCommands
- (void)showTabGridTabAtIndex:(int)index {
+ if (index == self.webStateList.active_index())
+ return;
self.webStateList.ActivateWebStateAt(index);
// PLACEHOLDER: The tab coordinator should be able to get the active webState
// on its own.
@@ -184,6 +200,10 @@ - (void)showTabGrid {
[self registerForToolsMenuCommands];
}
+- (void)showTabGridTabWithWebState:(const web::WebState*)webState {
+ [self showTabGridTabAtIndex:self.webStateList.GetIndexOfWebState(webState)];
+}
+
#pragma mark - ToolsMenuCommands
- (void)showToolsMenu {
@@ -240,17 +260,9 @@ - (void)registerForSettingsCommands {
}
- (void)registerForTabGridCommands {
- [self.browser->dispatcher() startDispatchingToTarget:self
- forSelector:@selector(showTabGrid)];
- [self.browser->dispatcher()
- startDispatchingToTarget:self
- forSelector:@selector(showTabGridTabAtIndex:)];
- [self.browser->dispatcher()
- startDispatchingToTarget:self
- forSelector:@selector(closeTabGridTabAtIndex:)];
[self.browser->dispatcher()
startDispatchingToTarget:self
- forSelector:@selector(createAndShowNewTabInTabGrid)];
+ forProtocol:@protocol(TabGridCommands)];
}
- (void)registerForToolsMenuCommands {

Powered by Google App Engine
This is Rietveld 408576698