OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_QUEUE_H_ | |
6 #define IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_QUEUE_H_ | |
7 | |
8 #import <Foundation/Foundation.h> | |
9 | |
10 #import "ios/clean/chrome/browser/ui/overlays/overlay_coordinator.h" | |
11 #import "ios/web/public/web_state/web_state_user_data.h" | |
12 | |
13 @protocol OverlaySchedulerCommands; | |
14 | |
15 // Class used to enqueue overlay coordinators that are requested by a WebState. | |
16 // It uses OverlaySchedulerCommands to communicate with OverlayScheduler | |
17 // to decide when to display the overlay UI. | |
18 class OverlayQueue : public web::WebStateUserData<OverlayQueue> { | |
19 public: | |
20 ~OverlayQueue() override; | |
21 | |
22 // Factory method that instantaites a OverlayQueue for |web_state| that | |
23 // uses |dispatcher| to send overlay scheduling commands. | |
24 static void CreateForWebState(web::WebState* web_state, | |
25 id<OverlaySchedulerCommands> dispatcher); | |
26 | |
27 // Adds |overlay_coordinator| to the queue and schedules its presentation. | |
28 void AddOverlay(OverlayCoordinator* overlay_coordinator); | |
29 // Removes the currently displayed overlay and adds |overlay_coordinator| to | |
30 // the front of the queue to be displayed immediately. | |
31 void ReplaceVisibleOverlay(OverlayCoordinator* overlay_coordinator); | |
32 // Returns whether there are any queued overlays. | |
33 bool HasQueuedOverlays() const; | |
34 // Displays the next overlay over |web_coordinator|'s UI. |web_coordinator| | |
35 // is expected to be displaying the web view that requested the overlay. | |
36 void StartNextOverlay(BrowserCoordinator* web_coordinator); | |
37 // Returns whether an overlay is curently started. | |
38 bool IsShowingOverlay() const; | |
39 // Notifies the OverlayQueue that |overlay_coordinator| was stopped. | |
40 void OverlayWasStopped(OverlayCoordinator* overlay_coordinator); | |
41 // Cancels all queued overlays for this WebState. If one is being displayed, | |
42 // it will be stopped and cancelled. | |
43 void CancelOverlays(); | |
44 | |
45 private: | |
46 friend class web::WebStateUserData<OverlayQueue>; | |
47 // The WebState with which this presenter is associated. | |
48 web::WebState* web_state_; | |
49 // The OverlayScheduler dispatcher passed on construction. | |
50 __weak id<OverlaySchedulerCommands> dispatcher_; | |
51 // The queue of overlays that were added for this WebState. Overlays will be | |
52 // 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 :)
| |
53 NSMutableArray<OverlayCoordinator*>* overlays_; | |
54 // 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.
| |
55 bool showing_overlay_; | |
56 | |
57 // Private constructor. New instances should be created via | |
58 // CreateForWebState() and accessed via FromWebState(). | |
59 explicit OverlayQueue(web::WebState* web_state, | |
60 id<OverlaySchedulerCommands> dispatcher); | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(OverlayQueue); | |
63 }; | |
64 #endif // IOS_CLEAN_CHROME_BROWSER_UI_OVERLAYS_OVERLAY_QUEUE_H_ | |
OLD | NEW |