| 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 #include <set> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "components/web_modal/single_web_contents_dialog_manager.h" | 13 #include "components/web_modal/single_web_contents_dialog_manager.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 16 | 17 |
| 17 namespace web_modal { | 18 namespace web_modal { |
| 18 | 19 |
| 19 class WebContentsModalDialogManagerDelegate; | 20 class WebContentsModalDialogManagerDelegate; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 void SetDelegate(WebContentsModalDialogManagerDelegate* d); | 31 void SetDelegate(WebContentsModalDialogManagerDelegate* d); |
| 31 | 32 |
| 32 static SingleWebContentsDialogManager* CreateNativeWebModalManager( | 33 static SingleWebContentsDialogManager* CreateNativeWebModalManager( |
| 33 gfx::NativeWindow dialog, | 34 gfx::NativeWindow dialog, |
| 34 SingleWebContentsDialogManagerDelegate* native_delegate); | 35 SingleWebContentsDialogManagerDelegate* native_delegate); |
| 35 | 36 |
| 36 // Shows the dialog as a web contents modal dialog. The dialog will notify via | 37 // Shows the dialog as a web contents modal dialog. The dialog will notify via |
| 37 // WillClose() when it is being destroyed. | 38 // WillClose() when it is being destroyed. |
| 38 void ShowModalDialog(gfx::NativeWindow dialog); | 39 void ShowModalDialog(gfx::NativeWindow dialog); |
| 39 | 40 |
| 41 // Shows the dialog as a non clipped web contents modal dialog. The dialog |
| 42 // will be able to extend outside the bounds of the parent window on platforms |
| 43 // where this is allowed. The dialog will notify via WillClose() when it is |
| 44 // being destroyed. |
| 45 void ShowNonClippedModalDialog(gfx::NativeWindow dialog); |
| 46 |
| 40 // Allow clients to supply their own native dialog manager. Suitable for | 47 // Allow clients to supply their own native dialog manager. Suitable for |
| 41 // bubble clients. | 48 // bubble clients. |
| 42 void ShowDialogWithManager( | 49 void ShowDialogWithManager( |
| 43 gfx::NativeWindow dialog, | 50 gfx::NativeWindow dialog, |
| 44 std::unique_ptr<SingleWebContentsDialogManager> manager); | 51 std::unique_ptr<SingleWebContentsDialogManager> manager); |
| 45 | 52 |
| 46 // Returns true if any dialogs are active and not closed. | 53 // Returns true if any dialogs are active and not closed. |
| 47 bool IsDialogActive() const; | 54 bool IsDialogActive() const; |
| 48 | 55 |
| 49 // Focus the topmost modal dialog. IsDialogActive() must be true when calling | 56 // Focus the topmost modal dialog. IsDialogActive() must be true when calling |
| 50 // this function. | 57 // this function. |
| 51 void FocusTopmostDialog() const; | 58 void FocusTopmostDialog() const; |
| 52 | 59 |
| 53 // SingleWebContentsDialogManagerDelegate: | 60 // SingleWebContentsDialogManagerDelegate: |
| 54 content::WebContents* GetWebContents() const override; | 61 content::WebContents* GetWebContents() const override; |
| 55 void WillClose(gfx::NativeWindow dialog) override; | 62 void WillClose(gfx::NativeWindow dialog) override; |
| 63 bool IsNonClipped(gfx::NativeWindow dialog) const override; |
| 56 | 64 |
| 57 // For testing. | 65 // For testing. |
| 58 class TestApi { | 66 class TestApi { |
| 59 public: | 67 public: |
| 60 explicit TestApi(WebContentsModalDialogManager* manager) | 68 explicit TestApi(WebContentsModalDialogManager* manager) |
| 61 : manager_(manager) {} | 69 : manager_(manager) {} |
| 62 | 70 |
| 63 void CloseAllDialogs() { manager_->CloseAllDialogs(); } | 71 void CloseAllDialogs() { manager_->CloseAllDialogs(); } |
| 64 void DidAttachInterstitialPage() { manager_->DidAttachInterstitialPage(); } | 72 void DidAttachInterstitialPage() { manager_->DidAttachInterstitialPage(); } |
| 65 void WebContentsWasShown() { manager_->WasShown(); } | 73 void WebContentsWasShown() { manager_->WasShown(); } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::set<gfx::NativeWindow> 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 |