| 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 CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_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" |
| 11 #include "chrome/browser/ui/native_web_contents_modal_dialog_manager.h" | 11 #include "chrome/browser/ui/native_web_contents_modal_dialog_manager.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 | 15 |
| 16 class WebContentsModalDialog; | 16 class WebContentsModalDialog; |
| 17 class WebContentsModalDialogManagerDelegate; | 17 class WebContentsModalDialogManagerDelegate; |
| 18 | 18 |
| 19 // Per-WebContents class to manage WebContents-modal dialogs. | 19 // Per-WebContents class to manage WebContents-modal dialogs. |
| 20 class WebContentsModalDialogManager | 20 class WebContentsModalDialogManager |
| 21 : public content::WebContentsObserver, | 21 : public NativeWebContentsModalDialogManagerDelegate, |
| 22 public content::WebContentsObserver, |
| 22 public content::WebContentsUserData<WebContentsModalDialogManager> { | 23 public content::WebContentsUserData<WebContentsModalDialogManager> { |
| 23 public: | 24 public: |
| 24 virtual ~WebContentsModalDialogManager(); | 25 virtual ~WebContentsModalDialogManager(); |
| 25 | 26 |
| 26 WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; } | 27 WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; } |
| 27 void set_delegate(WebContentsModalDialogManagerDelegate* d) { delegate_ = d; } | 28 void set_delegate(WebContentsModalDialogManagerDelegate* d) { delegate_ = d; } |
| 28 | 29 |
| 29 static NativeWebContentsModalDialogManager* CreateNativeManager( | 30 static NativeWebContentsModalDialogManager* CreateNativeManager( |
| 30 WebContentsModalDialogManager* manager); | 31 NativeWebContentsModalDialogManagerDelegate* native_delegate); |
| 31 | 32 |
| 32 // Adds the given dialog to the list of child dialogs. The dialog will notify | 33 // Adds the given dialog to the list of child dialogs. The dialog will notify |
| 33 // via WillClose() when it is being destroyed. | 34 // via WillClose() when it is being destroyed. |
| 34 void AddDialog(WebContentsModalDialog* dialog); | 35 void AddDialog(WebContentsModalDialog* dialog); |
| 35 | 36 |
| 36 // Called when a WebContentsModalDialogs we own is about to be closed. | |
| 37 void WillClose(WebContentsModalDialog* dialog); | |
| 38 | |
| 39 // Blocks/unblocks interaction with renderer process. | 37 // Blocks/unblocks interaction with renderer process. |
| 40 void BlockWebContentsInteraction(bool blocked); | 38 void BlockWebContentsInteraction(bool blocked); |
| 41 | 39 |
| 42 // Returns true if a dialog is currently being shown. | 40 // Returns true if a dialog is currently being shown. |
| 43 bool IsShowingDialog() const; | 41 bool IsShowingDialog() const; |
| 44 | 42 |
| 45 // Focus the topmost modal dialog. IsShowingDialog() must be true when | 43 // Focus the topmost modal dialog. IsShowingDialog() must be true when |
| 46 // calling this function. | 44 // calling this function. |
| 47 void FocusTopmostDialog(); | 45 void FocusTopmostDialog(); |
| 48 | 46 |
| 47 // Overriden from NativeWebContentsModalDialogManagerDelegate: |
| 48 // Called when a WebContentsModalDialogs we own is about to be closed. |
| 49 virtual void WillClose(WebContentsModalDialog* dialog) OVERRIDE; |
| 50 |
| 49 // For testing. | 51 // For testing. |
| 50 class TestApi { | 52 class TestApi { |
| 51 public: | 53 public: |
| 52 explicit TestApi(WebContentsModalDialogManager* manager) | 54 explicit TestApi(WebContentsModalDialogManager* manager) |
| 53 : manager_(manager) {} | 55 : manager_(manager) {} |
| 54 | 56 |
| 55 void CloseAllDialogs() { manager_->CloseAllDialogs(); } | 57 void CloseAllDialogs() { manager_->CloseAllDialogs(); } |
| 56 void ResetNativeManager(NativeWebContentsModalDialogManager* delegate) { | 58 void ResetNativeManager(NativeWebContentsModalDialogManager* delegate) { |
| 57 manager_->native_manager_.reset(delegate); | 59 manager_->native_manager_.reset(delegate); |
| 58 } | 60 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Delegate for native UI-specific functions on the dialog. | 100 // Delegate for native UI-specific functions on the dialog. |
| 99 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_; | 101 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_; |
| 100 | 102 |
| 101 // All active dialogs. | 103 // All active dialogs. |
| 102 WebContentsModalDialogList child_dialogs_; | 104 WebContentsModalDialogList child_dialogs_; |
| 103 | 105 |
| 104 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); | 106 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 #endif // CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ | 109 #endif // CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ |
| OLD | NEW |