Index: ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm |
diff --git a/ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm b/ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm |
index 6198cab7d5b55770b97724151373fdd9f7165066..8275a7fc17c5f9c81fd04d7da1b78ac2ad5c5d68 100644 |
--- a/ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm |
+++ b/ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm |
@@ -7,8 +7,10 @@ |
#include "base/mac/foundation_util.h" |
#include "base/memory/ptr_util.h" |
#import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" |
+#import "ios/clean/chrome/browser/ui/commands/overlay_commands.h" |
#import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" |
#import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h" |
+#import "ios/clean/chrome/browser/ui/overlays/overlay_queue.h" |
#import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" |
#import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h" |
#import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
@@ -22,11 +24,21 @@ |
#error "This file requires ARC support." |
#endif |
-@interface WebCoordinator ()<ContextMenuCommands, CRWWebStateDelegate> { |
+@interface WebCoordinator ()<ContextMenuCommands, |
+ CRWWebStateDelegate, |
+ OverlayPresentationCommands> { |
std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
} |
@property(nonatomic, strong) WebContentsViewController* viewController; |
@property(nonatomic, strong) WebContentsMediator* mediator; |
+ |
+// Lazily creates a WebJavaScriptDialogPresenter and OverlayQueue for the |
+// WebState. |
+- (void)createDialogHelpers; |
+ |
+// Starts the next overlay in |webState|'s OverlayQueue. |
+- (void)startNextOverlay; |
+ |
@end |
@implementation WebCoordinator |
@@ -50,13 +62,21 @@ - (void)setWebState:(web::WebState*)webState { |
} |
- (void)start { |
+ // Create the view controller and start it. |
self.viewController = [[WebContentsViewController alloc] init]; |
self.mediator.consumer = self.viewController; |
self.mediator.webStateList = &self.browser->web_state_list(); |
[super start]; |
+ // Register for overlay commands and start the next overlay. |
+ [self.browser->dispatcher() |
+ startDispatchingToTarget:self |
+ forProtocol:@protocol(OverlayPresentationCommands)]; |
+ [self createDialogHelpers]; |
+ [self startNextOverlay]; |
} |
- (void)stop { |
+ [self.browser->dispatcher() stopDispatchingToTarget:self]; |
[super stop]; |
[self.mediator disconnect]; |
} |
@@ -114,4 +134,25 @@ - (BOOL)webState:(web::WebState*)webState |
return YES; |
} |
+#pragma mark - OverlayPresentationCommands |
+ |
+- (void)startNextOverlayForWebState:(web::WebState*)webState { |
+ DCHECK_EQ(self.webState, webState); |
+ [self startNextOverlay]; |
+} |
+ |
+#pragma mark - |
+ |
+- (void)createDialogHelpers { |
+ id<OverlaySchedulerCommands> overlayDispatcher = |
+ static_cast<id<OverlaySchedulerCommands>>(self.browser->dispatcher()); |
+ OverlayQueue::CreateForWebState(self.webState, overlayDispatcher); |
+} |
+ |
+- (void)startNextOverlay { |
+ OverlayQueue* queue = OverlayQueue::FromWebState(self.webState); |
marq (ping after 24h)
2017/06/14 10:02:32
This might belong in a mediator.
(The general id
kkhorimoto
2017/06/15 08:26:29
This is no longer necessary.
|
+ if (queue->HasQueuedOverlays() && !queue->IsShowingOverlay()) |
+ queue->StartNextOverlay(self); |
+} |
+ |
@end |