Chromium Code Reviews| Index: components/app_modal_dialogs/javascript_dialog_manager.h |
| diff --git a/components/app_modal_dialogs/javascript_dialog_manager.h b/components/app_modal_dialogs/javascript_dialog_manager.h |
| index cadf945804cf996e055e30b0e371178084945aef..8a41eba20a22cd9d91288dd7cd1509e5fb530bc1 100644 |
| --- a/components/app_modal_dialogs/javascript_dialog_manager.h |
| +++ b/components/app_modal_dialogs/javascript_dialog_manager.h |
| @@ -6,28 +6,82 @@ |
| #define COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_ |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/singleton.h" |
| +#include "components/app_modal_dialogs/javascript_app_modal_dialog.h" |
| +#include "content/public/browser/javascript_dialog_manager.h" |
| -namespace content { |
| -class JavaScriptDialogManager; |
| -} |
| +namespace app_modal_dialogs { |
| class JavaScriptDialogExtensionsClient; |
| class JavaScriptNativeDialogFactory; |
| -// Returns a JavaScriptDialogManager that creates real dialogs. |
| -// It returns a Singleton instance of JavaScriptDialogManager, |
| -// which should not be deleted. |
| -content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance(); |
| - |
| -// Sets the JavaScriptNativeDialogFactory used to create platform specific |
| -// dialog window implementation. |
| -void SetJavaScriptNativeDialogFactory( |
| - scoped_ptr<JavaScriptNativeDialogFactory> factory); |
| - |
| -// JavaScript dialog may be opened by an extensions/app, thus needs |
| -// access to extensions functionality. This sets a client interface to |
| -// access //extensions. |
| -void SetJavaScriptDialogExtensionsClient( |
| - scoped_ptr<JavaScriptDialogExtensionsClient> client); |
| +class JavaScriptDialogManager : public content::JavaScriptDialogManager { |
| + public: |
| + static JavaScriptDialogManager* GetInstance(); |
| + |
| + JavaScriptNativeDialogFactory* native_dialog_factory() { |
| + return native_dialog_factory_.get(); |
| + } |
| + |
| + // Sets the JavaScriptNativeDialogFactory used to create platform specific |
| + // dialog window implementation. |
|
msw
2014/11/15 00:51:57
nit: s/implementation/instances/
oshima
2014/11/18 17:42:41
Done.
|
| + void SetNativeDialogFactory( |
| + scoped_ptr<JavaScriptNativeDialogFactory> factory); |
| + |
| + // JavaScript dialog may be opened by an extensions/app, thus needs |
|
msw
2014/11/15 00:51:57
nit: "dialogs", "thus they need" or consider somet
oshima
2014/11/18 17:42:41
Done
|
| + // access to extensions functionality. This sets a client interface to |
| + // access //extensions. |
| + void SetExtensionsClient( |
| + scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client); |
| + |
| + private: |
| + friend struct DefaultSingletonTraits<JavaScriptDialogManager>; |
| + |
| + JavaScriptDialogManager(); |
| + ~JavaScriptDialogManager() override; |
| + |
| + // JavaScriptDialogManager: |
| + void RunJavaScriptDialog(content::WebContents* web_contents, |
| + const GURL& origin_url, |
| + const std::string& accept_lang, |
| + content::JavaScriptMessageType message_type, |
| + const base::string16& message_text, |
| + const base::string16& default_prompt_text, |
| + const DialogClosedCallback& callback, |
| + bool* did_suppress_message) override; |
| + void RunBeforeUnloadDialog(content::WebContents* web_contents, |
| + const base::string16& message_text, |
| + bool is_reload, |
| + const DialogClosedCallback& callback) override; |
| + bool HandleJavaScriptDialog(content::WebContents* web_contents, |
| + bool accept, |
| + const base::string16* prompt_override) override; |
| + void CancelActiveAndPendingDialogs( |
| + content::WebContents* web_contents) override; |
| + void WebContentsDestroyed(content::WebContents* web_contents) override; |
| + |
| + base::string16 GetTitle(content::WebContents* web_contents, |
| + const GURL& origin_url, |
| + const std::string& accept_lang, |
| + bool is_alert); |
| + |
| + // Wrapper around a DialogClosedCallback so that we can intercept it before |
| + // passing it onto the original callback. |
| + void OnDialogClosed(content::WebContents* web_contents, |
| + DialogClosedCallback callback, |
| + bool success, |
| + const base::string16& user_input); |
| + |
| + // Mapping between the WebContents and their extra data. The key |
| + // is a void* because the pointer is just a cookie and is never dereferenced. |
| + JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_; |
| + |
| + scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_; |
| + scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager); |
| +}; |
| + |
| +} // namespace app_modal_dialogs |
| #endif // COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_ |