mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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:
181
libcef_dll/cpptoc/extension_cpptoc.cc
Normal file
181
libcef_dll/cpptoc/extension_cpptoc.cc
Normal file
@ -0,0 +1,181 @@
|
||||
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=59b3e055a5cdd19a3af4b3e313f2d7095bd578e5$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/extension_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/extension_handler_ctocpp.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK
|
||||
extension_get_identifier(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefExtensionCppToC::Get(self)->GetIdentifier();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK
|
||||
extension_get_path(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefString _retval = CefExtensionCppToC::Get(self)->GetPath();
|
||||
|
||||
// Return type: string
|
||||
return _retval.DetachToUserFree();
|
||||
}
|
||||
|
||||
struct _cef_dictionary_value_t* CEF_CALLBACK
|
||||
extension_get_manifest(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDictionaryValue> _retval =
|
||||
CefExtensionCppToC::Get(self)->GetManifest();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDictionaryValueCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK extension_is_same(struct _cef_extension_t* self,
|
||||
struct _cef_extension_t* that) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: that; type: refptr_same
|
||||
DCHECK(that);
|
||||
if (!that)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval =
|
||||
CefExtensionCppToC::Get(self)->IsSame(CefExtensionCppToC::Unwrap(that));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_extension_handler_t* CEF_CALLBACK
|
||||
extension_get_handler(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefExtensionHandler> _retval =
|
||||
CefExtensionCppToC::Get(self)->GetHandler();
|
||||
|
||||
// Return type: refptr_diff
|
||||
return CefExtensionHandlerCToCpp::Unwrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_request_context_t* CEF_CALLBACK
|
||||
extension_get_loader_context(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefRequestContext> _retval =
|
||||
CefExtensionCppToC::Get(self)->GetLoaderContext();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestContextCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK extension_is_loaded(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefExtensionCppToC::Get(self)->IsLoaded();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK extension_unload(struct _cef_extension_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefExtensionCppToC::Get(self)->Unload();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefExtensionCppToC::CefExtensionCppToC() {
|
||||
GetStruct()->get_identifier = extension_get_identifier;
|
||||
GetStruct()->get_path = extension_get_path;
|
||||
GetStruct()->get_manifest = extension_get_manifest;
|
||||
GetStruct()->is_same = extension_is_same;
|
||||
GetStruct()->get_handler = extension_get_handler;
|
||||
GetStruct()->get_loader_context = extension_get_loader_context;
|
||||
GetStruct()->is_loaded = extension_is_loaded;
|
||||
GetStruct()->unload = extension_unload;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefRefPtr<CefExtension>
|
||||
CefCppToCRefCounted<CefExtensionCppToC, CefExtension, cef_extension_t>::
|
||||
UnwrapDerived(CefWrapperType type, cef_extension_t* s) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
template <>
|
||||
base::AtomicRefCount
|
||||
CefCppToCRefCounted<CefExtensionCppToC, CefExtension, cef_extension_t>::
|
||||
DebugObjCt ATOMIC_DECLARATION;
|
||||
#endif
|
||||
|
||||
template <>
|
||||
CefWrapperType CefCppToCRefCounted<CefExtensionCppToC,
|
||||
CefExtension,
|
||||
cef_extension_t>::kWrapperType =
|
||||
WT_EXTENSION;
|
Reference in New Issue
Block a user