2010-10-20 17:12:46 +02:00
|
|
|
// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
|
2010-10-03 23:04:50 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "include/cef.h"
|
|
|
|
#include "include/cef_capi.h"
|
|
|
|
#include "include/cef_nplugin.h"
|
|
|
|
#include "include/cef_nplugin_capi.h"
|
2011-11-18 18:30:55 +01:00
|
|
|
#include "include/cef_version.h"
|
2011-11-23 23:47:09 +01:00
|
|
|
#include "libcef_dll/cpptoc/app_cpptoc.h"
|
2011-05-24 01:39:07 +02:00
|
|
|
#include "libcef_dll/cpptoc/content_filter_cpptoc.h"
|
2011-04-09 03:05:30 +02:00
|
|
|
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
2011-02-23 04:45:13 +01:00
|
|
|
#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h"
|
|
|
|
#include "libcef_dll/cpptoc/domvisitor_cpptoc.h"
|
2010-10-18 17:37:33 +02:00
|
|
|
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "libcef_dll/cpptoc/read_handler_cpptoc.h"
|
|
|
|
#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h"
|
|
|
|
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
|
2011-10-06 15:34:47 +02:00
|
|
|
#include "libcef_dll/cpptoc/storage_visitor_cpptoc.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "libcef_dll/cpptoc/task_cpptoc.h"
|
2011-04-07 03:58:49 +02:00
|
|
|
#include "libcef_dll/cpptoc/v8accessor_cpptoc.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "libcef_dll/cpptoc/v8handler_cpptoc.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "libcef_dll/cpptoc/write_handler_cpptoc.h"
|
|
|
|
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
2011-02-23 04:45:13 +01:00
|
|
|
#include "libcef_dll/ctocpp/domdocument_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/domevent_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "libcef_dll/ctocpp/post_data_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/post_data_element_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/request_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
|
|
|
|
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
|
2011-02-21 23:44:06 +01:00
|
|
|
#include "libcef_dll/ctocpp/v8context_ctocpp.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "libcef_dll/ctocpp/web_urlrequest_ctocpp.h"
|
2010-10-20 17:12:46 +02:00
|
|
|
#include "libcef_dll/ctocpp/xml_reader_ctocpp.h"
|
2010-10-24 18:41:21 +02:00
|
|
|
#include "libcef_dll/ctocpp/zip_reader_ctocpp.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
|
2011-11-23 23:47:09 +01:00
|
|
|
bool CefInitialize(const CefSettings& settings, CefRefPtr<CefApp> application)
|
2010-10-03 23:04:50 +02:00
|
|
|
{
|
2011-11-18 18:30:55 +01:00
|
|
|
int build_revision = cef_build_revision();
|
|
|
|
if (build_revision != CEF_REVISION) {
|
|
|
|
// The libcef build revision does not match the CEF API revision.
|
2011-11-18 23:10:53 +01:00
|
|
|
DCHECK(false);
|
2011-11-18 18:30:55 +01:00
|
|
|
return false;
|
|
|
|
}
|
2011-11-23 23:47:09 +01:00
|
|
|
|
|
|
|
return cef_initialize(&settings, CefAppCppToC::Wrap(application))?true:false;
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefShutdown()
|
|
|
|
{
|
|
|
|
cef_shutdown();
|
|
|
|
|
2011-05-20 16:42:25 +02:00
|
|
|
#ifndef NDEBUG
|
2010-10-03 23:04:50 +02:00
|
|
|
// Check that all wrapper objects have been destroyed
|
2011-05-24 01:39:07 +02:00
|
|
|
DCHECK(CefContentFilterCppToC::DebugObjCt == 0);
|
2011-04-09 03:05:30 +02:00
|
|
|
DCHECK(CefCookieVisitorCppToC::DebugObjCt == 0);
|
2011-02-23 04:45:13 +01:00
|
|
|
DCHECK(CefDOMEventListenerCppToC::DebugObjCt == 0);
|
|
|
|
DCHECK(CefDOMVisitorCppToC::DebugObjCt == 0);
|
2010-10-18 17:37:33 +02:00
|
|
|
DCHECK(CefDownloadHandlerCppToC::DebugObjCt == 0);
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(CefReadHandlerCppToC::DebugObjCt == 0);
|
|
|
|
DCHECK(CefSchemeHandlerCppToC::DebugObjCt == 0);
|
|
|
|
DCHECK(CefSchemeHandlerFactoryCppToC::DebugObjCt == 0);
|
2011-10-06 15:34:47 +02:00
|
|
|
DCHECK(CefStorageVisitorCppToC::DebugObjCt == 0);
|
2011-04-07 03:58:49 +02:00
|
|
|
DCHECK(CefV8AccessorCppToC::DebugObjCt == 0);
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(CefV8HandlerCppToC::DebugObjCt == 0);
|
2011-02-15 19:07:24 +01:00
|
|
|
DCHECK(CefWebURLRequestClientCppToC::DebugObjCt == 0);
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(CefWriteHandlerCppToC::DebugObjCt == 0);
|
|
|
|
DCHECK(CefBrowserCToCpp::DebugObjCt == 0);
|
2011-02-23 04:45:13 +01:00
|
|
|
DCHECK(CefDOMDocumentCToCpp::DebugObjCt == 0);
|
|
|
|
DCHECK(CefDOMEventCToCpp::DebugObjCt == 0);
|
|
|
|
DCHECK(CefDOMNodeCToCpp::DebugObjCt == 0);
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(CefRequestCToCpp::DebugObjCt == 0);
|
|
|
|
DCHECK(CefPostDataCToCpp::DebugObjCt == 0);
|
|
|
|
DCHECK(CefPostDataElementCToCpp::DebugObjCt == 0);
|
|
|
|
DCHECK(CefStreamReaderCToCpp::DebugObjCt == 0);
|
|
|
|
DCHECK(CefStreamWriterCToCpp::DebugObjCt == 0);
|
2011-02-21 23:44:06 +01:00
|
|
|
DCHECK(CefV8ContextCToCpp::DebugObjCt == 0);
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(CefV8ValueCToCpp::DebugObjCt == 0);
|
2011-02-15 19:07:24 +01:00
|
|
|
DCHECK(CefWebURLRequestCToCpp::DebugObjCt == 0);
|
2010-10-20 17:12:46 +02:00
|
|
|
DCHECK(CefXmlReaderCToCpp::DebugObjCt == 0);
|
2010-10-24 18:41:21 +02:00
|
|
|
DCHECK(CefZipReaderCToCpp::DebugObjCt == 0);
|
2011-05-20 16:42:25 +02:00
|
|
|
#endif // !NDEBUG
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefDoMessageLoopWork()
|
|
|
|
{
|
|
|
|
cef_do_message_loop_work();
|
|
|
|
}
|
|
|
|
|
2011-03-24 21:36:47 +01:00
|
|
|
void CefRunMessageLoop()
|
|
|
|
{
|
|
|
|
cef_run_message_loop();
|
|
|
|
}
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
bool CefRegisterExtension(const CefString& extension_name,
|
|
|
|
const CefString& javascript_code,
|
2010-10-03 23:04:50 +02:00
|
|
|
CefRefPtr<CefV8Handler> handler)
|
|
|
|
{
|
2010-11-22 18:49:46 +01:00
|
|
|
return cef_register_extension(extension_name.GetStruct(),
|
|
|
|
javascript_code.GetStruct(), CefV8HandlerCppToC::Wrap(handler))?
|
|
|
|
true:false;
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
2011-02-15 19:07:24 +01:00
|
|
|
bool CefRegisterPlugin(const CefPluginInfo& plugin_info)
|
2010-10-03 23:04:50 +02:00
|
|
|
{
|
2011-02-15 19:07:24 +01:00
|
|
|
return cef_register_plugin(&plugin_info)?true:false;
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
2011-05-27 18:20:32 +02:00
|
|
|
bool CefRegisterCustomScheme(const CefString& scheme_name,
|
|
|
|
bool is_standard,
|
|
|
|
bool is_local,
|
|
|
|
bool is_display_isolated)
|
2010-10-03 23:04:50 +02:00
|
|
|
{
|
2011-05-27 18:20:32 +02:00
|
|
|
return cef_register_custom_scheme(scheme_name.GetStruct(), is_standard,
|
|
|
|
is_local, is_display_isolated)?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name,
|
|
|
|
const CefString& domain_name,
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory> factory)
|
|
|
|
{
|
|
|
|
cef_scheme_handler_factory_t* factory_struct = NULL;
|
|
|
|
if (factory.get())
|
|
|
|
factory_struct = CefSchemeHandlerFactoryCppToC::Wrap(factory);
|
|
|
|
|
|
|
|
return cef_register_scheme_handler_factory(scheme_name.GetStruct(),
|
|
|
|
domain_name.GetStruct(), factory_struct)?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefClearSchemeHandlerFactories()
|
|
|
|
{
|
|
|
|
return cef_clear_scheme_handler_factories()?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin,
|
|
|
|
const CefString& target_protocol,
|
|
|
|
const CefString& target_domain,
|
|
|
|
bool allow_target_subdomains)
|
|
|
|
{
|
|
|
|
return cef_add_cross_origin_whitelist_entry(source_origin.GetStruct(),
|
|
|
|
target_protocol.GetStruct(), target_domain.GetStruct(),
|
|
|
|
allow_target_subdomains)?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefRemoveCrossOriginWhitelistEntry(const CefString& source_origin,
|
|
|
|
const CefString& target_protocol,
|
|
|
|
const CefString& target_domain,
|
|
|
|
bool allow_target_subdomains)
|
|
|
|
{
|
|
|
|
return cef_remove_cross_origin_whitelist_entry(source_origin.GetStruct(),
|
|
|
|
target_protocol.GetStruct(), target_domain.GetStruct(),
|
|
|
|
allow_target_subdomains)?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefClearCrossOriginWhitelist()
|
|
|
|
{
|
|
|
|
return cef_clear_cross_origin_whitelist()?true:false;
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefCurrentlyOn(CefThreadId threadId)
|
|
|
|
{
|
|
|
|
return cef_currently_on(threadId)?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task)
|
|
|
|
{
|
|
|
|
return cef_post_task(threadId, CefTaskCppToC::Wrap(task))?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
|
|
|
|
long delay_ms)
|
|
|
|
{
|
|
|
|
return cef_post_delayed_task(threadId, CefTaskCppToC::Wrap(task), delay_ms)?
|
|
|
|
true:false;
|
|
|
|
}
|
2011-01-31 21:47:04 +01:00
|
|
|
|
|
|
|
bool CefParseURL(const CefString& url,
|
|
|
|
CefURLParts& parts)
|
|
|
|
{
|
|
|
|
return cef_parse_url(url.GetStruct(), &parts) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefCreateURL(const CefURLParts& parts,
|
|
|
|
CefString& url)
|
|
|
|
{
|
|
|
|
return cef_create_url(&parts, url.GetWritableStruct()) ? true : false;
|
|
|
|
}
|
2011-04-09 03:05:30 +02:00
|
|
|
|
|
|
|
bool CefVisitAllCookies(CefRefPtr<CefCookieVisitor> visitor)
|
|
|
|
{
|
|
|
|
return cef_visit_all_cookies(CefCookieVisitorCppToC::Wrap(visitor)) ?
|
|
|
|
true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly,
|
|
|
|
CefRefPtr<CefCookieVisitor> visitor)
|
|
|
|
{
|
|
|
|
return cef_visit_url_cookies(url.GetStruct(), includeHttpOnly,
|
|
|
|
CefCookieVisitorCppToC::Wrap(visitor)) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefSetCookie(const CefString& url, const CefCookie& cookie)
|
|
|
|
{
|
|
|
|
return cef_set_cookie(url.GetStruct(), &cookie) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefDeleteCookies(const CefString& url, const CefString& cookie_name)
|
|
|
|
{
|
|
|
|
return cef_delete_cookies(url.GetStruct(), cookie_name.GetStruct()) ?
|
|
|
|
true : false;
|
|
|
|
}
|
2011-10-06 15:34:47 +02:00
|
|
|
|
2011-11-02 20:50:00 +01:00
|
|
|
bool CefSetCookiePath(const CefString& path)
|
|
|
|
{
|
|
|
|
return cef_set_cookie_path(path.GetStruct()) ? true : false;
|
|
|
|
}
|
|
|
|
|
2011-10-06 15:34:47 +02:00
|
|
|
bool CefVisitStorage(CefStorageType type, const CefString& origin,
|
|
|
|
const CefString& key,
|
|
|
|
CefRefPtr<CefStorageVisitor> visitor)
|
|
|
|
{
|
|
|
|
return cef_visit_storage(type, origin.GetStruct(), key.GetStruct(),
|
|
|
|
CefStorageVisitorCppToC::Wrap(visitor)) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefSetStorage(CefStorageType type, const CefString& origin,
|
|
|
|
const CefString& key, const CefString& value)
|
|
|
|
{
|
|
|
|
return cef_set_storage(type, origin.GetStruct(), key.GetStruct(),
|
|
|
|
value.GetStruct()) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefDeleteStorage(CefStorageType type, const CefString& origin,
|
|
|
|
const CefString& key)
|
|
|
|
{
|
|
|
|
return cef_delete_storage(type, origin.GetStruct(), key.GetStruct()) ?
|
|
|
|
true : false;
|
|
|
|
}
|
2011-11-02 20:50:00 +01:00
|
|
|
|
|
|
|
bool CefSetStoragePath(CefStorageType type, const CefString& path)
|
|
|
|
{
|
|
|
|
return cef_set_storage_path(type, path.GetStruct()) ? true : false;
|
|
|
|
}
|