Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 void SetDelegate(WebContentsModalDialogManagerDelegate* d); | 30 void SetDelegate(WebContentsModalDialogManagerDelegate* d); |
| 31 | 31 |
| 32 static SingleWebContentsDialogManager* CreateNativeWebModalManager( | 32 static SingleWebContentsDialogManager* CreateNativeWebModalManager( |
| 33 gfx::NativeWindow dialog, | 33 gfx::NativeWindow dialog, |
| 34 SingleWebContentsDialogManagerDelegate* native_delegate); | 34 SingleWebContentsDialogManagerDelegate* native_delegate); |
| 35 | 35 |
| 36 // Shows the dialog as a web contents modal dialog. The dialog will notify via | 36 // Shows the dialog as a web contents modal dialog. The dialog will notify via |
| 37 // WillClose() when it is being destroyed. | 37 // WillClose() when it is being destroyed. |
| 38 void ShowModalDialog(gfx::NativeWindow dialog); | 38 void ShowModalDialog(gfx::NativeWindow dialog); |
| 39 | 39 |
| 40 // Shows the dialog as a non clipped web contents modal dialog. The dialog | |
| 41 // will be able to extend outside the bounds of the parent window on platforms | |
| 42 // where this is allowed. The dialog will notify via WillClose() when it is | |
| 43 // being destroyed. | |
| 44 void ShowNonClippedModalDialog(gfx::NativeWindow dialog); | |
| 45 | |
| 40 // Allow clients to supply their own native dialog manager. Suitable for | 46 // Allow clients to supply their own native dialog manager. Suitable for |
| 41 // bubble clients. | 47 // bubble clients. |
| 42 void ShowDialogWithManager( | 48 void ShowDialogWithManager( |
| 43 gfx::NativeWindow dialog, | 49 gfx::NativeWindow dialog, |
| 44 std::unique_ptr<SingleWebContentsDialogManager> manager); | 50 std::unique_ptr<SingleWebContentsDialogManager> manager); |
| 45 | 51 |
| 46 // Returns true if any dialogs are active and not closed. | 52 // Returns true if any dialogs are active and not closed. |
| 47 bool IsDialogActive() const; | 53 bool IsDialogActive() const; |
| 48 | 54 |
| 49 // Focus the topmost modal dialog. IsDialogActive() must be true when calling | 55 // Focus the topmost modal dialog. IsDialogActive() must be true when calling |
| 50 // this function. | 56 // this function. |
| 51 void FocusTopmostDialog() const; | 57 void FocusTopmostDialog() const; |
| 52 | 58 |
| 53 // SingleWebContentsDialogManagerDelegate: | 59 // SingleWebContentsDialogManagerDelegate: |
| 54 content::WebContents* GetWebContents() const override; | 60 content::WebContents* GetWebContents() const override; |
| 55 void WillClose(gfx::NativeWindow dialog) override; | 61 void WillClose(gfx::NativeWindow dialog) override; |
| 62 bool IsNonClipped(gfx::NativeWindow dialog) override; | |
| 56 | 63 |
| 57 // For testing. | 64 // For testing. |
| 58 class TestApi { | 65 class TestApi { |
| 59 public: | 66 public: |
| 60 explicit TestApi(WebContentsModalDialogManager* manager) | 67 explicit TestApi(WebContentsModalDialogManager* manager) |
| 61 : manager_(manager) {} | 68 : manager_(manager) {} |
| 62 | 69 |
| 63 void CloseAllDialogs() { manager_->CloseAllDialogs(); } | 70 void CloseAllDialogs() { manager_->CloseAllDialogs(); } |
| 64 void DidAttachInterstitialPage() { manager_->DidAttachInterstitialPage(); } | 71 void DidAttachInterstitialPage() { manager_->DidAttachInterstitialPage(); } |
| 65 void WebContentsWasShown() { manager_->WasShown(); } | 72 void WebContentsWasShown() { manager_->WasShown(); } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 78 struct DialogState { | 85 struct DialogState { |
| 79 DialogState(gfx::NativeWindow dialog, | 86 DialogState(gfx::NativeWindow dialog, |
| 80 std::unique_ptr<SingleWebContentsDialogManager> manager); | 87 std::unique_ptr<SingleWebContentsDialogManager> manager); |
| 81 ~DialogState(); | 88 ~DialogState(); |
| 82 | 89 |
| 83 gfx::NativeWindow dialog; | 90 gfx::NativeWindow dialog; |
| 84 std::unique_ptr<SingleWebContentsDialogManager> manager; | 91 std::unique_ptr<SingleWebContentsDialogManager> manager; |
| 85 }; | 92 }; |
| 86 | 93 |
| 87 typedef std::deque<DialogState*> WebContentsModalDialogList; | 94 typedef std::deque<DialogState*> WebContentsModalDialogList; |
| 95 typedef std::deque<gfx::NativeWindow> NativeWindowDialogList; | |
|
Mike Wittman
2016/08/12 22:51:34
std::set would be better given how this is used. A
rbpotter
2016/08/15 18:03:46
Done.
| |
| 88 | 96 |
| 89 // Utility function to get the dialog state for a dialog. | 97 // Utility function to get the dialog state for a dialog. |
| 90 WebContentsModalDialogList::iterator FindDialogState( | 98 WebContentsModalDialogList::iterator FindDialogState( |
| 91 gfx::NativeWindow dialog); | 99 gfx::NativeWindow dialog); |
| 92 | 100 |
| 93 // Blocks/unblocks interaction with renderer process. | 101 // Blocks/unblocks interaction with renderer process. |
| 94 void BlockWebContentsInteraction(bool blocked); | 102 void BlockWebContentsInteraction(bool blocked); |
| 95 | 103 |
| 96 bool IsWebContentsVisible() const; | 104 bool IsWebContentsVisible() const; |
| 97 | 105 |
| 98 // Closes all WebContentsModalDialogs. | 106 // Closes all WebContentsModalDialogs. |
| 99 void CloseAllDialogs(); | 107 void CloseAllDialogs(); |
| 100 | 108 |
| 101 // Overridden from content::WebContentsObserver: | 109 // Overridden from content::WebContentsObserver: |
| 102 void DidNavigateMainFrame( | 110 void DidNavigateMainFrame( |
| 103 const content::LoadCommittedDetails& details, | 111 const content::LoadCommittedDetails& details, |
| 104 const content::FrameNavigateParams& params) override; | 112 const content::FrameNavigateParams& params) override; |
| 105 void DidGetIgnoredUIEvent() override; | 113 void DidGetIgnoredUIEvent() override; |
| 106 void WasShown() override; | 114 void WasShown() override; |
| 107 void WasHidden() override; | 115 void WasHidden() override; |
| 108 void WebContentsDestroyed() override; | 116 void WebContentsDestroyed() override; |
| 109 void DidAttachInterstitialPage() override; | 117 void DidAttachInterstitialPage() override; |
| 110 | 118 |
| 111 // Delegate for notifying our owner about stuff. Not owned by us. | 119 // Delegate for notifying our owner about stuff. Not owned by us. |
| 112 WebContentsModalDialogManagerDelegate* delegate_; | 120 WebContentsModalDialogManagerDelegate* delegate_; |
| 113 | 121 |
| 114 // All active dialogs. | 122 // All active dialogs. |
| 115 WebContentsModalDialogList child_dialogs_; | 123 WebContentsModalDialogList child_dialogs_; |
| 116 | 124 |
| 125 // All non clipped active dialogs. | |
| 126 NativeWindowDialogList nonclipped_child_dialogs_; | |
| 127 | |
| 117 // True while closing the dialogs on WebContents close. | 128 // True while closing the dialogs on WebContents close. |
| 118 bool closing_all_dialogs_; | 129 bool closing_all_dialogs_; |
| 119 | 130 |
| 120 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); | 131 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); |
| 121 }; | 132 }; |
| 122 | 133 |
| 123 } // namespace web_modal | 134 } // namespace web_modal |
| 124 | 135 |
| 125 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 136 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
| OLD | NEW |