Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/overlays/overlay_queue.h |
| diff --git a/ios/clean/chrome/browser/ui/overlays/overlay_queue.h b/ios/clean/chrome/browser/ui/overlays/overlay_queue.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fe73ad3681a3a71c6acd8e6f82968f18473fff4b |
| --- /dev/null |
| +++ b/ios/clean/chrome/browser/ui/overlays/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_OVERLAY_QUEUE_H_ |
| +#define IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_QUEUE_H_ |
| + |
| +#import <Foundation/Foundation.h> |
| + |
| +#include "base/observer_list.h" |
| +#import "ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.h" |
| +#import "ios/clean/chrome/browser/ui/overlays/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. |
| + NSMutableArray<BrowserCoordinator*>* overlays_; |
|
marq (ping after 24h)
2017/06/21 09:41:53
Please explicitly mark ObjC member variables '__st
kkhorimoto
2017/06/23 06:11:15
Done.
|
| + // Whether an overlay is currently started. If this is true, the first |
| + // BrowserCoordinator in |overlays_| is started. |
|
marq (ping after 24h)
2017/06/21 09:41:53
s/is started/has been started/ to clarify what the
kkhorimoto
2017/06/23 06:11:16
Done.
|
| + bool showing_overlay_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OverlayQueue); |
| +}; |
| + |
| +#endif // IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_QUEUE_H_ |