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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Returns true if any dialogs are active and not closed. | 41 // Returns true if any dialogs are active and not closed. |
42 // TODO(wittman): Give this a better name, since it can return true if no | 42 // TODO(wittman): Give this a better name, since it can return true if no |
43 // dialogs are displayed. | 43 // dialogs are displayed. |
44 bool IsShowingDialog() const; | 44 bool IsShowingDialog() const; |
45 | 45 |
46 // Focus the topmost modal dialog. IsShowingDialog() must be true when | 46 // Focus the topmost modal dialog. IsShowingDialog() must be true when |
47 // calling this function. | 47 // calling this function. |
48 void FocusTopmostDialog(); | 48 void FocusTopmostDialog(); |
49 | 49 |
| 50 // Set to true to close the window when a page load starts on the WebContents. |
| 51 void SetCloseOnInterstitialWebUI(NativeWebContentsModalDialog dialog, |
| 52 bool close); |
| 53 |
50 // Overriden from NativeWebContentsModalDialogManagerDelegate: | 54 // Overriden from NativeWebContentsModalDialogManagerDelegate: |
51 virtual content::WebContents* GetWebContents() const OVERRIDE; | 55 virtual content::WebContents* GetWebContents() const OVERRIDE; |
52 // Called when a WebContentsModalDialogs we own is about to be closed. | 56 // Called when a WebContentsModalDialogs we own is about to be closed. |
53 virtual void WillClose(NativeWebContentsModalDialog dialog) OVERRIDE; | 57 virtual void WillClose(NativeWebContentsModalDialog dialog) OVERRIDE; |
54 | 58 |
55 // content::NotificationObserver overrides | 59 // content::NotificationObserver overrides |
56 virtual void Observe(int type, | 60 virtual void Observe(int type, |
57 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
58 const content::NotificationDetails& details) OVERRIDE; | 62 const content::NotificationDetails& details) OVERRIDE; |
59 | 63 |
60 // For testing. | 64 // For testing. |
61 class TestApi { | 65 class TestApi { |
62 public: | 66 public: |
63 explicit TestApi(WebContentsModalDialogManager* manager) | 67 explicit TestApi(WebContentsModalDialogManager* manager) |
64 : manager_(manager) {} | 68 : manager_(manager) {} |
65 | 69 |
66 void CloseAllDialogs() { manager_->CloseAllDialogs(); } | 70 void CloseAllDialogs() { manager_->CloseAllDialogs(); } |
| 71 void DidAttachInterstitialPage() { manager_->DidAttachInterstitialPage(); } |
67 void ResetNativeManager(NativeWebContentsModalDialogManager* delegate) { | 72 void ResetNativeManager(NativeWebContentsModalDialogManager* delegate) { |
68 manager_->native_manager_.reset(delegate); | 73 manager_->native_manager_.reset(delegate); |
69 } | 74 } |
70 | 75 |
71 private: | 76 private: |
72 WebContentsModalDialogManager* manager_; | 77 WebContentsModalDialogManager* manager_; |
73 | 78 |
74 DISALLOW_COPY_AND_ASSIGN(TestApi); | 79 DISALLOW_COPY_AND_ASSIGN(TestApi); |
75 }; | 80 }; |
76 | 81 |
77 private: | 82 private: |
78 explicit WebContentsModalDialogManager(content::WebContents* web_contents); | 83 explicit WebContentsModalDialogManager(content::WebContents* web_contents); |
79 friend class content::WebContentsUserData<WebContentsModalDialogManager>; | 84 friend class content::WebContentsUserData<WebContentsModalDialogManager>; |
80 | 85 |
81 typedef std::deque<NativeWebContentsModalDialog> WebContentsModalDialogList; | 86 struct DialogState { |
| 87 explicit DialogState(NativeWebContentsModalDialog dialog); |
| 88 |
| 89 NativeWebContentsModalDialog dialog; |
| 90 bool close_on_interstitial_webui; |
| 91 }; |
| 92 |
| 93 typedef std::deque<DialogState> WebContentsModalDialogList; |
| 94 |
| 95 // Utility function to get the dialog state for a dialog. |
| 96 WebContentsModalDialogList::iterator FindDialogState( |
| 97 NativeWebContentsModalDialog dialog); |
82 | 98 |
83 // Blocks/unblocks interaction with renderer process. | 99 // Blocks/unblocks interaction with renderer process. |
84 void BlockWebContentsInteraction(bool blocked); | 100 void BlockWebContentsInteraction(bool blocked); |
85 | 101 |
86 bool IsWebContentsVisible() const; | 102 bool IsWebContentsVisible() const; |
87 | 103 |
88 // Closes all WebContentsModalDialogs. | 104 // Closes all WebContentsModalDialogs. |
89 void CloseAllDialogs(); | 105 void CloseAllDialogs(); |
90 | 106 |
91 // Overridden from content::WebContentsObserver: | 107 // Overridden from content::WebContentsObserver: |
92 virtual void DidNavigateMainFrame( | 108 virtual void DidNavigateMainFrame( |
93 const content::LoadCommittedDetails& details, | 109 const content::LoadCommittedDetails& details, |
94 const content::FrameNavigateParams& params) OVERRIDE; | 110 const content::FrameNavigateParams& params) OVERRIDE; |
95 virtual void DidGetIgnoredUIEvent() OVERRIDE; | 111 virtual void DidGetIgnoredUIEvent() OVERRIDE; |
96 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; | 112 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; |
| 113 virtual void DidAttachInterstitialPage() OVERRIDE; |
97 | 114 |
98 // Delegate for notifying our owner about stuff. Not owned by us. | 115 // Delegate for notifying our owner about stuff. Not owned by us. |
99 WebContentsModalDialogManagerDelegate* delegate_; | 116 WebContentsModalDialogManagerDelegate* delegate_; |
100 | 117 |
101 // Delegate for native UI-specific functions on the dialog. | 118 // Delegate for native UI-specific functions on the dialog. |
102 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_; | 119 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_; |
103 | 120 |
104 // All active dialogs. | 121 // All active dialogs. |
105 WebContentsModalDialogList child_dialogs_; | 122 WebContentsModalDialogList child_dialogs_; |
106 | 123 |
107 // True while closing the dialogs on WebContents close. | 124 // True while closing the dialogs on WebContents close. |
108 bool closing_all_dialogs_; | 125 bool closing_all_dialogs_; |
109 | 126 |
110 // A scoped container for notification registries. | 127 // A scoped container for notification registries. |
111 content::NotificationRegistrar registrar_; | 128 content::NotificationRegistrar registrar_; |
112 | 129 |
113 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); | 130 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); |
114 }; | 131 }; |
115 | 132 |
116 } // namespace web_modal | 133 } // namespace web_modal |
117 | 134 |
118 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 135 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
OLD | NEW |