Index: ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue.h |
diff --git a/ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue.h b/ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8af6856810bb98c05fc005166a644c91206afce0 |
--- /dev/null |
+++ b/ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue.h |
@@ -0,0 +1,74 @@ |
+// 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_INTERNAL_OVERLAY_QUEUE_H_ |
+#define IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_INTERNAL_OVERLAY_QUEUE_H_ |
+ |
+#import <Foundation/Foundation.h> |
+ |
+#include "base/observer_list.h" |
+#import "ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay_support.h" |
+#import "ios/clean/chrome/browser/ui/overlay_service/internal/overlay_queue_observer.h" |
+ |
+namespace web { |
+class WebState; |
+} |
+ |
+// Class used to enqueue BrowserCoordinators. It uses OverlayQueueObservers to |
+// communicate changes in the queue. |
+class OverlayQueue { |
+ public: |
+ virtual ~OverlayQueue(); |
+ |
+ // Adds and removes OverlayQueueObservers. |
+ void AddObserver(OverlayQueueObserver* observer); |
+ void RemoveObserver(OverlayQueueObserver* observer); |
+ |
+ // Starts the next overlay in the queue. If GetWebState() returns non-null, |
+ // it is expected that its content area is visible before this is called. |
+ virtual void StartNextOverlay() = 0; |
+ // Called to notify the OverlayQueue that |overlay_coordinator| was stopped. |
+ virtual void OverlayWasStopped(BrowserCoordinator* overlay_coordinator); |
+ // Removes the currently displayed overlay and adds |overlay_coordinator| to |
+ // the front of the queue to be displayed immediately. |
+ virtual void ReplaceVisibleOverlay(BrowserCoordinator* overlay_coordinator); |
+ // Returns whether there are any queued overlays. |
+ bool HasQueuedOverlays() const; |
+ // Returns whether an overlay is curently started. |
+ bool IsShowingOverlay() const; |
+ // Cancels all queued overlays for this queue. If one is being displayed, it |
+ // will also be stopped |
+ void CancelOverlays(); |
+ |
+ // Some OverlayQueues require that a particular WebState's content area is |
+ // visible before its queued BrowserCoordinators can be started. If this |
+ // queue's overlays require showing a WebState, this function will return that |
+ // WebState. |
+ virtual web::WebState* GetWebState() const; |
+ |
+ protected: |
+ // Adds |overlay_coordinator| to the queue and schedules its presentation. |
+ void AddOverlay(BrowserCoordinator* overlay_coordinator); |
+ // Returns the number of overlays in the queue. |
+ NSUInteger GetCount() const; |
+ // Returns the first BrowserCoordinator in the queue. |
+ BrowserCoordinator* GetFirstOverlay(); |
+ // Called when the first overlay in the queue is started. |
+ void OverlayWasStarted(); |
+ // Default constructor. |
+ OverlayQueue(); |
+ |
+ private: |
+ // The observers for this queue. |
+ base::ObserverList<OverlayQueueObserver> observers_; |
+ // The queue of overlays that were added for this WebState. |
+ __strong NSMutableArray<BrowserCoordinator*>* overlays_; |
+ // Whether an overlay is currently started. If this is true, the first |
+ // BrowserCoordinator in |overlays_| has been started. |
+ bool showing_overlay_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(OverlayQueue); |
+}; |
+ |
+#endif // IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_INTERNAL_OVERLAY_QUEUE_H_ |