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 COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 5 #ifndef COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
6 #define COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 6 #define COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // WillClose() when it is being destroyed. | 38 // WillClose() when it is being destroyed. |
39 void ShowDialog(NativeWebContentsModalDialog dialog); | 39 void ShowDialog(NativeWebContentsModalDialog dialog); |
40 | 40 |
41 // Returns true if a dialog is currently being shown. | 41 // Returns true if a dialog is currently being shown. |
42 bool IsShowingDialog() const; | 42 bool IsShowingDialog() const; |
43 | 43 |
44 // Focus the topmost modal dialog. IsShowingDialog() must be true when | 44 // Focus the topmost modal dialog. IsShowingDialog() must be true when |
45 // calling this function. | 45 // calling this function. |
46 void FocusTopmostDialog(); | 46 void FocusTopmostDialog(); |
47 | 47 |
48 // Set to true to prevent closing the window when a page load starts on the | |
49 // WebContents. | |
50 void SetPreventCloseOnLoadStart(NativeWebContentsModalDialog dialog, | |
51 bool prevent); | |
52 | |
53 // Overriden from NativeWebContentsModalDialogManagerDelegate: | 48 // Overriden from NativeWebContentsModalDialogManagerDelegate: |
54 virtual content::WebContents* GetWebContents() const OVERRIDE; | 49 virtual content::WebContents* GetWebContents() const OVERRIDE; |
55 // Called when a WebContentsModalDialogs we own is about to be closed. | 50 // Called when a WebContentsModalDialogs we own is about to be closed. |
56 virtual void WillClose(NativeWebContentsModalDialog dialog) OVERRIDE; | 51 virtual void WillClose(NativeWebContentsModalDialog dialog) OVERRIDE; |
57 | 52 |
58 // content::NotificationObserver overrides | 53 // content::NotificationObserver overrides |
59 virtual void Observe(int type, | 54 virtual void Observe(int type, |
60 const content::NotificationSource& source, | 55 const content::NotificationSource& source, |
61 const content::NotificationDetails& details) OVERRIDE; | 56 const content::NotificationDetails& details) OVERRIDE; |
62 | 57 |
(...skipping 11 matching lines...) Expand all Loading... |
74 private: | 69 private: |
75 WebContentsModalDialogManager* manager_; | 70 WebContentsModalDialogManager* manager_; |
76 | 71 |
77 DISALLOW_COPY_AND_ASSIGN(TestApi); | 72 DISALLOW_COPY_AND_ASSIGN(TestApi); |
78 }; | 73 }; |
79 | 74 |
80 private: | 75 private: |
81 explicit WebContentsModalDialogManager(content::WebContents* web_contents); | 76 explicit WebContentsModalDialogManager(content::WebContents* web_contents); |
82 friend class content::WebContentsUserData<WebContentsModalDialogManager>; | 77 friend class content::WebContentsUserData<WebContentsModalDialogManager>; |
83 | 78 |
84 struct DialogState { | 79 typedef std::deque<NativeWebContentsModalDialog> WebContentsModalDialogList; |
85 explicit DialogState(NativeWebContentsModalDialog dialog); | |
86 | |
87 NativeWebContentsModalDialog dialog; | |
88 bool prevent_close_on_load_start; | |
89 }; | |
90 | |
91 typedef std::deque<DialogState> WebContentsModalDialogList; | |
92 | |
93 // Utility function to get the dialog state for a dialog. | |
94 WebContentsModalDialogList::iterator FindDialogState( | |
95 NativeWebContentsModalDialog dialog); | |
96 | 80 |
97 // Blocks/unblocks interaction with renderer process. | 81 // Blocks/unblocks interaction with renderer process. |
98 void BlockWebContentsInteraction(bool blocked); | 82 void BlockWebContentsInteraction(bool blocked); |
99 | 83 |
100 bool IsWebContentsVisible() const; | 84 bool IsWebContentsVisible() const; |
101 | 85 |
102 // Closes all WebContentsModalDialogs. | 86 // Closes all WebContentsModalDialogs. |
103 void CloseAllDialogs(); | 87 void CloseAllDialogs(); |
104 | 88 |
105 // Overridden from content::WebContentsObserver: | 89 // Overridden from content::WebContentsObserver: |
| 90 virtual void DidNavigateMainFrame( |
| 91 const content::LoadCommittedDetails& details, |
| 92 const content::FrameNavigateParams& params) OVERRIDE; |
106 virtual void DidGetIgnoredUIEvent() OVERRIDE; | 93 virtual void DidGetIgnoredUIEvent() OVERRIDE; |
107 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; | 94 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
108 | 95 |
109 // Delegate for notifying our owner about stuff. Not owned by us. | 96 // Delegate for notifying our owner about stuff. Not owned by us. |
110 WebContentsModalDialogManagerDelegate* delegate_; | 97 WebContentsModalDialogManagerDelegate* delegate_; |
111 | 98 |
112 // Delegate for native UI-specific functions on the dialog. | 99 // Delegate for native UI-specific functions on the dialog. |
113 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_; | 100 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_; |
114 | 101 |
115 // All active dialogs. | 102 // All active dialogs. |
116 WebContentsModalDialogList child_dialogs_; | 103 WebContentsModalDialogList child_dialogs_; |
117 | 104 |
118 // True while closing the dialogs on WebContents close. | 105 // True while closing the dialogs on WebContents close. |
119 bool closing_all_dialogs_; | 106 bool closing_all_dialogs_; |
120 | 107 |
121 // A scoped container for notification registries. | 108 // A scoped container for notification registries. |
122 content::NotificationRegistrar registrar_; | 109 content::NotificationRegistrar registrar_; |
123 | 110 |
124 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); | 111 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); |
125 }; | 112 }; |
126 | 113 |
127 } // namespace web_modal | 114 } // namespace web_modal |
128 | 115 |
129 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 116 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
OLD | NEW |