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_WEB_CONTENTS_OVERLAYS_WEB_OVERLAY_QUEUE_H_ |
| 6 #define IOS_CLEAN_CHROME_BROWSER_UI_WEB_CONTENTS_OVERLAYS_WEB_OVERLAY_QUEUE_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 #include "base/ios/weak_nsobject.h" |
| 11 #import "base/mac/scoped_nsobject.h" |
| 12 #import "ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_coordinat
or.h" |
| 13 #import "ios/web/public/web_state/web_state_user_data.h" |
| 14 |
| 15 @protocol WebOverlaySchedulerCommands; |
| 16 |
| 17 // Class used to enqueue overlay coordinators that are requested by a WebState. |
| 18 // It uses WebOverlaySchedulerCommands to communicate with WebOverlayScheduler |
| 19 // to decide when to display the overlay UI. |
| 20 class WebOverlayQueue : public web::WebStateUserData<WebOverlayQueue> { |
| 21 public: |
| 22 ~WebOverlayQueue() override; |
| 23 |
| 24 // Factory method that instantaites a WebOverlayQueue for |web_state| that |
| 25 // uses |dispatcher| to send overlay scheduling commands. |
| 26 static void CreateForWebState(web::WebState* web_state, |
| 27 id<WebOverlaySchedulerCommands> dispatcher); |
| 28 |
| 29 // Adds |web_overlay| to the queue and schedules its presentation. |
| 30 void AddWebOverlay(WebOverlayCoordinator* overlay_coordinator); |
| 31 // Returns whether there are any queued overlays. |
| 32 bool HasQueuedOverlays() const; |
| 33 // Displays the next overlay over |web_coordinator|'s UI. |web_coordinator| |
| 34 // is expected to be displaying the web view that requested the overlay. |
| 35 void StartNextOverlay(BrowserCoordinator* web_coordinator); |
| 36 // Returns whether an overlay is curently started. |
| 37 bool IsShowingOverlay() const; |
| 38 // Notifies the WebOverlayQueue that |overlay_coordinator| was stopped. |
| 39 void WebOverlayWasStopped(WebOverlayCoordinator* overlay_coordinator); |
| 40 // Cancels all queued overlays for this WebState. If one is being displayed, |
| 41 // it will be stopped and cancelled. |
| 42 void CancelOverlays(); |
| 43 |
| 44 private: |
| 45 friend class web::WebStateUserData<WebOverlayQueue>; |
| 46 // The WebState with which this presenter is associated. |
| 47 web::WebState* web_state_; |
| 48 // The WebOverlayScheduler dispatcher passed on construction. |
| 49 base::WeakNSProtocol<id<WebOverlaySchedulerCommands>> dispatcher_; |
| 50 // The queue of overlays that were added for this WebState. Overlays will be |
| 51 // removed when they are stopped or when they |
| 52 base::scoped_nsobject<NSMutableArray<WebOverlayCoordinator*>> overlays_; |
| 53 // Whether the first overlay in |overlays_| is started. |
| 54 bool showing_overlay_; |
| 55 |
| 56 // Private constructor. New instances should be created via |
| 57 // CreateForWebState() and accessed via FromWebState(). |
| 58 explicit WebOverlayQueue(web::WebState* web_state, |
| 59 id<WebOverlaySchedulerCommands> dispatcher); |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(WebOverlayQueue); |
| 62 }; |
| 63 #endif // IOS_CLEAN_CHROME_BROWSER_UI_WEB_CONTENTS_OVERLAYS_WEB_OVERLAY_QUEUE_H
_ |
OLD | NEW |