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..e574d19ba5f59b17fc996c58bd4483d36a0e7203 |
| --- /dev/null |
| +++ b/ios/clean/chrome/browser/ui/overlays/overlay_queue.h |
| @@ -0,0 +1,64 @@ |
| +// 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> |
| + |
| +#import "ios/clean/chrome/browser/ui/overlays/overlay_coordinator.h" |
| +#import "ios/web/public/web_state/web_state_user_data.h" |
| + |
| +@protocol OverlaySchedulerCommands; |
| + |
| +// Class used to enqueue overlay coordinators that are requested by a WebState. |
| +// It uses OverlaySchedulerCommands to communicate with OverlayScheduler |
| +// to decide when to display the overlay UI. |
| +class OverlayQueue : public web::WebStateUserData<OverlayQueue> { |
| + public: |
| + ~OverlayQueue() override; |
| + |
| + // Factory method that instantaites a OverlayQueue for |web_state| that |
| + // uses |dispatcher| to send overlay scheduling commands. |
| + static void CreateForWebState(web::WebState* web_state, |
| + id<OverlaySchedulerCommands> dispatcher); |
| + |
| + // Adds |overlay_coordinator| to the queue and schedules its presentation. |
| + void AddOverlay(OverlayCoordinator* overlay_coordinator); |
| + // Removes the currently displayed overlay and adds |overlay_coordinator| to |
| + // the front of the queue to be displayed immediately. |
| + void ReplaceVisibleOverlay(OverlayCoordinator* overlay_coordinator); |
| + // Returns whether there are any queued overlays. |
| + bool HasQueuedOverlays() const; |
| + // Displays the next overlay over |web_coordinator|'s UI. |web_coordinator| |
| + // is expected to be displaying the web view that requested the overlay. |
| + void StartNextOverlay(BrowserCoordinator* web_coordinator); |
| + // Returns whether an overlay is curently started. |
| + bool IsShowingOverlay() const; |
| + // Notifies the OverlayQueue that |overlay_coordinator| was stopped. |
| + void OverlayWasStopped(OverlayCoordinator* overlay_coordinator); |
| + // Cancels all queued overlays for this WebState. If one is being displayed, |
| + // it will be stopped and cancelled. |
| + void CancelOverlays(); |
| + |
| + private: |
| + friend class web::WebStateUserData<OverlayQueue>; |
| + // The WebState with which this presenter is associated. |
| + web::WebState* web_state_; |
| + // The OverlayScheduler dispatcher passed on construction. |
| + __weak id<OverlaySchedulerCommands> dispatcher_; |
| + // The queue of overlays that were added for this WebState. Overlays will be |
| + // removed when they are stopped or when they |
|
marq (ping after 24h)
2017/06/14 10:02:32
This comment now has me on tenterhooks ... ;-)
kkhorimoto
2017/06/15 08:26:28
Hah just trying to keep it interesting :)
|
| + NSMutableArray<OverlayCoordinator*>* overlays_; |
| + // Whether the first overlay in |overlays_| is started. |
|
marq (ping after 24h)
2017/06/14 10:02:32
If |overlays_| is empty, what value does this have
kkhorimoto
2017/06/15 08:26:28
It returns false; comments have been updated.
|
| + bool showing_overlay_; |
| + |
| + // Private constructor. New instances should be created via |
| + // CreateForWebState() and accessed via FromWebState(). |
| + explicit OverlayQueue(web::WebState* web_state, |
| + id<OverlaySchedulerCommands> dispatcher); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OverlayQueue); |
| +}; |
| +#endif // IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_QUEUE_H_ |