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,12 +9,13 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=782642e65456b32ab0fab59db2b9442783b7f574$
// $hash=ce23c8ba14803b0a15b9b2899632f2c03d6b3a97$
//
#include "libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h"
#include "libcef_dll/ctocpp/views/button_ctocpp.h"
#include "libcef_dll/ctocpp/views/menu_button_ctocpp.h"
#include "libcef_dll/ctocpp/views/menu_button_pressed_lock_ctocpp.h"
#include "libcef_dll/ctocpp/views/view_ctocpp.h"
namespace {
@ -24,7 +25,8 @@ namespace {
void CEF_CALLBACK menu_button_delegate_on_menu_button_pressed(
struct _cef_menu_button_delegate_t* self,
cef_menu_button_t* menu_button,
const cef_point_t* screen_point) {
const cef_point_t* screen_point,
cef_menu_button_pressed_lock_t* button_pressed_lock) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
@ -38,13 +40,18 @@ void CEF_CALLBACK menu_button_delegate_on_menu_button_pressed(
DCHECK(screen_point);
if (!screen_point)
return;
// Verify param: button_pressed_lock; type: refptr_diff
DCHECK(button_pressed_lock);
if (!button_pressed_lock)
return;
// Translate param: screen_point; type: simple_byref_const
CefPoint screen_pointVal = screen_point ? *screen_point : CefPoint();
// Execute
CefMenuButtonDelegateCppToC::Get(self)->OnMenuButtonPressed(
CefMenuButtonCToCpp::Wrap(menu_button), screen_pointVal);
CefMenuButtonCToCpp::Wrap(menu_button), screen_pointVal,
CefMenuButtonPressedLockCToCpp::Wrap(button_pressed_lock));
}
void CEF_CALLBACK

View File

@ -0,0 +1,44 @@
// 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=dffd7542aef11aa1adb55bd8c5dd6c29081f5caf$
//
#include "libcef_dll/cpptoc/views/menu_button_pressed_lock_cpptoc.h"
// CONSTRUCTOR - Do not edit by hand.
CefMenuButtonPressedLockCppToC::CefMenuButtonPressedLockCppToC() {}
template <>
CefRefPtr<CefMenuButtonPressedLock>
CefCppToCRefCounted<CefMenuButtonPressedLockCppToC,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t>::
UnwrapDerived(CefWrapperType type, cef_menu_button_pressed_lock_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCppToCRefCounted<
CefMenuButtonPressedLockCppToC,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t>::DebugObjCt ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType
CefCppToCRefCounted<CefMenuButtonPressedLockCppToC,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t>::kWrapperType =
WT_MENU_BUTTON_PRESSED_LOCK;

View File

@ -0,0 +1,39 @@
// 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=5b9354b2db247aaa4a3a6623ebdcb97aef98d0b7$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_VIEWS_MENU_BUTTON_PRESSED_LOCK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_VIEWS_MENU_BUTTON_PRESSED_LOCK_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/views/cef_menu_button_capi.h"
#include "include/capi/views/cef_menu_button_delegate_capi.h"
#include "include/views/cef_menu_button.h"
#include "include/views/cef_menu_button_delegate.h"
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefMenuButtonPressedLockCppToC
: public CefCppToCRefCounted<CefMenuButtonPressedLockCppToC,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t> {
public:
CefMenuButtonPressedLockCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_VIEWS_MENU_BUTTON_PRESSED_LOCK_CPPTOC_H_

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=9cf5d66da05ef9e423995bc8f527ef1315812134$
// $hash=80a92fb23bc01d46903ea4e2076950a4ffe07b18$
//
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
@ -56,6 +56,51 @@ window_delegate_on_window_destroyed(struct _cef_window_delegate_t* self,
CefWindowCToCpp::Wrap(window));
}
cef_window_t* CEF_CALLBACK
window_delegate_get_parent_window(struct _cef_window_delegate_t* self,
cef_window_t* window,
int* is_menu,
int* can_activate_menu) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: window; type: refptr_diff
DCHECK(window);
if (!window)
return NULL;
// Verify param: is_menu; type: bool_byaddr
DCHECK(is_menu);
if (!is_menu)
return NULL;
// Verify param: can_activate_menu; type: bool_byaddr
DCHECK(can_activate_menu);
if (!can_activate_menu)
return NULL;
// Translate param: is_menu; type: bool_byaddr
bool is_menuBool = (is_menu && *is_menu) ? true : false;
// Translate param: can_activate_menu; type: bool_byaddr
bool can_activate_menuBool =
(can_activate_menu && *can_activate_menu) ? true : false;
// Execute
CefRefPtr<CefWindow> _retval =
CefWindowDelegateCppToC::Get(self)->GetParentWindow(
CefWindowCToCpp::Wrap(window), &is_menuBool, &can_activate_menuBool);
// Restore param: is_menu; type: bool_byaddr
if (is_menu)
*is_menu = is_menuBool ? true : false;
// Restore param: can_activate_menu; type: bool_byaddr
if (can_activate_menu)
*can_activate_menu = can_activate_menuBool ? true : false;
// Return type: refptr_diff
return CefWindowCToCpp::Unwrap(_retval);
}
int CEF_CALLBACK
window_delegate_is_frameless(struct _cef_window_delegate_t* self,
cef_window_t* window) {
@ -392,6 +437,7 @@ void CEF_CALLBACK window_delegate_on_blur(struct _cef_view_delegate_t* self,
CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
GetStruct()->on_window_created = window_delegate_on_window_created;
GetStruct()->on_window_destroyed = window_delegate_on_window_destroyed;
GetStruct()->get_parent_window = window_delegate_get_parent_window;
GetStruct()->is_frameless = window_delegate_is_frameless;
GetStruct()->can_resize = window_delegate_can_resize;
GetStruct()->can_maximize = window_delegate_can_maximize;