1 // Copyright 2014 Samsung Electronics. 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.
5 #ifndef JAVASCRIPT_DIALOG_MANAGER_EFL_H_
6 #define JAVASCRIPT_DIALOG_MANAGER_EFL_H_
9 #include "base/strings/string16.h"
10 #include "content/public/browser/javascript_dialog_manager.h"
11 #include "content/public/common/javascript_message_type.h"
12 #include "eweb_view.h"
15 #include "tizen_webview/public/tw_content_security_policy.h"
20 class JavaScriptModalDialogEfl;
22 class JavaScriptModalCallbacksData {
24 bool Run(Evas_Object* obj, const char* content_text, const char* default_text);
25 static JavaScriptModalCallbacksData* CreateWithAlertDialogData(tizen_webview::View_JavaScript_Alert_Callback callback,
27 static JavaScriptModalCallbacksData* CreateWithConfirmDialogData(tizen_webview::View_JavaScript_Confirm_Callback callback,
29 static JavaScriptModalCallbacksData* CreateWithPromptDialogData(tizen_webview::View_JavaScript_Prompt_Callback callback,
31 ~JavaScriptModalCallbacksData() { }
34 JavaScriptModalCallbacksData(content::JavaScriptMessageType javascript_message_type, void* user_data);
36 tizen_webview::View_JavaScript_Alert_Callback alert_callback_;
37 tizen_webview::View_JavaScript_Confirm_Callback confirm_callback_;
38 tizen_webview::View_JavaScript_Prompt_Callback prompt_callback_;
41 content::JavaScriptMessageType javascript_message_type_;
45 class JavaScriptDialogManagerEfl: public content::JavaScriptDialogManager {
47 JavaScriptDialogManagerEfl();
48 virtual ~JavaScriptDialogManagerEfl();
49 virtual void RunJavaScriptDialog(
50 content::WebContents* web_contents,
51 const GURL& origin_url,
52 const std::string& accept_lang,
53 content::JavaScriptMessageType javascript_message_type,
54 const base::string16& message_text,
55 const base::string16& default_prompt_text,
56 const DialogClosedCallback& callback,
57 bool* did_suppress_message) OVERRIDE;
59 virtual void RunBeforeUnloadDialog(content::WebContents* web_contents,
60 const base::string16& message_text,
62 const DialogClosedCallback& callback) OVERRIDE;
64 virtual bool HandleJavaScriptDialog(content::WebContents* web_contents,
66 const base::string16* prompt_override) OVERRIDE
72 virtual void CancelActiveAndPendingDialogs(content::WebContents* web_contents) OVERRIDE
77 virtual void WebContentsDestroyed(content::WebContents* web_contents) OVERRIDE
82 void SetAlertCallback(tizen_webview::View_JavaScript_Alert_Callback callback, void* user_data);
83 void SetConfirmCallback(tizen_webview::View_JavaScript_Confirm_Callback callback, void* user_data);
84 void SetPromptCallback(tizen_webview::View_JavaScript_Prompt_Callback callback, void* user_data);
85 void ExecuteDialogClosedCallBack(bool result, const std::string prompt_data);
88 JavaScriptModalDialogEfl* dialog_;
89 scoped_ptr<JavaScriptModalCallbacksData> alert_callback_data_;
90 scoped_ptr<JavaScriptModalCallbacksData> confirm_callback_data_;
91 scoped_ptr<JavaScriptModalCallbacksData> prompt_callback_data_;
92 DialogClosedCallback dialog_closed_callback_;
96 #endif /* JAVASCRIPT_DIALOG_MANAGER_EFL_H_ */