1 module dash.utility.bindings.awesomium;
2 
3 version( Windows ):
4 
5 public {
6     import core.stdc.stddef;
7     version(Windows) {
8         import core.sys.windows.windows;
9     }
10 }
11 
12 
13 extern(C) {
14 alias wchar wchar16;
15 
16 alias long int64;
17 
18 /// WebView instance
19 struct awe_webview {}
20 /// JSValue instance
21 struct awe_jsvalue {}
22 /// JSArray instance
23 struct awe_jsarray {}
24 /// JSObject instance
25 struct awe_jsobject {}
26 /// RenderBuffer instance, owned by the WebView
27 struct awe_renderbuffer {}
28 /// HeaderDefinition instance
29 struct awe_header_definition {}
30 /// ResourceResponse instance
31 struct awe_resource_response {}
32 /// ResourceRequest instance
33 struct awe_resource_request {}
34 /// UploadElement instance
35 struct awe_upload_element {}
36 /// String instance
37 struct awe_string {}
38 /// HistoryQueryResult instance
39 struct awe_history_query_result {}
40 /// HistoryEntry instance
41 struct awe_history_entry {}
42 
43 enum awe_loglevel
44 {
45     AWE_LL_NONE,
46     AWE_LL_NORMAL,
47     AWE_LL_VERBOSE
48 }
49 
50 enum awe_mousebutton
51 {
52     AWE_MB_LEFT,
53     AWE_MB_MIDDLE,
54     AWE_MB_RIGHT
55 }
56 
57 enum awe_url_filtering_mode
58 {
59     AWE_UFM_NONE,
60     AWE_UFM_BLACKLIST,
61     AWE_UFM_WHITELIST
62 }
63 
64 enum awe_webkey_type
65 {
66     AWE_WKT_KEYDOWN,
67     AWE_WKT_KEYUP,
68     AWE_WKT_CHAR
69 }
70 
71 enum awe_webkey_modifiers
72 {
73     /// Whether or not a Shift key is down
74     AWE_WKM_SHIFT_KEY       = 1 << 0,
75     /// Whether or not a Control key is down
76     AWE_WKM_CONTROL_KEY     = 1 << 1,
77     /// Whether or not an ALT key is down
78     AWE_WKM_ALT_KEY         = 1 << 2,
79     /// Whether or not a meta key (Command-key on Mac, Windows-key on Windows) is down
80     AWE_WKM_META_KEY        = 1 << 3,
81     /// Whether or not the key pressed is on the keypad
82     AWE_WKM_IS_KEYPAD       = 1 << 4,
83     /// Whether or not the character input is the result of an auto-repeat timer.
84     AWE_WKM_IS_AUTOREPEAT   = 1 << 5,
85 }
86 
87 enum awe_cursor_type
88 {
89     AWE_CUR_POINTER,
90     AWE_CUR_CROSS,
91     AWE_CUR_HAND,
92     AWE_CUR_IBEAM,
93     AWE_CUR_WAIT,
94     AWE_CUR_HELP,
95     AWE_CUR_EAST_RESIZE,
96     AWE_CUR_NORTH_RESIZE,
97     AWE_CUR_NORTHEAST_RESIZE,
98     AWE_CUR_NORTHWEST_RESIZE,
99     AWE_CUR_SOUTH_RESIZE,
100     AWE_CUR_SOUTHEAST_RESIZE,
101     AWE_CUR_SOUTHWEST_RESIZE,
102     AWE_CUR_WEST_RESIZE,
103     AWE_CUR_NORTHSOUTH_RESIZE,
104     AWE_CUR_EASTWEST_RESIZE,
105     AWE_CUR_NORTHEAST_SOUTHWEST_RESIZE,
106     AWE_CUR_NORTHWEST_SOUTHEAST_RESIZE,
107     AWE_CUR_COLUMN_RESIZE,
108     AWE_CUR_ROW_RESIZE,
109     AWE_CUR_MIDDLE_PANNING,
110     AWE_CUR_EAST_PANNING,
111     AWE_CUR_NORTH_PANNING,
112     AWE_CUR_NORTHEAST_PANNING,
113     AWE_CUR_NORTHWEST_PANNING,
114     AWE_CUR_SOUTH_PANNING,
115     AWE_CUR_SOUTHEAST_PANNING,
116     AWE_CUR_SOUTHWEST_PANNING,
117     AWE_CUR_WEST_PANNING,
118     AWE_CUR_MOVE,
119     AWE_CUR_VERTICAL_TEXT,
120     AWE_CUR_CELL,
121     AWE_CUR_CONTEXT_MENU,
122     AWE_CUR_ALIAS,
123     AWE_CUR_PROGRESS,
124     AWE_CUR_NO_DROP,
125     AWE_CUR_COPY,
126     AWE_CUR_NONE,
127     AWE_CUR_NOT_ALLOWED,
128     AWE_CUR_ZOOM_IN,
129     AWE_CUR_ZOOM_OUT,
130     AWE_CUR_CUSTOM
131 }
132 
133 enum awe_ime_state
134 {
135     AWE_IME_DISABLE = 0,
136     AWE_IME_MOVE_WINDOW = 1,
137     AWE_IME_COMPLETE_COMPOSITION = 2
138 }
139 
140 enum awe_media_type
141 {
142     AWE_MEDIA_TYPE_NONE,
143     AWE_MEDIA_TYPE_IMAGE,
144     AWE_MEDIA_TYPE_VIDEO,
145     AWE_MEDIA_TYPE_AUDIO
146 }
147 
148 enum awe_media_state
149 {
150     AWE_MEDIA_STATE_NONE = 0x0,
151     AWE_MEDIA_STATE_ERROR = 0x1,
152     AWE_MEDIA_STATE_PAUSED = 0x2,
153     AWE_MEDIA_STATE_MUTED = 0x4,
154     AWE_MEDIA_STATE_LOOP = 0x8,
155     AWE_MEDIA_STATE_CAN_SAVE = 0x10,
156     AWE_MEDIA_STATE_HAS_AUDIO = 0x20
157 }
158 
159 enum awe_can_edit_flags
160 {
161     AWE_CAN_EDIT_NOTHING = 0x0,
162     AWE_CAN_UNDO = 0x1,
163     AWE_CAN_REDO = 0x2,
164     AWE_CAN_CUT = 0x4,
165     AWE_CAN_COPY = 0x8,
166     AWE_CAN_PASTE = 0x10,
167     AWE_CAN_DELETE = 0x20,
168     AWE_CAN_SELECT_ALL = 0x40
169 }
170 
171 enum awe_dialog_flags
172 {
173     AWE_DIALOG_HAS_OK_BUTTON = 0x1,
174     AWE_DIALOG_HAS_CANCEL_BUTTON = 0x2,
175     AWE_DIALOG_HAS_PROMPT_FIELD = 0x4,
176     AWE_DIALOG_HAS_MESSAGE = 0x8
177 }
178 
179 struct awe_webkeyboardevent
180 {
181     awe_webkey_type type;
182     int modifiers;
183     int virtual_key_code;
184     int native_key_code;
185     wchar16[4] text = [0, 0, 0, 0];
186     wchar16[4] unmodified_text = [0, 0, 0, 0];
187     bool is_system_key;
188 }
189 
190 struct awe_rect
191 {
192     int x, y, width, height;
193 }
194 
195 
196 version(Windows) {
197     bool awe_is_child_process(HINSTANCE hInstance);
198 
199 
200     int awe_child_process_main(HINSTANCE hInstance);
201 } else {
202     bool awe_is_child_process(int argc, char** argv);
203 
204     int awe_child_process_main(int argc, char** argv);
205 }
206 
207 
208 /*****************************
209  * UTF-16 String Definitions *
210  *****************************/
211 
212 /**
213  * Get an instance of an empty string. This is a convenience method to
214  * quickly pass an empty string to the C API-- you should not destroy
215  * this string yourself.
216  */
217 const(awe_string)* awe_string_empty();
218 
219 /**
220  * Create a string from an ASCII string. You must call awe_string_destroy
221  * with the returned instance once you're done using it.
222  *
223  * @param   str An ASCII string to be copied from.
224  *
225  * @param   len The length of the string
226  */
227 awe_string* awe_string_create_from_ascii(const(char)* str,
228                                          size_t len);
229 
230 /**
231  * Create a string from a Wide string. You must call awe_string_destroy
232  * with the returned instance once you're done using it.
233  *
234  * @param   str A Wide string to be copied from.
235  *
236  * @param   len The length of the string
237  */
238 awe_string* awe_string_create_from_wide(const(wchar_t)* str,
239                                                    size_t len);
240 
241 /**
242  * Create a string from a UTF-8 string. You must call awe_string_destroy
243  * with the returned instance once you're done using it.
244  *
245  * @param   str A UTF-8 string to be copied from.
246  *
247  * @param   len The length of the string.
248  */
249 awe_string* awe_string_create_from_utf8(const(char)* str,
250                                                    size_t len);
251 
252 /**
253  * Create a string from a UTF-16 string. You must call awe_string_destroy
254  * with the returned instance once you're done using it.
255  *
256  * @param   str A UTF-16 string to be copied from.
257  *
258  * @param   len The length of the string.
259  */
260 awe_string* awe_string_create_from_utf16(const(wchar16)* str,
261                                                    size_t len);
262 
263 /**
264  * Destroys a string instance created with one of the above functions.
265  *
266  * @param   str The instance to destroy.
267  */
268 void awe_string_destroy(awe_string* str);
269 
270 /**
271  * Gets the length of a string.
272  *
273  * @param   str The string to get the length of.
274  *
275  * @return  The length of the string.
276  */
277 size_t awe_string_get_length(const(awe_string)* str);
278 
279 /**
280  * Get a pointer to the actual internal UTF-16 bytes of a string.
281  *
282  * @param   str The string to get the UTF-16 bytes of.
283  *
284  * @return  A constant pointer to the UTF-16 buffer of the string.
285  */
286 const(wchar16)* awe_string_get_utf16(const(awe_string)* str);
287 
288 /**
289  * Converts a string to a wide string by copying to the destination buffer.
290  *
291  * @param   str The source string instance
292  *
293  * @param   dest    The destination buffer to copy to.
294  *
295  * @param   len The size of the destination buffer.
296  *
297  * @return  Returns the full size of the string-- you can use this for
298  *          pre-allocation purposes: call this method once with a NULL
299  *          destination and 0 length to get the size to allocate your
300  *          destination buffer, and then call it again to actually
301  *          convert the string.
302  */
303 int awe_string_to_wide(const(awe_string)* str,
304                                   wchar_t* dest,
305                                   size_t len);
306 
307 /**
308  * Converts a string to a UTF-8 string by copying to the destination buffer.
309  *
310  * @param   str The source string instance
311  *
312  * @param   dest    The destination buffer to copy to.
313  *
314  * @param   len The size of the destination buffer.
315  *
316  * @return  Returns the full size of the string-- you can use this for
317  *          pre-allocation purposes: call this method once with a NULL
318  *          destination and 0 length to get the size to allocate your
319  *          destination buffer, and then call it again to actually
320  *          convert the string.
321  */
322 int awe_string_to_utf8(const(awe_string)* str,
323                                   char* dest,
324                                   size_t len);
325 
326 /***********************
327  * Web Core Functions  *
328  ***********************/
329 
330 /**
331  * Instantiates the WebCore singleton with a set of configuration
332  * parameters.
333  *
334  * Here are recommendations for the default parameters:
335  * <pre>
336  *     enable_plugins              = false
337  *     enable_javascript           = true
338  *     enable_databases            = false
339  *     package_path                = awe_string_empty()
340  *     locale_path                 = awe_string_empty()
341  *     user_data_path              = awe_string_empty()
342  *     plugin_path                 = awe_string_empty()
343  *     log_path                    = awe_string_empty()
344  *     log_level                   = AWE_LL_NORMAL
345  *     forceSingleProcess          = false
346  *     childProcessPath            = (empty)
347  *     enable_auto_detect_encoding = true
348  *     accept_language_override    = awe_string_empty()
349  *     default_charset_override    = awe_string_empty()
350  *     user_agent_override         = awe_string_empty()
351  *     proxy_server                = awe_string_empty()
352  *     proxy_config_script         = awe_string_empty()
353  *     save_cache_and_cookies      = true
354  *     max_cache_size              = 0
355  *     disable_same_origin_policy  = false
356  *     disable_win_message_pump    = false
357  *     custom_css                  = awe_string_empty()
358  * </pre>
359  */
360 void awe_webcore_initialize(bool enable_plugins,
361                                        bool enable_javascript,
362                                        bool enable_databases,
363                                        const(awe_string)* package_path,
364                                        const(awe_string)* locale_path,
365                                        const(awe_string)* user_data_path,
366                                        const(awe_string)* plugin_path,
367                                        const(awe_string)* log_path,
368                                        awe_loglevel log_level,
369                                        bool force_single_process,
370                                        const(awe_string)* child_process_path,
371                                        bool enable_auto_detect_encoding,
372                                        const(awe_string)* accept_language_override,
373                                        const(awe_string)* default_charset_override,
374                                        const(awe_string)* user_agent_override,
375                                        const(awe_string)* proxy_server,
376                                        const(awe_string)* proxy_config_script,
377                                        const(awe_string)* auth_server_whitelist,
378                                        bool save_cache_and_cookies,
379                                        int max_cache_size,
380                                        bool disable_same_origin_policy,
381                                        bool disable_win_message_pump,
382                                        const(awe_string)* custom_css);
383 
384 /**
385  * Instantiates the WebCore singleton with the default parameters
386  * specified in the method above.
387  */
388 void awe_webcore_initialize_default();
389 
390 /**
391  * Destroys the WebCore singleton and destroys any remaining WebViews.
392  */
393 void awe_webcore_shutdown();
394 
395 /**
396  * Sets the base directory.
397  *
398  * @param   base_dir_path   The absolute path to your base directory.
399  *                          The base directory is a location that holds
400  *                          all of your local assets. It will be used
401  *                          for WebView::loadFile and WebView::loadHTML
402  *                          (to resolve relative URLs).
403  */
404 void awe_webcore_set_base_directory(const(awe_string)* base_dir_path);
405 
406 /**
407  * Creates a new WebView.
408  *
409  * @param   width   The width of the WebView in pixels.
410  * @param   height  The height of the WebView in pixels.
411  * @param   viewSource  Enable this to view the HTML source of any web-page
412  *                      loaded into this WebView. Default is false.
413  *
414  * @return  Returns a pointer to the created WebView instance. To call methods
415  *          on the WebView, see awe_webview_load_url() and related functions.
416  */
417 awe_webview* awe_webcore_create_webview(int width, int height,
418                                                    bool view_source);
419 
420 /**
421  * Sets a custom response page to use when a WebView encounters a
422  * certain HTML status code from the server (like '404 - File not found').
423  *
424  * @param   status_code The status code this response page should be
425  *                      associated with.
426  *                      See <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes>
427  *
428  * @param   file_path   The local page to load as a response, should be
429  *                      a path relative to the base directory.
430  */
431 void awe_webcore_set_custom_response_page(int status_code,
432                                                      const(awe_string)* file_path);
433 
434 /**
435  * Updates the WebCore and allows it to conduct various operations such
436  * as updating the render buffer of each WebView, destroying any
437  * WebViews that are queued for destruction, and invoking any queued
438  * callback events.
439  */
440 void awe_webcore_update();
441 
442 /**
443  * Retrieves the base directory.
444  *
445  * @return  Returns a string instance representing the current
446  *          base directory. (You do not need to destroy this instance)
447  */
448 const(awe_string)* awe_webcore_get_base_directory();
449 
450 /**
451  * Returns whether or not plugins are enabled.
452  */
453 bool awe_webcore_are_plugins_enabled();
454 
455 /**
456  * Clear the disk cache and media cache.
457  */
458 void awe_webcore_clear_cache();
459 
460 /**
461  * Clear all cookies.
462  */
463 void awe_webcore_clear_cookies();
464 
465 /**
466  * Sets a cookie for a certain URL.
467  *
468  * @param   url The URL to set the cookie on.
469  *
470  * @param   cookie_string   The cookie string, for example:
471  *                          <pre> "key1=value1; key2=value2" </pre>
472  *
473  * @param   is_http_only    Whether or not this cookie is HTTP-only.
474  *
475  * @param   force_session_cookie    Whether or not to force this as a
476  *                              session cookie.
477  *
478  */
479 void awe_webcore_set_cookie(const(awe_string)* url,
480                                        const(awe_string)* cookie_string,
481                                        bool is_http_only,
482                                        bool force_session_cookie);
483 
484 /**
485  * Gets all cookies for a certain URL.
486  *
487  * @param   url The URL whose cookies will be retrieved.
488  *
489  * @param   exclude_http_only   Whether or not to exclude HTTP-only
490  *                              cookies from the result.
491  *
492  * @return  Returns the cookie string. (You do not need to destroy this string)
493  */
494 const(awe_string)* awe_webcore_get_cookies(const(awe_string)* url,
495                                                   bool exclude_http_only);
496 
497 /**
498  * Deletes a certain cookie on a certain URL.
499  *
500  * @param   url The URL that we will be deleting cookies on.
501  *
502  * @param   cookie_name The name of the cookie that will be deleted.
503  */
504 void awe_webcore_delete_cookie(const(awe_string)* url,
505                                           const(awe_string)* cookie_name);
506 
507 
508 /**
509  * Set whether or not the printer dialog should be suppressed or not.
510  * Set this to "true" to hide printer dialogs and print immediately
511  * using the OS's default printer when WebView::print is called.
512  * Default is "false" if you never call this.
513  *
514  * @param   suppress    Whether or not the printer dialog should be
515  *                      suppressed.
516  */
517 void awe_webcore_set_suppress_printer_dialog(bool suppress);
518 
519 /**
520  * Query the on-disk history database.
521  *
522  * @param   full_text_query All results returned should match the
523  *                          specified text (either in the page title or
524  *                          in the actual text of the page itself).
525  *                          Specify an empty string to match anything.
526  *
527  * @param   num_days_ago    Limit results to a specified number of days ago.
528  *
529  * @param   max_count   Limit results to a maximum count. Specify 0 to
530  *                      use no limit.
531  *
532  * @note    You must enable "SaveCacheAndCookies" (see awe_webcore_initialize) for
533  *          this method to work (otherwise no results will be returned).
534  *
535  * @return  Returns an instance of awe_history_query_result containing the results
536  *          of the query. You must call awe_history_query_result_destroy once
537  *          you are finished using the instance.
538  */
539 awe_history_query_result* awe_webcore_query_history(const(awe_string)* full_text_query,
540                                           int num_days_ago, int max_count);
541 
542 
543 /***********************
544  * Web View Functions  *
545  ***********************/
546 
547 /**
548  * Queue a WebView for destruction by the WebCore.
549  *
550  * @param   webview     The WebView instance.
551  *
552  */
553 void awe_webview_destroy(awe_webview* webview);
554 
555 /**
556  * Loads a URL into the WebView asynchronously.
557  *
558  * @param   webview     The WebView instance.
559  *
560  * @param   url The URL to load.
561  *
562  * @param   frame_name  The name of the frame to load the URL
563  *                      in; leave this blank to load in the main frame.
564  *
565  * @param   username    If the URL requires authentication, the username
566  *                      to authorize as, otherwise just pass an empty string.
567  *
568  * @param   password    If the URL requires authentication, the password
569  *                      to use, otherwise just pass an empty string.
570  */
571 void awe_webview_load_url(awe_webview* webview,
572                                      const(awe_string)* url,
573                                      const(awe_string)* frame_name,
574                                      const(awe_string)* username,
575                                      const(awe_string)* password);
576 
577 /**
578  * Loads a string of HTML into the WebView asynchronously.
579  *
580  * @param   webview     The WebView instance.
581  *
582  * @param   html    The HTML string (ASCII) to load.
583  *
584  * @param   frame_name  The name of the frame to load the HTML
585  *                      in; leave this blank to load in the main frame.
586  */
587 void awe_webview_load_html(awe_webview* webview,
588                                       const(awe_string)* html,
589                                       const(awe_string)* frame_name);
590 
591 /**
592  * Loads a local file into the WebView asynchronously.
593  *
594  * @param   webview     The WebView instance.
595  *
596  * @param   file    The file to load.
597  *
598  * @param   frame_name  The name of the frame to load the file
599  *                      in; leave this blank to load in the main frame.
600  *
601  * @note    The file should exist within the base directory.
602  */
603 void awe_webview_load_file(awe_webview* webview,
604                                       const(awe_string)* file,
605                                       const(awe_string)* frame_name);
606 
607 awe_string* awe_webview_get_url(awe_webview* webview);
608 
609 /**
610  * Navigates back/forward in history via a relative offset.
611  *
612  * @param   webview     The WebView instance.
613  *
614  * @param   offset  The relative offset in history to navigate to.
615  */
616 void awe_webview_go_to_history_offset(awe_webview* webview,
617                                                  int offset);
618 
619 /// Get the number of steps back in history we can go.
620 int awe_webview_get_history_back_count(awe_webview* webview);
621 
622 /// Get the number of steps forward in history we can go.
623 int awe_webview_get_history_forward_count(awe_webview* webview);
624 
625 /**
626  * Stops the current navigation.
627  */
628 void awe_webview_stop(awe_webview* webview);
629 
630 /**
631  * Reloads the current page.
632  */
633 void awe_webview_reload(awe_webview* webview);
634 
635 /**
636  * Executes a string of Javascript in the context of the current page
637  * asynchronously.
638  *
639  * @param   javascript  The string of Javascript to execute.
640  *
641  * @param   frame_name  The name of the frame to execute in;
642  *                      pass an empty string to execute in the main frame.
643  */
644 void awe_webview_execute_javascript(awe_webview* webview,
645                                                const(awe_string)* javascript,
646                                                const(awe_string)* frame_name);
647 
648 /**
649  * Executes a string of Javascript in the context of the current page
650  * asynchronously with a result.
651  *
652  * @param   javascript  The string of Javascript to execute.
653  *
654  * @param   frame_name  The name of the frame to execute in;
655  *                      pass an empty string to execute in the main frame.
656  *
657  * @param   timeout_ms  The maximum amount of time (in milliseconds) to wait
658  *                      for a result. Pass 0 to use no timeout. (If no result
659  *                      is obtained, or the timeout is reached, this function
660  *                      will return a jsvalue with type "null")
661  *
662  * @return  Returns an awe_jsvalue instance. You must call awe_jsvalue_destroy
663  *          on this instance when you're done using it.
664  */
665 awe_jsvalue* awe_webview_execute_javascript_with_result(
666                                                     awe_webview* webview,
667                                                     const(awe_string)* javascript,
668                                                     const(awe_string)* frame_name,
669                                                     int timeout_ms);
670 /**
671  * Call a certain function defined in Javascript directly.
672  *
673  * @param   object  The name of the object that contains the function,
674  *                  pass an empty string if the function is defined in
675  *                  the global scope.
676  *
677  * @param   function    The name of the function.
678  *
679  * @param   args    The arguments to pass to the function.
680  *
681  * @param   frame_name  The name of the frame to execute in;
682  *                      leave this blank to execute in the main frame.
683  */
684 void awe_webview_call_javascript_function(awe_webview* webview,
685                                                      const(awe_string)* object,
686                                                      const(awe_string)* function_,
687                                                      const(awe_jsarray)* arguments,
688                                                      const(awe_string)* frame_name);
689 
690 /**
691  * Creates a new global Javascript object that will persist throughout
692  * the lifetime of this WebView. This object is managed directly by
693  * Awesomium and so you can modify its properties and bind callback
694  * functions via awe_webview_set_object_property() and
695  * awe_webview_set_object_callback(), respectively.
696  *
697  * @param   objectName  The name of the object.
698  */
699 void awe_webview_create_object(awe_webview* webview,
700                                           const(awe_string)* object_name);
701 
702 /**
703  * Destroys a Javascript object previously created by
704  * awe_webview_create_object
705  *
706  * @param   object_name The name of the object to destroy.
707  */
708 void awe_webview_destroy_object(awe_webview* webview,
709                                            const(awe_string)* object_name);
710 
711 /**
712  * Sets a property of a Javascript object previously created by
713  * awe_webview_create_object().
714  *
715  * @param   object_name The name of the Javascript object.
716  *
717  * @param   property_name   The name of the property.
718  *
719  * @param   value   The javascript-value of the property.
720  */
721 void awe_webview_set_object_property(awe_webview* webview,
722                                                 const(awe_string)* object_name,
723                                                 const(awe_string)* property_name,
724                                                 const(awe_jsvalue)* value);
725 
726 /**
727  * Sets a callback function of a Javascript object previously created
728  * by awe_webview_create_object(). This is very useful for passing events
729  * from Javascript to C. To receive notification of the callback, please
730  * see awe_webview_set_callback_js_callback().
731  *
732  * @param   object_name The name of the Javascript object.
733  *
734  * @param   callback_name   The name of the callback function.
735  */
736 void awe_webview_set_object_callback(awe_webview* webview,
737                                                 const(awe_string)* object_name,
738                                                 const(awe_string)* callback_name);
739 
740 /**
741  * Returns whether or not a page is currently loading in the WebView.
742  *
743  * @return  If a page is loading, returns true, otherwise returns false.
744  */
745 bool awe_webview_is_loading_page(awe_webview* webview);
746 
747 /**
748  * Returns whether or not the WebView is dirty and needs to be
749  * re-rendered via awe_webview_render.
750  *
751  * @return  If the WebView is dirty, returns true, otherwise returns
752  *          false.
753  */
754 bool awe_webview_is_dirty(awe_webview* webview);
755 
756 /**
757  * Returns the bounds of the area that has changed since the last call
758  * to awe_webview_render.
759  *
760  * @return  The bounds of the dirty area.
761  */
762 awe_rect awe_webview_get_dirty_bounds(awe_webview* webview);
763 
764 /**
765  * Renders this WebView into an offscreen render buffer and clears the
766  * dirty state.
767  *
768  * @return  A pointer to the internal render buffer instance that was used to
769  *           render this WebView. This value may change between renders and
770  *           may return NULL if the WebView has crashed.
771  */
772 const(awe_renderbuffer)* awe_webview_render(awe_webview* webview);
773 
774 /**
775  * All rendering is actually done asynchronously in a separate process
776  * and so the page is usually continuously rendering even if you never
777  * call awe_webview_render. Call this to temporarily pause rendering.
778  */
779 void awe_webview_pause_rendering(awe_webview* webview);
780 
781 /**
782  * Resume rendering after all call to awe_webview_pause_rendering.
783  */
784 void awe_webview_resume_rendering(awe_webview* webview);
785 
786 /**
787  * Injects a mouse-move event in local coordinates.
788  *
789  * @param   x   The absolute x-coordinate of the mouse (localized to
790  *              the WebView).
791  *
792  * @param   y   The absolute y-coordinate of the mouse (localized to
793  *              the WebView).
794  */
795 void awe_webview_inject_mouse_move(awe_webview* webview,
796                                               int x,
797                                               int y);
798 
799 /**
800  * Injects a mouse-down event.
801  *
802  * @param   button  The button that was pressed.
803  */
804 void awe_webview_inject_mouse_down(awe_webview* webview,
805                                               awe_mousebutton button);
806 
807 /**
808  * Injects a mouse-up event.
809  *
810  * @param   button  The button that was released.
811  */
812 void awe_webview_inject_mouse_up(awe_webview* webview,
813                                             awe_mousebutton button);
814 
815 /**
816  * Injects a mouse-wheel event.
817  *
818  * @param   scrollAmountVert    The relative amount of pixels to scroll vertically.
819  *
820  * @param   scrollAmountHorz    The relative amount of pixels to scroll horizontally.
821  */
822 void awe_webview_inject_mouse_wheel(awe_webview* webview,
823                                                int scroll_amount_vert,
824                                                int scroll_amount_horz);
825 
826 /**
827  * Injects a keyboard event. You'll need to initialize the members of
828  * awe_webkeyboardevent yourself.
829  *
830  * @param   keyboardEvent   The keyboard event to inject.
831  */
832 void awe_webview_inject_keyboard_event(awe_webview* webview,
833                                                   awe_webkeyboardevent key_event);
834 
835 version(Windows) {
836     /**
837     * Injects a native Windows keyboard event.
838     *
839     * @param    msg The msg parameter.
840     * @param    wparam  The wparam parameter.
841     * @param    lparam  The lparam parameter.
842     */
843     void awe_webview_inject_keyboard_event_win(awe_webview* webview,
844                                                         UINT msg,
845                                                         WPARAM wparam,
846                                                         LPARAM lparam);
847 }
848 
849 /**
850  * Invokes a 'cut' action using the system clipboard.
851  */
852 void awe_webview_cut(awe_webview* webview);
853 
854 /**
855  * Invokes a 'copy' action using the system clipboard.
856  */
857 void awe_webview_copy(awe_webview* webview);
858 
859 /**
860  * Invokes a 'paste' action using the system clipboard.
861  */
862 void awe_webview_paste(awe_webview* webview);
863 
864 /**
865  * Selects all items on the current page.
866  */
867 void awe_webview_select_all(awe_webview* webview);
868 
869 /// Copies an image on the page to the system clipboard.
870 void awe_webview_copy_image_at(awe_webview* webview,
871                                           int x,
872                                           int y);
873 
874 /**
875  * Zooms the page a specified percent.
876  *
877  * @param   zoom_percent    The percent of the page to zoom to. Valid range
878  *                          is from 10% to 500%.
879  */
880 void awe_webview_set_zoom(awe_webview* webview,
881                                      int zoom_percent);
882 
883 /**
884  * Resets the zoom level.
885  */
886 void awe_webview_reset_zoom(awe_webview* webview);
887 
888 /// Gets the current zoom level.
889 int awe_webview_get_zoom(awe_webview* webview);
890 
891 /// Gets the zoom level for a specific hostname.
892 int awe_webview_get_zoom_for_host(awe_webview* webview,
893                                              const(awe_string)* host);
894 
895 /**
896  * Resizes this WebView to certain dimensions.
897  *
898  * @param   width   The width in pixels to resize to.
899  *
900  * @param   height  The height in pixels to resize to.
901  *
902  * @param   wait_for_repaint    Whether or not to wait for the WebView
903  *                          to finish repainting.
904  *
905  * @param   repaint_timeout_ms  The maximum amount of time to wait
906  *                              for a repaint, in milliseconds.
907  *
908  * @return  Returns true if the resize was successful. This operation
909  *          can fail if there is another resize already pending (see
910  *          awe_webview_is_resizing) or if the repaint timeout was exceeded.
911  */
912 bool awe_webview_resize(awe_webview* webview,
913                                    int width,
914                                    int height,
915                                    bool wait_for_repaint,
916                                    int repaint_timeout_ms);
917 
918 /**
919 * Checks whether or not there is a resize operation pending.
920 *
921 * @return   Returns true if we are waiting for the WebView process to
922 *           return acknowledgement of a pending resize operation.
923 */
924 bool awe_webview_is_resizing(awe_webview* webview);
925 
926 /**
927  * Notifies the current page that it has lost focus.
928  */
929 void awe_webview_unfocus(awe_webview* webview);
930 
931 /**
932  * Notifies the current page that is has gained focus. You will need
933  * to call this to gain textbox focus, among other things. (If you
934  * fail to ever see a blinking caret when typing text, this is why).
935  */
936 void awe_webview_focus(awe_webview* webview);
937 
938 /**
939  * Sets whether or not pages should be rendered with transparency
940  * preserved. (ex, for pages with style="background-color:transparent")
941  *
942  * @param   is_transparent  Whether or not this WebView is transparent.
943  */
944 void awe_webview_set_transparent(awe_webview* webview,
945                                             bool is_transparent);
946 
947 bool awe_webview_is_transparent(awe_webview* webview);
948 
949 /**
950  * Sets the current URL Filtering Mode (default is AWE_UFM_NONE).
951  * See awe_url_filtering_mode for more information on the modes.
952  *
953  * @param   mode    The URL filtering mode to use.
954  */
955 void awe_webview_set_url_filtering_mode(awe_webview* webview,
956                                                    awe_url_filtering_mode mode);
957 
958 /**
959  * Adds a new URL Filter rule.
960  *
961  * @param   filter  A string with optional wildcards that describes a
962  *                  certain URL.
963  *
964  * @note        For example, to match all URLs from the domain
965  *              "google.com", your filter string might be:
966  *                  http://google.com/*
967  *
968  * @note        You may also use the "local://" scheme prefix to
969  *              describe the URL to the base directory (set via
970  *              awe_webcore_set_base_directory).
971  */
972 void awe_webview_add_url_filter(awe_webview* webview,
973                                            const(awe_string)* filter);
974 
975 /**
976  * Clears all URL Filter rules.
977  */
978 void awe_webview_clear_all_url_filters(awe_webview* webview);
979 
980 /**
981  * Defines a new Header Definition or updates it if it already exists.
982  *
983  * @param   name    The unique name of the Header Definition; this is
984  *                  used to refer to it later in
985  *                  awe_webview_add_header_rewrite_rule and
986  *                  related methods.
987  *
988  * @param   num_fields  The number of fields in the header.
989  *
990  * @param   field_names An array of strings representing the field names
991  *
992  * @param   field_vales An array of strings representing the field values
993  */
994 void awe_webview_set_header_definition(awe_webview* webview,
995                                             const(awe_string)* name,
996                                             size_t num_fields,
997                                             const(awe_string*)* field_names,
998                                             const(awe_string*)* field_values);
999 
1000 /**
1001  * Adds a new a header re-write rule. All requests whose URL matches the
1002  * specified rule will have its  HTTP headers re-written with the
1003  * specified header definition before sending it to the server.
1004  *
1005  * @param   rule    A string with optional wildcards (*, ?) that
1006  *                  matches the URL(s) that will have its headers
1007  *                  re-written with the specified header definition.
1008  *
1009  * @param   name    The name of the header definition (specified in
1010  *                  awe_webview_set_header_definition).
1011  *
1012  * @note        The case where a URL is matched by multiple rules is
1013  *              unsupported, only the first match will be used.
1014  */
1015 void awe_webview_add_header_rewrite_rule(awe_webview* webview,
1016                                                     const(awe_string)* rule,
1017                                                     const(awe_string)* name);
1018 
1019 /**
1020  * Removes a header re-write rule from this WebView.
1021  *
1022  * @param   rule    The rule to remove (should match the string
1023  *                  specified in awe_webview_add_header_rewrite_rule exactly).
1024  */
1025 void awe_webview_remove_header_rewrite_rule(awe_webview* webview,
1026                                                        const(awe_string)* rule);
1027 
1028 /**
1029  * Removes all header re-write rules that are using a certain header
1030  * definition.
1031  *
1032  * @param   name    The name of the header definition (specified in
1033  *                  awe_webview_set_header_definition). If you specify an
1034  *                  empty string, this will remove ALL header re-write rules.
1035  */
1036 void awe_webview_remove_header_rewrite_rules_by_definition_name(
1037                                                         awe_webview* webview,
1038                                                         const(awe_string)* name);
1039 
1040 /**
1041  * This should be called as a response to the request file chooser callback.
1042  *
1043  * @param   file_path   The full path to the file that was chosen.
1044  */
1045 void awe_webview_choose_file(awe_webview* webview,
1046                                         const(awe_string)* file_path);
1047 
1048 /**
1049  * Print the current page. To suppress the printer selection dialog and
1050  * print immediately using the operating system's defaults, see
1051  * awe_webcore_set_suppress_printer_dialog.
1052  */
1053 void awe_webview_print(awe_webview* webview);
1054 
1055 /**
1056  * Request the page dimensions and scroll position of the page. You can
1057  * retrieve the response via the get scroll data callback.
1058  *
1059  * @param   frame_name  The frame's scroll data to retrieve. Leave blank
1060  *                      to get the main frame's scroll data.
1061  */
1062 void awe_webview_request_scroll_data(awe_webview* webview,
1063                                                 const(awe_string)* frame_name);
1064 
1065 /**
1066  * Start finding a certain string on the current web-page. All matches
1067  * of the string will be highlighted on the page and you can jump
1068  * to different instances of the string by using the 'findNext'
1069  * parameter. To get actual stats about a certain query, please see
1070  * awe_webview_set_callback_get_find_results.
1071  *
1072  * @param   request_id  A unique numeric ID for each search. You will
1073  *                      need to generate one yourself for each unique
1074  *                      search-- please note that you should use the
1075  *                      same request_id if you wish to iterate through
1076  *                      all the search results using the 'findNext'
1077  *                      parameter.
1078  *
1079  * @param   search_string   The string to search for.
1080  *
1081  * @param   forward     Whether or not we should search forward, down
1082  *                      the page.
1083  *
1084  * @param   case_sensitive  Whether or not this search is case-sensitive.
1085  *
1086  * @param   find_next   Whether or not we should jump to the next
1087  *                      instance of a search string (you should use
1088  *                      the same request_id as a previously-successful
1089  *                      search).
1090  */
1091 void awe_webview_find(awe_webview* webview,
1092                                  int request_id,
1093                                  const(awe_string)* search_string,
1094                                  bool forward,
1095                                  bool case_sensitive,
1096                                  bool find_next);
1097 
1098 
1099 /**
1100  * Stop finding. This will un-highlight all matches of a previous
1101  * call to awe_webview_find.
1102  *
1103  * @param   clear_selection Whether or not we should also deselect
1104  *                          the currently-selected string instance.
1105  */
1106 void awe_webview_stop_find(awe_webview* webview,
1107                                       bool clear_selection);
1108 
1109 /**
1110  * Attempt automatic translation of the current page via Google
1111  * Translate. All language codes are ISO 639-2.
1112  *
1113  * @param   source_language The language to translate from
1114  *                              (for ex. "en" for English)
1115  *
1116  * @param   target_language The language to translate to
1117  *                              (for ex. "fr" for French)
1118  */
1119 void awe_webview_translate_page(awe_webview* webview,
1120                                            const(awe_string)* source_language,
1121                                            const(awe_string)* target_language);
1122 
1123 /**
1124  * Call this method to let the WebView know you will be passing
1125  * text input via IME and will need to be notified of any
1126  * IME-related events (caret position, user unfocusing textbox, etc.)
1127  * Please see awe_webview_set_callback_update_ime
1128  */
1129 void awe_webview_activate_ime(awe_webview* webview,
1130                                          bool activate);
1131 
1132 /**
1133  * Update the current IME text composition.
1134  *
1135  * @param   inputString The string generated by your IME.
1136  * @param   cursorPos   The current cursor position in your IME composition.
1137  * @param   targetStart The position of the beginning of the selection.
1138  * @param   targetEnd   The position of the end of the selection.
1139  */
1140 void awe_webview_set_ime_composition(awe_webview* webview,
1141                                                 const(awe_string)* input_string,
1142                                                 int cursor_pos,
1143                                                 int target_start,
1144                                                 int target_end);
1145 
1146 /**
1147  * Confirm a current IME text composition.
1148  *
1149  * @param   inputString The string generated by your IME.
1150  */
1151 void awe_webview_confirm_ime_composition(awe_webview* webview,
1152                                                     const(awe_string)* input_string);
1153 
1154 /**
1155  * Cancel a current IME text composition.
1156  */
1157 void awe_webview_cancel_ime_composition(awe_webview* webview);
1158 
1159 /**
1160  * Respond to the "request login" callback with some user-supplied
1161  * credentials.
1162  *
1163  * @param   request_id  The unique ID of the request.
1164  *
1165  * @param   username    The username supplied by the user.
1166  *
1167  * @param   password    The password supplied by the user.
1168  */
1169 void awe_webview_login(awe_webview* webview,
1170                                   int request_id,
1171                                   const(awe_string)* username,
1172                                   const(awe_string)* password);
1173 
1174 /**
1175  * Respond to the "request login" callback by telling the
1176  * server that the user cancelled the authentication request.
1177  *
1178  * @param   request_id  The unique ID of the request.
1179  */
1180 void awe_webview_cancel_login(awe_webview* webview,
1181                                          int request_id);
1182 
1183 /**
1184  * Respond to the "show javascript dialog" callback.
1185  *
1186  * @param   request_id  The unique ID of the dialog request.
1187  *
1188  * @param   was_cancelled   Whether or not the dialog was cancelled/ignored.
1189  *
1190  * @param   prompt_text If the dialog had a prompt, you should pass whatever
1191  *                      text the user entered into the textbox via this parameter.
1192  */
1193 void awe_webview_close_javascript_dialog(awe_webview* webview,
1194                                                     int request_id,
1195                                                     bool was_cancelled,
1196                                                     const(awe_string)* prompt_text);
1197 
1198 /**
1199  * Assign a callback function to be notified when a WebView begins navigation
1200  * to a certain URL.
1201  *
1202  * @param   webview     The WebView instance.
1203  *
1204  * @param   callback    A function pointer to the callback.
1205  */
1206 void awe_webview_set_callback_begin_navigation(
1207                             awe_webview* webview,
1208                             void function(awe_webview* caller,
1209                                              const(awe_string)* url,
1210                                              const(awe_string)* frame_name) callback);
1211 
1212 /**
1213  * Assign a callback function to be notified when a WebView begins to actually
1214  * receive data from a server.
1215  *
1216  * @param   webview     The WebView instance.
1217  *
1218  * @param   callback    A function pointer to the callback.
1219  */
1220 void awe_webview_set_callback_begin_loading(
1221                             awe_webview* webview,
1222                             void function(awe_webview* caller,
1223                                              const(awe_string)* url,
1224                                              const(awe_string)* frame_name,
1225                                              int status_code,
1226                                              const(awe_string)* mime_type) callback);
1227 
1228 /**
1229  * Assign a callback function to be notified when a WebView has finished
1230  * all loads.
1231  *
1232  * @param   webview     The WebView instance.
1233  *
1234  * @param   callback    A function pointer to the callback.
1235  */
1236 void awe_webview_set_callback_finish_loading(
1237                             awe_webview* webview,
1238                             void function(awe_webview* caller) callback);
1239 
1240 /**
1241  * Assign a callback function to be notified when a Javascript object callback
1242  * has been invoked on a page.
1243  *
1244  * @param   webview     The WebView instance.
1245  *
1246  * @param   callback    A function pointer to the callback.
1247  */
1248 void awe_webview_set_callback_js_callback(
1249                             awe_webview* webview,
1250                             void function(awe_webview* caller,
1251                                              const(awe_string)* object_name,
1252                                              const(awe_string)* callback_name,
1253                                              const(awe_jsarray)* arguments) callback);
1254 
1255 /**
1256  * Assign a callback function to be notified when a page title is received.
1257  *
1258  * @param   webview     The WebView instance.
1259  *
1260  * @param   callback    A function pointer to the callback.
1261  */
1262 void awe_webview_set_callback_receive_title(
1263                             awe_webview* webview,
1264                             void function(awe_webview* caller,
1265                                              const(awe_string)* title,
1266                                              const(awe_string)* frame_name) callback);
1267 
1268 /**
1269  * Assign a callback function to be notified when a tooltip has changed state.
1270  *
1271  * @param   webview     The WebView instance.
1272  *
1273  * @param   callback    A function pointer to the callback.
1274  */
1275 void awe_webview_set_callback_change_tooltip(
1276                             awe_webview* webview,
1277                             void function(awe_webview* caller,
1278                                              const(awe_string)* tooltip) callback);
1279 
1280 /**
1281  * Assign a callback function to be notified when a cursor has changed state.
1282  *
1283  * @param   webview     The WebView instance.
1284  *
1285  * @param   callback    A function pointer to the callback.
1286  */
1287 void awe_webview_set_callback_change_cursor(
1288                             awe_webview* webview,
1289                             void function(awe_webview* caller,
1290                                              awe_cursor_type cursor) callback);
1291 
1292 /**
1293  * Assign a callback function to be notified when keyboard focus has changed.
1294  *
1295  * @param   webview     The WebView instance.
1296  *
1297  * @param   callback    A function pointer to the callback.
1298  */
1299 void awe_webview_set_callback_change_keyboard_focus(
1300                             awe_webview* webview,
1301                             void function(awe_webview* caller,
1302                                              bool is_focused) callback);
1303 
1304 /**
1305  * Assign a callback function to be notified when the target URL has changed.
1306  * This is usually the result of hovering over a link on the page.
1307  *
1308  * @param   webview     The WebView instance.
1309  *
1310  * @param   callback    A function pointer to the callback.
1311  */
1312 void awe_webview_set_callback_change_target_url(
1313                             awe_webview* webview,
1314                             void function(awe_webview* caller,
1315                                              const(awe_string)* url) callback);
1316 
1317 /**
1318  * Assign a callback function to be notified when an external link is attempted
1319  * to be opened. An external link is any link that normally opens in a new
1320  * window in a standard browser (for example, links with target="_blank",
1321  * calls to window.open(url), and URL open events from Flash plugins).
1322  *
1323  * @param   webview     The WebView instance.
1324  *
1325  * @param   callback    A function pointer to the callback.
1326  */
1327 void awe_webview_set_callback_open_external_link(
1328                             awe_webview* webview,
1329                             void function(awe_webview* caller,
1330                                              const(awe_string)* url,
1331                                              const(awe_string)* source) callback);
1332 
1333 /**
1334  * Assign a callback function to be notified when a page requests for a certain
1335  * URL to be downloaded by the user.
1336  *
1337  * @param   webview     The WebView instance.
1338  *
1339  * @param   callback    A function pointer to the callback.
1340  */
1341 void awe_webview_set_callback_request_download(
1342                             awe_webview* webview,
1343                             void function(awe_webview* caller,
1344                                              const(awe_string)* download) callback);
1345 
1346 /**
1347  * Assign a callback function to be notified when the renderer for a certain
1348  * WebView (which is isolated in a separate process) crashes unexpectedly.
1349  *
1350  * @param   webview     The WebView instance.
1351  *
1352  * @param   callback    A function pointer to the callback.
1353  */
1354 void awe_webview_set_callback_web_view_crashed(
1355                             awe_webview* webview,
1356                             void function(awe_webview* caller) callback);
1357 
1358 /**
1359  * Assign a callback function to be notified when when the renderer for a
1360  * certain plugin (usually Flash, which is isolated in a separate process)
1361  * crashes unexpectedly.
1362  *
1363  * @param   webview     The WebView instance.
1364  *
1365  * @param   callback    A function pointer to the callback.
1366  */
1367 void awe_webview_set_callback_plugin_crashed(
1368                             awe_webview* webview,
1369                             void function(awe_webview* caller,
1370                                              const(awe_string)* plugin_name) callback);
1371 
1372 /**
1373  * Assign a callback function to be notified when the page requests for the
1374  * containing window to be moved to a certain location on the screen.
1375  *
1376  * @param   webview     The WebView instance.
1377  *
1378  * @param   callback    A function pointer to the callback.
1379  */
1380 void awe_webview_set_callback_request_move(
1381                             awe_webview* webview,
1382                             void function(awe_webview* caller,
1383                                              int x,
1384                                              int y) callback);
1385 
1386 /**
1387  * Assign a callback function to be notified when the contents of the page has finished
1388  * loading. This occurs at the end of most page loads.
1389  *
1390  * @param   webview     The WebView instance.
1391  *
1392  * @param   callback    A function pointer to the callback.
1393  */
1394 void awe_webview_set_callback_get_page_contents(
1395                             awe_webview* webview,
1396                             void function(awe_webview* caller,
1397                                              const(awe_string)* url,
1398                                              const(awe_string)* contents) callback);
1399 
1400 /**
1401  * Assign a callback function to be notified once the DOM (Document Object
1402  * Model) for a page is ready. This is very useful for executing Javascript
1403  * on a page before its content has finished loading.
1404  *
1405  * @param   webview     The WebView instance.
1406  *
1407  * @param   callback    A function pointer to the callback.
1408  */
1409 void awe_webview_set_callback_dom_ready(
1410                             awe_webview* webview,
1411                             void function(awe_webview* caller) callback);
1412 
1413 /**
1414  * Assign a callback function to be notified whenever a page requests a file
1415  * chooser dialog to be displayed (usually the result of an "input" element
1416  * with type "file" being clicked by a user). You will need to display your
1417  * own dialog (it does not have to be modal, this request does not block).
1418  * Once a file has been chosen by the user, awe_webview_choose_file or
1419  * awe_webview_choose_multiple_files should be called.
1420  *
1421  * @param   webview     The WebView instance.
1422  *
1423  * @param   callback    A function pointer to the callback.
1424  */
1425 void awe_webview_set_callback_request_file_chooser(
1426                             awe_webview* webview,
1427                             void function(awe_webview* caller,
1428                                              bool select_multiple_files,
1429                                              const(awe_string)* title,
1430                                              const(awe_string)* default_path) callback);
1431 
1432 /**
1433  * Assign a callback function to be notified of a response to
1434  * awe_webview_request_scroll_data.
1435  *
1436  * @param   webview     The WebView instance.
1437  *
1438  * @param   callback    A function pointer to the callback.
1439  */
1440 void awe_webview_set_callback_get_scroll_data(
1441                             awe_webview* webview,
1442                             void function(awe_webview* caller,
1443                                              int contentWidth,
1444                                              int contentHeight,
1445                                              int preferredWidth,
1446                                              int scrollX,
1447                                              int scrollY) callback);
1448 
1449 /**
1450  * Assign a callback function to be notified of any Javascript
1451  * console messages. (Usually Javascript errors encountered in scripts)
1452  *
1453  * @param   webview     The WebView instance
1454  *
1455  * @param   callback    A function pointer to the callback.
1456  */
1457 void awe_webview_set_callback_js_console_message(
1458                             awe_webview* webview,
1459                             void function(awe_webview* caller,
1460                                            const(awe_string)* message,
1461                                            int line_number,
1462                                            const(awe_string)* source) callback);
1463 
1464 /**
1465  * Assign a callback function to be notified whenever we receive
1466  * results back from an in-page find operation (awe_webview_find).
1467  *
1468  * @param   webview     The WebView instance
1469  *
1470  * @param   callback    A function pointer to the callback.
1471  */
1472 void awe_webview_set_callback_get_find_results(
1473                             awe_webview* webview,
1474                             void function(awe_webview* caller,
1475                                            int request_id,
1476                                            int num_matches,
1477                                            awe_rect selection,
1478                                            int cur_match,
1479                                            bool finalUpdate) callback);
1480 
1481 /**
1482  * Assign a callback function to be notified whenever the user does
1483  * something that may change the position or visiblity of the IME Widget.
1484  * This callback is only active when IME is activated (please
1485  * see awe_webview_activate_ime).
1486  *
1487  * @param   webview     The WebView instance
1488  *
1489  * @param   callback    A function pointer to the callback.
1490  */
1491 void awe_webview_set_callback_update_ime(
1492                             awe_webview* webview,
1493                             void function(awe_webview* caller,
1494                                            awe_ime_state state,
1495                                            awe_rect caret_rect) callback);
1496 
1497 /**
1498  * Assign a callback function to be notified whenever the page requests
1499  * a context menu to be shown (usually the result of a user right-clicking
1500  * somewhere on the page). It is your responsiblity to display a menu for
1501  * the user to select an appropriate action.
1502  *
1503  * @param   webview The WebView instance
1504  *
1505  * @param   callback    A function pointer to the callback.
1506  */
1507 void awe_webview_set_callback_show_context_menu(
1508                             awe_webview* webview,
1509                             void function(awe_webview* caller,
1510                                        int mouse_x,
1511                                        int mouse_y,
1512                                        awe_media_type type,
1513                                        int media_state,
1514                                        const(awe_string)* link_url,
1515                                        const(awe_string)* src_url,
1516                                        const(awe_string)* page_url,
1517                                        const(awe_string)* frame_url,
1518                                        const(awe_string)* selection_text,
1519                                        bool is_editable,
1520                                        int edit_flags) callback);
1521 
1522 /**
1523  * Assign a callback function to be notified whenever a page requests
1524  * authentication from the user (ex, Basic HTTP Auth, NTLM Auth, etc.).
1525  * See awe_webview_login and awe_webview_cancel_login
1526  *
1527  * @param   webview The WebView instance
1528  *
1529  * @param   callback A function pointer to the callback.
1530  */
1531 void awe_webview_set_callback_request_login(
1532                             awe_webview* webview,
1533                             void function(awe_webview* caller,
1534                                    int request_id,
1535                                    const(awe_string)* request_url,
1536                                    bool is_proxy,
1537                                    const(awe_string)* host_and_port,
1538                                    const(awe_string)* scheme,
1539                                    const(awe_string)* realm) callback);
1540 
1541 /**
1542  * Assign a callback function to be notified whenever the history state
1543  * has changed. (eg, the state of thie back/forward buttons should be
1544  * updated)
1545  *
1546  * @param   webview The WebView instance
1547  *
1548  * @param   callback    A function pointer to the callback.
1549  */
1550 void awe_webview_set_callback_change_history(
1551                             awe_webview* webview,
1552                             void function(awe_webview* caller,
1553                                     int back_count,
1554                                     int forward_count) callback);
1555 
1556 /**
1557  * Assign a callback function to be notified whenever a WebView has
1558  * finished resizing to a certain size (and has finished repainting
1559  * the RenderBuffer).
1560  *
1561  * @param   webview The WebView instance
1562  *
1563  * @param   callback    A function pointer to the callback.
1564  */
1565 void awe_webview_set_callback_finish_resize(
1566                             awe_webview* webview,
1567                             void function(awe_webview* caller,
1568                                    int width,
1569                                    int height) callback);
1570 
1571 /**
1572  * Assign a callback function to be notified whenever a WebView
1573  * requests that a certain Javascript dialog be shown (eg, alert,
1574  * confirm, prompt). See awe_webview_close_javascript_dialog for
1575  * more information.
1576  *
1577  * @param   webview The WebView instance
1578  *
1579  * @param   callback    A function pointer to the callback.
1580  */
1581 void awe_webview_set_callback_show_javascript_dialog(
1582                             awe_webview* webview,
1583                             void function(awe_webview* caller,
1584                                             int request_id,
1585                                             int dialog_flags,
1586                                             const(awe_string)* message,
1587                                             const(awe_string)* default_prompt,
1588                                             const(awe_string)* frame_url) callback);
1589 
1590 /***********************
1591  * JS Value Functions  *
1592  ***********************/
1593 
1594 enum awe_jsvalue_type
1595 {
1596     JSVALUE_TYPE_NULL,
1597     JSVALUE_TYPE_BOOLEAN,
1598     JSVALUE_TYPE_INTEGER,
1599     JSVALUE_TYPE_DOUBLE,
1600     JSVALUE_TYPE_STRING,
1601     JSVALUE_TYPE_OBJECT,
1602     JSVALUE_TYPE_ARRAY
1603 }
1604 
1605 /**
1606  * Create a JSValue instance initialized as a null type. You must call
1607  * awe_jsvalue_destroy with the returned instance once you're done using it.
1608  */
1609 awe_jsvalue* awe_jsvalue_create_null_value();
1610 
1611 /**
1612  * Create a JSValue instance initialized with a boolean type. You must call
1613  * awe_jsvalue_destroy with the returned instance once you're done using it.
1614  *
1615  * @param   value   The initial value
1616  */
1617 awe_jsvalue* awe_jsvalue_create_bool_value(bool value);
1618 
1619 /**
1620  * Create a JSValue instance initialized with an integer type. You must call
1621  * awe_jsvalue_destroy with the returned instance once you're done using it.
1622  *
1623  * @param   value   The initial value
1624  */
1625 awe_jsvalue* awe_jsvalue_create_integer_value(int value);
1626 
1627 /**
1628  * Create a JSValue instance initialized with a double type. You must call
1629  * awe_jsvalue_destroy with the returned instance once you're done using it.
1630  *
1631  * @param   value   The initial value
1632  */
1633 awe_jsvalue* awe_jsvalue_create_double_value(double value);
1634 
1635 /**
1636  * Create a JSValue instance initialized with a string type. You must call
1637  * awe_jsvalue_destroy with the returned instance once you're done using it.
1638  *
1639  * @param   value   The initial value
1640  */
1641 awe_jsvalue* awe_jsvalue_create_string_value(const(awe_string)* value);
1642 
1643 /**
1644  * Create a JSValue instance initialized with an object type. You must call
1645  * awe_jsvalue_destroy with the returned instance once you're done using it.
1646  *
1647  * @param   value   The initial value
1648  */
1649 awe_jsvalue* awe_jsvalue_create_object_value(const(awe_jsobject)* value);
1650 
1651 /**
1652  * Create a JSValue instance initialized with an array type. You must call
1653  * awe_jsvalue_destroy with the returned instance once you're done using it.
1654  *
1655  * @param   value   The initial value
1656  */
1657 awe_jsvalue* awe_jsvalue_create_array_value(const(awe_jsarray)* value);
1658 
1659 /**
1660  * Destroys a JSValue instance.
1661  *
1662  * @param   jsvalue The JSValue instance.
1663  */
1664 void awe_jsvalue_destroy(awe_jsvalue* jsvalue);
1665 
1666 /**
1667  * Get the type of a JSValue.
1668  *
1669  * @param   jsvalue The JSValue instance.
1670  *
1671  * @return  Returns the type of the JSValue (see enum awe_jsvalue_type)
1672  */
1673 awe_jsvalue_type awe_jsvalue_get_type(const(awe_jsvalue)* jsvalue);
1674 
1675 /**
1676  * Get the value as a string.
1677  *
1678  * @param   jsvalue The JSValue instance.
1679  *
1680  * @return  Returns a string instance. You'll need to call awe_string_destroy
1681  *          with this instance when you're done using it.
1682  */
1683 awe_string* awe_jsvalue_to_string(const(awe_jsvalue)* jsvalue);
1684 
1685 /// Returns this value as an integer.
1686 int awe_jsvalue_to_integer(const(awe_jsvalue)* jsvalue);
1687 
1688 /// Returns this value as an double.
1689 double awe_jsvalue_to_double(const(awe_jsvalue)* jsvalue);
1690 
1691 /// Returns this value as an boolean.
1692 bool awe_jsvalue_to_boolean(const(awe_jsvalue)* jsvalue);
1693 
1694 /// Returns this value as an array. Will throw an exception if not an array.
1695 const(awe_jsarray)* awe_jsvalue_get_array(const(awe_jsvalue)* jsvalue);
1696 
1697 /// Returns this value as an object. Will throw an exception if not an object.
1698 const(awe_jsobject)* awe_jsvalue_get_object(const(awe_jsvalue)* jsvalue);
1699 
1700 /****************************
1701  * JS Value Array Functions *
1702  ****************************/
1703 
1704 /**
1705  * Create a JSValue Array.
1706  *
1707  * @param   jsvalue_array   An array of JSValue instances to be copied from.
1708  * @param   length      Length of the array.
1709  */
1710 awe_jsarray* awe_jsarray_create(const(awe_jsvalue*)* jsvalue_array,
1711                                            size_t length);
1712 
1713 /**
1714  * Destroys a JSValue Array created with awe_jsarray_create.
1715  */
1716 void awe_jsarray_destroy(awe_jsarray* jsarray);
1717 
1718 /**
1719  * Get the size of a JSValue Array.
1720  */
1721 size_t awe_jsarray_get_size(const(awe_jsarray)* jsarray);
1722 
1723 /**
1724  * Get a specific element of a JSValue Array. The Array retains ownership
1725  * of the returned JSValue instance (you do not need to destroy it).
1726  */
1727 const(awe_jsvalue)* awe_jsarray_get_element(const(awe_jsarray)* jsarray,
1728                                                        size_t index);
1729 
1730 /*****************************
1731  * JS Value Object Functions *
1732  *****************************/
1733 
1734 /**
1735  * Creates a JSValue Object.
1736  */
1737 awe_jsobject* awe_jsobject_create();
1738 
1739 /**
1740  * Destroys a JSValue Object created with awe_jsobject_create
1741  */
1742 void awe_jsobject_destroy(awe_jsobject* jsobject);
1743 
1744 /**
1745  * Returns whether or not a JSValue Object has a certained named property.
1746  */
1747 bool awe_jsobject_has_property(const(awe_jsobject)* jsobject,
1748                                           const(awe_string)* property_name);
1749 
1750 /**
1751  * Gets the value of a certain named property of a JSValue Object. You do not
1752  * need to destroy the returned jsvalue instance, it is owned by the object.
1753  */
1754 const(awe_jsvalue)* awe_jsobject_get_property(const(awe_jsobject)* jsobject,
1755                                                         const(awe_string)* property_name);
1756 
1757 /**
1758  * Sets the value of a certained named property of a JSValue Object.
1759  */
1760 void awe_jsobject_set_property(awe_jsobject* jsobject,
1761                                           const(awe_string)* property_name,
1762                                           const(awe_jsvalue)* value);
1763 
1764 /**
1765  * Get the number of key/value pairs in a JSValue object.
1766  */
1767 size_t awe_jsobject_get_size(awe_jsobject* jsobject);
1768 
1769 /**
1770  * Get a list of all key names as a JSValue Array, you need to call
1771  * awe_jsarray_destroy on the returned value after you're done using it.
1772  */
1773 awe_jsarray* awe_jsobject_get_keys(awe_jsobject* jsobject);
1774 
1775 /***************************
1776  * Render Buffer Functions *
1777  ***************************/
1778 
1779 /**
1780  * Get the width (in pixels) of a RenderBuffer.
1781  */
1782 int awe_renderbuffer_get_width(const(awe_renderbuffer)* renderbuffer);
1783 
1784 /**
1785  * Get the height (in pixels) of a RenderBuffer.
1786  */
1787 int awe_renderbuffer_get_height(const(awe_renderbuffer)* renderbuffer);
1788 
1789 /**
1790  * Get the rowspan (number of bytes per row) of a RenderBuffer.
1791  */
1792 int awe_renderbuffer_get_rowspan(const(awe_renderbuffer)* renderbuffer);
1793 
1794 /**
1795  * Get a pointer to the actual pixel buffer within a RenderBuffer.
1796  */
1797 const(ubyte)* awe_renderbuffer_get_buffer(const(awe_renderbuffer)* renderbuffer);
1798 
1799 /**
1800  * Copy a RenderBuffer to a specific destination with the same dimensions.
1801  */
1802 void awe_renderbuffer_copy_to(const(awe_renderbuffer)* renderbuffer,
1803                                          ubyte* dest_buffer,
1804                                          int dest_rowspan,
1805                                          int dest_depth,
1806                                          bool convert_to_rgba,
1807                                          bool flip_y);
1808 
1809 /**
1810  * Copy a RenderBuffer to a pixel buffer with a floating-point pixel format
1811  * for use with game engines like Unity3D.
1812  */
1813 void awe_renderbuffer_copy_to_float(const(awe_renderbuffer)* renderbuffer,
1814                                                float* dest_buffer);
1815 
1816 /**
1817  * Save a copy of this RenderBuffer to a PNG image file.
1818  */
1819 bool awe_renderbuffer_save_to_png(const(awe_renderbuffer)* renderbuffer,
1820                                              const(awe_string)* file_path,
1821                                              bool preserve_transparency);
1822 
1823 /**
1824  * Save a copy of this RenderBuffer to a JPEG image file with quality 1 to 100.
1825  */
1826 bool awe_renderbuffer_save_to_jpeg(const(awe_renderbuffer)* renderbuffer,
1827                                               const(awe_string)* file_path,
1828                                               int quality);
1829 
1830 /**
1831  * Get the alpha value at a certain point (origin is top-left). This is
1832  * useful for alpha-picking.
1833  *
1834  * @param   x   The x-value of the point.
1835  * @param   y   The y-value of the point.
1836  *
1837  * @return  Returns the alpha value at a certain point (255 is comppletely
1838  *          opaque, 0 is completely transparent).
1839  */
1840 ubyte awe_renderbuffer_get_alpha_at_point(const(awe_renderbuffer)* renderbuffer,
1841                                                              int x,
1842                                                              int y);
1843 
1844 /**
1845  * Sets the alpha channel to completely opaque values.
1846  */
1847 void awe_renderbuffer_flush_alpha(const(awe_renderbuffer)* renderbuffer);
1848 
1849 /************************
1850  * Resource Interceptor *
1851  ************************/
1852 
1853 /**
1854  * Assign a callback function to intercept requests for resources. You can use
1855  * this to modify requests before they are sent, respond to requests using
1856  * your own custom resource-loading back-end, or to monitor requests for
1857  * tracking purposes.
1858  *
1859  * @param   webview     The WebView instance.
1860  *
1861  * @param   callback    A function pointer to the callback.
1862  */
1863 void awe_webview_set_callback_resource_request(
1864                             awe_webview* webview,
1865                             awe_resource_response* function(
1866                                 awe_webview* caller,
1867                                 awe_resource_request* request) callback);
1868 
1869 /**
1870  * Assign a callback function to intercept responses to requests. You can use
1871  * this for tracking/statistic purposes.
1872  */
1873 void awe_webview_set_callback_resource_response(
1874                             awe_webview* webview,
1875                             void function(
1876                                 awe_webview* caller,
1877                                 const(awe_string)* url,
1878                                 int status_code,
1879                                 bool was_cached,
1880                                 int64 request_time_ms,
1881                                 int64 response_time_ms,
1882                                 int64 expected_content_size,
1883                                 const(awe_string)* mime_type) callback);
1884 
1885 /**
1886  * Create a ResourceResponse from a raw block of data. (Buffer is copied)
1887  */
1888 awe_resource_response* awe_resource_response_create(
1889                                                   size_t num_bytes,
1890                                                   ubyte* buffer,
1891                                                   const(awe_string)* mime_type);
1892 
1893 /**
1894  * Create a ResourceResponse from a file on disk.
1895  */
1896 awe_resource_response* awe_resource_response_create_from_file(
1897                                                   const(awe_string)* file_path);
1898 
1899 /************************
1900  * Resource Request     *
1901  ************************/
1902 
1903 /// Cancel the request (this is useful for blocking a resource load).
1904 void awe_resource_request_cancel(awe_resource_request* request);
1905 
1906 /// Get the URL associated with this request. (You must destroy returned string)
1907 awe_string* awe_resource_request_get_url(awe_resource_request* request);
1908 
1909 /// Get the HTTP method (usually "GET" or "POST") (You must destroy returned string)
1910 awe_string* awe_resource_request_get_method(awe_resource_request* request);
1911 
1912 /// Set the HTTP method
1913 void awe_resource_request_set_method(awe_resource_request* request,
1914                                                 const(awe_string)* method);
1915 
1916 /// Get the referrer  (You must destroy returned string)
1917 awe_string* awe_resource_request_get_referrer(awe_resource_request* request);
1918 
1919 /// Set the referrer
1920 void awe_resource_request_set_referrer(awe_resource_request* request,
1921                                                   const(awe_string)* referrer);
1922 
1923 /// Get extra headers for the request (You must destroy returned string)
1924 awe_string* awe_resource_request_get_extra_headers(awe_resource_request* request);
1925 
1926 /**
1927  * Override extra headers for the request, delimited by /r/n (CRLF).
1928  *
1929  * Format should be:
1930  *   Name: Value/r/nName: Value/r/nName: Value
1931  *
1932  * Headers should NOT end in /r/n (CRLF)
1933  */
1934 void awe_resource_request_set_extra_headers(awe_resource_request* request,
1935                                                 const(awe_string)* headers);
1936 
1937 /**
1938  * Append an extra header to the request.
1939  *
1940  * @param   name    Name of the header
1941  * @param   value   Value of the header
1942  */
1943 void awe_resource_request_append_extra_header(awe_resource_request* request,
1944                                                          const(awe_string)* name,
1945                                                          const(awe_string)* value);
1946 
1947 /// Get the number of upload elements (essentially, batches of POST data).
1948 size_t awe_resource_request_get_num_upload_elements(awe_resource_request* request);
1949 
1950 /// Get a certain upload element (returned instance is owned by this class)
1951 const(awe_upload_element)* awe_resource_request_get_upload_element(awe_resource_request* request,
1952                                                                              size_t idx);
1953 
1954 /// Clear all upload elements
1955 void awe_resource_request_clear_upload_elements(awe_resource_request* request);
1956 
1957 /// Append a file for POST data (adds a new UploadElement)
1958 void awe_resource_request_append_upload_file_path(awe_resource_request* request,
1959                                                              const(awe_string)* file_path);
1960 
1961 /// Append a string of bytes for POST data (adds a new UploadElement)
1962 void awe_resource_request_append_upload_bytes(awe_resource_request* request,
1963                                                          const(awe_string)* bytes);
1964 
1965 /************************
1966  * Upload Element       *
1967  ************************/
1968 
1969 /// Whether or not this UploadElement is a file
1970 bool awe_upload_element_is_file_path(const(awe_upload_element)* ele);
1971 
1972 /// Whether or not this UploadElement is a string of bytes
1973 bool awe_upload_element_is_bytes(const(awe_upload_element)* ele);
1974 
1975 /// Get the string of bytes associated with this UploadElement (You must destroy returned string)
1976 awe_string* awe_upload_element_get_bytes(const(awe_upload_element)* ele);
1977 
1978 /// Get the file path associated with this UploadElement (You must destroy returned string)
1979 awe_string* awe_upload_element_get_file_path(const(awe_upload_element)* ele);
1980 
1981 
1982 /************************
1983  * History Query Result *
1984  ************************/
1985 
1986 /// Destroy the instance (you must call this once you're done using the instance)
1987 void awe_history_query_result_destroy(awe_history_query_result* res);
1988 
1989 /// Get the total number of entries
1990 size_t awe_history_query_result_get_size(awe_history_query_result* res);
1991 
1992 /// Get a certain entry (you must destroy any returned entry using awe_history_entry_destroy).
1993 /// May return NULL if the index is out of bounds.
1994 awe_history_entry* awe_history_query_result_get_entry_at_index(awe_history_query_result* res,
1995                                                                           size_t idx);
1996 
1997 /************************
1998  * History Entry        *
1999  ************************/
2000 
2001 /// Destroy the instance
2002 void awe_history_entry_destroy(awe_history_entry* entry);
2003 
2004 /// Get the URL of the page
2005 awe_string* awe_history_entry_get_url(awe_history_entry* entry);
2006 
2007 /// Get the title of the page
2008 awe_string* awe_history_entry_get_title(awe_history_entry* entry);
2009 
2010 /// Get the last time this page was visited (in seconds since epoch)
2011 double awe_history_entry_get_visit_time(awe_history_entry* entry);
2012 
2013 /// Get the number of times this page was visited.
2014 int awe_history_entry_get_visit_count(awe_history_entry* entry);
2015 
2016 }
2017 
2018 /**
2019  * @mainpage Awesomium C API
2020  *
2021  * @section intro_sec Introduction
2022  *
2023  * Hi there, welcome to the Awesomium C API docs! Awesomium is a software
2024  * library that makes it easy to put the web in your applications. Whether
2025  * that means embedded web browsing, rendering pages as images, streaming
2026  * pages over the net, or manipulating web content live for some other
2027  * purpose, Awesomium does it all.
2028  *
2029  * Our C API provides much more compatibility than our C++ API at the cost
2030  * of some extra convenience.
2031  *
2032  * To start off, we'd recommend looking at some of the following functions:
2033  * <pre>
2034  *    awe_webcore_initialize()
2035  *    awe_webcore_initialize_default()
2036  *    awe_webcore_shutdown()
2037  *    awe_webcore_create_webview()
2038  *    awe_webview_load_url()
2039  *    awe_webview_render()
2040  *    awe_webview_destroy()
2041  * </pre>
2042  *
2043  * To avoid memory leaks, there is one major rule that you must follow in
2044  * our C API regarding ownership of returned objects: if a function returns
2045  * a regular pointer to an instance, you must destroy the instance using the
2046  * relevant method. Otherwise, if a function returns a const pointer to an
2047  * instance, you should not destroy it (ownership is retained by Awesomium).
2048  *
2049  * For example, you must destroy all strings you create in Awesomium:
2050  *
2051  * <pre>
2052  *     awe_string* str = awe_string_create_from_ascii("Hello", strlen("Hello"));
2053  *
2054  *     // Use the string somewhere... then destroy it when we are done:
2055  *
2056  *     awe_string_destroy(str);
2057  * </pre>
2058  *
2059  * But you should not destroy certain strings returned from certain methods:
2060  *
2061  * <pre>
2062  *     const(awe_string)* str = awe_webcore_get_base_directory();
2063  *
2064  *     // We do not need to destroy this string: when a function returns
2065  *     // a const pointer in Awesomium, it means ownership is retained by
2066  *     // Awesomium and the instance will be destroyed automatically later.
2067  * </pre>
2068  *
2069  * For more help and tips with the API, please visit our Knowledge Base
2070  *     <http://support.awesomium.com/faqs>
2071  *
2072  * @section usefullinks_sec Useful Links
2073  * - Awesomium Main: <http://www.awesomium.com>
2074  * - Support Home: <http://support.awesomium.com>
2075  *
2076  * @section copyright_sec Copyright
2077  * This documentation is copyright (C) 2011 Khrona. All rights reserved.
2078  * Awesomium is a trademark of Khrona.
2079  */