1 // Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // ---------------------------------------------------------------------------
32 // This file was generated by the CEF translator tool and should not edited
33 // by hand. See the translator.README.txt file in the tools directory for
37 #ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
38 #define CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
41 #include "include/capi/cef_base_capi.h"
42 #include "include/capi/cef_browser_capi.h"
50 // Callback structure used for asynchronous continuation of JavaScript dialog
53 typedef struct _cef_jsdialog_callback_t {
60 // Continue the JS dialog request. Set |success| to true (1) if the OK button
61 // was pressed. The |user_input| value should be specified for prompt dialogs.
63 void (CEF_CALLBACK *cont)(struct _cef_jsdialog_callback_t* self, int success,
64 const cef_string_t* user_input);
65 } cef_jsdialog_callback_t;
69 // Implement this structure to handle events related to JavaScript dialogs. The
70 // functions of this structure will be called on the UI thread.
72 typedef struct _cef_jsdialog_handler_t {
79 // Called to run a JavaScript dialog. The |default_prompt_text| value will be
80 // specified for prompt dialogs only. Set |suppress_message| to true (1) and
81 // return false (0) to suppress the message (suppressing messages is
82 // preferable to immediately executing the callback as this is used to detect
83 // presumably malicious behavior like spamming alert messages in
84 // onbeforeunload). Set |suppress_message| to false (0) and return false (0)
85 // to use the default implementation (the default implementation will show one
86 // modal dialog at a time and suppress any additional dialog requests until
87 // the displayed dialog is dismissed). Return true (1) if the application will
88 // use a custom dialog or if the callback has been executed immediately.
89 // Custom dialogs may be either modal or modeless. If a custom dialog is used
90 // the application must execute |callback| once the custom dialog is
93 int (CEF_CALLBACK *on_jsdialog)(struct _cef_jsdialog_handler_t* self,
94 struct _cef_browser_t* browser, const cef_string_t* origin_url,
95 const cef_string_t* accept_lang, cef_jsdialog_type_t dialog_type,
96 const cef_string_t* message_text,
97 const cef_string_t* default_prompt_text,
98 struct _cef_jsdialog_callback_t* callback, int* suppress_message);
101 // Called to run a dialog asking the user if they want to leave a page. Return
102 // false (0) to use the default dialog implementation. Return true (1) if the
103 // application will use a custom dialog or if the callback has been executed
104 // immediately. Custom dialogs may be either modal or modeless. If a custom
105 // dialog is used the application must execute |callback| once the custom
106 // dialog is dismissed.
108 int (CEF_CALLBACK *on_before_unload_dialog)(
109 struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser,
110 const cef_string_t* message_text, int is_reload,
111 struct _cef_jsdialog_callback_t* callback);
114 // Called to cancel any pending dialogs and reset any saved dialog state. Will
115 // be called due to events like page navigation irregardless of whether any
116 // dialogs are currently pending.
118 void (CEF_CALLBACK *on_reset_dialog_state)(
119 struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser);
122 // Called when the default implementation dialog is closed.
124 void (CEF_CALLBACK *on_dialog_closed)(struct _cef_jsdialog_handler_t* self,
125 struct _cef_browser_t* browser);
126 } cef_jsdialog_handler_t;
133 #endif // CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_