]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/cef_jsdialog_handler.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / cef_jsdialog_handler.h
1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
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
12 // distribution.
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.
17 //
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.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36
37 #ifndef CEF_INCLUDE_CEF_JSDIALOG_HANDLER_H_
38 #define CEF_INCLUDE_CEF_JSDIALOG_HANDLER_H_
39 #pragma once
40
41 #include "include/cef_base.h"
42 #include "include/cef_browser.h"
43
44 ///
45 // Callback interface used for asynchronous continuation of JavaScript dialog
46 // requests.
47 ///
48 /*--cef(source=library)--*/
49 class CefJSDialogCallback : public virtual CefBase {
50  public:
51   ///
52   // Continue the JS dialog request. Set |success| to true if the OK button was
53   // pressed. The |user_input| value should be specified for prompt dialogs.
54   ///
55   /*--cef(capi_name=cont,optional_param=user_input)--*/
56   virtual void Continue(bool success,
57                         const CefString& user_input) =0;
58 };
59
60
61 ///
62 // Implement this interface to handle events related to JavaScript dialogs. The
63 // methods of this class will be called on the UI thread.
64 ///
65 /*--cef(source=client)--*/
66 class CefJSDialogHandler : public virtual CefBase {
67  public:
68   typedef cef_jsdialog_type_t JSDialogType;
69
70   ///
71   // Called to run a JavaScript dialog. The |default_prompt_text| value will be
72   // specified for prompt dialogs only. Set |suppress_message| to true and
73   // return false to suppress the message (suppressing messages is preferable
74   // to immediately executing the callback as this is used to detect presumably
75   // malicious behavior like spamming alert messages in onbeforeunload). Set
76   // |suppress_message| to false and return false to use the default
77   // implementation (the default implementation will show one modal dialog at a
78   // time and suppress any additional dialog requests until the displayed dialog
79   // is dismissed). Return true if the application will use a custom dialog or
80   // if the callback has been executed immediately. Custom dialogs may be either
81   // modal or modeless. If a custom dialog is used the application must execute
82   // |callback| once the custom dialog is dismissed.
83   ///
84   /*--cef(optional_param=origin_url,optional_param=accept_lang,
85           optional_param=message_text,optional_param=default_prompt_text)--*/
86   virtual bool OnJSDialog(CefRefPtr<CefBrowser> browser,
87                           const CefString& origin_url,
88                           const CefString& accept_lang,
89                           JSDialogType dialog_type,
90                           const CefString& message_text,
91                           const CefString& default_prompt_text,
92                           CefRefPtr<CefJSDialogCallback> callback,
93                           bool& suppress_message) {
94     return false;
95   }
96
97   ///
98   // Called to run a dialog asking the user if they want to leave a page. Return
99   // false to use the default dialog implementation. Return true if the
100   // application will use a custom dialog or if the callback has been executed
101   // immediately. Custom dialogs may be either modal or modeless. If a custom
102   // dialog is used the application must execute |callback| once the custom
103   // dialog is dismissed.
104   ///
105   /*--cef(optional_param=message_text)--*/
106   virtual bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
107                                     const CefString& message_text,
108                                     bool is_reload,
109                                     CefRefPtr<CefJSDialogCallback> callback) {
110     return false;
111   }
112
113   ///
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.
117   ///
118   /*--cef()--*/
119   virtual void OnResetDialogState(CefRefPtr<CefBrowser> browser) {}
120   
121   ///
122   // Called when the default implementation dialog is closed.
123   ///
124   /*--cef()--*/
125   virtual void OnDialogClosed(CefRefPtr<CefBrowser> browser) {}
126 };
127
128 #endif  // CEF_INCLUDE_CEF_JSDIALOG_HANDLER_H_