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,19 +9,21 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c1af150d3b847d4fda504d0f9c668d90fa348308$
// $hash=81cf9c1f1aff3557bd27f8751d2df517f2f73249$
//
#include "libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h"
#include "libcef_dll/cpptoc/views/button_cpptoc.h"
#include "libcef_dll/cpptoc/views/menu_button_cpptoc.h"
#include "libcef_dll/cpptoc/views/menu_button_pressed_lock_cpptoc.h"
#include "libcef_dll/cpptoc/views/view_cpptoc.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefMenuButtonDelegateCToCpp::OnMenuButtonPressed(
CefRefPtr<CefMenuButton> menu_button,
const CefPoint& screen_point) {
const CefPoint& screen_point,
CefRefPtr<CefMenuButtonPressedLock> button_pressed_lock) {
cef_menu_button_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_menu_button_pressed))
return;
@ -32,10 +34,15 @@ void CefMenuButtonDelegateCToCpp::OnMenuButtonPressed(
DCHECK(menu_button.get());
if (!menu_button.get())
return;
// Verify param: button_pressed_lock; type: refptr_diff
DCHECK(button_pressed_lock.get());
if (!button_pressed_lock.get())
return;
// Execute
_struct->on_menu_button_pressed(
_struct, CefMenuButtonCppToC::Wrap(menu_button), &screen_point);
_struct, CefMenuButtonCppToC::Wrap(menu_button), &screen_point,
CefMenuButtonPressedLockCppToC::Wrap(button_pressed_lock));
}
void CefMenuButtonDelegateCToCpp::OnButtonPressed(CefRefPtr<CefButton> button) {

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=71ef57288d2a5fc3a22b1f22385ac43303f37256$
// $hash=f9fc3392a980679bb9c2786f0f61ce1a12219c24$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_DELEGATE_CTOCPP_H_
@ -36,8 +36,10 @@ class CefMenuButtonDelegateCToCpp
CefMenuButtonDelegateCToCpp();
// CefMenuButtonDelegate methods.
void OnMenuButtonPressed(CefRefPtr<CefMenuButton> menu_button,
const CefPoint& screen_point) override;
void OnMenuButtonPressed(
CefRefPtr<CefMenuButton> menu_button,
const CefPoint& screen_point,
CefRefPtr<CefMenuButtonPressedLock> button_pressed_lock) override;
// CefButtonDelegate methods.
void OnButtonPressed(CefRefPtr<CefButton> button) override;

View File

@ -0,0 +1,45 @@
// 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=c43f3b09cdeca57178d011390a0b1aef581ead6a$
//
#include "libcef_dll/ctocpp/views/menu_button_pressed_lock_ctocpp.h"
// CONSTRUCTOR - Do not edit by hand.
CefMenuButtonPressedLockCToCpp::CefMenuButtonPressedLockCToCpp() {}
template <>
cef_menu_button_pressed_lock_t* CefCToCppRefCounted<
CefMenuButtonPressedLockCToCpp,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t>::UnwrapDerived(CefWrapperType type,
CefMenuButtonPressedLock*
c) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCToCppRefCounted<
CefMenuButtonPressedLockCToCpp,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t>::DebugObjCt ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType
CefCToCppRefCounted<CefMenuButtonPressedLockCToCpp,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t>::kWrapperType =
WT_MENU_BUTTON_PRESSED_LOCK;

View File

@ -0,0 +1,41 @@
// 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=2a275bd4a57c74df08bef4a5a0d8e3f8d2b22305$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_PRESSED_LOCK_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_PRESSED_LOCK_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-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/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefMenuButtonPressedLockCToCpp
: public CefCToCppRefCounted<CefMenuButtonPressedLockCToCpp,
CefMenuButtonPressedLock,
cef_menu_button_pressed_lock_t> {
public:
CefMenuButtonPressedLockCToCpp();
// CefMenuButtonPressedLock methods.
};
#endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_PRESSED_LOCK_CTOCPP_H_

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c2256192e44464a7c89f2e43619a92049d1c080c$
// $hash=8c1a14a8634516a37f562c6b295c30fe3f30c179$
//
#include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h"
@ -50,6 +50,50 @@ void CefWindowDelegateCToCpp::OnWindowDestroyed(CefRefPtr<CefWindow> window) {
_struct->on_window_destroyed(_struct, CefWindowCppToC::Wrap(window));
}
CefRefPtr<CefWindow> CefWindowDelegateCToCpp::GetParentWindow(
CefRefPtr<CefWindow> window,
bool* is_menu,
bool* can_activate_menu) {
cef_window_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_parent_window))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: window; type: refptr_diff
DCHECK(window.get());
if (!window.get())
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
int is_menuInt = is_menu ? *is_menu : 0;
// Translate param: can_activate_menu; type: bool_byaddr
int can_activate_menuInt = can_activate_menu ? *can_activate_menu : 0;
// Execute
cef_window_t* _retval =
_struct->get_parent_window(_struct, CefWindowCppToC::Wrap(window),
&is_menuInt, &can_activate_menuInt);
// Restore param:is_menu; type: bool_byaddr
if (is_menu)
*is_menu = is_menuInt ? true : false;
// Restore param:can_activate_menu; type: bool_byaddr
if (can_activate_menu)
*can_activate_menu = can_activate_menuInt ? true : false;
// Return type: refptr_diff
return CefWindowCppToC::Unwrap(_retval);
}
bool CefWindowDelegateCToCpp::IsFrameless(CefRefPtr<CefWindow> window) {
cef_window_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, is_frameless))

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=d6154885643d45eb81ecbd3a017776983a841651$
// $hash=9eb43c9bb618484946e6915808822b1af7ad2258$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_
@ -38,6 +38,9 @@ class CefWindowDelegateCToCpp
// CefWindowDelegate methods.
void OnWindowCreated(CefRefPtr<CefWindow> window) override;
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override;
CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
bool* is_menu,
bool* can_activate_menu) override;
bool IsFrameless(CefRefPtr<CefWindow> window) override;
bool CanResize(CefRefPtr<CefWindow> window) override;
bool CanMaximize(CefRefPtr<CefWindow> window) override;