Add support for loading extensions (issue #1947)

- Add CefRequestContext::LoadExtension, CefExtension, CefExtensionHandler and
  related methods/interfaces.
- Add chrome://extensions-support that lists supported Chrome APIs.
- Add CefBrowserHost::SetAutoResizeEnabled and CefDisplayHandler::OnAutoResize
  to support browser resize based on preferred web contents size.
- views: Add support for custom CefMenuButton popups.
- cefclient: Run with `--load-extension=set_page_color` command-line flag for
  an extension loading example. Add `--use-views` on Windows and Linux for an
  even better example.
This commit is contained in:
Marshall Greenblatt
2017-08-03 18:55:19 -04:00
parent 5b12134a45
commit 9cff99dc4e
178 changed files with 10360 additions and 650 deletions

View File

@ -9,14 +9,16 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=12152d9a0c2f7acf5c7ac9d0eb2facc83c00d688$
// $hash=a36935b62972aa8bf8d9132a86a3c5f1c37f1d57$
//
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/extension_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
#include "libcef_dll/ctocpp/completion_callback_ctocpp.h"
#include "libcef_dll/ctocpp/extension_handler_ctocpp.h"
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
#include "libcef_dll/ctocpp/resolve_callback_ctocpp.h"
#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h"
@ -444,6 +446,120 @@ request_context_resolve_host_cached(struct _cef_request_context_t* self,
return _retval;
}
void CEF_CALLBACK
request_context_load_extension(struct _cef_request_context_t* self,
const cef_string_t* root_directory,
struct _cef_dictionary_value_t* manifest,
cef_extension_handler_t* handler) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: root_directory; type: string_byref_const
DCHECK(root_directory);
if (!root_directory)
return;
// Unverified params: manifest, handler
// Execute
CefRequestContextCppToC::Get(self)->LoadExtension(
CefString(root_directory), CefDictionaryValueCppToC::Unwrap(manifest),
CefExtensionHandlerCToCpp::Wrap(handler));
}
int CEF_CALLBACK
request_context_did_load_extension(struct _cef_request_context_t* self,
const cef_string_t* extension_id) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: extension_id; type: string_byref_const
DCHECK(extension_id);
if (!extension_id)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(self)->DidLoadExtension(
CefString(extension_id));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
request_context_has_extension(struct _cef_request_context_t* self,
const cef_string_t* extension_id) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: extension_id; type: string_byref_const
DCHECK(extension_id);
if (!extension_id)
return 0;
// Execute
bool _retval =
CefRequestContextCppToC::Get(self)->HasExtension(CefString(extension_id));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
request_context_get_extensions(struct _cef_request_context_t* self,
cef_string_list_t extension_ids) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: extension_ids; type: string_vec_byref
DCHECK(extension_ids);
if (!extension_ids)
return 0;
// Translate param: extension_ids; type: string_vec_byref
std::vector<CefString> extension_idsList;
transfer_string_list_contents(extension_ids, extension_idsList);
// Execute
bool _retval =
CefRequestContextCppToC::Get(self)->GetExtensions(extension_idsList);
// Restore param: extension_ids; type: string_vec_byref
cef_string_list_clear(extension_ids);
transfer_string_list_contents(extension_idsList, extension_ids);
// Return type: bool
return _retval;
}
cef_extension_t* CEF_CALLBACK
request_context_get_extension(struct _cef_request_context_t* self,
const cef_string_t* extension_id) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: extension_id; type: string_byref_const
DCHECK(extension_id);
if (!extension_id)
return NULL;
// Execute
CefRefPtr<CefExtension> _retval =
CefRequestContextCppToC::Get(self)->GetExtension(CefString(extension_id));
// Return type: refptr_same
return CefExtensionCppToC::Wrap(_retval);
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@ -472,6 +588,11 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
GetStruct()->close_all_connections = request_context_close_all_connections;
GetStruct()->resolve_host = request_context_resolve_host;
GetStruct()->resolve_host_cached = request_context_resolve_host_cached;
GetStruct()->load_extension = request_context_load_extension;
GetStruct()->did_load_extension = request_context_did_load_extension;
GetStruct()->has_extension = request_context_has_extension;
GetStruct()->get_extensions = request_context_get_extensions;
GetStruct()->get_extension = request_context_get_extension;
}
template <>