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

Unified Diff: ios/clean/chrome/browser/ui/web_contents/web_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/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..af3bc51138c33c1dc6d9161b1cfc9f89a3b3fa68 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/web_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/web_contents/overlays/web_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,
+ WebOverlayPresentationCommands> {
std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
}
@property(nonatomic, strong) WebContentsViewController* viewController;
@property(nonatomic, strong) WebContentsMediator* mediator;
+
+// Lazily creates a WebJavaScriptDialogPresenter and WebOverlayQueue for the
+// WebState.
+- (void)createDialogHelpers;
+
+// Starts the next overlay in |webState|'s WebOverlayQueue.
+- (void)startNextWebOverlay;
+
@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(WebOverlayPresentationCommands)];
+ [self createDialogHelpers];
+ [self startNextWebOverlay];
}
- (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 - WebOverlayPresentationCommands
+
+- (void)startNextWebOverlayForWebState:(web::WebState*)webState {
+ DCHECK_EQ(self.webState, webState);
+ [self startNextWebOverlay];
+}
+
+#pragma mark -
+
+- (void)createDialogHelpers {
+ id<WebOverlaySchedulerCommands> overlayDispatcher =
+ static_cast<id<WebOverlaySchedulerCommands>>(self.browser->dispatcher());
+ WebOverlayQueue::CreateForWebState(self.webState, overlayDispatcher);
+}
+
+- (void)startNextWebOverlay {
+ WebOverlayQueue* queue = WebOverlayQueue::FromWebState(self.webState);
+ if (queue->HasQueuedOverlays() && !queue->IsShowingOverlay())
+ queue->StartNextOverlay(self);
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698