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

Unified Diff: ios/clean/chrome/browser/ui/overlays/overlay_service.h

Issue 2921833002: [iOS Clean] Created OverlayService.
Patch Set: Use service pattern Created 3 years, 6 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/overlays/overlay_service.h
diff --git a/ios/clean/chrome/browser/ui/overlays/overlay_service.h b/ios/clean/chrome/browser/ui/overlays/overlay_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..456ae5c1eee86f87ca9857b593dd96eab2138085
--- /dev/null
+++ b/ios/clean/chrome/browser/ui/overlays/overlay_service.h
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_SERVICE_H_
+#define IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_SERVICE_H_
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+namespace web {
+class WebState;
+}
+
+class Browser;
+@class BrowserCoordinator;
+
+// OverlayService allows for the easy presentation and dismissal of overlay
marq (ping after 24h) 2017/06/21 09:41:54 The division of responsibilities between the Overl
kkhorimoto 2017/06/23 06:11:16 The main entry point to this overlay system is add
marq (ping after 24h) 2017/06/23 10:42:01 I don't agree that adding this service makes the n
+// cordinators. Overlays are modal and displayed in the order in which this
+// service receives them. If an overlay is added to this service while one is
+// already presented, it will be queued until that current overlay is stopped.
+class OverlayService : public KeyedService {
+ public:
+ OverlayService() = default;
+ ~OverlayService() override = default;
+
+ // Whether an overlay is currently displayed for |browser|. This will return
+ // true for both WebState-specific or Browser-level overlays.
+ virtual bool IsBrowserShowingOverlay(Browser* browser) const = 0;
+
+ // Replaces |browser|'s currently-visible overlay with |overlay_coordinator|.
+ // The replacement overlay will use the visible overlays parent as its own.
+ // This will replace the current overlay regardless of if it's WebState-
+ // specific.
+ virtual void ReplaceVisibleOverlay(BrowserCoordinator* overlay_coordinator,
+ Browser* browser) = 0;
+
+ // Cancels all scheduled overlays added to this service. If an overlay is
+ // currently visible, it will be stopped.
+ virtual void CancelOverlays() = 0;
+
+ // Browser-specific overlays:
+
+ // Shows |overlay_coordinator| over |parent_coordinator|'s UI.
+ virtual void ShowOverlayForBrowser(BrowserCoordinator* overlay_coordinator,
+ BrowserCoordinator* parent_coordiantor,
+ Browser* browser) = 0;
+
+ // WebState-specific overlays:
+
+ // Switches the active WebState to |web_state| and displays
+ // |overlay_coordinator|'s UI over it.
+ virtual void ShowOverlayForWebState(BrowserCoordinator* overlay_coordinator,
+ web::WebState* web_state) = 0;
+
+ // Cancels all scheduled overlays for |web_state|. If a |web_state|-specific
+ // overlay is currently visible, it will be stopped.
+ virtual void CancelOverlayForWebState(web::WebState* web_state) = 0;
+
+ // Overlays added via ShowOverlayForWebState() can only be started when their
+ // associated WebState's content are is visible. When a coordinator showing
+ // a WebState's content is started, it can notify the OverlayService to use
+ // itself as the parent for that WebState's overlays.
+ virtual void SetWebStateParentCoordinator(
+ BrowserCoordinator* parent_coordinator,
+ web::WebState* web_state) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OverlayService);
+};
+
+#endif // IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698