CefRuntime RegisterExtension Method Xilium.CefGlue

[This is preliminary documentation and is subject to change.]

Register a new V8 extension with the specified JavaScript extension code and handler. Functions implemented by the handler are prototyped using the keyword 'native'. The calling of a native function is restricted to the scope in which the prototype of the native function is defined. This function may only be called on the render process main thread. Example JavaScript extension code:
// create the 'example' global object if it doesn't already exist. 
if (!example)
  example = {};
// create the 'example.test' global object if it doesn't already exist. 
if (!example.test)
  example.test = {};
(function() {
  // Define the function 'example.test.myfunction'.
  example.test.myfunction = function() {
    // Call CefV8Handler::Execute() with the function name 'MyFunction' 
    // and no arguments.
    native function MyFunction();
    return MyFunction();
  };
  // Define the getter function for parameter 'example.test.myparam'.
  example.test.__defineGetter__('myparam', function() {
    // Call CefV8Handler::Execute() with the function name 'GetMyParam' 
    // and no arguments.
    native function GetMyParam();
    return GetMyParam();
  });
  // Define the setter function for parameter 'example.test.myparam'.
  example.test.__defineSetter__('myparam', function(b) {
    // Call CefV8Handler::Execute() with the function name 'SetMyParam' 
    // and a single argument.
    native function SetMyParam();
    if(b) SetMyParam(b);
  });

  // Extension definitions can also contain normal JavaScript variables 
  // and functions. 
  var myint = 0;
  example.test.increment = function() {
    myint += 1;
    return myint;
  };
})();
Example usage in the page:
// Call the function.
example.test.myfunction();
// Set the parameter.
example.test.myparam = value;
// Get the parameter. 
value = example.test.myparam;
// Call another function.
example.test.increment();

Namespace: Xilium.CefGlue
Assembly: Xilium.CefGlue (in Xilium.CefGlue.dll) Version: 3.2272.2035.0 (3.2272.2035.0)
Syntax

public static bool RegisterExtension(
	string extensionName,
	string javascriptCode,
	CefV8Handler handler
)

Parameters

extensionName
Type: OnlineSystem String

[Missing <param name="extensionName"/> documentation for "M:Xilium.CefGlue.CefRuntime.RegisterExtension(System.String,System.String,Xilium.CefGlue.CefV8Handler)"]

javascriptCode
Type: OnlineSystem String

[Missing <param name="javascriptCode"/> documentation for "M:Xilium.CefGlue.CefRuntime.RegisterExtension(System.String,System.String,Xilium.CefGlue.CefV8Handler)"]

handler
Type: Xilium.CefGlue CefV8Handler

[Missing <param name="handler"/> documentation for "M:Xilium.CefGlue.CefRuntime.RegisterExtension(System.String,System.String,Xilium.CefGlue.CefV8Handler)"]

Return Value

Type: OnlineBoolean

[Missing <returns> documentation for "M:Xilium.CefGlue.CefRuntime.RegisterExtension(System.String,System.String,Xilium.CefGlue.CefV8Handler)"]

See Also