| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_IMPL_H_ | |
| 6 #define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_IMPL_H_ | |
| 7 | |
| 8 #include "content/public/browser/javascript_dialog_manager.h" | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "components/app_modal/javascript_app_modal_dialog.h" | |
| 13 | |
| 14 class JavaScriptDialogExtensionsClient; | |
| 15 class JavaScriptNativeDialogFactory; | |
| 16 | |
| 17 class JavaScriptDialogManagerImpl : public content::JavaScriptDialogManager { | |
| 18 public: | |
| 19 static JavaScriptDialogManagerImpl* GetInstance(); | |
| 20 | |
| 21 // JavaScriptDialogManager: | |
| 22 void RunJavaScriptDialog(content::WebContents* web_contents, | |
| 23 const GURL& origin_url, | |
| 24 const std::string& accept_lang, | |
| 25 content::JavaScriptMessageType message_type, | |
| 26 const base::string16& message_text, | |
| 27 const base::string16& default_prompt_text, | |
| 28 const DialogClosedCallback& callback, | |
| 29 bool* did_suppress_message) override; | |
| 30 void RunBeforeUnloadDialog(content::WebContents* web_contents, | |
| 31 const base::string16& message_text, | |
| 32 bool is_reload, | |
| 33 const DialogClosedCallback& callback) override; | |
| 34 bool HandleJavaScriptDialog(content::WebContents* web_contents, | |
| 35 bool accept, | |
| 36 const base::string16* prompt_override) override; | |
| 37 void CancelActiveAndPendingDialogs( | |
| 38 content::WebContents* web_contents) override; | |
| 39 void WebContentsDestroyed(content::WebContents* web_contents) override; | |
| 40 | |
| 41 JavaScriptNativeDialogFactory* native_dialog_factory() { | |
| 42 return native_dialog_factory_.get(); | |
| 43 } | |
| 44 | |
| 45 void SetNativeDialogFactory( | |
| 46 scoped_ptr<JavaScriptNativeDialogFactory> factory); | |
| 47 | |
| 48 void SetExtensionsClient( | |
| 49 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client); | |
| 50 | |
| 51 private: | |
| 52 friend struct DefaultSingletonTraits<JavaScriptDialogManagerImpl>; | |
| 53 | |
| 54 JavaScriptDialogManagerImpl(); | |
| 55 ~JavaScriptDialogManagerImpl() override; | |
| 56 | |
| 57 base::string16 GetTitle(content::WebContents* web_contents, | |
| 58 const GURL& origin_url, | |
| 59 const std::string& accept_lang, | |
| 60 bool is_alert); | |
| 61 | |
| 62 // Wrapper around a DialogClosedCallback so that we can intercept it before | |
| 63 // passing it onto the original callback. | |
| 64 void OnDialogClosed(content::WebContents* web_contents, | |
| 65 DialogClosedCallback callback, | |
| 66 bool success, | |
| 67 const base::string16& user_input); | |
| 68 | |
| 69 // Mapping between the WebContents and their extra data. The key | |
| 70 // is a void* because the pointer is just a cookie and is never dereferenced. | |
| 71 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_; | |
| 72 | |
| 73 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_; | |
| 74 scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManagerImpl); | |
| 77 }; | |
| 78 | |
| 79 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_IMPL_H_ | |
| OLD | NEW |