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