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