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:
@ -99,7 +99,8 @@ def get_comment(body, name):
|
||||
if len(line) == 0:
|
||||
# check if the next previous line is a comment
|
||||
prevdata = get_prev_line(body, pos)
|
||||
if string.strip(prevdata['line'])[0:2] == '//':
|
||||
prevline = string.strip(prevdata['line'])
|
||||
if prevline[0:2] == '//' and prevline[0:3] != '///':
|
||||
result.append(None)
|
||||
else:
|
||||
break
|
||||
@ -538,26 +539,6 @@ class obj_header:
|
||||
p = re.compile('\nclass' + _cre_space + _cre_cfname + ';')
|
||||
forward_declares = p.findall(data)
|
||||
|
||||
# extract classes
|
||||
p = re.compile('\n' + _cre_attrib + '\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + ':' + _cre_space + 'public' + _cre_virtual +
|
||||
_cre_space + _cre_cfname + _cre_space + '{(.*?)\n};',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
added = True
|
||||
|
||||
# build the class objects
|
||||
for attrib, name, parent_name, body in list:
|
||||
# Style may place the ':' on the next line.
|
||||
comment = get_comment(data, name + ' :')
|
||||
if len(comment) == 0:
|
||||
comment = get_comment(data, name + "\n")
|
||||
validate_comment(filename, name, comment)
|
||||
self.classes.append(
|
||||
obj_class(self, filename, attrib, name, parent_name, body, comment,
|
||||
includes, forward_declares))
|
||||
|
||||
# extract empty classes
|
||||
p = re.compile('\n' + _cre_attrib + '\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + ':' + _cre_space + 'public' + _cre_virtual +
|
||||
@ -578,6 +559,30 @@ class obj_header:
|
||||
obj_class(self, filename, attrib, name, parent_name, "", comment,
|
||||
includes, forward_declares))
|
||||
|
||||
# Remove empty classes from |data| so we don't mess up the non-empty
|
||||
# class search that follows.
|
||||
data = p.sub('', data)
|
||||
|
||||
# extract classes
|
||||
p = re.compile('\n' + _cre_attrib + '\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + ':' + _cre_space + 'public' + _cre_virtual +
|
||||
_cre_space + _cre_cfname + _cre_space + '{(.*?)\n};',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
added = True
|
||||
|
||||
# build the class objects
|
||||
for attrib, name, parent_name, body in list:
|
||||
# Style may place the ':' on the next line.
|
||||
comment = get_comment(data, name + ' :')
|
||||
if len(comment) == 0:
|
||||
comment = get_comment(data, name + "\n")
|
||||
validate_comment(filename, name, comment)
|
||||
self.classes.append(
|
||||
obj_class(self, filename, attrib, name, parent_name, body, comment,
|
||||
includes, forward_declares))
|
||||
|
||||
if added:
|
||||
# a global function or class was read from the header file
|
||||
self.filenames.append(filename)
|
||||
|
@ -613,9 +613,15 @@ def make_cpptoc_class_impl(header, clsname, impl):
|
||||
# any derived classes can be unwrapped
|
||||
unwrapderived = make_cpptoc_unwrap_derived(header, cls, base_scoped)
|
||||
|
||||
const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \
|
||||
clsname+'CppToC::'+clsname+'CppToC() {\n'
|
||||
const += make_cpptoc_virtual_function_assignment(header, cls, prefixname,
|
||||
defined_names)
|
||||
const += '}\n\n'
|
||||
|
||||
# determine what includes are required by identifying what translation
|
||||
# classes are being used
|
||||
includes = format_translation_includes(header, resultingimpl +
|
||||
includes = format_translation_includes(header, const + resultingimpl +
|
||||
(unwrapderived[0]
|
||||
if base_scoped else unwrapderived))
|
||||
|
||||
@ -626,12 +632,6 @@ def make_cpptoc_class_impl(header, clsname, impl):
|
||||
|
||||
parent_sig = template_class + '<' + clsname + 'CppToC, ' + clsname + ', ' + capiname + '>'
|
||||
|
||||
const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \
|
||||
clsname+'CppToC::'+clsname+'CppToC() {\n'
|
||||
const += make_cpptoc_virtual_function_assignment(header, cls, prefixname,
|
||||
defined_names)
|
||||
const += '}\n\n'
|
||||
|
||||
if base_scoped:
|
||||
const += 'template<> CefOwnPtr<'+clsname+'> '+parent_sig+'::UnwrapDerivedOwn(CefWrapperType type, '+capiname+'* s) {\n' + \
|
||||
unwrapderived[0] + \
|
||||
|
@ -610,9 +610,13 @@ def make_ctocpp_class_impl(header, clsname, impl):
|
||||
# any derived classes can be unwrapped
|
||||
unwrapderived = make_ctocpp_unwrap_derived(header, cls, base_scoped)
|
||||
|
||||
const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \
|
||||
clsname+'CToCpp::'+clsname+'CToCpp() {\n'+ \
|
||||
'}\n\n'
|
||||
|
||||
# determine what includes are required by identifying what translation
|
||||
# classes are being used
|
||||
includes = format_translation_includes(header, resultingimpl +
|
||||
includes = format_translation_includes(header, const + resultingimpl +
|
||||
(unwrapderived[0]
|
||||
if base_scoped else unwrapderived))
|
||||
|
||||
@ -623,10 +627,6 @@ def make_ctocpp_class_impl(header, clsname, impl):
|
||||
|
||||
parent_sig = template_class + '<' + clsname + 'CToCpp, ' + clsname + ', ' + capiname + '>'
|
||||
|
||||
const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \
|
||||
clsname+'CToCpp::'+clsname+'CToCpp() {\n'+ \
|
||||
'}\n\n'
|
||||
|
||||
if base_scoped:
|
||||
const += 'template<> '+capiname+'* '+parent_sig+'::UnwrapDerivedOwn(CefWrapperType type, CefOwnPtr<'+clsname+'> c) {\n'+ \
|
||||
unwrapderived[0] + \
|
||||
|
@ -618,6 +618,8 @@ if mode == 'standard':
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources_extensions_set_page_color'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer common cefsimple files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_common'], \
|
||||
|
Reference in New Issue
Block a user