OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "content/public/browser/web_contents_user_data.h" |
| 12 |
| 13 class WebContentsModalDialog; |
| 14 class WebContentsModalDialogManagerDelegate; |
| 15 |
| 16 // Per-WebContents class to manage WebContents-modal dialogs. |
| 17 class WebContentsModalDialogManager |
| 18 : public content::WebContentsObserver, |
| 19 public content::WebContentsUserData<WebContentsModalDialogManager> { |
| 20 public: |
| 21 virtual ~WebContentsModalDialogManager(); |
| 22 |
| 23 WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; } |
| 24 void set_delegate(WebContentsModalDialogManagerDelegate* d) { delegate_ = d; } |
| 25 |
| 26 // Adds the given dialog to the list of child dialogs. The dialog will notify |
| 27 // via WillClose() when it is being destroyed. |
| 28 void AddDialog(WebContentsModalDialog* dialog); |
| 29 |
| 30 // Closes all WebContentsModalDialogs. |
| 31 void CloseAllDialogs(); |
| 32 |
| 33 // Called when a WebContentsModalDialogs we own is about to be closed. |
| 34 void WillClose(WebContentsModalDialog* dialog); |
| 35 |
| 36 // Blocks/unblocks interaction with renderer process. |
| 37 void BlockWebContentsInteraction(bool blocked); |
| 38 |
| 39 // Returns the number of dialogs in this tab. |
| 40 size_t dialog_count() { return child_dialogs_.size(); } |
| 41 |
| 42 typedef std::deque<WebContentsModalDialog*> WebContentsModalDialogList; |
| 43 |
| 44 // Return an iterator for the first dialog in this web contents. |
| 45 WebContentsModalDialogList::iterator dialog_begin() { |
| 46 return child_dialogs_.begin(); |
| 47 } |
| 48 |
| 49 // Return an iterator for the last dialog in this web contents. |
| 50 WebContentsModalDialogList::iterator dialog_end() { |
| 51 return child_dialogs_.end(); |
| 52 } |
| 53 |
| 54 private: |
| 55 explicit WebContentsModalDialogManager(content::WebContents* web_contents); |
| 56 friend class content::WebContentsUserData<WebContentsModalDialogManager>; |
| 57 |
| 58 // Overridden from content::WebContentsObserver: |
| 59 virtual void DidNavigateMainFrame( |
| 60 const content::LoadCommittedDetails& details, |
| 61 const content::FrameNavigateParams& params) OVERRIDE; |
| 62 virtual void DidGetIgnoredUIEvent() OVERRIDE; |
| 63 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
| 64 |
| 65 // Delegate for notifying our owner about stuff. Not owned by us. |
| 66 WebContentsModalDialogManagerDelegate* delegate_; |
| 67 |
| 68 // All active dialogs. |
| 69 WebContentsModalDialogList child_dialogs_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); |
| 72 }; |
| 73 |
| 74 #endif // CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
OLD | NEW |