Exemple #1
0
void InitTest() {
  // Structure providing information about the client plugin.
  CefPluginInfo plugin_info;
  CefString(&plugin_info.display_name).FromASCII("Client Plugin");
  CefString(&plugin_info.unique_name).FromASCII("client_plugin");
  CefString(&plugin_info.description).FromASCII("My Example Client Plugin");
  CefString(&plugin_info.mime_types).FromASCII("application/x-client-plugin");
  CefString(&plugin_info.file_extensions).FromASCII("xcp");

  plugin_info.np_getentrypoints = NP_ClientGetEntryPoints;
  plugin_info.np_initialize = NP_ClientInitialize;
  plugin_info.np_shutdown = NP_ClientShutdown;

  // Register the internal client plugin
  CefRegisterPlugin(plugin_info);
}
Exemple #2
0
void InitUIPluginTest()
{
  // Structure providing information about the client plugin.
  CefPluginInfo plugin_info;
  CefString(&plugin_info.display_name).FromASCII("Client UI Plugin");
  CefString(&plugin_info.unique_name).FromASCII("client_ui_plugin");
  CefString(&plugin_info.description).FromASCII("My Example Client UI Plugin");
  CefString(&plugin_info.mime_type).FromASCII("application/x-client-ui-plugin");

  plugin_info.np_getentrypoints = NP_UIGetEntryPoints;
  plugin_info.np_initialize = NP_UIInitialize;
  plugin_info.np_shutdown = NP_UIShutdown;

  // Register the internal client plugin
  CefRegisterPlugin(plugin_info);

  // Register a V8 extension with the below JavaScript code that calls native
  // methods implemented in ClientV8UIHandler.
  std::string code = "var cef;"
    "if (!cef)"
    "  cef = {};"
    "if (!cef.uiapp)"
    "  cef.uiapp = {};"
    "(function() {"
    "  cef.uiapp.modifyRotation = function(val) {"
    "    native function modifyRotation();"
    "    return modifyRotation(val);"
    "  };"
    "  cef.uiapp.resetRotation = function() {"
    "    native function resetRotation();"
    "    return resetRotation();"
    "  };"
    "  cef.uiapp.viewSource = function() {"
    "    native function viewSource();"
    "    return viewSource();"
    "  };"
    "})();";
  CefRegisterExtension("uiplugin/test", code, new ClientV8UIHandler());
}