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_CONSTRAINED_WINDOW_TAB_HELPER_H_ | |
6 #define CHROME_BROWSER_UI_CONSTRAINED_WINDOW_TAB_HELPER_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 ConstrainedWindow; | |
14 class ConstrainedWindowTabHelperDelegate; | |
15 | |
16 // Per-tab class to manage constrained windows. | |
17 class ConstrainedWindowTabHelper | |
18 : public content::WebContentsObserver, | |
19 public content::WebContentsUserData<ConstrainedWindowTabHelper> { | |
20 public: | |
21 virtual ~ConstrainedWindowTabHelper(); | |
22 | |
23 ConstrainedWindowTabHelperDelegate* delegate() const { return delegate_; } | |
24 void set_delegate(ConstrainedWindowTabHelperDelegate* d) { delegate_ = d; } | |
25 | |
26 // Adds the given window to the list of child windows. The window will notify | |
27 // via WillClose() when it is being destroyed. | |
28 void AddDialog(ConstrainedWindow* window); | |
29 | |
30 // Closes all WebContentsModalDialogs. | |
31 void CloseAllDialogs(); | |
32 | |
33 // Called when a WebContentsModalDialogs we own is about to be closed. | |
34 void WillClose(ConstrainedWindow* window); | |
35 | |
36 // Blocks/unblocks interaction with renderer process. | |
37 void BlockWebContentsInteraction(bool blocked); | |
38 | |
39 // Returns the number of constrained windows in this tab. | |
40 size_t dialog_count() { return child_dialogs_.size(); } | |
41 | |
42 typedef std::deque<ConstrainedWindow*> WebContentsModalDialogList; | |
43 | |
44 // Return an iterator for the first constrained window in this web contents. | |
45 WebContentsModalDialogList::iterator dialog_begin() { | |
46 return child_dialogs_.begin(); | |
47 } | |
48 | |
49 // Return an iterator for the last constrained window in this web contents. | |
50 WebContentsModalDialogList::iterator dialog_end() { | |
51 return child_dialogs_.end(); | |
52 } | |
53 | |
54 private: | |
55 explicit ConstrainedWindowTabHelper(content::WebContents* web_contents); | |
56 friend class content::WebContentsUserData<ConstrainedWindowTabHelper>; | |
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 ConstrainedWindowTabHelperDelegate* delegate_; | |
67 | |
68 // All active constrained windows. | |
69 WebContentsModalDialogList child_dialogs_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowTabHelper); | |
72 }; | |
73 | |
74 #endif // CHROME_BROWSER_UI_CONSTRAINED_WINDOW_TAB_HELPER_H_ | |
OLD | NEW |