| 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 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "components/web_modal/single_web_contents_dialog_manager.h" | 12 #include "components/web_modal/single_web_contents_dialog_manager.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
| 16 | 16 |
| 17 namespace web_modal { | 17 namespace web_modal { |
| 18 | 18 |
| 19 class WebContentsModalDialogManagerDelegate; | 19 class WebContentsModalDialogManagerDelegate; |
| 20 | 20 |
| 21 // Per-WebContents class to manage WebContents-modal dialogs. | 21 // Per-WebContents class to manage WebContents-modal dialogs. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 // Allow clients to supply their own native dialog manager. Suitable for | 40 // Allow clients to supply their own native dialog manager. Suitable for |
| 41 // bubble clients. | 41 // bubble clients. |
| 42 void ShowDialogWithManager( | 42 void ShowDialogWithManager( |
| 43 gfx::NativeWindow dialog, | 43 gfx::NativeWindow dialog, |
| 44 scoped_ptr<SingleWebContentsDialogManager> manager); | 44 std::unique_ptr<SingleWebContentsDialogManager> manager); |
| 45 | 45 |
| 46 // Returns true if any dialogs are active and not closed. | 46 // Returns true if any dialogs are active and not closed. |
| 47 bool IsDialogActive() const; | 47 bool IsDialogActive() const; |
| 48 | 48 |
| 49 // Focus the topmost modal dialog. IsDialogActive() must be true when calling | 49 // Focus the topmost modal dialog. IsDialogActive() must be true when calling |
| 50 // this function. | 50 // this function. |
| 51 void FocusTopmostDialog() const; | 51 void FocusTopmostDialog() const; |
| 52 | 52 |
| 53 // SingleWebContentsDialogManagerDelegate: | 53 // SingleWebContentsDialogManagerDelegate: |
| 54 content::WebContents* GetWebContents() const override; | 54 content::WebContents* GetWebContents() const override; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(TestApi); | 71 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 explicit WebContentsModalDialogManager(content::WebContents* web_contents); | 75 explicit WebContentsModalDialogManager(content::WebContents* web_contents); |
| 76 friend class content::WebContentsUserData<WebContentsModalDialogManager>; | 76 friend class content::WebContentsUserData<WebContentsModalDialogManager>; |
| 77 | 77 |
| 78 struct DialogState { | 78 struct DialogState { |
| 79 DialogState(gfx::NativeWindow dialog, | 79 DialogState(gfx::NativeWindow dialog, |
| 80 scoped_ptr<SingleWebContentsDialogManager> manager); | 80 std::unique_ptr<SingleWebContentsDialogManager> manager); |
| 81 ~DialogState(); | 81 ~DialogState(); |
| 82 | 82 |
| 83 gfx::NativeWindow dialog; | 83 gfx::NativeWindow dialog; |
| 84 scoped_ptr<SingleWebContentsDialogManager> manager; | 84 std::unique_ptr<SingleWebContentsDialogManager> manager; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 typedef std::deque<DialogState*> WebContentsModalDialogList; | 87 typedef std::deque<DialogState*> WebContentsModalDialogList; |
| 88 | 88 |
| 89 // Utility function to get the dialog state for a dialog. | 89 // Utility function to get the dialog state for a dialog. |
| 90 WebContentsModalDialogList::iterator FindDialogState( | 90 WebContentsModalDialogList::iterator FindDialogState( |
| 91 gfx::NativeWindow dialog); | 91 gfx::NativeWindow dialog); |
| 92 | 92 |
| 93 // Blocks/unblocks interaction with renderer process. | 93 // Blocks/unblocks interaction with renderer process. |
| 94 void BlockWebContentsInteraction(bool blocked); | 94 void BlockWebContentsInteraction(bool blocked); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 | 116 |
| 117 // True while closing the dialogs on WebContents close. | 117 // True while closing the dialogs on WebContents close. |
| 118 bool closing_all_dialogs_; | 118 bool closing_all_dialogs_; |
| 119 | 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); | 120 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 } // namespace web_modal | 123 } // namespace web_modal |
| 124 | 124 |
| 125 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 125 #endif // COMPONENTS_WEB_MODAL_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
| OLD | NEW |