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