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_V8_CAPI_H_
38 #define CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_
41 #include "include/capi/cef_base_capi.h"
42 #include "include/capi/cef_browser_capi.h"
43 #include "include/capi/cef_frame_capi.h"
44 #include "include/capi/cef_task_capi.h"
50 struct _cef_v8exception_t;
51 struct _cef_v8handler_t;
52 struct _cef_v8stack_frame_t;
53 struct _cef_v8value_t;
56 // Structure representing a V8 context handle. V8 handles can only be accessed
57 // from the thread on which they are created. Valid threads for creating a V8
58 // handle include the render process main thread (TID_RENDERER) and WebWorker
59 // threads. A task runner for posting tasks on the associated thread can be
60 // retrieved via the cef_v8context_t::get_task_runner() function.
62 typedef struct _cef_v8context_t {
69 // Returns the task runner associated with this context. V8 handles can only
70 // be accessed from the thread on which they are created. This function can be
71 // called on any render process thread.
73 struct _cef_task_runner_t* (CEF_CALLBACK *get_task_runner)(
74 struct _cef_v8context_t* self);
77 // Returns true (1) if the underlying handle is valid and it can be accessed
78 // on the current thread. Do not call any other functions if this function
81 int (CEF_CALLBACK *is_valid)(struct _cef_v8context_t* self);
84 // Returns the browser for this context. This function will return an NULL
85 // reference for WebWorker contexts.
87 struct _cef_browser_t* (CEF_CALLBACK *get_browser)(
88 struct _cef_v8context_t* self);
91 // Returns the frame for this context. This function will return an NULL
92 // reference for WebWorker contexts.
94 struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_v8context_t* self);
97 // Returns the global object for this context. The context must be entered
98 // before calling this function.
100 struct _cef_v8value_t* (CEF_CALLBACK *get_global)(
101 struct _cef_v8context_t* self);
104 // Enter this context. A context must be explicitly entered before creating a
105 // V8 Object, Array, Function or Date asynchronously. exit() must be called
106 // the same number of times as enter() before releasing this context. V8
107 // objects belong to the context in which they are created. Returns true (1)
108 // if the scope was entered successfully.
110 int (CEF_CALLBACK *enter)(struct _cef_v8context_t* self);
113 // Exit this context. Call this function only after calling enter(). Returns
114 // true (1) if the scope was exited successfully.
116 int (CEF_CALLBACK *exit)(struct _cef_v8context_t* self);
119 // Returns true (1) if this object is pointing to the same handle as |that|
122 int (CEF_CALLBACK *is_same)(struct _cef_v8context_t* self,
123 struct _cef_v8context_t* that);
126 // Evaluates the specified JavaScript code using this context's global object.
127 // On success |retval| will be set to the return value, if any, and the
128 // function will return true (1). On failure |exception| will be set to the
129 // exception, if any, and the function will return false (0).
131 int (CEF_CALLBACK *eval)(struct _cef_v8context_t* self,
132 const cef_string_t* code, struct _cef_v8value_t** retval,
133 struct _cef_v8exception_t** exception);
138 // Returns the current (top) context object in the V8 context stack.
140 CEF_EXPORT cef_v8context_t* cef_v8context_get_current_context();
143 // Returns the entered (bottom) context object in the V8 context stack.
145 CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context();
148 // Returns true (1) if V8 is currently inside a context.
150 CEF_EXPORT int cef_v8context_in_context();
154 // Structure that should be implemented to handle V8 function calls. The
155 // functions of this structure will be called on the thread associated with the
158 typedef struct _cef_v8handler_t {
165 // Handle execution of the function identified by |name|. |object| is the
166 // receiver ('this' object) of the function. |arguments| is the list of
167 // arguments passed to the function. If execution succeeds set |retval| to the
168 // function return value. If execution fails set |exception| to the exception
169 // that will be thrown. Return true (1) if execution was handled.
171 int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self,
172 const cef_string_t* name, struct _cef_v8value_t* object,
173 size_t argumentsCount, struct _cef_v8value_t* const* arguments,
174 struct _cef_v8value_t** retval, cef_string_t* exception);
179 // Structure that should be implemented to handle V8 accessor calls. Accessor
180 // identifiers are registered by calling cef_v8value_t::set_value(). The
181 // functions of this structure will be called on the thread associated with the
184 typedef struct _cef_v8accessor_t {
191 // Handle retrieval the accessor value identified by |name|. |object| is the
192 // receiver ('this' object) of the accessor. If retrieval succeeds set
193 // |retval| to the return value. If retrieval fails set |exception| to the
194 // exception that will be thrown. Return true (1) if accessor retrieval was
197 int (CEF_CALLBACK *get)(struct _cef_v8accessor_t* self,
198 const cef_string_t* name, struct _cef_v8value_t* object,
199 struct _cef_v8value_t** retval, cef_string_t* exception);
202 // Handle assignment of the accessor value identified by |name|. |object| is
203 // the receiver ('this' object) of the accessor. |value| is the new value
204 // being assigned to the accessor. If assignment fails set |exception| to the
205 // exception that will be thrown. Return true (1) if accessor assignment was
208 int (CEF_CALLBACK *set)(struct _cef_v8accessor_t* self,
209 const cef_string_t* name, struct _cef_v8value_t* object,
210 struct _cef_v8value_t* value, cef_string_t* exception);
215 // Structure representing a V8 exception. The functions of this structure may be
216 // called on any render process thread.
218 typedef struct _cef_v8exception_t {
225 // Returns the exception message.
227 // The resulting string must be freed by calling cef_string_userfree_free().
228 cef_string_userfree_t (CEF_CALLBACK *get_message)(
229 struct _cef_v8exception_t* self);
232 // Returns the line of source code that the exception occurred within.
234 // The resulting string must be freed by calling cef_string_userfree_free().
235 cef_string_userfree_t (CEF_CALLBACK *get_source_line)(
236 struct _cef_v8exception_t* self);
239 // Returns the resource name for the script from where the function causing
240 // the error originates.
242 // The resulting string must be freed by calling cef_string_userfree_free().
243 cef_string_userfree_t (CEF_CALLBACK *get_script_resource_name)(
244 struct _cef_v8exception_t* self);
247 // Returns the 1-based number of the line where the error occurred or 0 if the
248 // line number is unknown.
250 int (CEF_CALLBACK *get_line_number)(struct _cef_v8exception_t* self);
253 // Returns the index within the script of the first character where the error
256 int (CEF_CALLBACK *get_start_position)(struct _cef_v8exception_t* self);
259 // Returns the index within the script of the last character where the error
262 int (CEF_CALLBACK *get_end_position)(struct _cef_v8exception_t* self);
265 // Returns the index within the line of the first character where the error
268 int (CEF_CALLBACK *get_start_column)(struct _cef_v8exception_t* self);
271 // Returns the index within the line of the last character where the error
274 int (CEF_CALLBACK *get_end_column)(struct _cef_v8exception_t* self);
279 // Structure representing a V8 value handle. V8 handles can only be accessed
280 // from the thread on which they are created. Valid threads for creating a V8
281 // handle include the render process main thread (TID_RENDERER) and WebWorker
282 // threads. A task runner for posting tasks on the associated thread can be
283 // retrieved via the cef_v8context_t::get_task_runner() function.
285 typedef struct _cef_v8value_t {
292 // Returns true (1) if the underlying handle is valid and it can be accessed
293 // on the current thread. Do not call any other functions if this function
294 // returns false (0).
296 int (CEF_CALLBACK *is_valid)(struct _cef_v8value_t* self);
299 // True if the value type is undefined.
301 int (CEF_CALLBACK *is_undefined)(struct _cef_v8value_t* self);
304 // True if the value type is null.
306 int (CEF_CALLBACK *is_null)(struct _cef_v8value_t* self);
309 // True if the value type is bool.
311 int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* self);
314 // True if the value type is int.
316 int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* self);
319 // True if the value type is unsigned int.
321 int (CEF_CALLBACK *is_uint)(struct _cef_v8value_t* self);
324 // True if the value type is double.
326 int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* self);
329 // True if the value type is Date.
331 int (CEF_CALLBACK *is_date)(struct _cef_v8value_t* self);
334 // True if the value type is string.
336 int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* self);
339 // True if the value type is object.
341 int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* self);
344 // True if the value type is array.
346 int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* self);
349 // True if the value type is function.
351 int (CEF_CALLBACK *is_function)(struct _cef_v8value_t* self);
354 // Returns true (1) if this object is pointing to the same handle as |that|
357 int (CEF_CALLBACK *is_same)(struct _cef_v8value_t* self,
358 struct _cef_v8value_t* that);
361 // Return a bool value. The underlying data will be converted to if
364 int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self);
367 // Return an int value. The underlying data will be converted to if
370 int32 (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self);
373 // Return an unisgned int value. The underlying data will be converted to if
376 uint32 (CEF_CALLBACK *get_uint_value)(struct _cef_v8value_t* self);
379 // Return a double value. The underlying data will be converted to if
382 double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self);
385 // Return a Date value. The underlying data will be converted to if
388 cef_time_t (CEF_CALLBACK *get_date_value)(struct _cef_v8value_t* self);
391 // Return a string value. The underlying data will be converted to if
394 // The resulting string must be freed by calling cef_string_userfree_free().
395 cef_string_userfree_t (CEF_CALLBACK *get_string_value)(
396 struct _cef_v8value_t* self);
399 // OBJECT METHODS - These functions are only available on objects. Arrays and
400 // functions are also objects. String- and integer-based keys can be used
401 // interchangably with the framework converting between them as necessary.
404 // Returns true (1) if this is a user created object.
406 int (CEF_CALLBACK *is_user_created)(struct _cef_v8value_t* self);
409 // Returns true (1) if the last function call resulted in an exception. This
410 // attribute exists only in the scope of the current CEF value object.
412 int (CEF_CALLBACK *has_exception)(struct _cef_v8value_t* self);
415 // Returns the exception resulting from the last function call. This attribute
416 // exists only in the scope of the current CEF value object.
418 struct _cef_v8exception_t* (CEF_CALLBACK *get_exception)(
419 struct _cef_v8value_t* self);
422 // Clears the last exception and returns true (1) on success.
424 int (CEF_CALLBACK *clear_exception)(struct _cef_v8value_t* self);
427 // Returns true (1) if this object will re-throw future exceptions. This
428 // attribute exists only in the scope of the current CEF value object.
430 int (CEF_CALLBACK *will_rethrow_exceptions)(struct _cef_v8value_t* self);
433 // Set whether this object will re-throw future exceptions. By default
434 // exceptions are not re-thrown. If a exception is re-thrown the current
435 // context should not be accessed again until after the exception has been
436 // caught and not re-thrown. Returns true (1) on success. This attribute
437 // exists only in the scope of the current CEF value object.
439 int (CEF_CALLBACK *set_rethrow_exceptions)(struct _cef_v8value_t* self,
443 // Returns true (1) if the object has a value with the specified identifier.
445 int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self,
446 const cef_string_t* key);
449 // Returns true (1) if the object has a value with the specified identifier.
451 int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index);
454 // Deletes the value with the specified identifier and returns true (1) on
455 // success. Returns false (0) if this function is called incorrectly or an
456 // exception is thrown. For read-only and don't-delete values this function
457 // will return true (1) even though deletion failed.
459 int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self,
460 const cef_string_t* key);
463 // Deletes the value with the specified identifier and returns true (1) on
464 // success. Returns false (0) if this function is called incorrectly, deletion
465 // fails or an exception is thrown. For read-only and don't-delete values this
466 // function will return true (1) even though deletion failed.
468 int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self,
472 // Returns the value with the specified identifier on success. Returns NULL if
473 // this function is called incorrectly or an exception is thrown.
475 struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)(
476 struct _cef_v8value_t* self, const cef_string_t* key);
479 // Returns the value with the specified identifier on success. Returns NULL if
480 // this function is called incorrectly or an exception is thrown.
482 struct _cef_v8value_t* (CEF_CALLBACK *get_value_byindex)(
483 struct _cef_v8value_t* self, int index);
486 // Associates a value with the specified identifier and returns true (1) on
487 // success. Returns false (0) if this function is called incorrectly or an
488 // exception is thrown. For read-only values this function will return true
489 // (1) even though assignment failed.
491 int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self,
492 const cef_string_t* key, struct _cef_v8value_t* value,
493 cef_v8_propertyattribute_t attribute);
496 // Associates a value with the specified identifier and returns true (1) on
497 // success. Returns false (0) if this function is called incorrectly or an
498 // exception is thrown. For read-only values this function will return true
499 // (1) even though assignment failed.
501 int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index,
502 struct _cef_v8value_t* value);
505 // Registers an identifier and returns true (1) on success. Access to the
506 // identifier will be forwarded to the cef_v8accessor_t instance passed to
507 // cef_v8value_t::cef_v8value_create_object(). Returns false (0) if this
508 // function is called incorrectly or an exception is thrown. For read-only
509 // values this function will return true (1) even though assignment failed.
511 int (CEF_CALLBACK *set_value_byaccessor)(struct _cef_v8value_t* self,
512 const cef_string_t* key, cef_v8_accesscontrol_t settings,
513 cef_v8_propertyattribute_t attribute);
516 // Read the keys for the object's values into the specified vector. Integer-
517 // based keys will also be returned as strings.
519 int (CEF_CALLBACK *get_keys)(struct _cef_v8value_t* self,
520 cef_string_list_t keys);
523 // Sets the user data for this object and returns true (1) on success. Returns
524 // false (0) if this function is called incorrectly. This function can only be
525 // called on user created objects.
527 int (CEF_CALLBACK *set_user_data)(struct _cef_v8value_t* self,
528 struct _cef_base_t* user_data);
531 // Returns the user data, if any, assigned to this object.
533 struct _cef_base_t* (CEF_CALLBACK *get_user_data)(
534 struct _cef_v8value_t* self);
537 // Returns the amount of externally allocated memory registered for the
540 int (CEF_CALLBACK *get_externally_allocated_memory)(
541 struct _cef_v8value_t* self);
544 // Adjusts the amount of registered external memory for the object. Used to
545 // give V8 an indication of the amount of externally allocated memory that is
546 // kept alive by JavaScript objects. V8 uses this information to decide when
547 // to perform global garbage collection. Each cef_v8value_t tracks the amount
548 // of external memory associated with it and automatically decreases the
549 // global total by the appropriate amount on its destruction.
550 // |change_in_bytes| specifies the number of bytes to adjust by. This function
551 // returns the number of bytes associated with the object after the
552 // adjustment. This function can only be called on user created objects.
554 int (CEF_CALLBACK *adjust_externally_allocated_memory)(
555 struct _cef_v8value_t* self, int change_in_bytes);
558 // ARRAY METHODS - These functions are only available on arrays.
561 // Returns the number of elements in the array.
563 int (CEF_CALLBACK *get_array_length)(struct _cef_v8value_t* self);
566 // FUNCTION METHODS - These functions are only available on functions.
569 // Returns the function name.
571 // The resulting string must be freed by calling cef_string_userfree_free().
572 cef_string_userfree_t (CEF_CALLBACK *get_function_name)(
573 struct _cef_v8value_t* self);
576 // Returns the function handler or NULL if not a CEF-created function.
578 struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)(
579 struct _cef_v8value_t* self);
582 // Execute the function using the current V8 context. This function should
583 // only be called from within the scope of a cef_v8handler_t or
584 // cef_v8accessor_t callback, or in combination with calling enter() and
585 // exit() on a stored cef_v8context_t reference. |object| is the receiver
586 // ('this' object) of the function. If |object| is NULL the current context's
587 // global object will be used. |arguments| is the list of arguments that will
588 // be passed to the function. Returns the function return value on success.
589 // Returns NULL if this function is called incorrectly or an exception is
592 struct _cef_v8value_t* (CEF_CALLBACK *execute_function)(
593 struct _cef_v8value_t* self, struct _cef_v8value_t* object,
594 size_t argumentsCount, struct _cef_v8value_t* const* arguments);
597 // Execute the function using the specified V8 context. |object| is the
598 // receiver ('this' object) of the function. If |object| is NULL the specified
599 // context's global object will be used. |arguments| is the list of arguments
600 // that will be passed to the function. Returns the function return value on
601 // success. Returns NULL if this function is called incorrectly or an
602 // exception is thrown.
604 struct _cef_v8value_t* (CEF_CALLBACK *execute_function_with_context)(
605 struct _cef_v8value_t* self, struct _cef_v8context_t* context,
606 struct _cef_v8value_t* object, size_t argumentsCount,
607 struct _cef_v8value_t* const* arguments);
612 // Create a new cef_v8value_t object of type undefined.
614 CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined();
617 // Create a new cef_v8value_t object of type null.
619 CEF_EXPORT cef_v8value_t* cef_v8value_create_null();
622 // Create a new cef_v8value_t object of type bool.
624 CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value);
627 // Create a new cef_v8value_t object of type int.
629 CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int32 value);
632 // Create a new cef_v8value_t object of type unsigned int.
634 CEF_EXPORT cef_v8value_t* cef_v8value_create_uint(uint32 value);
637 // Create a new cef_v8value_t object of type double.
639 CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value);
642 // Create a new cef_v8value_t object of type Date. This function should only be
643 // called from within the scope of a cef_render_process_handler_t,
644 // cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
645 // enter() and exit() on a stored cef_v8context_t reference.
647 CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date);
650 // Create a new cef_v8value_t object of type string.
652 CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value);
655 // Create a new cef_v8value_t object of type object with optional accessor. This
656 // function should only be called from within the scope of a
657 // cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback,
658 // or in combination with calling enter() and exit() on a stored cef_v8context_t
661 CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_v8accessor_t* accessor);
664 // Create a new cef_v8value_t object of type array with the specified |length|.
665 // If |length| is negative the returned array will have length 0. This function
666 // should only be called from within the scope of a
667 // cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback,
668 // or in combination with calling enter() and exit() on a stored cef_v8context_t
671 CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length);
674 // Create a new cef_v8value_t object of type function. This function should only
675 // be called from within the scope of a cef_render_process_handler_t,
676 // cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
677 // enter() and exit() on a stored cef_v8context_t reference.
679 CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name,
680 cef_v8handler_t* handler);
684 // Structure representing a V8 stack trace handle. V8 handles can only be
685 // accessed from the thread on which they are created. Valid threads for
686 // creating a V8 handle include the render process main thread (TID_RENDERER)
687 // and WebWorker threads. A task runner for posting tasks on the associated
688 // thread can be retrieved via the cef_v8context_t::get_task_runner() function.
690 typedef struct _cef_v8stack_trace_t {
697 // Returns true (1) if the underlying handle is valid and it can be accessed
698 // on the current thread. Do not call any other functions if this function
699 // returns false (0).
701 int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_trace_t* self);
704 // Returns the number of stack frames.
706 int (CEF_CALLBACK *get_frame_count)(struct _cef_v8stack_trace_t* self);
709 // Returns the stack frame at the specified 0-based index.
711 struct _cef_v8stack_frame_t* (CEF_CALLBACK *get_frame)(
712 struct _cef_v8stack_trace_t* self, int index);
713 } cef_v8stack_trace_t;
717 // Returns the stack trace for the currently active context. |frame_limit| is
718 // the maximum number of frames that will be captured.
720 CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit);
724 // Structure representing a V8 stack frame handle. V8 handles can only be
725 // accessed from the thread on which they are created. Valid threads for
726 // creating a V8 handle include the render process main thread (TID_RENDERER)
727 // and WebWorker threads. A task runner for posting tasks on the associated
728 // thread can be retrieved via the cef_v8context_t::get_task_runner() function.
730 typedef struct _cef_v8stack_frame_t {
737 // Returns true (1) if the underlying handle is valid and it can be accessed
738 // on the current thread. Do not call any other functions if this function
739 // returns false (0).
741 int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_frame_t* self);
744 // Returns the name of the resource script that contains the function.
746 // The resulting string must be freed by calling cef_string_userfree_free().
747 cef_string_userfree_t (CEF_CALLBACK *get_script_name)(
748 struct _cef_v8stack_frame_t* self);
751 // Returns the name of the resource script that contains the function or the
752 // sourceURL value if the script name is undefined and its source ends with a
753 // "//@ sourceURL=..." string.
755 // The resulting string must be freed by calling cef_string_userfree_free().
756 cef_string_userfree_t (CEF_CALLBACK *get_script_name_or_source_url)(
757 struct _cef_v8stack_frame_t* self);
760 // Returns the name of the function.
762 // The resulting string must be freed by calling cef_string_userfree_free().
763 cef_string_userfree_t (CEF_CALLBACK *get_function_name)(
764 struct _cef_v8stack_frame_t* self);
767 // Returns the 1-based line number for the function call or 0 if unknown.
769 int (CEF_CALLBACK *get_line_number)(struct _cef_v8stack_frame_t* self);
772 // Returns the 1-based column offset on the line for the function call or 0 if
775 int (CEF_CALLBACK *get_column)(struct _cef_v8stack_frame_t* self);
778 // Returns true (1) if the function was compiled using eval().
780 int (CEF_CALLBACK *is_eval)(struct _cef_v8stack_frame_t* self);
783 // Returns true (1) if the function was called as a constructor via "new".
785 int (CEF_CALLBACK *is_constructor)(struct _cef_v8stack_frame_t* self);
786 } cef_v8stack_frame_t;
790 // Register a new V8 extension with the specified JavaScript extension code and
791 // handler. Functions implemented by the handler are prototyped using the
792 // keyword 'native'. The calling of a native function is restricted to the scope
793 // in which the prototype of the native function is defined. This function may
794 // only be called on the render process main thread.
796 // Example JavaScript extension code: <pre>
797 // // create the 'example' global object if it doesn't already exist.
800 // // create the 'example.test' global object if it doesn't already exist.
801 // if (!example.test)
802 // example.test = {};
804 // // Define the function 'example.test.myfunction'.
805 // example.test.myfunction = function() {
806 // // Call CefV8Handler::Execute() with the function name 'MyFunction'
807 // // and no arguments.
808 // native function MyFunction();
809 // return MyFunction();
811 // // Define the getter function for parameter 'example.test.myparam'.
812 // example.test.__defineGetter__('myparam', function() {
813 // // Call CefV8Handler::Execute() with the function name 'GetMyParam'
814 // // and no arguments.
815 // native function GetMyParam();
816 // return GetMyParam();
818 // // Define the setter function for parameter 'example.test.myparam'.
819 // example.test.__defineSetter__('myparam', function(b) {
820 // // Call CefV8Handler::Execute() with the function name 'SetMyParam'
821 // // and a single argument.
822 // native function SetMyParam();
823 // if(b) SetMyParam(b);
826 // // Extension definitions can also contain normal JavaScript variables
829 // example.test.increment = function() {
834 // </pre> Example usage in the page: <pre>
835 // // Call the function.
836 // example.test.myfunction();
837 // // Set the parameter.
838 // example.test.myparam = value;
839 // // Get the parameter.
840 // value = example.test.myparam;
841 // // Call another function.
842 // example.test.increment();
845 CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
846 const cef_string_t* javascript_code, cef_v8handler_t* handler);
852 #endif // CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_