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

@ -374,12 +374,16 @@ static_library("libcef_static") {
"libcef/browser/download_item_impl.h",
"libcef/browser/download_manager_delegate.cc",
"libcef/browser/download_manager_delegate.h",
"libcef/browser/extension_impl.cc",
"libcef/browser/extension_impl.h",
"libcef/browser/extensions/api/tabs/tabs_api.cc",
"libcef/browser/extensions/api/tabs/tabs_api.h",
"libcef/browser/extensions/browser_context_keyed_service_factories.cc",
"libcef/browser/extensions/browser_context_keyed_service_factories.h",
"libcef/browser/extensions/browser_extensions_util.cc",
"libcef/browser/extensions/browser_extensions_util.h",
"libcef/browser/extensions/browser_platform_delegate_background.cc",
"libcef/browser/extensions/browser_platform_delegate_background.h",
"libcef/browser/extensions/chrome_api_registration.cc",
"libcef/browser/extensions/chrome_api_registration.h",
"libcef/browser/extensions/component_extension_resource_manager.cc",
@ -388,10 +392,18 @@ static_library("libcef_static") {
"libcef/browser/extensions/extensions_api_client.h",
"libcef/browser/extensions/extensions_browser_client.cc",
"libcef/browser/extensions/extensions_browser_client.h",
"libcef/browser/extensions/extension_background_host.cc",
"libcef/browser/extensions/extension_background_host.h",
"libcef/browser/extensions/extension_function_details.cc",
"libcef/browser/extensions/extension_function_details.h",
"libcef/browser/extensions/extension_host_delegate.cc",
"libcef/browser/extensions/extension_host_delegate.h",
"libcef/browser/extensions/extension_system.cc",
"libcef/browser/extensions/extension_system.h",
"libcef/browser/extensions/extension_system_factory.cc",
"libcef/browser/extensions/extension_system_factory.h",
"libcef/browser/extensions/extension_view_host.cc",
"libcef/browser/extensions/extension_view_host.h",
"libcef/browser/extensions/extension_web_contents_observer.cc",
"libcef/browser/extensions/extension_web_contents_observer.h",
"libcef/browser/extensions/mime_handler_view_guest_delegate.cc",
@ -1578,6 +1590,13 @@ if (is_mac) {
]
}
bundle_data("cefclient_resources_bundle_data_extensions_set_page_color") {
sources = gypi_paths2.cefclient_sources_resources_extensions_set_page_color
outputs = [
"{{bundle_resources_dir}}/extensions/set_page_color/{{source_file_part}}",
]
}
bundle_data("cefclient_resources_bundle_data_english") {
sources = [
"tests/cefclient/resources/mac/English.lproj/InfoPlist.strings",
@ -1622,6 +1641,7 @@ if (is_mac) {
gypi_paths2.cefclient_sources_mac
deps = [
":cefclient_resources_bundle_data",
":cefclient_resources_bundle_data_extensions_set_page_color",
":cefclient_resources_bundle_data_english",
":cefclient_xibs",
":libcef_dll_wrapper",
@ -1785,6 +1805,11 @@ if (is_mac) {
gypi_paths2.cefclient_sources_resources
outputs = [ "${root_out_dir}/cefclient_files/{{source_file_part}}" ]
}
copy("copy_cefclient_files_extensions_set_page_color") {
sources = gypi_paths2.cefclient_sources_resources_extensions_set_page_color
outputs = [ "${root_out_dir}/cefclient_files/extensions/set_page_color/{{source_file_part}}" ]
}
}
executable("cefclient") {
@ -1797,7 +1822,8 @@ if (is_mac) {
gypi_paths2.cefclient_sources_browser +
gypi_paths2.cefclient_sources_common +
gypi_paths2.cefclient_sources_renderer +
gypi_paths2.cefclient_sources_resources
gypi_paths2.cefclient_sources_resources +
gypi_paths2.cefclient_sources_resources_extensions_set_page_color
deps = [
":libcef",
@ -1845,6 +1871,7 @@ if (is_mac) {
deps += [
":copy_cefclient_files",
":copy_cefclient_files_extensions_set_page_color",
]
libs = [

View File

@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=20588ad142633d169a929c7631888e287ab66b9a$
# $hash=2a6e7c37a8421d3c0d032cc907fb3058790ac71d$
#
{
@ -32,6 +32,8 @@
'include/cef_download_item.h',
'include/cef_drag_data.h',
'include/cef_drag_handler.h',
'include/cef_extension.h',
'include/cef_extension_handler.h',
'include/cef_file_util.h',
'include/cef_find_handler.h',
'include/cef_focus_handler.h',
@ -122,6 +124,8 @@
'include/capi/cef_download_item_capi.h',
'include/capi/cef_drag_data_capi.h',
'include/capi/cef_drag_handler_capi.h',
'include/capi/cef_extension_capi.h',
'include/capi/cef_extension_handler_capi.h',
'include/capi/cef_file_util_capi.h',
'include/capi/cef_find_handler_capi.h',
'include/capi/cef_focus_handler_capi.h',
@ -266,6 +270,10 @@
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
'libcef_dll/cpptoc/extension_cpptoc.cc',
'libcef_dll/cpptoc/extension_cpptoc.h',
'libcef_dll/ctocpp/extension_handler_ctocpp.cc',
'libcef_dll/ctocpp/extension_handler_ctocpp.h',
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc',
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
@ -280,6 +288,8 @@
'libcef_dll/cpptoc/geolocation_callback_cpptoc.h',
'libcef_dll/ctocpp/geolocation_handler_ctocpp.cc',
'libcef_dll/ctocpp/geolocation_handler_ctocpp.h',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
'libcef_dll/ctocpp/get_geolocation_callback_ctocpp.cc',
'libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h',
'libcef_dll/cpptoc/image_cpptoc.cc',
@ -304,6 +314,8 @@
'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h',
'libcef_dll/cpptoc/views/menu_button_pressed_lock_cpptoc.cc',
'libcef_dll/cpptoc/views/menu_button_pressed_lock_cpptoc.h',
'libcef_dll/cpptoc/menu_model_cpptoc.cc',
'libcef_dll/cpptoc/menu_model_cpptoc.h',
'libcef_dll/ctocpp/menu_model_delegate_ctocpp.cc',
@ -540,6 +552,10 @@
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
'libcef_dll/ctocpp/extension_ctocpp.cc',
'libcef_dll/ctocpp/extension_ctocpp.h',
'libcef_dll/cpptoc/extension_handler_cpptoc.cc',
'libcef_dll/cpptoc/extension_handler_cpptoc.h',
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc',
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
@ -554,6 +570,8 @@
'libcef_dll/ctocpp/geolocation_callback_ctocpp.h',
'libcef_dll/cpptoc/geolocation_handler_cpptoc.cc',
'libcef_dll/cpptoc/geolocation_handler_cpptoc.h',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
'libcef_dll/cpptoc/get_geolocation_callback_cpptoc.cc',
'libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h',
'libcef_dll/ctocpp/image_ctocpp.cc',
@ -578,6 +596,8 @@
'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h',
'libcef_dll/ctocpp/views/menu_button_pressed_lock_ctocpp.cc',
'libcef_dll/ctocpp/views/menu_button_pressed_lock_ctocpp.h',
'libcef_dll/ctocpp/menu_model_ctocpp.cc',
'libcef_dll/ctocpp/menu_model_ctocpp.h',
'libcef_dll/cpptoc/menu_model_delegate_cpptoc.cc',

View File

@ -146,6 +146,10 @@
'shared_sources_browser': [
'tests/shared/browser/client_app_browser.cc',
'tests/shared/browser/client_app_browser.h',
'tests/shared/browser/extension_util.cc',
'tests/shared/browser/extension_util.h',
'tests/shared/browser/file_util.cc',
'tests/shared/browser/file_util.h',
'tests/shared/browser/geometry_util.cc',
'tests/shared/browser/geometry_util.h',
'tests/shared/browser/main_message_loop.cc',
@ -155,7 +159,6 @@
'tests/shared/browser/main_message_loop_std.cc',
'tests/shared/browser/main_message_loop_std.h',
'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util.cc',
'tests/shared/browser/resource_util.h',
],
'shared_sources_common': [
@ -216,6 +219,8 @@
'tests/cefclient/browser/dialog_test.h',
'tests/cefclient/browser/drm_test.cc',
'tests/cefclient/browser/drm_test.h',
'tests/cefclient/browser/image_cache.cc',
'tests/cefclient/browser/image_cache.h',
'tests/cefclient/browser/main_context.cc',
'tests/cefclient/browser/main_context.h',
'tests/cefclient/browser/main_context_impl.cc',
@ -278,6 +283,13 @@
'tests/cefclient/resources/window.html',
'tests/cefclient/resources/xmlhttprequest.html',
],
'cefclient_sources_resources_extensions_set_page_color': [
'tests/cefclient/resources/extensions/set_page_color/icon.png',
'tests/cefclient/resources/extensions/set_page_color/manifest.json',
'tests/cefclient/resources/extensions/set_page_color/popup.html',
'tests/cefclient/resources/extensions/set_page_color/popup.js',
'tests/cefclient/resources/extensions/set_page_color/README.md',
],
'cefclient_sources_win': [
'tests/cefclient/browser/browser_window_osr_win.cc',
'tests/cefclient/browser/browser_window_osr_win.h',
@ -417,8 +429,11 @@
'tests/ceftests/dom_unittest.cc',
'tests/ceftests/download_unittest.cc',
'tests/ceftests/draggable_regions_unittest.cc',
'tests/ceftests/file_util.cc',
'tests/ceftests/file_util.h',
'tests/ceftests/extensions/background_unittest.cc',
'tests/ceftests/extensions/chrome_tabs_unittest.cc',
'tests/ceftests/extensions/extension_test_handler.cc',
'tests/ceftests/extensions/extension_test_handler.h',
'tests/ceftests/extensions/view_unittest.cc',
'tests/ceftests/file_util_unittest.cc',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/geolocation_unittest.cc',
@ -494,15 +509,14 @@
'tests/ceftests/run_all_unittests_mac.mm',
],
'ceftests_sources_mac_helper': [
'tests/shared/browser/resource_util.cc',
'tests/shared/browser/file_util.cc',
'tests/shared/browser/file_util.h',
'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util_mac.mm',
'tests/shared/browser/resource_util_posix.cc',
'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/dom_unittest.cc',
'tests/ceftests/file_util.cc',
'tests/ceftests/file_util.h',
'tests/ceftests/frame_unittest.cc',
'tests/ceftests/message_router_unittest.cc',
'tests/ceftests/navigation_unittest.cc',

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b6308ab5e97eb9f7af95f1f4c371fd6e7edbf852$
// $hash=a4831deeb05bc0a022c1a0ee6f1c484b338c741c$
//
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
@ -115,7 +115,8 @@ typedef struct _cef_browser_t {
void(CEF_CALLBACK* stop_load)(struct _cef_browser_t* self);
///
// Returns the globally unique identifier for this browser.
// Returns the globally unique identifier for this browser. This value is also
// used as the tabId for extension APIs.
///
int(CEF_CALLBACK* get_identifier)(struct _cef_browser_t* self);
@ -812,6 +813,30 @@ typedef struct _cef_browser_host_t {
///
void(CEF_CALLBACK* set_accessibility_state)(struct _cef_browser_host_t* self,
cef_state_t accessibility_state);
///
// Enable notifications of auto resize via
// cef_display_handler_t::OnAutoResize. Notifications are disabled by default.
// |min_size| and |max_size| define the range of allowed sizes.
///
void(CEF_CALLBACK* set_auto_resize_enabled)(struct _cef_browser_host_t* self,
int enabled,
const cef_size_t* min_size,
const cef_size_t* max_size);
///
// Returns the extension hosted in this browser or NULL if no extension is
// hosted. See cef_request_tContext::LoadExtension for details.
///
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_browser_host_t* self);
///
// Returns true (1) if this browser is hosting an extension background script.
// Background hosts do not have a window and are not displayable. See
// cef_request_tContext::LoadExtension for details.
///
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
} cef_browser_host_t;
///

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=f0f3fd4cab00c0eb11956e674a111cb30d3af100$
// $hash=979968e494e9d7c4d5117a1753acade5d0e79215$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
@ -121,6 +121,16 @@ typedef struct _cef_display_handler_t {
const cef_string_t* message,
const cef_string_t* source,
int line);
///
// Called when auto-resize is enabled via
// cef_browser_host_t::SetAutoResizeEnabled and the contents have auto-
// resized. |new_size| will be the desired size in view coordinates. Return
// true (1) if the resize was handled or false (0) for default handling.
///
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
struct _cef_browser_t* browser,
const cef_size_t* new_size);
} cef_display_handler_t;
#ifdef __cplusplus

View File

@ -0,0 +1,130 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=aef2f0bc7a2491b5745b5eae8d02e2e8bd7335af$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_extension_handler_t;
struct _cef_request_context_t;
///
// Object representing an extension. Methods may be called on any thread unless
// otherwise indicated.
///
typedef struct _cef_extension_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Returns the unique extension identifier. This is calculated based on the
// extension public key, if available, or on the extension path. See
// https://developer.chrome.com/extensions/manifest/key for details.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_identifier)(
struct _cef_extension_t* self);
///
// Returns the absolute path to the extension directory on disk. This value
// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
// cef_request_tContext::LoadExtension.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t(CEF_CALLBACK* get_path)(struct _cef_extension_t* self);
///
// Returns the extension manifest contents as a cef_dictionary_value_t object.
// See https://developer.chrome.com/extensions/manifest for details.
///
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_manifest)(
struct _cef_extension_t* self);
///
// Returns true (1) if this object is the same extension as |that| object.
// Extensions are considered the same if identifier, path and loader context
// match.
///
int(CEF_CALLBACK* is_same)(struct _cef_extension_t* self,
struct _cef_extension_t* that);
///
// Returns the handler for this extension. Will return NULL for internal
// extensions or if no handler was passed to
// cef_request_tContext::LoadExtension.
///
struct _cef_extension_handler_t*(CEF_CALLBACK* get_handler)(
struct _cef_extension_t* self);
///
// Returns the request context that loaded this extension. Will return NULL
// for internal extensions or if the extension has been unloaded. See the
// cef_request_tContext::LoadExtension documentation for more information
// about loader contexts. Must be called on the browser process UI thread.
///
struct _cef_request_context_t*(CEF_CALLBACK* get_loader_context)(
struct _cef_extension_t* self);
///
// Returns true (1) if this extension is currently loaded. Must be called on
// the browser process UI thread.
///
int(CEF_CALLBACK* is_loaded)(struct _cef_extension_t* self);
///
// Unload this extension if it is not an internal extension and is currently
// loaded. Will result in a call to
// cef_extension_tHandler::OnExtensionUnloaded on success.
///
void(CEF_CALLBACK* unload)(struct _cef_extension_t* self);
} cef_extension_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_

View File

@ -0,0 +1,183 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b49f4c91db8eccdfe9ded503d8bb32ee0e433f60$
//
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_stream_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
struct _cef_client_t;
///
// Callback structure used for asynchronous continuation of
// cef_extension_tHandler::GetExtensionResource.
///
typedef struct _cef_get_extension_resource_callback_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Continue the request. Read the resource contents from |stream|.
///
void(CEF_CALLBACK* cont)(struct _cef_get_extension_resource_callback_t* self,
struct _cef_stream_reader_t* stream);
///
// Cancel the request.
///
void(CEF_CALLBACK* cancel)(
struct _cef_get_extension_resource_callback_t* self);
} cef_get_extension_resource_callback_t;
///
// Implement this structure to handle events related to browser extensions. The
// functions of this structure will be called on the UI thread. See
// cef_request_tContext::LoadExtension for information about extension loading.
///
typedef struct _cef_extension_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called if the cef_request_tContext::LoadExtension request fails. |result|
// will be the error code.
///
void(CEF_CALLBACK* on_extension_load_failed)(
struct _cef_extension_handler_t* self,
cef_errorcode_t result);
///
// Called if the cef_request_tContext::LoadExtension request succeeds.
// |extension| is the loaded extension.
///
void(CEF_CALLBACK* on_extension_loaded)(struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension);
///
// Called after the cef_extension_t::Unload request has completed.
///
void(CEF_CALLBACK* on_extension_unloaded)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension);
///
// Called when an extension needs a browser to host a background script
// specified via the "background" manifest key. The browser will have no
// visible window and cannot be displayed. |extension| is the extension that
// is loading the background script. |url| is an internally generated
// reference to an HTML page that will be used to load the background script
// via a <script> src attribute. To allow creation of the browser optionally
// modify |client| and |settings| and return false (0). To cancel creation of
// the browser (and consequently cancel load of the background script) return
// true (1). Successful creation will be indicated by a call to
// cef_life_span_handler_t::OnAfterCreated, and
// cef_browser_host_t::IsBackgroundHost will return true (1) for the resulting
// browser. See https://developer.chrome.com/extensions/event_pages for more
// information about extension background script usage.
///
int(CEF_CALLBACK* on_before_background_browser)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
const cef_string_t* url,
struct _cef_client_t** client,
struct _cef_browser_settings_t* settings);
///
// Called when no tabId is specified to an extension API call that accepts a
// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
// source of the API call. Return the browser that will be acted on by the API
// call or return NULL to act on |browser|. The returned browser must share
// the same cef_request_tContext as |browser|. Incognito browsers should not
// be considered unless the source extension has incognito access enabled, in
// which case |include_incognito| will be true (1).
///
struct _cef_browser_t*(CEF_CALLBACK* get_active_browser)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
int include_incognito);
///
// Called when the tabId associated with |target_browser| is specified to an
// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
// |extension| and |browser| are the source of the API call. Return true (1)
// to allow access of false (0) to deny access. Access to incognito browsers
// should not be allowed unless the source extension has incognito access
// enabled, in which case |include_incognito| will be true (1).
///
int(CEF_CALLBACK* can_access_browser)(struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
int include_incognito,
struct _cef_browser_t* target_browser);
///
// Called to retrieve an extension resource that would normally be loaded from
// disk (e.g. if a file parameter is specified to chrome.tabs.executeScript).
// |extension| and |browser| are the source of the resource request. |file| is
// the requested relative file path. To handle the resource request return
// true (1) and execute |callback| either synchronously or asynchronously. For
// the default behavior which reads the resource from the extension directory
// on disk return false (0). Localization substitutions will not be applied to
// resources handled via this function.
///
int(CEF_CALLBACK* get_extension_resource)(
struct _cef_extension_handler_t* self,
struct _cef_extension_t* extension,
struct _cef_browser_t* browser,
const cef_string_t* file,
struct _cef_get_extension_resource_callback_t* callback);
} cef_extension_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=791231acc78a2b601257fb0b86d904eace796d63$
// $hash=81e857497b1f5e1732af7fca2250edf78c0e5415$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
@ -42,6 +42,8 @@
#include "include/capi/cef_callback_capi.h"
#include "include/capi/cef_cookie_capi.h"
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_request_context_handler_capi.h"
#include "include/capi/cef_values_capi.h"
@ -61,9 +63,9 @@ typedef struct _cef_resolve_callback_t {
cef_base_ref_counted_t base;
///
// Called after the ResolveHost request has completed. |result| will be the
// result code. |resolved_ips| will be the list of resolved IP addresses or
// NULL if the resolution failed.
// Called on the UI thread after the ResolveHost request has completed.
// |result| will be the result code. |resolved_ips| will be the list of
// resolved IP addresses or NULL if the resolution failed.
///
void(CEF_CALLBACK* on_resolve_completed)(struct _cef_resolve_callback_t* self,
cef_errorcode_t result,
@ -267,6 +269,95 @@ typedef struct _cef_request_context_t {
struct _cef_request_context_t* self,
const cef_string_t* origin,
cef_string_list_t resolved_ips);
///
// Load an extension.
//
// If extension resources will be read from disk using the default load
// implementation then |root_directory| should be the absolute path to the
// extension resources directory and |manifest| should be NULL. If extension
// resources will be provided by the client (e.g. via cef_request_tHandler
// and/or cef_extension_tHandler) then |root_directory| should be a path
// component unique to the extension (if not absolute this will be internally
// prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the
// contents that would otherwise be read from the "manifest.json" file on
// disk.
//
// The loaded extension will be accessible in all contexts sharing the same
// storage (HasExtension returns true (1)). However, only the context on which
// this function was called is considered the loader (DidLoadExtension returns
// true (1)) and only the loader will receive cef_request_tContextHandler
// callbacks for the extension.
//
// cef_extension_tHandler::OnExtensionLoaded will be called on load success or
// cef_extension_tHandler::OnExtensionLoadFailed will be called on load
// failure.
//
// If the extension specifies a background script via the "background"
// manifest key then cef_extension_tHandler::OnBeforeBackgroundBrowser will be
// called to create the background browser. See that function for additional
// information about background scripts.
//
// For visible extension views the client application should evaluate the
// manifest to determine the correct extension URL to load and then pass that
// URL to the cef_browser_host_t::CreateBrowser* function after the extension
// has loaded. For example, the client can look for the "browser_action"
// manifest key as documented at
// https://developer.chrome.com/extensions/browserAction. Extension URLs take
// the form "chrome-extension://<extension_id>/<path>".
//
// Browsers that host extensions differ from normal browsers as follows:
// - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
// chrome://extensions-support for the list of extension APIs currently
// supported by CEF.
// - Main frame navigation to non-extension content is blocked.
// - Pinch-zooming is disabled.
// - CefBrowserHost::GetExtension returns the hosted extension.
// - CefBrowserHost::IsBackgroundHost returns true for background hosts.
//
// See https://developer.chrome.com/extensions for extension implementation
// and usage documentation.
///
void(CEF_CALLBACK* load_extension)(struct _cef_request_context_t* self,
const cef_string_t* root_directory,
struct _cef_dictionary_value_t* manifest,
struct _cef_extension_handler_t* handler);
///
// Returns true (1) if this context was used to load the extension identified
// by |extension_id|. Other contexts sharing the same storage will also have
// access to the extension (see HasExtension). This function must be called on
// the browser process UI thread.
///
int(CEF_CALLBACK* did_load_extension)(struct _cef_request_context_t* self,
const cef_string_t* extension_id);
///
// Returns true (1) if this context has access to the extension identified by
// |extension_id|. This may not be the context that was used to load the
// extension (see DidLoadExtension). This function must be called on the
// browser process UI thread.
///
int(CEF_CALLBACK* has_extension)(struct _cef_request_context_t* self,
const cef_string_t* extension_id);
///
// Retrieve the list of all extensions that this context has access to (see
// HasExtension). |extension_ids| will be populated with the list of extension
// ID values. Returns true (1) on success. This function must be called on the
// browser process UI thread.
///
int(CEF_CALLBACK* get_extensions)(struct _cef_request_context_t* self,
cef_string_list_t extension_ids);
///
// Returns the extension matching |extension_id| or NULL if no matching
// extension is accessible in this context (see HasExtension). This function
// must be called on the browser process UI thread.
///
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
struct _cef_request_context_t* self,
const cef_string_t* extension_id);
} cef_request_context_t;
///

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=9359e227c9d534c9c612d2ede790136461836501$
// $hash=5a72321dd65325d93c1f920b08fc6bd462e74bdf$
//
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_
@ -48,6 +48,8 @@
extern "C" {
#endif
struct _cef_request_context_t;
///
// Implement this structure to provide handler implementations. The handler
// instance will not be released until all objects related to the context have
@ -59,6 +61,14 @@ typedef struct _cef_request_context_handler_t {
///
cef_base_ref_counted_t base;
///
// Called on the browser process UI thread immediately after the request
// context has been initialized.
///
void(CEF_CALLBACK* on_request_context_initialized)(
struct _cef_request_context_handler_t* self,
struct _cef_request_context_t* request_context);
///
// Called on the browser process IO thread to retrieve the cookie manager. If
// this function returns NULL the default cookie manager retrievable via

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=a2b3912f8188f19f3d5109aec1b1d03227e31429$
// $hash=bf895e77fc8bfc4760c17e2ec32d74a5cd9a91a1$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_MENU_BUTTON_DELEGATE_CAPI_H_
@ -48,6 +48,16 @@ extern "C" {
struct _cef_menu_button_t;
///
// MenuButton pressed lock is released when this object is destroyed.
///
typedef struct _cef_menu_button_pressed_lock_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
} cef_menu_button_pressed_lock_t;
///
// Implement this structure to handle MenuButton events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
@ -61,12 +71,15 @@ typedef struct _cef_menu_button_delegate_t {
///
// Called when |button| is pressed. Call cef_menu_button_t::show_menu() to
// show the resulting menu at |screen_point|.
// show a popup menu at |screen_point|. When showing a custom popup such as a
// window keep a reference to |button_pressed_lock| until the popup is hidden
// to maintain the pressed button state.
///
void(CEF_CALLBACK* on_menu_button_pressed)(
struct _cef_menu_button_delegate_t* self,
struct _cef_menu_button_t* menu_button,
const cef_point_t* screen_point);
const cef_point_t* screen_point,
struct _cef_menu_button_pressed_lock_t* button_pressed_lock);
} cef_menu_button_delegate_t;
#ifdef __cplusplus

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e4957abc4c3b80b9f324d74d2c8c6aa2632c52d9$
// $hash=5664bec47eefda37f8adb7bd153620559116f4a9$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@ -73,6 +73,20 @@ typedef struct _cef_window_delegate_t {
void(CEF_CALLBACK* on_window_destroyed)(struct _cef_window_delegate_t* self,
struct _cef_window_t* window);
///
// Return the parent for |window| or NULL if the |window| does not have a
// parent. Windows with parents will not get a taskbar button. Set |is_menu|
// to true (1) if |window| will be displayed as a menu, in which case it will
// not be clipped to the parent window bounds. Set |can_activate_menu| to
// false (0) if |is_menu| is true (1) and |window| should not be activated
// (given keyboard focus) when displayed.
///
struct _cef_window_t*(CEF_CALLBACK* get_parent_window)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window,
int* is_menu,
int* can_activate_menu);
///
// Return true (1) if |window| should be created without a frame or title bar.
// The window will be resizable if can_resize() returns true (1). Use

View File

@ -115,7 +115,8 @@ class CefBrowser : public virtual CefBaseRefCounted {
virtual void StopLoad() = 0;
///
// Returns the globally unique identifier for this browser.
// Returns the globally unique identifier for this browser. This value is also
// used as the tabId for extension APIs.
///
/*--cef()--*/
virtual int GetIdentifier() = 0;
@ -832,6 +833,31 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual void SetAccessibilityState(cef_state_t accessibility_state) = 0;
///
// Enable notifications of auto resize via CefDisplayHandler::OnAutoResize.
// Notifications are disabled by default. |min_size| and |max_size| define the
// range of allowed sizes.
///
/*--cef()--*/
virtual void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) = 0;
///
// Returns the extension hosted in this browser or NULL if no extension is
// hosted. See CefRequestContext::LoadExtension for details.
///
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension() = 0;
///
// Returns true if this browser is hosting an extension background script.
// Background hosts do not have a window and are not displayable. See
// CefRequestContext::LoadExtension for details.
///
/*--cef()--*/
virtual bool IsBackgroundHost() = 0;
};
#endif // CEF_INCLUDE_CEF_BROWSER_H_

View File

@ -114,6 +114,18 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
int line) {
return false;
}
///
// Called when auto-resize is enabled via CefBrowserHost::SetAutoResizeEnabled
// and the contents have auto-resized. |new_size| will be the desired size in
// view coordinates. Return true if the resize was handled or false for
// default handling.
///
/*--cef()--*/
virtual bool OnAutoResize(CefRefPtr<CefBrowser> browser,
const CefSize& new_size) {
return false;
}
};
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_

117
include/cef_extension.h Normal file
View File

@ -0,0 +1,117 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_EXTENSION_H_
#define CEF_INCLUDE_CEF_EXTENSION_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_values.h"
class CefExtensionHandler;
class CefRequestContext;
///
// Object representing an extension. Methods may be called on any thread unless
// otherwise indicated.
///
/*--cef(source=library)--*/
class CefExtension : public CefBaseRefCounted {
public:
///
// Returns the unique extension identifier. This is calculated based on the
// extension public key, if available, or on the extension path. See
// https://developer.chrome.com/extensions/manifest/key for details.
///
/*--cef()--*/
virtual CefString GetIdentifier() = 0;
///
// Returns the absolute path to the extension directory on disk. This value
// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
// CefRequestContext::LoadExtension.
///
/*--cef()--*/
virtual CefString GetPath() = 0;
///
// Returns the extension manifest contents as a CefDictionaryValue object. See
// https://developer.chrome.com/extensions/manifest for details.
///
/*--cef()--*/
virtual CefRefPtr<CefDictionaryValue> GetManifest() = 0;
///
// Returns true if this object is the same extension as |that| object.
// Extensions are considered the same if identifier, path and loader context
// match.
///
/*--cef()--*/
virtual bool IsSame(CefRefPtr<CefExtension> that) = 0;
///
// Returns the handler for this extension. Will return NULL for internal
// extensions or if no handler was passed to CefRequestContext::LoadExtension.
///
/*--cef()--*/
virtual CefRefPtr<CefExtensionHandler> GetHandler() = 0;
///
// Returns the request context that loaded this extension. Will return NULL
// for internal extensions or if the extension has been unloaded. See the
// CefRequestContext::LoadExtension documentation for more information about
// loader contexts. Must be called on the browser process UI thread.
///
/*--cef()--*/
virtual CefRefPtr<CefRequestContext> GetLoaderContext() = 0;
///
// Returns true if this extension is currently loaded. Must be called on the
// browser process UI thread.
///
/*--cef()--*/
virtual bool IsLoaded() = 0;
///
// Unload this extension if it is not an internal extension and is currently
// loaded. Will result in a call to CefExtensionHandler::OnExtensionUnloaded
// on success.
///
/*--cef()--*/
virtual void Unload() = 0;
};
#endif // CEF_INCLUDE_CEF_EXTENSION_H_

View File

@ -0,0 +1,172 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_
#define CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "include/cef_extension.h"
#include "include/cef_stream.h"
class CefClient;
///
// Callback interface used for asynchronous continuation of
// CefExtensionHandler::GetExtensionResource.
///
/*--cef(source=library)--*/
class CefGetExtensionResourceCallback : public CefBaseRefCounted {
public:
///
// Continue the request. Read the resource contents from |stream|.
///
/*--cef(capi_name=cont,optional_param=stream)--*/
virtual void Continue(CefRefPtr<CefStreamReader> stream) = 0;
///
// Cancel the request.
///
/*--cef()--*/
virtual void Cancel() = 0;
};
///
// Implement this interface to handle events related to browser extensions.
// The methods of this class will be called on the UI thread. See
// CefRequestContext::LoadExtension for information about extension loading.
///
/*--cef(source=client)--*/
class CefExtensionHandler : public virtual CefBaseRefCounted {
public:
///
// Called if the CefRequestContext::LoadExtension request fails. |result| will
// be the error code.
///
/*--cef()--*/
virtual void OnExtensionLoadFailed(cef_errorcode_t result) {}
///
// Called if the CefRequestContext::LoadExtension request succeeds.
// |extension| is the loaded extension.
///
/*--cef()--*/
virtual void OnExtensionLoaded(CefRefPtr<CefExtension> extension) {}
///
// Called after the CefExtension::Unload request has completed.
///
/*--cef()--*/
virtual void OnExtensionUnloaded(CefRefPtr<CefExtension> extension) {}
///
// Called when an extension needs a browser to host a background script
// specified via the "background" manifest key. The browser will have no
// visible window and cannot be displayed. |extension| is the extension that
// is loading the background script. |url| is an internally generated
// reference to an HTML page that will be used to load the background script
// via a <script> src attribute. To allow creation of the browser optionally
// modify |client| and |settings| and return false. To cancel creation of the
// browser (and consequently cancel load of the background script) return
// true. Successful creation will be indicated by a call to
// CefLifeSpanHandler::OnAfterCreated, and CefBrowserHost::IsBackgroundHost
// will return true for the resulting browser. See
// https://developer.chrome.com/extensions/event_pages for more information
// about extension background script usage.
///
/*--cef()--*/
virtual bool OnBeforeBackgroundBrowser(CefRefPtr<CefExtension> extension,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
return false;
}
///
// Called when no tabId is specified to an extension API call that accepts a
// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
// source of the API call. Return the browser that will be acted on by the API
// call or return NULL to act on |browser|. The returned browser must share
// the same CefRequestContext as |browser|. Incognito browsers should not be
// considered unless the source extension has incognito access enabled, in
// which case |include_incognito| will be true.
///
/*--cef()--*/
virtual CefRefPtr<CefBrowser> GetActiveBrowser(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito) {
return NULL;
}
///
// Called when the tabId associated with |target_browser| is specified to an
// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
// |extension| and |browser| are the source of the API call. Return true
// to allow access of false to deny access. Access to incognito browsers
// should not be allowed unless the source extension has incognito access
// enabled, in which case |include_incognito| will be true.
///
/*--cef()--*/
virtual bool CanAccessBrowser(CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito,
CefRefPtr<CefBrowser> target_browser) {
return true;
}
///
// Called to retrieve an extension resource that would normally be loaded from
// disk (e.g. if a file parameter is specified to chrome.tabs.executeScript).
// |extension| and |browser| are the source of the resource request. |file| is
// the requested relative file path. To handle the resource request return
// true and execute |callback| either synchronously or asynchronously. For the
// default behavior which reads the resource from the extension directory on
// disk return false. Localization substitutions will not be applied to
// resources handled via this method.
///
/*--cef()--*/
virtual bool GetExtensionResource(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
const CefString& file,
CefRefPtr<CefGetExtensionResourceCallback> callback) {
return false;
}
};
#endif // CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_

View File

@ -42,6 +42,8 @@
#include "include/cef_callback.h"
#include "include/cef_cookie.h"
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_request_context_handler.h"
#include "include/cef_values.h"
@ -54,9 +56,9 @@ class CefSchemeHandlerFactory;
class CefResolveCallback : public virtual CefBaseRefCounted {
public:
///
// Called after the ResolveHost request has completed. |result| will be the
// result code. |resolved_ips| will be the list of resolved IP addresses or
// empty if the resolution failed.
// Called on the UI thread after the ResolveHost request has completed.
// |result| will be the result code. |resolved_ips| will be the list of
// resolved IP addresses or empty if the resolution failed.
///
/*--cef(optional_param=resolved_ips)--*/
virtual void OnResolveCompleted(
@ -278,6 +280,92 @@ class CefRequestContext : public virtual CefBaseRefCounted {
virtual cef_errorcode_t ResolveHostCached(
const CefString& origin,
std::vector<CefString>& resolved_ips) = 0;
///
// Load an extension.
//
// If extension resources will be read from disk using the default load
// implementation then |root_directory| should be the absolute path to the
// extension resources directory and |manifest| should be NULL. If extension
// resources will be provided by the client (e.g. via CefRequestHandler and/or
// CefExtensionHandler) then |root_directory| should be a path component
// unique to the extension (if not absolute this will be internally prefixed
// with the PK_DIR_RESOURCES path) and |manifest| should contain the contents
// that would otherwise be read from the "manifest.json" file on disk.
//
// The loaded extension will be accessible in all contexts sharing the same
// storage (HasExtension returns true). However, only the context on which
// this method was called is considered the loader (DidLoadExtension returns
// true) and only the loader will receive CefRequestContextHandler callbacks
// for the extension.
//
// CefExtensionHandler::OnExtensionLoaded will be called on load success or
// CefExtensionHandler::OnExtensionLoadFailed will be called on load failure.
//
// If the extension specifies a background script via the "background"
// manifest key then CefExtensionHandler::OnBeforeBackgroundBrowser will be
// called to create the background browser. See that method for additional
// information about background scripts.
//
// For visible extension views the client application should evaluate the
// manifest to determine the correct extension URL to load and then pass that
// URL to the CefBrowserHost::CreateBrowser* function after the extension has
// loaded. For example, the client can look for the "browser_action" manifest
// key as documented at https://developer.chrome.com/extensions/browserAction.
// Extension URLs take the form "chrome-extension://<extension_id>/<path>".
//
// Browsers that host extensions differ from normal browsers as follows:
// - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
// chrome://extensions-support for the list of extension APIs currently
// supported by CEF.
// - Main frame navigation to non-extension content is blocked.
// - Pinch-zooming is disabled.
// - CefBrowserHost::GetExtension returns the hosted extension.
// - CefBrowserHost::IsBackgroundHost returns true for background hosts.
//
// See https://developer.chrome.com/extensions for extension implementation
// and usage documentation.
///
/*--cef(optional_param=manifest,optional_param=handler)--*/
virtual void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler) = 0;
///
// Returns true if this context was used to load the extension identified by
// |extension_id|. Other contexts sharing the same storage will also have
// access to the extension (see HasExtension). This method must be called on
// the browser process UI thread.
///
/*--cef()--*/
virtual bool DidLoadExtension(const CefString& extension_id) = 0;
///
// Returns true if this context has access to the extension identified by
// |extension_id|. This may not be the context that was used to load the
// extension (see DidLoadExtension). This method must be called on the browser
// process UI thread.
///
/*--cef()--*/
virtual bool HasExtension(const CefString& extension_id) = 0;
///
// Retrieve the list of all extensions that this context has access to (see
// HasExtension). |extension_ids| will be populated with the list of extension
// ID values. Returns true on success. This method must be called on the
// browser process UI thread.
///
/*--cef()--*/
virtual bool GetExtensions(std::vector<CefString>& extension_ids) = 0;
///
// Returns the extension matching |extension_id| or NULL if no matching
// extension is accessible in this context (see HasExtension). This method
// must be called on the browser process UI thread.
///
/*--cef()--*/
virtual CefRefPtr<CefExtension> GetExtension(
const CefString& extension_id) = 0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_

View File

@ -42,6 +42,8 @@
#include "include/cef_cookie.h"
#include "include/cef_web_plugin.h"
class CefRequestContext;
///
// Implement this interface to provide handler implementations. The handler
// instance will not be released until all objects related to the context have
@ -52,6 +54,14 @@ class CefRequestContextHandler : public virtual CefBaseRefCounted {
public:
typedef cef_plugin_policy_t PluginPolicy;
///
// Called on the browser process UI thread immediately after the request
// context has been initialized.
///
/*--cef()--*/
virtual void OnRequestContextInitialized(
CefRefPtr<CefRequestContext> request_context) {}
///
// Called on the browser process IO thread to retrieve the cookie manager. If
// this method returns NULL the default cookie manager retrievable via

View File

@ -840,6 +840,12 @@ typedef enum {
// and "~/Library/Application Support" directory on Mac OS X.
///
PK_USER_DATA,
///
// Directory containing application resources. Can be configured via
// CefSettings.resources_dir_path.
///
PK_DIR_RESOURCES,
} cef_path_key_t;
///

View File

@ -42,6 +42,12 @@
class CefMenuButton;
///
// MenuButton pressed lock is released when this object is destroyed.
///
/*--cef(source=library)--*/
class CefMenuButtonPressedLock : public CefBaseRefCounted {};
///
// Implement this interface to handle MenuButton events. The methods of this
// class will be called on the browser process UI thread unless otherwise
@ -51,12 +57,16 @@ class CefMenuButton;
class CefMenuButtonDelegate : public CefButtonDelegate {
public:
///
// Called when |button| is pressed. Call CefMenuButton::ShowMenu() to show the
// resulting menu at |screen_point|.
// Called when |button| is pressed. Call CefMenuButton::ShowMenu() to show a
// popup menu at |screen_point|. When showing a custom popup such as a window
// keep a reference to |button_pressed_lock| until the popup is hidden to
// maintain the pressed button state.
///
/*--cef()--*/
virtual void OnMenuButtonPressed(CefRefPtr<CefMenuButton> menu_button,
const CefPoint& screen_point) = 0;
virtual void OnMenuButtonPressed(
CefRefPtr<CefMenuButton> menu_button,
const CefPoint& screen_point,
CefRefPtr<CefMenuButtonPressedLock> button_pressed_lock) = 0;
};
#endif // CEF_INCLUDE_VIEWS_CEF_MENU_BUTTON_DELEGATE_H_

View File

@ -63,6 +63,21 @@ class CefWindowDelegate : public CefPanelDelegate {
/*--cef()--*/
virtual void OnWindowDestroyed(CefRefPtr<CefWindow> window) {}
///
// Return the parent for |window| or NULL if the |window| does not have a
// parent. Windows with parents will not get a taskbar button. Set |is_menu|
// to true if |window| will be displayed as a menu, in which case it will not
// be clipped to the parent window bounds. Set |can_activate_menu| to false
// if |is_menu| is true and |window| should not be activated (given keyboard
// focus) when displayed.
///
/*--cef()--*/
virtual CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
bool* is_menu,
bool* can_activate_menu) {
return NULL;
}
///
// Return true if |window| should be created without a frame or title bar. The
// window will be resizable if CanResize() returns true. Use

View File

@ -14,6 +14,7 @@
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/process_manager.h"
CefBrowserContext::CefBrowserContext(bool is_proxy)
: is_proxy_(is_proxy), extension_system_(NULL) {}
@ -49,6 +50,11 @@ void CefBrowserContext::Initialize() {
extension_system_->InitForRegularProfile(true);
}
resource_context_->set_extensions_info_map(extension_system_->info_map());
// Make sure the ProcessManager is created so that it receives extension
// load notifications. This is necessary for the proper initialization of
// background/event pages.
extensions::ProcessManager::Get(this);
}
}

View File

@ -329,6 +329,11 @@ void CefBrowserContextImpl::AddCefRequestContext(
void CefBrowserContextImpl::RemoveCefRequestContext(
CefRequestContextImpl* context) {
CEF_REQUIRE_UIT();
if (extensions::ExtensionsEnabled()) {
extension_system()->OnRequestContextDeleted(context);
}
request_context_set_.erase(context);
// Delete ourselves when the reference count reaches zero.
@ -382,7 +387,9 @@ CefBrowserContextImpl::CreateZoomLevelDelegate(
}
bool CefBrowserContextImpl::IsOffTheRecord() const {
return cache_path_.empty();
// CEF contexts are never flagged as off-the-record. It causes problems
// for the extension system.
return false;
}
content::DownloadManagerDelegate*

View File

@ -18,6 +18,10 @@
#include "libcef/browser/devtools_frontend.h"
#include "libcef/browser/devtools_manager_delegate.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_view_host.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/browser/image_impl.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/navigate_params.h"
@ -35,11 +39,11 @@
#include "libcef/common/main_delegate.h"
#include "libcef/common/process_message_impl.h"
#include "libcef/common/request_impl.h"
#include "libcef/common/values_impl.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
@ -66,6 +70,7 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/common/favicon_url.h"
#include "extensions/browser/process_manager.h"
#include "net/base/net_errors.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/events/base_event_utils.h"
@ -259,7 +264,7 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
CefBrowserHostImpl::CreateParams create_params;
create_params.window_info.reset(new CefWindowInfo(windowInfo));
create_params.client = client;
create_params.url = url;
create_params.url = GURL(url.ToString());
create_params.settings = settings;
create_params.request_context = request_context;
@ -303,7 +308,40 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
create_params.request_context = request_context_impl.get();
}
content::WebContents::CreateParams wc_create_params(browser_context);
CefRefPtr<CefExtension> cef_extension;
scoped_refptr<content::SiteInstance> site_instance;
if (extensions::ExtensionsEnabled() && !create_params.url.is_empty()) {
if (!create_params.extension) {
// We might be loading an extension app view where the extension URL is
// provided by the client.
create_params.extension =
extensions::GetExtensionForUrl(browser_context, create_params.url);
}
if (create_params.extension) {
cef_extension = browser_context->extension_system()->GetExtension(
create_params.extension->id());
DCHECK(cef_extension);
if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) {
// Default to dialog behavior.
create_params.extension_host_type =
extensions::VIEW_TYPE_EXTENSION_DIALOG;
}
// Extension resources will fail to load if we don't use a SiteInstance
// associated with the extension.
// (CefContentBrowserClient::SiteInstanceGotProcess won't find the
// extension to register with InfoMap, and AllowExtensionResourceLoad in
// ExtensionProtocolHandler::MaybeCreateJob will return false resulting in
// ERR_BLOCKED_BY_CLIENT).
site_instance = extensions::ProcessManager::Get(browser_context)
->GetSiteInstanceForURL(create_params.url);
DCHECK(site_instance);
}
}
content::WebContents::CreateParams wc_create_params(browser_context,
site_instance);
if (platform_delegate->IsWindowless()) {
// Create the OSR view for the WebContents.
@ -318,12 +356,21 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::CreateInternal(
create_params.settings, create_params.client, web_contents, info,
create_params.devtools_opener, is_devtools_popup,
create_params.request_context, std::move(platform_delegate));
if (browser.get() && !create_params.url.empty()) {
browser->LoadURL(CefFrameHostImpl::kMainFrameId, create_params.url,
create_params.request_context, std::move(platform_delegate),
cef_extension);
if (!browser)
return nullptr;
if (create_params.extension) {
browser->CreateExtensionHost(create_params.extension, browser_context,
web_contents, create_params.url,
create_params.extension_host_type);
} else if (!create_params.url.is_empty()) {
browser->LoadURL(CefFrameHostImpl::kMainFrameId, create_params.url.spec(),
content::Referrer(), ui::PAGE_TRANSITION_TYPED,
std::string());
}
return browser.get();
}
@ -336,7 +383,8 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
CefRefPtr<CefBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContext> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate) {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension) {
CEF_REQUIRE_UIT();
DCHECK(web_contents);
DCHECK(browser_info);
@ -363,7 +411,7 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
CefRefPtr<CefBrowserHostImpl> browser = new CefBrowserHostImpl(
settings, client, web_contents, browser_info, opener, request_context,
std::move(platform_delegate));
std::move(platform_delegate), extension);
if (!browser->CreateHostWindow())
return nullptr;
@ -947,6 +995,35 @@ void CefBrowserHostImpl::SetAccessibilityState(
web_contents_impl->SetAccessibilityMode(accMode);
}
void CefBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SetAutoResizeEnabled,
this, enabled, min_size, max_size));
return;
}
if (!web_contents() || !web_contents()->GetRenderViewHost())
return;
if (enabled) {
web_contents()->GetRenderViewHost()->EnableAutoResize(
gfx::Size(min_size.width, min_size.height),
gfx::Size(max_size.width, max_size.height));
} else {
web_contents()->GetRenderViewHost()->DisableAutoResize(gfx::Size());
}
}
CefRefPtr<CefExtension> CefBrowserHostImpl::GetExtension() {
return extension_;
}
bool CefBrowserHostImpl::IsBackgroundHost() {
return is_background_host_;
}
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
base::AutoLock lock_scope(state_lock_);
mouse_cursor_change_disabled_ = disabled;
@ -1446,6 +1523,7 @@ void CefBrowserHostImpl::DestroyBrowser() {
javascript_dialog_manager_->Destroy();
if (menu_manager_.get())
menu_manager_->Destroy();
DestroyExtensionHost();
// Notify any observers that may have state associated with this browser.
for (auto& observer : observers_)
@ -1783,6 +1861,13 @@ int CefBrowserHostImpl::browser_id() const {
return browser_info_->browser_id();
}
content::BrowserContext* CefBrowserHostImpl::GetBrowserContext() {
CEF_REQUIRE_UIT();
if (web_contents_)
return web_contents_->GetBrowserContext();
return nullptr;
}
void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
if (CEF_CURRENTLY_ON_UIT()) {
// SetFocus() might be called while inside the OnSetFocus() callback. If so,
@ -2098,6 +2183,26 @@ content::WebContents* CefBrowserHostImpl::OpenURLFromTab(
return nullptr;
}
bool CefBrowserHostImpl::ShouldTransferNavigation(
bool is_main_frame_navigation) {
if (extension_host_) {
return extension_host_->ShouldTransferNavigation(is_main_frame_navigation);
}
return true;
}
void CefBrowserHostImpl::AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
if (extension_host_) {
extension_host_->AddNewContents(source, new_contents, disposition,
initial_rect, user_gesture, was_blocked);
}
}
void CefBrowserHostImpl::LoadingStateChanged(content::WebContents* source,
bool to_different_document) {
int current_index =
@ -2274,6 +2379,14 @@ void CefBrowserHostImpl::HandleKeyboardEvent(
platform_delegate_->HandleKeyboardEvent(event);
}
bool CefBrowserHostImpl::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
if (extension_host_)
return extension_host_->PreHandleGestureEvent(source, event);
return false;
}
bool CefBrowserHostImpl::CanDragEnter(content::WebContents* source,
const content::DropData& data,
blink::WebDragOperationsMask mask) {
@ -2334,7 +2447,8 @@ void CefBrowserHostImpl::WebContentsCreated(
CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::CreateInternal(
settings, client, new_contents, info, opener, false,
browser_context->GetCefRequestContext(), std::move(platform_delegate));
browser_context->GetCefRequestContext(), std::move(platform_delegate),
nullptr);
}
void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
@ -2379,6 +2493,21 @@ void CefBrowserHostImpl::UpdatePreferredSize(content::WebContents* source,
#endif
}
void CefBrowserHostImpl::ResizeDueToAutoResize(content::WebContents* source,
const gfx::Size& new_size) {
CEF_REQUIRE_UIT();
if (client_) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler && handler->OnAutoResize(
this, CefSize(new_size.width(), new_size.height()))) {
return;
}
}
UpdatePreferredSize(source, new_size);
}
void CefBrowserHostImpl::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
@ -2444,6 +2573,12 @@ bool CefBrowserHostImpl::CheckMediaAccessPermission(
return command_line->HasSwitch(switches::kEnableMediaStream);
}
bool CefBrowserHostImpl::IsNeverVisible(content::WebContents* web_contents) {
if (extension_host_)
return extension_host_->IsNeverVisible(web_contents);
return false;
}
// content::WebContentsObserver methods.
// -----------------------------------------------------------------------------
@ -2924,7 +3059,8 @@ CefBrowserHostImpl::CefBrowserHostImpl(
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<CefBrowserHostImpl> opener,
CefRefPtr<CefRequestContext> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate)
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension)
: content::WebContentsObserver(web_contents),
settings_(settings),
client_(client),
@ -2949,7 +3085,8 @@ CefBrowserHostImpl::CefBrowserHostImpl(
is_in_onsetfocus_(false),
focus_on_editable_field_(false),
mouse_cursor_change_disabled_(false),
devtools_frontend_(NULL) {
devtools_frontend_(NULL),
extension_(extension) {
if (opener.get() && !platform_delegate_->IsViewsHosted()) {
// GetOpenerWindowHandle() only returns a value for non-views-hosted
// popup browsers.
@ -2986,8 +3123,10 @@ CefBrowserHostImpl::CefBrowserHostImpl(
printing::CefPrintViewManager::CreateForWebContents(web_contents_.get());
if (extensions::ExtensionsEnabled()) {
extensions::CefExtensionWebContentsObserver::CreateForWebContents(
web_contents_.get());
// Used by the tabs extension API.
SessionTabHelper::CreateForWebContents(web_contents_.get());
zoom::ZoomController::CreateForWebContents(web_contents_.get());
}
@ -3009,6 +3148,63 @@ bool CefBrowserHostImpl::CreateHostWindow() {
return success;
}
void CefBrowserHostImpl::CreateExtensionHost(
const extensions::Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
extensions::ViewType host_type) {
DCHECK(!extension_host_);
// Use the *Impl context because ProcessManager expects it for notification
// registration.
CefBrowserContextImpl* impl_context =
CefBrowserContextImpl::GetForContext(browser_context);
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
// Create an extension host that we own.
extension_host_ = new extensions::CefExtensionViewHost(
this, extension, impl_context, host_contents, url, host_type);
// Trigger load of the extension URL.
extension_host_->CreateRenderViewSoon();
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
is_background_host_ = true;
// Create an extension host that will be owned by ProcessManager.
extension_host_ = new extensions::CefExtensionBackgroundHost(
this, base::BindOnce(&CefBrowserHostImpl::OnExtensionHostDeleted, this),
extension, impl_context, host_contents, url, host_type);
// Load will be triggered by ProcessManager::CreateBackgroundHost.
} else {
NOTREACHED() << " Unsupported extension host type: " << host_type;
}
}
void CefBrowserHostImpl::DestroyExtensionHost() {
if (!extension_host_)
return;
if (extension_host_->extension_host_type() ==
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
DCHECK(is_background_host_);
// Close notification for background pages arrives via CloseContents.
// The extension host will be deleted by
// ProcessManager::CloseBackgroundHost and OnExtensionHostDeleted will be
// called to notify us.
extension_host_->Close();
} else {
DCHECK(!is_background_host_);
// We own the extension host and must delete it.
delete extension_host_;
extension_host_ = nullptr;
}
}
void CefBrowserHostImpl::OnExtensionHostDeleted() {
DCHECK(is_background_host_);
DCHECK(extension_host_);
extension_host_ = nullptr;
}
CefRefPtr<CefFrame> CefBrowserHostImpl::GetOrCreateFrame(
int64 frame_id,
int64 parent_frame_id,

View File

@ -31,12 +31,18 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/common/view_type.h"
namespace content {
struct DragEventSourceInfo;
class RenderWidgetHostImpl;
} // namespace content
namespace extensions {
class Extension;
class ExtensionHost;
} // namespace extensions
namespace net {
class URLRequest;
}
@ -111,8 +117,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Client implementation. May be nullptr.
CefRefPtr<CefClient> client;
// Initial URL to load. May be empty.
CefString url;
// Initial URL to load. May be empty. If this is a valid extension URL then
// the browser will be created as an app view extension host.
GURL url;
// Browser settings.
CefBrowserSettings settings;
@ -124,6 +131,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Request context to use when creating the browser. If nullptr the global
// request context will be used.
CefRefPtr<CefRequestContext> request_context;
// Used when explicitly creating the browser as an extension host via
// ProcessManager::CreateBackgroundHost.
const extensions::Extension* extension = nullptr;
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
};
// Create a new CefBrowserHostImpl instance.
@ -234,6 +246,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
void SetAccessibilityState(cef_state_t accessibility_state) override;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) override;
CefRefPtr<CefExtension> GetExtension() override;
bool IsBackgroundHost() override;
// CefBrowser methods.
CefRefPtr<CefBrowserHost> GetHost() override;
@ -352,6 +369,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; }
int browser_id() const;
// Accessors that must be called on the UI thread.
content::BrowserContext* GetBrowserContext();
extensions::ExtensionHost* extension_host() const { return extension_host_; }
void OnSetFocus(cef_focus_source_t source);
// Run the file chooser dialog specified by |params|. Only a single dialog may
@ -382,6 +403,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) override;
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) override;
void LoadingStateChanged(content::WebContents* source,
bool to_different_document) override;
void CloseContents(content::WebContents* source) override;
@ -402,6 +430,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
bool CanDragEnter(content::WebContents* source,
const content::DropData& data,
blink::WebDragOperationsMask operations_allowed) override;
@ -440,6 +470,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool final_update) override;
void UpdatePreferredSize(content::WebContents* source,
const gfx::Size& pref_size) override;
void ResizeDueToAutoResize(content::WebContents* source,
const gfx::Size& new_size) override;
void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
@ -447,6 +479,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool CheckMediaAccessPermission(content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type) override;
bool IsNeverVisible(content::WebContents* web_contents) override;
// content::WebContentsObserver methods.
using content::WebContentsObserver::BeforeUnloadFired;
@ -504,7 +537,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefBrowserHostImpl> opener,
bool is_devtools_popup,
CefRefPtr<CefRequestContext> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
// content::WebContentsObserver::OnMessageReceived() message handlers.
void OnFrameIdentified(int64 frame_id,
@ -533,11 +567,21 @@ class CefBrowserHostImpl : public CefBrowserHost,
scoped_refptr<CefBrowserInfo> browser_info,
CefRefPtr<CefBrowserHostImpl> opener,
CefRefPtr<CefRequestContext> request_context,
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
CefRefPtr<CefExtension> extension);
// Give the platform delegate an opportunity to create the host window.
bool CreateHostWindow();
// Create/delete the host for extensions.
void CreateExtensionHost(const extensions::Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
extensions::ViewType host_type);
void DestroyExtensionHost();
void OnExtensionHostDeleted();
// Updates and returns an existing frame or creates a new frame. Pass
// CefFrameHostImpl::kUnspecifiedFrameId for |parent_frame_id| if unknown.
CefRefPtr<CefFrame> GetOrCreateFrame(int64 frame_id,
@ -649,6 +693,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Used to provide unique incremental IDs for each find request.
int find_request_id_counter_ = 0;
// Used when the browser is hosting an extension.
extensions::ExtensionHost* extension_host_ = nullptr;
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);
};

View File

@ -210,6 +210,9 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
// NOTE: Destroy objects in reverse order of creation.
CefDevToolsManagerDelegate::StopHttpHandler();
// There should be no additional references to the global CefRequestContext
// during shutdown. Did you forget to release a CefBrowser reference?
DCHECK(global_request_context_->HasOneRef());
global_request_context_ = NULL;
if (extensions::ExtensionsEnabled()) {

View File

@ -11,6 +11,8 @@
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
#if defined(OS_WIN)
#include "libcef/browser/native/browser_platform_delegate_native_win.h"
#include "libcef/browser/osr/browser_platform_delegate_osr_win.h"
@ -78,6 +80,13 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
if (is_windowless)
return CreateOSRDelegate(std::move(native_delegate));
return std::move(native_delegate);
} else if (create_params.extension_host_type ==
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
// Creating a background extension host without a window.
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
CreateNativeDelegate(CefWindowInfo(), background_color);
return base::MakeUnique<CefBrowserPlatformDelegateBackground>(
std::move(native_delegate));
}
#if defined(USE_AURA)
else {

View File

@ -7,7 +7,7 @@
#include <algorithm>
#include <utility>
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
@ -574,6 +574,10 @@ void CefContentBrowserClient::SiteInstanceDeleting(
if (!extensions::ExtensionsBrowserClient::Get())
return;
// May be NULL during shutdown.
if (!site_instance->HasProcess())
return;
// If this isn't an extension renderer there's nothing to do.
const extensions::Extension* extension = GetExtension(site_instance);
if (!extension)
@ -625,6 +629,13 @@ CefContentBrowserClient::GetExtraServiceManifests() {
});
}
bool CefContentBrowserClient::IsSameBrowserContext(
content::BrowserContext* context1,
content::BrowserContext* context2) {
return CefBrowserContextImpl::GetForContext(context1) ==
CefBrowserContextImpl::GetForContext(context2);
}
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line,
int child_process_id) {
@ -731,8 +742,9 @@ void CefContentBrowserClient::GetQuotaSettings(
content::BrowserContext* context,
content::StoragePartition* partition,
storage::OptionalQuotaSettingsCallback callback) {
storage::GetNominalDynamicSettings(
partition->GetPath(), context->IsOffTheRecord(), std::move(callback));
const base::FilePath& cache_path = partition->GetPath();
storage::GetNominalDynamicSettings(cache_path, !cache_path.empty(),
std::move(callback));
}
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
@ -1015,6 +1027,8 @@ const extensions::Extension* CefContentBrowserClient::GetExtension(
content::SiteInstance* site_instance) {
extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(site_instance->GetBrowserContext());
if (!registry)
return nullptr;
return registry->enabled_extensions().GetExtensionOrAppByURL(
site_instance->GetSiteURL());
}

View File

@ -53,6 +53,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
std::unique_ptr<base::Value> GetServiceManifestOverlay(
base::StringPiece name) override;
std::vector<ServiceManifestInfo> GetExtraServiceManifests() override;
bool IsSameBrowserContext(content::BrowserContext* context1,
content::BrowserContext* context2) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override;
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;

View File

@ -0,0 +1,114 @@
// 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.
#include "libcef/browser/extension_impl.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/values_impl.h"
#include "extensions/common/extension.h"
CefExtensionImpl::CefExtensionImpl(const extensions::Extension* extension,
CefRequestContext* loader_context,
CefRefPtr<CefExtensionHandler> handler)
: id_(extension->id()),
path_(extension->path().value()),
manifest_(
new CefDictionaryValueImpl(extension->manifest()->value()->DeepCopy(),
true,
true)),
loader_context_(loader_context),
handler_(handler) {}
CefString CefExtensionImpl::GetIdentifier() {
return id_;
}
CefString CefExtensionImpl::GetPath() {
return path_;
}
CefRefPtr<CefDictionaryValue> CefExtensionImpl::GetManifest() {
return manifest_;
}
bool CefExtensionImpl::IsSame(CefRefPtr<CefExtension> that) {
CefExtensionImpl* that_impl = static_cast<CefExtensionImpl*>(that.get());
if (!that_impl)
return false;
// Maybe the same object.
if (this == that_impl)
return true;
return id_ == that_impl->id_ && path_ == that_impl->path_ &&
loader_context_ == that_impl->loader_context_;
}
CefRefPtr<CefExtensionHandler> CefExtensionImpl::GetHandler() {
return handler_;
}
CefRefPtr<CefRequestContext> CefExtensionImpl::GetLoaderContext() {
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return nullptr;
}
return loader_context_;
}
bool CefExtensionImpl::IsLoaded() {
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return false;
}
return !unloaded_;
}
void CefExtensionImpl::Unload() {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefExtensionImpl::Unload, this));
return;
}
// Will be NULL for internal extensions. They can't be unloaded.
if (!loader_context_)
return;
if (unloaded_)
return;
// CefExtensionHandler callbacks triggered by UnloadExtension may check this
// flag, so set it here.
unloaded_ = true;
const bool result = static_cast<CefRequestContextImpl*>(loader_context_)
->GetBrowserContext()
->extension_system()
->UnloadExtension(id_);
ALLOW_UNUSED_LOCAL(result);
DCHECK(result);
}
void CefExtensionImpl::OnExtensionLoaded() {
CEF_REQUIRE_UIT();
if (handler_)
handler_->OnExtensionLoaded(this);
}
void CefExtensionImpl::OnExtensionUnloaded() {
CEF_REQUIRE_UIT();
// Should not be called for internal extensions.
DCHECK(loader_context_);
unloaded_ = true;
loader_context_ = nullptr;
if (handler_)
handler_->OnExtensionUnloaded(this);
}

View File

@ -0,0 +1,58 @@
// 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.
#ifndef CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_
#define CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_
#pragma once
#include <memory>
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_request_context.h"
namespace extensions {
class Extension;
};
// CefNavigationEntry implementation
class CefExtensionImpl : public CefExtension {
public:
CefExtensionImpl(const extensions::Extension* extension,
CefRequestContext* loader_context,
CefRefPtr<CefExtensionHandler> handler);
// CefExtension methods.
CefString GetIdentifier() override;
CefString GetPath() override;
CefRefPtr<CefDictionaryValue> GetManifest() override;
bool IsSame(CefRefPtr<CefExtension> that) override;
CefRefPtr<CefExtensionHandler> GetHandler() override;
CefRefPtr<CefRequestContext> GetLoaderContext() override;
bool IsLoaded() override;
void Unload() override;
void OnExtensionLoaded();
void OnExtensionUnloaded();
// Use this instead of the GetLoaderContext version during
// CefRequestContext destruction.
CefRequestContext* loader_context() const { return loader_context_; }
private:
CefString id_;
CefString path_;
CefRefPtr<CefDictionaryValue> manifest_;
CefRequestContext* loader_context_;
CefRefPtr<CefExtensionHandler> handler_;
// Only accessed on the UI thread.
bool unloaded_ = false;
IMPLEMENT_REFCOUNTING(CefExtensionImpl);
DISALLOW_COPY_AND_ASSIGN(CefExtensionImpl);
};
#endif // CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_

View File

@ -1,21 +1,20 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright 2017 The Chromium Embedded Framework Authors. Portions copyright
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/extensions/api/tabs/tabs_api.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/request_context_impl.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/page_zoom.h"
#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/extension_zoom_request_client.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permissions_data.h"
namespace extensions {
@ -24,83 +23,12 @@ namespace cef {
namespace keys = extensions::tabs_constants;
namespace tabs = api::tabs;
using api::extension_types::InjectDetails;
namespace {
const char kNotImplementedError[] = "Not implemented";
// Any out parameter (|browser|, |contents|, & |tab_index|) may be NULL and will
// not be set within the function.
// Based on ExtensionTabUtil::GetTabById().
bool GetTabById(int tab_id,
content::BrowserContext* browser_context,
bool include_incognito,
CefRefPtr<CefBrowserHostImpl>* browser,
content::WebContents** contents) {
if (tab_id == api::tabs::TAB_ID_NONE)
return false;
// As an extra security check make sure we're operating in the same
// BrowserContext.
Profile* profile = Profile::FromBrowserContext(browser_context);
Profile* incognito_profile =
include_incognito && profile->HasOffTheRecordProfile()
? profile->GetOffTheRecordProfile()
: NULL;
CefBrowserInfoManager::BrowserInfoList list;
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList(list);
for (auto browser_info : list) {
CefRefPtr<CefBrowserHostImpl> cef_browser = browser_info->browser();
if (!cef_browser)
continue;
CefRefPtr<CefRequestContext> request_context =
cef_browser->GetRequestContext();
if (!request_context)
continue;
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetOrCreateForRequestContext(request_context);
if (!request_context_impl)
continue;
CefBrowserContext* browser_context =
request_context_impl->GetBrowserContext();
if (!browser_context)
continue;
if (browser_context == profile || browser_context == incognito_profile) {
content::WebContents* web_contents = cef_browser->web_contents();
if (SessionTabHelper::IdForTab(web_contents) == tab_id) {
if (browser)
*browser = cef_browser;
if (contents)
*contents = web_contents;
return true;
}
}
}
return false;
}
// |error_message| can optionally be passed in and will be set with an
// appropriate message if the tab cannot be found by id.
bool GetTabById(int tab_id,
content::BrowserContext* browser_context,
bool include_incognito,
CefRefPtr<CefBrowserHostImpl>* browser,
content::WebContents** contents,
std::string* error_message) {
if (GetTabById(tab_id, browser_context, include_incognito, browser,
contents)) {
return true;
}
if (error_message) {
*error_message = ErrorUtils::FormatErrorMessage(keys::kTabNotFoundError,
base::IntToString(tab_id));
}
return false;
}
void ZoomModeToZoomSettings(zoom::ZoomController::ZoomMode zoom_mode,
api::tabs::ZoomSettings* zoom_settings) {
DCHECK(zoom_settings);
@ -130,18 +58,172 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() {
return RespondNow(Error(kNotImplementedError));
}
content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
content::WebContents* web_contents = NULL;
if (tab_id != -1) {
// We assume this call leaves web_contents unchanged if it is unsuccessful.
GetTabById(tab_id, context_, include_incognito(),
NULL /* ignore CefBrowserHostImpl* output */, &web_contents,
&error_);
} else {
// Use the sender as the default.
web_contents = GetSenderWebContents();
ExecuteCodeInTabFunction::ExecuteCodeInTabFunction()
: cef_details_(this), execute_tab_id_(-1) {}
ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {}
bool ExecuteCodeInTabFunction::HasPermission() {
if (Init() == SUCCESS &&
// TODO(devlin/lazyboy): Consider removing the following check as it isn't
// doing anything. The fallback to ExtensionFunction::HasPermission()
// below dictates what this function returns.
extension_->permissions_data()->HasAPIPermissionForTab(
execute_tab_id_, APIPermission::kTab)) {
return true;
}
return web_contents;
return ExtensionFunction::HasPermission();
}
ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
if (init_result_)
return init_result_.value();
// |tab_id| is optional so it's ok if it's not there.
int tab_id = -1;
if (args_->GetInteger(0, &tab_id) && tab_id < 0)
return set_init_result(VALIDATION_FAILURE);
// |details| are not optional.
base::DictionaryValue* details_value = NULL;
if (!args_->GetDictionary(1, &details_value))
return set_init_result(VALIDATION_FAILURE);
std::unique_ptr<InjectDetails> details(new InjectDetails());
if (!InjectDetails::Populate(*details_value, details.get()))
return set_init_result(VALIDATION_FAILURE);
// Find a browser that we can access, or fail with error.
std::string error;
CefRefPtr<CefBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error);
if (!browser)
return set_init_result_error(error);
execute_tab_id_ = browser->GetIdentifier();
details_ = std::move(details);
set_host_id(HostID(HostID::EXTENSIONS, extension()->id()));
return set_init_result(SUCCESS);
}
bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
CHECK_GE(execute_tab_id_, 0);
CefRefPtr<CefBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, &error_);
if (!browser)
return false;
int frame_id = details_->frame_id ? *details_->frame_id
: ExtensionApiFrameIdMap::kTopFrameId;
content::RenderFrameHost* rfh =
ExtensionApiFrameIdMap::GetRenderFrameHostById(browser->web_contents(),
frame_id);
if (!rfh) {
error_ = ErrorUtils::FormatErrorMessage(keys::kFrameNotFoundError,
base::IntToString(frame_id),
base::IntToString(execute_tab_id_));
return false;
}
// Content scripts declared in manifest.json can access frames at about:-URLs
// if the extension has permission to access the frame's origin, so also allow
// programmatic content scripts at about:-URLs for allowed origins.
GURL effective_document_url(rfh->GetLastCommittedURL());
bool is_about_url = effective_document_url.SchemeIs(url::kAboutScheme);
if (is_about_url && details_->match_about_blank &&
*details_->match_about_blank) {
effective_document_url = GURL(rfh->GetLastCommittedOrigin().Serialize());
}
if (!effective_document_url.is_valid()) {
// Unknown URL, e.g. because no load was committed yet. Allow for now, the
// renderer will check again and fail the injection if needed.
return true;
}
// NOTE: This can give the wrong answer due to race conditions, but it is OK,
// we check again in the renderer.
if (!extension()->permissions_data()->CanAccessPage(
extension(), effective_document_url, execute_tab_id_, &error_)) {
if (is_about_url &&
extension()->permissions_data()->active_permissions().HasAPIPermission(
APIPermission::kTab)) {
error_ = ErrorUtils::FormatErrorMessage(
manifest_errors::kCannotAccessAboutUrl,
rfh->GetLastCommittedURL().spec(),
rfh->GetLastCommittedOrigin().Serialize());
}
return false;
}
return true;
}
ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor() {
CHECK_GE(execute_tab_id_, 0);
CefRefPtr<CefBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, &error_);
if (!browser)
return nullptr;
return CefExtensionWebContentsObserver::FromWebContents(
browser->web_contents())
->script_executor();
}
bool ExecuteCodeInTabFunction::IsWebView() const {
return false;
}
const GURL& ExecuteCodeInTabFunction::GetWebViewSrc() const {
return GURL::EmptyGURL();
}
bool ExecuteCodeInTabFunction::LoadFile(const std::string& file) {
if (cef_details_.LoadFile(
file, base::BindOnce(&ExecuteCodeInTabFunction::LoadFileComplete,
this, file))) {
return true;
}
// Default handling.
return ExecuteCodeFunction::LoadFile(file);
}
void ExecuteCodeInTabFunction::LoadFileComplete(
const std::string& file,
std::unique_ptr<std::string> data) {
DidLoadAndLocalizeFile(file, !!data.get(), std::move(data));
}
bool TabsExecuteScriptFunction::ShouldInsertCSS() const {
return false;
}
void TabsExecuteScriptFunction::OnExecuteCodeFinished(
const std::string& error,
const GURL& on_url,
const base::ListValue& result) {
if (error.empty())
SetResult(result.CreateDeepCopy());
ExecuteCodeInTabFunction::OnExecuteCodeFinished(error, on_url, result);
}
bool TabsInsertCSSFunction::ShouldInsertCSS() const {
return true;
}
ZoomAPIFunction::ZoomAPIFunction() : cef_details_(this) {}
content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
// Find a browser that we can access, or set |error_| and return nullptr.
CefRefPtr<CefBrowserHostImpl> browser =
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error_);
if (!browser)
return nullptr;
return browser->web_contents();
}
bool TabsSetZoomFunction::RunAsync() {

View File

@ -5,7 +5,10 @@
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
#include "libcef/browser/extensions/extension_function_details.h"
#include "chrome/common/extensions/api/tabs.h"
#include "extensions/browser/api/execute_code_function.h"
#include "extensions/browser/extension_function.h"
// The contents of this file are extracted from
@ -26,17 +29,72 @@ class TabsGetFunction : public UIThreadExtensionFunction {
DECLARE_EXTENSION_FUNCTION("tabs.get", TABS_GET)
};
// Implement API call tabs.executeScript and tabs.insertCSS.
class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
public:
ExecuteCodeInTabFunction();
protected:
~ExecuteCodeInTabFunction() override;
// ExtensionFunction:
bool HasPermission() override;
// Initializes |execute_tab_id_| and |details_|.
InitResult Init() override;
bool CanExecuteScriptOnPage() override;
ScriptExecutor* GetScriptExecutor() override;
bool IsWebView() const override;
const GURL& GetWebViewSrc() const override;
bool LoadFile(const std::string& file) override;
private:
const CefExtensionFunctionDetails cef_details_;
void LoadFileComplete(const std::string& file,
std::unique_ptr<std::string> data);
// Id of tab which executes code.
int execute_tab_id_;
};
class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
protected:
bool ShouldInsertCSS() const override;
private:
~TabsExecuteScriptFunction() override {}
void OnExecuteCodeFinished(const std::string& error,
const GURL& on_url,
const base::ListValue& script_result) override;
DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT)
};
class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
private:
~TabsInsertCSSFunction() override {}
bool ShouldInsertCSS() const override;
DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS)
};
class ZoomAPIFunction : public AsyncExtensionFunction {
public:
ZoomAPIFunction();
protected:
~ZoomAPIFunction() override {}
// Gets the WebContents for |tab_id| if it is specified. Otherwise get the
// WebContents for the active tab in the current window. Calling this function
// may set error_.
//
// TODO(...) many other tabs API functions use similar behavior. There should
// be a way to share this implementation somehow.
content::WebContents* GetWebContents(int tab_id);
private:
const CefExtensionFunctionDetails cef_details_;
};
class TabsSetZoomFunction : public ZoomAPIFunction {

View File

@ -4,6 +4,7 @@
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
@ -13,6 +14,7 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_plugin_guest_manager.h"
#include "extensions/browser/extension_registry.h"
namespace extensions {
@ -130,4 +132,45 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
return browser;
}
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabId(
int tab_id,
content::BrowserContext* browser_context) {
CEF_REQUIRE_UIT();
DCHECK(browser_context);
if (tab_id == -1 || !browser_context)
return nullptr;
CefBrowserContextImpl* browser_context_impl =
CefBrowserContextImpl::GetForContext(browser_context);
CefBrowserInfoManager::BrowserInfoList list;
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList(list);
for (auto browser_info : list) {
CefRefPtr<CefBrowserHostImpl> current_browser = browser_info->browser();
if (current_browser && current_browser->GetIdentifier() == tab_id) {
// Make sure we're operating in the same BrowserContextImpl.
if (CefBrowserContextImpl::GetForContext(
current_browser->GetBrowserContext()) == browser_context_impl) {
return current_browser;
} else {
LOG(WARNING) << "Browser with tabId " << tab_id
<< " cannot be accessed because is uses a different "
"CefRequestContext";
break;
}
}
}
return nullptr;
}
const Extension* GetExtensionForUrl(content::BrowserContext* browser_context,
const GURL& url) {
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context);
if (!registry)
return nullptr;
std::string extension_id = url.host();
return registry->enabled_extensions().GetByID(extension_id);
}
} // namespace extensions

View File

@ -9,13 +9,18 @@
#include "libcef/browser/browser_host_impl.h"
#include "url/gurl.h"
namespace content {
class BrowserContext;
class RenderViewHost;
class WebContents;
}
} // namespace content
namespace extensions {
class Extension;
// Returns the full-page guest WebContents for the specified |owner|, if any.
content::WebContents* GetFullPageGuestForOwnerContents(
content::WebContents* owner);
@ -47,6 +52,18 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
content::RenderFrameHost* host,
bool* is_guest_view);
// Returns the browser matching |tab_id| and |browser_context|. Returns false if
// |tab_id| is -1 or a matching browser cannot be found within
// |browser_context|. Similar in concept to ExtensionTabUtil::GetTabById.
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabId(
int tab_id,
content::BrowserContext* browser_context);
// Returns the extension associated with |url| in |profile|. Returns nullptr
// if the extension does not exist.
const Extension* GetExtensionForUrl(content::BrowserContext* browser_context,
const GURL& url);
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_

View File

@ -0,0 +1,153 @@
// Copyright 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.
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
#include <utility>
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/thread_util.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
CefBrowserPlatformDelegateBackground::CefBrowserPlatformDelegateBackground(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
: native_delegate_(std::move(native_delegate)) {
native_delegate_->set_windowless_handler(this);
}
bool CefBrowserPlatformDelegateBackground::CreateHostWindow() {
// Nothing to do here.
return true;
}
void CefBrowserPlatformDelegateBackground::CloseHostWindow() {
// No host window, so continue browser destruction now. Do it asynchronously
// so the call stack has a chance to unwind.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::WindowDestroyed, browser_));
}
CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle()
const {
return kNullWindowHandle;
}
SkColor CefBrowserPlatformDelegateBackground::GetBackgroundColor() const {
return native_delegate_->GetBackgroundColor();
}
void CefBrowserPlatformDelegateBackground::WasResized() {
// Nothing to do here.
}
void CefBrowserPlatformDelegateBackground::SendKeyEvent(
const content::NativeWebKeyboardEvent& event) {
// Nothing to do here.
}
void CefBrowserPlatformDelegateBackground::SendMouseEvent(
const blink::WebMouseEvent& event) {
// Nothing to do here.
}
void CefBrowserPlatformDelegateBackground::SendMouseWheelEvent(
const blink::WebMouseWheelEvent& event) {
// Nothing to do here.
}
void CefBrowserPlatformDelegateBackground::SendFocusEvent(bool setFocus) {
// Nothing to do here.
}
gfx::Point CefBrowserPlatformDelegateBackground::GetScreenPoint(
const gfx::Point& view_pt) const {
// Nothing to do here.
return view_pt;
}
void CefBrowserPlatformDelegateBackground::ViewText(const std::string& text) {
native_delegate_->ViewText(text);
}
void CefBrowserPlatformDelegateBackground::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
// Nothing to do here.
}
void CefBrowserPlatformDelegateBackground::HandleExternalProtocol(
const GURL& url) {
native_delegate_->HandleExternalProtocol(url);
}
void CefBrowserPlatformDelegateBackground::TranslateKeyEvent(
content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const {
native_delegate_->TranslateKeyEvent(result, key_event);
}
void CefBrowserPlatformDelegateBackground::TranslateClickEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const {
native_delegate_->TranslateClickEvent(result, mouse_event, type, mouseUp,
clickCount);
}
void CefBrowserPlatformDelegateBackground::TranslateMoveEvent(
blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const {
native_delegate_->TranslateMoveEvent(result, mouse_event, mouseLeave);
}
void CefBrowserPlatformDelegateBackground::TranslateWheelEvent(
blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const {
native_delegate_->TranslateWheelEvent(result, mouse_event, deltaX, deltaY);
}
CefEventHandle CefBrowserPlatformDelegateBackground::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
return native_delegate_->GetEventHandle(event);
}
std::unique_ptr<CefFileDialogRunner>
CefBrowserPlatformDelegateBackground::CreateFileDialogRunner() {
return native_delegate_->CreateFileDialogRunner();
}
std::unique_ptr<CefJavaScriptDialogRunner>
CefBrowserPlatformDelegateBackground::CreateJavaScriptDialogRunner() {
return native_delegate_->CreateJavaScriptDialogRunner();
}
std::unique_ptr<CefMenuRunner>
CefBrowserPlatformDelegateBackground::CreateMenuRunner() {
// No default menu implementation for background browsers.
return nullptr;
}
bool CefBrowserPlatformDelegateBackground::IsWindowless() const {
return false;
}
bool CefBrowserPlatformDelegateBackground::IsViewsHosted() const {
return false;
}
CefWindowHandle CefBrowserPlatformDelegateBackground::GetParentWindowHandle()
const {
return GetHostWindowHandle();
}
gfx::Point CefBrowserPlatformDelegateBackground::GetParentScreenPoint(
const gfx::Point& view) const {
return GetScreenPoint(view);
}

View File

@ -0,0 +1,66 @@
// Copyright 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.
#ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_
#define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/native/browser_platform_delegate_native.h"
// Implementation of browser functionality for background script hosts.
class CefBrowserPlatformDelegateBackground
: public CefBrowserPlatformDelegate,
public CefBrowserPlatformDelegateNative::WindowlessHandler {
public:
// Platform-specific behaviors will be delegated to |native_delegate|.
CefBrowserPlatformDelegateBackground(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate);
// CefBrowserPlatformDelegate methods:
bool CreateHostWindow() override;
void CloseHostWindow() override;
CefWindowHandle GetHostWindowHandle() const override;
SkColor GetBackgroundColor() const override;
void WasResized() override;
void SendKeyEvent(const content::NativeWebKeyboardEvent& event) override;
void SendMouseEvent(const blink::WebMouseEvent& event) override;
void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event) override;
void SendFocusEvent(bool setFocus) override;
gfx::Point GetScreenPoint(const gfx::Point& view) const override;
void ViewText(const std::string& text) override;
void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
void HandleExternalProtocol(const GURL& url) override;
void TranslateKeyEvent(content::NativeWebKeyboardEvent& result,
const CefKeyEvent& key_event) const override;
void TranslateClickEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
CefBrowserHost::MouseButtonType type,
bool mouseUp,
int clickCount) const override;
void TranslateMoveEvent(blink::WebMouseEvent& result,
const CefMouseEvent& mouse_event,
bool mouseLeave) const override;
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
const CefMouseEvent& mouse_event,
int deltaX,
int deltaY) const override;
CefEventHandle GetEventHandle(
const content::NativeWebKeyboardEvent& event) const override;
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
override;
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
bool IsWindowless() const override;
bool IsViewsHosted() const override;
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
CefWindowHandle GetParentWindowHandle() const override;
gfx::Point GetParentScreenPoint(const gfx::Point& view) const override;
private:
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
};
#endif // CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_

View File

@ -22,23 +22,29 @@ namespace cefimpl = extensions::cef;
#define EXTENSION_FUNCTION_NAME(classname) classname::function_name()
// Maintain the same order as https://developer.chrome.com/extensions/api_index
// so chrome://extensions-support looks nice.
const char* const kSupportedAPIs[] = {
"resourcesPrivate",
EXTENSION_FUNCTION_NAME(ResourcesPrivateGetStringsFunction),
"streamsPrivate",
EXTENSION_FUNCTION_NAME(StreamsPrivateAbortFunction),
"tabs",
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsExecuteScriptFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsInsertCSSFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomSettingsFunction),
nullptr, // Indicates end of array.
};
// Only add APIs to this list that have been tested in CEF.
// static
bool ChromeFunctionRegistry::IsSupported(const std::string& name) {
static const char* const supported_apis[] = {
"resourcesPrivate",
EXTENSION_FUNCTION_NAME(ResourcesPrivateGetStringsFunction),
"streamsPrivate",
EXTENSION_FUNCTION_NAME(StreamsPrivateAbortFunction),
"tabs",
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomSettingsFunction),
};
for (size_t i = 0; i < arraysize(supported_apis); ++i) {
if (name == supported_apis[i])
for (size_t i = 0; kSupportedAPIs[i] != nullptr; ++i) {
if (name == kSupportedAPIs[i])
return true;
}
return false;
@ -49,6 +55,8 @@ bool ChromeFunctionRegistry::IsSupported(const std::string& name) {
void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) {
registry->RegisterFunction<ResourcesPrivateGetStringsFunction>();
registry->RegisterFunction<StreamsPrivateAbortFunction>();
registry->RegisterFunction<cefimpl::TabsExecuteScriptFunction>();
registry->RegisterFunction<cefimpl::TabsInsertCSSFunction>();
registry->RegisterFunction<cefimpl::TabsGetFunction>();
registry->RegisterFunction<cefimpl::TabsSetZoomFunction>();
registry->RegisterFunction<cefimpl::TabsGetZoomFunction>();

View File

@ -13,6 +13,9 @@ namespace extensions {
namespace api {
namespace cef {
// Array of currently supported APIs.
extern const char* const kSupportedAPIs[];
class ChromeFunctionRegistry {
public:
static bool IsSupported(const std::string& name);

View File

@ -0,0 +1,46 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/extensions/extension_background_host.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/extensions/extension_host_delegate.h"
#include "base/callback.h"
namespace extensions {
CefExtensionBackgroundHost::CefExtensionBackgroundHost(
CefBrowserHostImpl* browser,
base::OnceClosure deleted_callback,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type)
: ExtensionHost(new CefExtensionHostDelegate(browser),
extension,
browser_context,
host_contents,
url,
host_type),
deleted_callback_(std::move(deleted_callback)) {
DCHECK(!deleted_callback_.is_null());
// Only used for background pages.
DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
}
CefExtensionBackgroundHost::~CefExtensionBackgroundHost() {
std::move(deleted_callback_).Run();
}
bool CefExtensionBackgroundHost::ShouldTransferNavigation(
bool is_main_frame_navigation) {
// Block navigations that cause the main frame to navigate to non-extension
// content (i.e. to web content).
return !is_main_frame_navigation;
}
} // namespace extensions

View File

@ -0,0 +1,48 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_BACKGROUND_HOST_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_BACKGROUND_HOST_H_
#include <memory>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "extensions/browser/extension_host.h"
class CefBrowserHostImpl;
namespace content {
class WebContents;
} // namespace content
namespace extensions {
// The ExtensionHost for a background page. This is a thin wrapper around the
// ExtensionHost base class to support CEF-specific constructor. Object lifespan
// is managed by ProcessManager.
class CefExtensionBackgroundHost : public ExtensionHost {
public:
CefExtensionBackgroundHost(CefBrowserHostImpl* browser,
base::OnceClosure deleted_callback,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type);
~CefExtensionBackgroundHost() override;
// content::WebContentsDelegate methods:
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
private:
// Callback that will be executed on host deletion.
base::OnceClosure deleted_callback_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionBackgroundHost);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_BACKGROUND_HOST_H_

View File

@ -0,0 +1,291 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2014 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/extensions/extension_function_details.h"
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/thread_util.h"
#include "base/task_scheduler/post_task.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/error_utils.h"
using content::WebContents;
using content::RenderViewHost;
namespace extensions {
namespace keys = extensions::tabs_constants;
namespace {
class CefGetExtensionLoadFileCallbackImpl
: public CefGetExtensionResourceCallback {
public:
CefGetExtensionLoadFileCallbackImpl(
const std::string& file,
CefExtensionFunctionDetails::LoadFileCallback callback)
: file_(file), callback_(std::move(callback)) {}
~CefGetExtensionLoadFileCallbackImpl() {
if (!callback_.is_null()) {
// The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_UIT()) {
RunNow(file_, std::move(callback_), nullptr);
} else {
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefGetExtensionLoadFileCallbackImpl::RunNow, file_,
base::Passed(std::move(callback_)), nullptr));
}
}
}
void Continue(CefRefPtr<CefStreamReader> stream) override {
if (CEF_CURRENTLY_ON_UIT()) {
if (!callback_.is_null()) {
// Always continue asynchronously.
CEF_POST_TASK(
CEF_UIT,
base::BindOnce(&CefGetExtensionLoadFileCallbackImpl::RunNow, file_,
base::Passed(std::move(callback_)), stream));
}
} else {
CEF_POST_TASK(CEF_UIT, base::BindOnce(
&CefGetExtensionLoadFileCallbackImpl::Continue,
this, stream));
}
}
void Cancel() override { Continue(nullptr); }
void Disconnect() { callback_.Reset(); }
private:
static void RunNow(const std::string& file,
CefExtensionFunctionDetails::LoadFileCallback callback,
CefRefPtr<CefStreamReader> stream) {
CEF_REQUIRE_UIT();
if (!stream) {
std::move(callback).Run(nullptr);
return;
}
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::BindOnce(LoadFileFromStream, file, stream), std::move(callback));
}
static std::unique_ptr<std::string> LoadFileFromStream(
const std::string& file,
CefRefPtr<CefStreamReader> stream) {
base::ThreadRestrictions::AssertIOAllowed();
// Move to the end of the stream.
stream->Seek(0, SEEK_END);
const int64 size = stream->Tell();
if (size == 0) {
LOG(WARNING) << "Extension resource " << file << " is empty.";
return nullptr;
}
std::unique_ptr<std::string> result(new std::string());
result->resize(size);
// Move to the beginning of the stream.
stream->Seek(0, SEEK_SET);
// Read all stream contents into the string.
int64 read, offset = 0;
do {
read =
static_cast<int>(stream->Read(&(*result)[offset], 1, size - offset));
offset += read;
} while (read > 0 && offset < size);
if (offset != size) {
LOG(WARNING) << "Extension resource " << file << " read failed; expected "
<< size << ", got " << offset << " bytes.";
return nullptr;
}
return result;
}
const std::string file_;
CefExtensionFunctionDetails::LoadFileCallback callback_;
IMPLEMENT_REFCOUNTING(CefGetExtensionLoadFileCallbackImpl);
DISALLOW_COPY_AND_ASSIGN(CefGetExtensionLoadFileCallbackImpl);
};
} // namespace
CefExtensionFunctionDetails::CefExtensionFunctionDetails(
UIThreadExtensionFunction* function)
: function_(function) {}
CefExtensionFunctionDetails::~CefExtensionFunctionDetails() {}
Profile* CefExtensionFunctionDetails::GetProfile() const {
return Profile::FromBrowserContext(function_->browser_context());
}
CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetSenderBrowser()
const {
content::WebContents* web_contents = function_->GetSenderWebContents();
if (web_contents)
return CefBrowserHostImpl::GetBrowserForContents(web_contents);
return nullptr;
}
CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
const {
// Start with the browser hosting the extension.
CefRefPtr<CefBrowserHostImpl> browser = GetSenderBrowser();
if (browser && browser->client()) {
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
if (handler) {
// Give the handler an opportunity to specify a different browser.
CefRefPtr<CefBrowser> active_browser = handler->GetActiveBrowser(
GetCefExtension(), browser.get(), function_->include_incognito());
if (active_browser && active_browser != browser) {
CefRefPtr<CefBrowserHostImpl> active_browser_impl =
static_cast<CefBrowserHostImpl*>(active_browser.get());
// Make sure we're operating in the same BrowserContextImpl.
if (CefBrowserContextImpl::GetForContext(
browser->GetBrowserContext()) ==
CefBrowserContextImpl::GetForContext(
active_browser_impl->GetBrowserContext())) {
browser = active_browser_impl;
} else {
LOG(WARNING) << "Browser with tabId "
<< active_browser->GetIdentifier()
<< " cannot be accessed because is uses a different "
"CefRequestContext";
}
}
}
}
// May be null during startup/shutdown.
return browser;
}
bool CefExtensionFunctionDetails::CanAccessBrowser(
CefRefPtr<CefBrowserHostImpl> target) const {
DCHECK(target);
// Start with the browser hosting the extension.
CefRefPtr<CefBrowserHostImpl> browser = GetSenderBrowser();
if (browser == target) {
// A sender can always access itself.
return true;
}
if (browser && browser->client()) {
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
if (handler) {
return handler->CanAccessBrowser(GetCefExtension(), browser.get(),
function_->include_incognito(), target);
}
}
// Default to allowing access.
return true;
}
CefRefPtr<CefBrowserHostImpl>
CefExtensionFunctionDetails::GetBrowserForTabIdFirstTime(
int tab_id,
std::string* error_message) const {
DCHECK_GE(tab_id, -1);
DCHECK(!get_browser_called_first_time_);
get_browser_called_first_time_ = true;
CefRefPtr<CefBrowserHostImpl> browser;
if (tab_id != -1) {
// May be an invalid tabId or in the wrong BrowserContext.
browser = GetBrowserForTabId(tab_id, function_->browser_context());
if (!browser || !browser->web_contents() || !CanAccessBrowser(browser)) {
if (error_message) {
*error_message = ErrorUtils::FormatErrorMessage(
keys::kTabNotFoundError, base::IntToString(tab_id));
}
return nullptr;
}
} else {
// May return NULL during shutdown.
browser = GetCurrentBrowser();
if (!browser || !browser->web_contents()) {
if (error_message) {
*error_message = keys::kNoCurrentWindowError;
}
return nullptr;
}
}
return browser;
}
CefRefPtr<CefBrowserHostImpl>
CefExtensionFunctionDetails::GetBrowserForTabIdAgain(
int tab_id,
std::string* error_message) const {
DCHECK_GE(tab_id, 0);
DCHECK(get_browser_called_first_time_);
// May return NULL during shutdown.
CefRefPtr<CefBrowserHostImpl> browser =
GetBrowserForTabId(tab_id, function_->browser_context());
if (!browser || !browser->web_contents()) {
if (error_message) {
*error_message = ErrorUtils::FormatErrorMessage(
keys::kTabNotFoundError, base::IntToString(tab_id));
}
}
return browser;
}
bool CefExtensionFunctionDetails::LoadFile(const std::string& file,
LoadFileCallback callback) const {
// Start with the browser hosting the extension.
CefRefPtr<CefBrowserHostImpl> browser = GetSenderBrowser();
if (browser && browser->client()) {
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
if (handler) {
CefRefPtr<CefGetExtensionLoadFileCallbackImpl> cef_callback(
new CefGetExtensionLoadFileCallbackImpl(file, std::move(callback)));
if (handler->GetExtensionResource(GetCefExtension(), browser.get(), file,
cef_callback)) {
return true;
}
cef_callback->Disconnect();
}
}
return false;
}
CefRefPtr<CefExtension> CefExtensionFunctionDetails::GetCefExtension() const {
if (!cef_extension_) {
cef_extension_ =
static_cast<CefBrowserContext*>(function_->browser_context())
->extension_system()
->GetExtension(function_->extension_id());
DCHECK(cef_extension_);
}
return cef_extension_;
}
} // namespace extensions

View File

@ -0,0 +1,114 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2014 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DETAILS_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DETAILS_H_
#include "libcef/browser/browser_host_impl.h"
#include "include/cef_extension.h"
#include "base/callback_forward.h"
#include "base/macros.h"
#include "ui/gfx/native_widget_types.h"
class Profile;
class UIThreadExtensionFunction;
namespace content {
class WebContents;
}
namespace extensions {
// Provides CEF-specific details to UIThreadExtensionFunction implementations.
// Based on chrome/browser/extensions/chrome_extension_function_details.h.
class CefExtensionFunctionDetails {
public:
// Constructs a new ChromeExtensionFunctionDetails instance for |function|.
// This instance does not own |function| and must outlive it.
explicit CefExtensionFunctionDetails(UIThreadExtensionFunction* function);
~CefExtensionFunctionDetails();
Profile* GetProfile() const;
// Get the "sender" browser that is hosting the extension. May return NULL
// during startup/shutdown.
CefRefPtr<CefBrowserHostImpl> GetSenderBrowser() const;
// Get the "current" browser that will be acted on by this extension function,
// if any. When mapping from a tabId use the GetBrowserForTabId* methods
// instead of calling this method directly.
//
// Many extension APIs operate relative to the browser that the calling code
// is running inside of. For example, popups and tabs all have a containing
// browser, but background pages and notification bubbles do not. Other APIs,
// like chrome.tabs.*, can act on either a specific browser (specified via the
// tabId parameter) or should allow the client to determine the most
// appropriate browser (for example, the browser that representing the
// foreground window).
//
// Incognito browsers should not be considered unless the calling extension
// has incognito access enabled. CEF does not internally enforce incognito
// status so we pass this flag to client callbacks for consideration.
//
// This method can return NULL if there is no matching browser, which can
// happen if only incognito windows are open, or early in startup or shutdown
// shutdown when there are no active windows.
CefRefPtr<CefBrowserHostImpl> GetCurrentBrowser() const;
// Returns true if the sender browser can access |target|. When mapping from a
// tabId use the GetBrowserForTabId* methods instead of calling this method
// directly.
bool CanAccessBrowser(CefRefPtr<CefBrowserHostImpl> target) const;
// Returns the browser matching |tab_id| or NULL if the browser cannot be
// found or does not have a WebContents. If |tab_id| is -1 the "current"
// browser will be returned. |error_message| can optionally be passed in and
// will be set with an appropriate message on error. This method should only
// be called one time per extension function and will check all necessary
// client permissions.
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabIdFirstTime(
int tab_id,
std::string* error_message) const;
// Returns the browser matching |tab_id| or NULL if the browser cannot be
// found or does not have a WebContents. |tab_id| must be >= 0.
// |error_message| can optionally be passed in and will be set with an
// appropriate message on error. This method should be called only after
// GetBrowserForTabIdFirstTime() has succeeded for the same |tab_id|.
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabIdAgain(
int tab_id,
std::string* error_message) const;
// Give the client a chance to handle |file|. |callback| will be executed
// once the file contents have been loaded. Returns false if the file is
// unhandled.
using LoadFileCallback =
base::OnceCallback<void(std::unique_ptr<std::string>)>;
bool LoadFile(const std::string& file, LoadFileCallback callback) const;
// Returns a pointer to the associated UIThreadExtensionFunction
UIThreadExtensionFunction* function() { return function_; }
const UIThreadExtensionFunction* function() const { return function_; }
protected:
CefRefPtr<CefExtension> GetCefExtension() const;
private:
// The function for which these details have been created. Must outlive the
// CefExtensionFunctionDetails instance.
UIThreadExtensionFunction* function_;
mutable CefRefPtr<CefExtension> cef_extension_;
// Verifies correct usage of GetBrowserForTabId* methods.
mutable bool get_browser_called_first_time_ = false;
DISALLOW_COPY_AND_ASSIGN(CefExtensionFunctionDetails);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DETAILS_H_

View File

@ -0,0 +1,63 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2014 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/extensions/extension_host_delegate.h"
#include "libcef/browser/extensions/extensions_browser_client.h"
#include "base/logging.h"
namespace extensions {
CefExtensionHostDelegate::CefExtensionHostDelegate(
CefBrowserHostImpl* browser) {}
CefExtensionHostDelegate::~CefExtensionHostDelegate() {}
void CefExtensionHostDelegate::OnExtensionHostCreated(
content::WebContents* web_contents) {}
void CefExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
ExtensionHost* host) {}
content::JavaScriptDialogManager*
CefExtensionHostDelegate::GetJavaScriptDialogManager() {
// Never routed here from CefBrowserHostImpl.
NOTREACHED();
return NULL;
}
void CefExtensionHostDelegate::CreateTab(content::WebContents* web_contents,
const std::string& extension_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture) {
// TODO(cef): Add support for extensions opening popup windows.
NOTIMPLEMENTED();
}
void CefExtensionHostDelegate::ProcessMediaAccessRequest(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
const Extension* extension) {
// Never routed here from CefBrowserHostImpl.
NOTREACHED();
}
bool CefExtensionHostDelegate::CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const Extension* extension) {
// Never routed here from CefBrowserHostImpl.
NOTREACHED();
return false;
}
ExtensionHostQueue* CefExtensionHostDelegate::GetExtensionHostQueue() const {
return CefExtensionsBrowserClient::Get()->GetExtensionHostQueue();
}
} // namespace extensions

View File

@ -0,0 +1,45 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2014 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef LIBCEF_BROWSER_EXTENSIONS_EXTENSION_HOST_DELEGATE_H_
#define LIBCEF_BROWSER_EXTENSIONS_EXTENSION_HOST_DELEGATE_H_
#include "base/macros.h"
#include "extensions/browser/extension_host_delegate.h"
class CefBrowserHostImpl;
namespace extensions {
class CefExtensionHostDelegate : public ExtensionHostDelegate {
public:
explicit CefExtensionHostDelegate(CefBrowserHostImpl* browser);
~CefExtensionHostDelegate() override;
// ExtensionHostDelegate implementation.
void OnExtensionHostCreated(content::WebContents* web_contents) override;
void OnRenderViewCreatedForBackgroundPage(ExtensionHost* host) override;
content::JavaScriptDialogManager* GetJavaScriptDialogManager() override;
void CreateTab(content::WebContents* web_contents,
const std::string& extension_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture) override;
void ProcessMediaAccessRequest(content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
const Extension* extension) override;
bool CheckMediaAccessPermission(content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type,
const Extension* extension) override;
ExtensionHostQueue* GetExtensionHostQueue() const override;
private:
DISALLOW_COPY_AND_ASSIGN(CefExtensionHostDelegate);
};
} // namespace extensions
#endif // LIBCEF_BROWSER_EXTENSIONS_EXTENSION_HOST_DELEGATE_H_

View File

@ -7,7 +7,9 @@
#include <string>
#include "libcef/browser/extension_impl.h"
#include "libcef/browser/extensions/pdf_extension_util.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h"
@ -17,6 +19,7 @@
#include "base/path_service.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/common/chrome_paths.h"
#include "components/crx_file/id_util.h"
@ -53,18 +56,9 @@ namespace extensions {
namespace {
std::string GenerateId(const base::DictionaryValue* manifest,
const base::FilePath& path) {
std::string raw_key;
std::string id_input;
CHECK(manifest->GetString(manifest_keys::kPublicKey, &raw_key));
CHECK(Extension::ParsePEMKeyBytes(raw_key, &id_input));
std::string id = crx_file::id_util::GenerateId(id_input);
return id;
}
// Implementation based on ComponentLoader::ParseManifest.
base::DictionaryValue* ParseManifest(const std::string& manifest_contents) {
std::unique_ptr<base::DictionaryValue> ParseManifest(
const std::string& manifest_contents) {
JSONStringValueDeserializer deserializer(manifest_contents);
std::unique_ptr<base::Value> manifest(deserializer.Deserialize(NULL, NULL));
@ -73,7 +67,81 @@ base::DictionaryValue* ParseManifest(const std::string& manifest_contents) {
return NULL;
}
// Transfer ownership to the caller.
return static_cast<base::DictionaryValue*>(manifest.release());
return base::WrapUnique(
static_cast<base::DictionaryValue*>(manifest.release()));
}
void ExecuteLoadFailure(CefRefPtr<CefExtensionHandler> handler,
cef_errorcode_t result) {
if (!handler)
return;
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(ExecuteLoadFailure, handler, result));
return;
}
handler->OnExtensionLoadFailed(result);
}
void LoadExtensionOnUIThread(base::WeakPtr<CefExtensionSystem> context,
std::unique_ptr<base::DictionaryValue> manifest,
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::BindOnce(LoadExtensionOnUIThread, context,
base::Passed(std::move(manifest)),
root_directory, internal,
loader_context, handler));
return;
}
if (context) {
context->LoadExtension(std::move(manifest), root_directory, internal,
loader_context, handler);
}
}
void LoadExtensionWithManifest(base::WeakPtr<CefExtensionSystem> context,
const std::string& manifest_contents,
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
base::ThreadRestrictions::AssertIOAllowed();
std::unique_ptr<base::DictionaryValue> manifest =
ParseManifest(manifest_contents);
if (!manifest) {
LOG(WARNING) << "Failed to parse extension manifest";
ExecuteLoadFailure(handler, ERR_INVALID_ARGUMENT);
return;
}
LoadExtensionOnUIThread(context, std::move(manifest), root_directory,
internal, loader_context, handler);
}
void LoadExtensionFromDisk(base::WeakPtr<CefExtensionSystem> context,
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
base::ThreadRestrictions::AssertIOAllowed();
base::FilePath manifest_path = root_directory.AppendASCII("manifest.json");
std::string manifest_contents;
if (!base::ReadFileToString(manifest_path, &manifest_contents)) {
LOG(WARNING) << "Failed to read extension manifest from "
<< manifest_path.MaybeAsASCII();
ExecuteLoadFailure(handler, ERR_FILE_NOT_FOUND);
return;
}
LoadExtensionWithManifest(context, manifest_contents, root_directory,
internal, loader_context, handler);
}
} // namespace
@ -110,7 +178,7 @@ void CefExtensionSystem::Init() {
content::Source<BrowserContext>(browser_context_),
content::NotificationService::NoDetails());
// Add the built-in PDF extension. PDF loading works as follows:
// Add the internal PDF extension. PDF loading works as follows:
// 1. PDF PPAPI plugin is registered to handle kPDFPluginOutOfProcessMimeType
// in libcef/common/content_client.cc ComputeBuiltInPlugins.
// 2. PDF extension is registered and associated with the "application/pdf"
@ -153,40 +221,139 @@ void CefExtensionSystem::Init() {
// CefExtensionWebContentsObserver::RenderViewCreated in the browser
// process.
if (PdfExtensionEnabled()) {
AddExtension(pdf_extension_util::GetManifest(),
base::FilePath(FILE_PATH_LITERAL("pdf")));
LoadExtension(pdf_extension_util::GetManifest(),
base::FilePath(FILE_PATH_LITERAL("pdf")), true /* internal */,
nullptr, nullptr);
}
initialized_ = true;
}
// Implementation based on ComponentLoader::Add.
const Extension* CefExtensionSystem::AddExtension(
void CefExtensionSystem::LoadExtension(
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
CEF_REQUIRE_UIT();
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
base::BindOnce(LoadExtensionFromDisk, weak_ptr_factory_.GetWeakPtr(),
root_directory, internal, loader_context, handler));
}
void CefExtensionSystem::LoadExtension(
const std::string& manifest_contents,
const base::FilePath& root_directory) {
base::DictionaryValue* manifest = ParseManifest(manifest_contents);
if (!manifest)
return NULL;
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
CEF_REQUIRE_UIT();
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
base::BindOnce(LoadExtensionWithManifest, weak_ptr_factory_.GetWeakPtr(),
manifest_contents, root_directory, internal,
loader_context, handler));
}
ComponentExtensionInfo info(manifest, root_directory);
const Extension* extension = LoadExtension(info);
delete manifest;
// Implementation based on ComponentLoader::Add.
void CefExtensionSystem::LoadExtension(
std::unique_ptr<base::DictionaryValue> manifest,
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
CEF_REQUIRE_UIT();
return extension;
// Internal extensions don't have a loader context. External extensions should.
#if DCHECK_IS_ON()
if (internal) {
DCHECK(!loader_context);
} else {
DCHECK(loader_context);
}
#endif
ComponentExtensionInfo info(manifest.get(), root_directory, internal);
const Extension* extension = LoadExtension(info, loader_context, handler);
if (!extension)
ExecuteLoadFailure(handler, ERR_FAILED);
}
// Implementation based on ExtensionService::RemoveComponentExtension.
void CefExtensionSystem::RemoveExtension(const std::string& extension_id) {
bool CefExtensionSystem::UnloadExtension(const std::string& extension_id) {
CEF_REQUIRE_UIT();
ExtensionMap::iterator it = extension_map_.find(extension_id);
if (it == extension_map_.end()) {
// No CEF representation so we've already unloaded it.
return false;
}
CefRefPtr<CefExtensionImpl> cef_extension =
static_cast<CefExtensionImpl*>(it->second.get());
// Erase first so that callbacks can't retrieve the unloaded extension.
extension_map_.erase(it);
cef_extension->OnExtensionUnloaded();
scoped_refptr<const Extension> extension(
registry_->enabled_extensions().GetByID(extension_id));
registry_->GetInstalledExtension(extension_id));
UnloadExtension(extension_id, UnloadedExtensionReason::UNINSTALL);
if (extension.get()) {
registry_->TriggerOnUninstalled(
extension.get(), extensions::UNINSTALL_REASON_COMPONENT_REMOVED);
}
return true;
}
void CefExtensionSystem::Shutdown() {}
bool CefExtensionSystem::HasExtension(const std::string& extension_id) const {
return !!GetExtension(extension_id);
}
CefRefPtr<CefExtension> CefExtensionSystem::GetExtension(
const std::string& extension_id) const {
CEF_REQUIRE_UIT();
ExtensionMap::const_iterator it = extension_map_.find(extension_id);
if (it != extension_map_.end())
return it->second;
return nullptr;
}
CefExtensionSystem::ExtensionMap CefExtensionSystem::GetExtensions() const {
CEF_REQUIRE_UIT();
return extension_map_;
}
void CefExtensionSystem::OnRequestContextDeleted(CefRequestContext* context) {
CEF_REQUIRE_UIT();
DCHECK(context);
// Make a copy of the map because UnloadExtension will modify it.
// Don't add any references to |context|.
ExtensionMap map = extension_map_;
ExtensionMap::const_iterator it = map.begin();
for (; it != map.end(); ++it) {
CefRefPtr<CefExtensionImpl> cef_extension =
static_cast<CefExtensionImpl*>(it->second.get());
if (cef_extension->loader_context() == context)
UnloadExtension(it->first);
}
}
void CefExtensionSystem::Shutdown() {
CEF_REQUIRE_UIT();
// Only internal extensions should exist at this point.
#if DCHECK_IS_ON()
ExtensionMap::iterator it = extension_map_.begin();
for (; it != extension_map_.end(); ++it) {
CefRefPtr<CefExtensionImpl> cef_extension =
static_cast<CefExtensionImpl*>(it->second.get());
DCHECK(!cef_extension->loader_context());
}
#endif
extension_map_.clear();
}
void CefExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
DCHECK(!initialized_);
@ -289,15 +456,15 @@ void CefExtensionSystem::InstallUpdate(const std::string& extension_id,
CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
const base::DictionaryValue* manifest,
const base::FilePath& directory)
: manifest(manifest), root_directory(directory) {
const base::FilePath& directory,
bool internal)
: manifest(manifest), root_directory(directory), internal(internal) {
if (!root_directory.IsAbsolute()) {
// This path structure is required by
// url_request_util::MaybeCreateURLRequestResourceBundleJob.
CHECK(PathService::Get(chrome::DIR_RESOURCES, &root_directory));
root_directory = root_directory.Append(directory);
}
extension_id = GenerateId(manifest, root_directory);
}
// Implementation based on ComponentLoader::CreateExtension.
@ -306,24 +473,45 @@ scoped_refptr<const Extension> CefExtensionSystem::CreateExtension(
std::string* utf8_error) {
// TODO(abarth): We should REQUIRE_MODERN_MANIFEST_VERSION once we've updated
// our component extensions to the new manifest version.
int flags = Extension::REQUIRE_KEY;
return Extension::Create(info.root_directory, Manifest::COMPONENT,
*info.manifest, flags, utf8_error);
int flags = 0;
if (info.internal) {
// Internal extensions must have kPublicKey in the manifest.
flags |= Extension::REQUIRE_KEY;
}
return Extension::Create(
info.root_directory,
info.internal ? Manifest::COMPONENT : Manifest::COMMAND_LINE,
*info.manifest, flags, utf8_error);
}
// Implementation based on ComponentLoader::Load and
// ExtensionService::AddExtension.
const Extension* CefExtensionSystem::LoadExtension(
const ComponentExtensionInfo& info) {
const ComponentExtensionInfo& info,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler) {
std::string error;
scoped_refptr<const Extension> extension(CreateExtension(info, &error));
if (!extension.get()) {
LOG(ERROR) << error;
return NULL;
return nullptr;
}
CHECK_EQ(info.extension_id, extension->id()) << extension->name();
if (registry_->GetInstalledExtension(extension->id())) {
LOG(ERROR) << "Extension with id " << extension->id()
<< "is already installed";
return nullptr;
}
CefRefPtr<CefExtensionImpl> cef_extension =
new CefExtensionImpl(extension.get(), loader_context.get(), handler);
// Insert first so that callbacks can retrieve the loaded extension.
extension_map_.insert(std::make_pair(extension->id(), cef_extension));
cef_extension->OnExtensionLoaded();
// This may trigger additional callbacks.
registry_->AddEnabled(extension.get());
NotifyExtensionLoaded(extension.get());

View File

@ -6,7 +6,11 @@
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
#include <vector>
#include <map>
#include <memory>
#include "include/cef_extension_handler.h"
#include "include/cef_request_context.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
@ -16,8 +20,9 @@
class BrowserContextKeyedServiceFactory;
namespace base {
class DictionaryValue;
class FilePath;
}
} // namespace base
namespace content {
class BrowserContext;
@ -41,13 +46,43 @@ class CefExtensionSystem : public ExtensionSystem {
// Initializes the extension system.
void Init();
// Add an extension. Returns the new Extension object on success or NULL on
// failure.
const Extension* AddExtension(const std::string& manifest_contents,
const base::FilePath& root_directory);
// Load an extension. For internal (built-in) extensions set |internal| to
// true and |loader_context| and |handler| to NULL. For external extensions
// set |internal| to false and |loader_context| must be the request context
// that loaded the extension. |handler| is optional for internal extensions
// and, if specified, will receive extension-related callbacks.
void LoadExtension(const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler);
void LoadExtension(const std::string& manifest_contents,
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler);
void LoadExtension(std::unique_ptr<base::DictionaryValue> manifest,
const base::FilePath& root_directory,
bool internal,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler);
// Remove an extension.
void RemoveExtension(const std::string& extension_id);
// Unload the external extension identified by |extension_id|.
bool UnloadExtension(const std::string& extension_id);
// Returns true if an extension matching |extension_id| is loaded.
bool HasExtension(const std::string& extension_id) const;
// Returns the loaded extention matching |extension_id| or NULL if not found.
CefRefPtr<CefExtension> GetExtension(const std::string& extension_id) const;
using ExtensionMap = std::map<std::string, CefRefPtr<CefExtension>>;
// Returns the map of all loaded extensions.
ExtensionMap GetExtensions() const;
// Called when a request context is deleted. Unregisters any external
// extensions that were registered with this context.
void OnRequestContextDeleted(CefRequestContext* context);
// KeyedService implementation:
void Shutdown() override;
@ -84,7 +119,8 @@ class CefExtensionSystem : public ExtensionSystem {
// Information about a registered component extension.
struct ComponentExtensionInfo {
ComponentExtensionInfo(const base::DictionaryValue* manifest,
const base::FilePath& root_directory);
const base::FilePath& root_directory,
bool internal);
// The parsed contents of the extensions's manifest file.
const base::DictionaryValue* manifest;
@ -92,8 +128,8 @@ class CefExtensionSystem : public ExtensionSystem {
// Directory where the extension is stored.
base::FilePath root_directory;
// The component extension's ID.
std::string extension_id;
// True if the extension is an internal (built-in) component.
bool internal;
};
scoped_refptr<const Extension> CreateExtension(
@ -101,7 +137,9 @@ class CefExtensionSystem : public ExtensionSystem {
std::string* utf8_error);
// Loads a registered component extension.
const Extension* LoadExtension(const ComponentExtensionInfo& info);
const Extension* LoadExtension(const ComponentExtensionInfo& info,
CefRefPtr<CefRequestContext> loader_context,
CefRefPtr<CefExtensionHandler> handler);
// Unload the specified extension.
void UnloadExtension(const std::string& extension_id,
@ -141,6 +179,9 @@ class CefExtensionSystem : public ExtensionSystem {
// ExtensionSystem, and thus us.
extensions::RendererStartupHelper* renderer_helper_;
// Map of extension ID to CEF extension object.
ExtensionMap extension_map_;
// Must be the last member.
base::WeakPtrFactory<CefExtensionSystem> weak_ptr_factory_;

View File

@ -0,0 +1,97 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "libcef/browser/extensions/extension_view_host.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/extensions/extension_host_delegate.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/runtime_data.h"
#include "third_party/WebKit/public/platform/WebGestureEvent.h"
using content::NativeWebKeyboardEvent;
using content::OpenURLParams;
using content::WebContents;
using content::WebContentsObserver;
namespace extensions {
CefExtensionViewHost::CefExtensionViewHost(
CefBrowserHostImpl* browser,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type)
: ExtensionHost(new CefExtensionHostDelegate(browser),
extension,
browser_context,
host_contents,
url,
host_type) {
// Only used for dialogs and popups.
DCHECK(host_type == VIEW_TYPE_EXTENSION_DIALOG ||
host_type == VIEW_TYPE_EXTENSION_POPUP);
}
CefExtensionViewHost::~CefExtensionViewHost() {}
void CefExtensionViewHost::OnDidStopFirstLoad() {
// Nothing to do here, but don't call the base class method.
}
void CefExtensionViewHost::LoadInitialURL() {
if (!ExtensionSystem::Get(browser_context())
->runtime_data()
->IsBackgroundPageReady(extension())) {
// Make sure the background page loads before any others.
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
content::Source<Extension>(extension()));
return;
}
ExtensionHost::LoadInitialURL();
}
bool CefExtensionViewHost::IsBackgroundPage() const {
return false;
}
bool CefExtensionViewHost::ShouldTransferNavigation(
bool is_main_frame_navigation) {
// Block navigations that cause the main frame to navigate to non-extension
// content (i.e. to web content).
return !is_main_frame_navigation;
}
bool CefExtensionViewHost::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
// Disable pinch zooming.
return blink::WebInputEvent::IsPinchGestureEventType(event.GetType());
}
WebContents* CefExtensionViewHost::GetVisibleWebContents() const {
if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP)
return host_contents();
return nullptr;
}
void CefExtensionViewHost::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY);
DCHECK(ExtensionSystem::Get(browser_context())
->runtime_data()
->IsBackgroundPageReady(extension()));
LoadInitialURL();
}
} // namespace extensions

View File

@ -0,0 +1,64 @@
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
#include <memory>
#include "base/macros.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/extension_host.h"
class CefBrowserHostImpl;
namespace content {
class WebContents;
} // namespace content
namespace extensions {
// The ExtensionHost for an extension that backs a view in the browser UI. For
// example, this could be an extension popup or dialog, but not a background
// page. Object lifespan is managed by CefBrowserHostImpl. Based on
// chrome/browser/extensions/extension_view_host.h.
class CefExtensionViewHost : public ExtensionHost,
public content::NotificationObserver {
public:
CefExtensionViewHost(CefBrowserHostImpl* browser,
const Extension* extension,
content::BrowserContext* browser_context,
content::WebContents* host_contents,
const GURL& url,
ViewType host_type);
~CefExtensionViewHost() override;
// ExtensionHost methods:
void OnDidStopFirstLoad() override;
void LoadInitialURL() override;
bool IsBackgroundPage() const override;
// content::WebContentsDelegate methods:
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
// extensions::ExtensionFunctionDispatcher::Delegate methods:
content::WebContents* GetVisibleWebContents() const override;
// content::NotificationObserver methods:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
private:
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionViewHost);
};
} // namespace extensions
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_

View File

@ -15,7 +15,9 @@ namespace extensions {
CefExtensionWebContentsObserver::CefExtensionWebContentsObserver(
content::WebContents* web_contents)
: ExtensionWebContentsObserver(web_contents) {}
: ExtensionWebContentsObserver(web_contents),
script_executor_(
new ScriptExecutor(web_contents, &script_execution_observers_)) {}
CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {}

View File

@ -5,8 +5,13 @@
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
#include <memory>
#include "base/observer_list.h"
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/browser/extension_web_contents_observer.h"
#include "extensions/browser/script_execution_observer.h"
#include "extensions/browser/script_executor.h"
namespace extensions {
@ -17,6 +22,8 @@ class CefExtensionWebContentsObserver
public:
~CefExtensionWebContentsObserver() override;
ScriptExecutor* script_executor() { return script_executor_.get(); }
private:
friend class content::WebContentsUserData<CefExtensionWebContentsObserver>;
@ -25,6 +32,12 @@ class CefExtensionWebContentsObserver
// content::WebContentsObserver overrides.
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
// Our content script observers. Declare at top so that it will outlive all
// other members, since they might add themselves as observers.
base::ObserverList<ScriptExecutionObserver> script_execution_observers_;
std::unique_ptr<ScriptExecutor> script_executor_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionWebContentsObserver);
};

View File

@ -13,7 +13,6 @@
#include "libcef/browser/printing/print_view_manager.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "components/pdf/browser/pdf_web_contents_helper.h"
#include "components/zoom/zoom_controller.h"
@ -64,7 +63,6 @@ void CefExtensionsAPIClient::AttachWebContentsHelpers(
new CefPDFWebContentsHelperClient()));
// Used by the tabs extension API.
SessionTabHelper::CreateForWebContents(web_contents);
zoom::ZoomController::CreateForWebContents(web_contents);
}

View File

@ -8,17 +8,19 @@
#include <utility>
#include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/extensions/chrome_api_registration.h"
#include "libcef/browser/extensions/component_extension_resource_manager.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/extensions/extension_system_factory.h"
#include "libcef/browser/extensions/extension_web_contents_observer.h"
#include "libcef/browser/extensions/extensions_api_client.h"
#include "libcef/browser/request_context_impl.h"
//#include "cef/libcef/browser/extensions/api/generated_api_registration.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/chrome_url_request_util.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@ -30,6 +32,7 @@
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/mojo/service_registration.h"
#include "extensions/browser/serial_extension_host_queue.h"
#include "extensions/browser/url_request_util.h"
#include "extensions/common/constants.h"
@ -44,6 +47,12 @@ CefExtensionsBrowserClient::CefExtensionsBrowserClient()
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {}
// static
CefExtensionsBrowserClient* CefExtensionsBrowserClient::Get() {
return static_cast<CefExtensionsBrowserClient*>(
ExtensionsBrowserClient::Get());
}
bool CefExtensionsBrowserClient::IsShuttingDown() {
return false;
}
@ -62,24 +71,28 @@ bool CefExtensionsBrowserClient::IsSameContext(BrowserContext* first,
BrowserContext* second) {
// Returns true if |first| and |second| share the same underlying
// CefBrowserContextImpl.
return CefBrowserContextImpl::GetForContext(first) ==
CefBrowserContextImpl::GetForContext(second);
return GetCefImplContext(first) == GetCefImplContext(second);
}
bool CefExtensionsBrowserClient::HasOffTheRecordContext(
BrowserContext* context) {
// CEF doesn't use incognito contexts.
return false;
}
BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
BrowserContext* context) {
// TODO(extensions): Do we need to support this?
return NULL;
}
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
BrowserContext* context) {
return chrome::GetBrowserContextRedirectedInIncognito(context);
return GetCefImplContext(context);
}
BrowserContext* CefExtensionsBrowserClient::GetCefImplContext(
BrowserContext* context) {
return CefBrowserContextImpl::GetForContext(context);
}
bool CefExtensionsBrowserClient::IsGuestSession(BrowserContext* context) const {
@ -148,11 +161,68 @@ ProcessManagerDelegate* CefExtensionsBrowserClient::GetProcessManagerDelegate()
std::unique_ptr<ExtensionHostDelegate>
CefExtensionsBrowserClient::CreateExtensionHostDelegate() {
// TODO(extensions): Implement to support Apps.
// CEF does not use the ExtensionHost constructor that calls this method.
NOTREACHED();
return std::unique_ptr<ExtensionHostDelegate>();
}
bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
const Extension* extension,
content::BrowserContext* browser_context,
const GURL& url,
ExtensionHost** host) {
// The BrowserContext referenced by ProcessManager should always be an *Impl.
DCHECK(!static_cast<CefBrowserContext*>(browser_context)->is_proxy());
CefBrowserContextImpl* browser_context_impl =
CefBrowserContextImpl::GetForContext(browser_context);
// A CEF representation should always exist.
CefRefPtr<CefExtension> cef_extension =
browser_context_impl->extension_system()->GetExtension(extension->id());
DCHECK(cef_extension);
if (!cef_extension) {
// Cancel the background host creation.
return true;
}
// Always use the same request context that the extension was registered with.
// May represent an *Impl or *Proxy BrowserContext.
// GetLoaderContext() will return NULL for internal extensions.
CefRefPtr<CefRequestContext> request_context =
cef_extension->GetLoaderContext();
if (!request_context) {
// Cancel the background host creation.
return true;
}
CefBrowserHostImpl::CreateParams create_params;
create_params.url = url;
create_params.request_context = request_context;
CefRefPtr<CefExtensionHandler> handler = cef_extension->GetHandler();
if (handler.get() && handler->OnBeforeBackgroundBrowser(
cef_extension, url.spec(), create_params.client,
create_params.settings)) {
// Cancel the background host creation.
return true;
}
// This triggers creation of the background host.
create_params.extension = extension;
create_params.extension_host_type =
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE;
// Browser creation may fail under certain rare circumstances. Fail the
// background host creation in that case.
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::Create(create_params);
if (browser) {
*host = browser->extension_host();
DCHECK(*host);
}
return true;
}
bool CefExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
// TODO(jamescook): We might want to tell extensions when app_shell updates.
return false;
@ -250,9 +320,10 @@ bool CefExtensionsBrowserClient::IsLockScreenContext(
return false;
}
void CefExtensionsBrowserClient::SetAPIClientForTest(
ExtensionsAPIClient* api_client) {
api_client_.reset(api_client);
ExtensionHostQueue* CefExtensionsBrowserClient::GetExtensionHostQueue() {
if (!extension_host_queue_)
extension_host_queue_.reset(new SerialExtensionHostQueue);
return extension_host_queue_.get();
}
} // namespace extensions

View File

@ -11,6 +11,7 @@
namespace extensions {
class ExtensionHostQueue;
class ExtensionsAPIClient;
// An ExtensionsBrowserClient that supports a single content::BrowserContent
@ -20,6 +21,9 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
CefExtensionsBrowserClient();
~CefExtensionsBrowserClient() override;
// Returns the singleton CefExtensionsBrowserClient instance.
static CefExtensionsBrowserClient* Get();
// ExtensionsBrowserClient overrides:
bool IsShuttingDown() override;
bool AreExtensionsDisabled(const base::CommandLine& command_line,
@ -32,6 +36,8 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context) override;
content::BrowserContext* GetOriginalContext(
content::BrowserContext* context) override;
content::BrowserContext* GetCefImplContext(
content::BrowserContext* context) override;
bool IsGuestSession(content::BrowserContext* context) const override;
bool IsExtensionIncognitoEnabled(
const std::string& extension_id,
@ -56,6 +62,10 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
std::vector<ExtensionPrefsObserver*>* observers) const override;
ProcessManagerDelegate* GetProcessManagerDelegate() const override;
std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
bool CreateBackgroundExtensionHost(const Extension* extension,
content::BrowserContext* browser_context,
const GURL& url,
ExtensionHost** host) override;
bool DidVersionUpdate(content::BrowserContext* context) override;
void PermitExternalProtocolHandler() override;
bool IsRunningInForcedAppMode() override;
@ -82,8 +92,7 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
KioskDelegate* GetKioskDelegate() override;
bool IsLockScreenContext(content::BrowserContext* context) override;
// Sets the API client.
void SetAPIClientForTest(ExtensionsAPIClient* api_client);
ExtensionHostQueue* GetExtensionHostQueue();
private:
// Support for extension APIs.
@ -92,6 +101,9 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
// Resource manager used to supply resources from pak files.
std::unique_ptr<ComponentExtensionResourceManager> resource_manager_;
// Used to create deferred RenderViews for extensions.
std::unique_ptr<ExtensionHostQueue> extension_host_queue_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionsBrowserClient);
};

View File

@ -94,7 +94,6 @@ CefMenuManager::CefMenuManager(CefBrowserHostImpl* browser,
custom_menu_callback_(NULL),
weak_ptr_factory_(this) {
DCHECK(web_contents());
DCHECK(runner_.get());
model_ = new CefMenuModelImpl(this, nullptr, false);
}
@ -106,7 +105,8 @@ CefMenuManager::~CefMenuManager() {
void CefMenuManager::Destroy() {
CancelContextMenu();
runner_.reset(NULL);
if (runner_)
runner_.reset(NULL);
}
bool CefMenuManager::IsShowingContextMenu() {
@ -184,7 +184,7 @@ bool CefMenuManager::CreateContextMenu(
}
}
if (custom_menu)
if (custom_menu || !runner_)
return true;
return runner_->RunContextMenu(browser_, model_.get(), params_);
}
@ -193,7 +193,7 @@ void CefMenuManager::CancelContextMenu() {
if (IsShowingContextMenu()) {
if (custom_menu_callback_)
custom_menu_callback_->Cancel();
else
else if (runner_)
runner_->CancelContextMenu();
}
}
@ -268,6 +268,8 @@ void CefMenuManager::MenuClosed(CefRefPtr<CefMenuModelImpl> source) {
bool CefMenuManager::FormatLabel(CefRefPtr<CefMenuModelImpl> source,
base::string16& label) {
if (!runner_)
return false;
return runner_->FormatLabel(label);
}

View File

@ -276,8 +276,9 @@ void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
// based on the current style.
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
// Size the window.
SetWindowPos(window, NULL, 0, 0, rect.right, rect.bottom,
// Size the window. The left/top values may be negative.
SetWindowPos(window, NULL, 0, 0, rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}

View File

@ -12,6 +12,7 @@
#include "include/cef_version.h"
#include "include/cef_web_plugin.h"
#include "libcef/browser/extensions/chrome_api_registration.h"
#include "libcef/browser/frame_host_impl.h"
#include "libcef/browser/net/internal_scheme_handler.h"
#include "libcef/browser/net/url_request_manager.h"
@ -41,12 +42,15 @@
#include "net/url_request/url_request.h"
#include "v8/include/v8.h"
using extensions::api::cef::kSupportedAPIs;
namespace scheme {
const char kChromeURL[] = "chrome://";
namespace {
const char kChromeUIExtensionsSupportHost[] = "extensions-support";
const char kChromeUILicenseHost[] = "license";
const char kChromeUIWebUIHostsHost[] = "webui-hosts";
@ -83,6 +87,7 @@ const char* kUnlistedHosts[] = {
enum ChromeHostId {
CHROME_UNKNOWN = 0,
CHROME_EXTENSIONS_SUPPORT,
CHROME_LICENSE,
CHROME_VERSION,
CHROME_WEBUI_HOSTS,
@ -93,6 +98,7 @@ const struct {
const char* host;
ChromeHostId host_id;
} kAllowedCefHosts[] = {
{kChromeUIExtensionsSupportHost, CHROME_EXTENSIONS_SUPPORT},
{kChromeUILicenseHost, CHROME_LICENSE},
{chrome::kChromeUIVersionHost, CHROME_VERSION},
{kChromeUIWebUIHostsHost, CHROME_WEBUI_HOSTS},
@ -510,6 +516,9 @@ class Delegate : public InternalHandlerDelegate {
ChromeHostId host_id = GetChromeHostId(url.host());
switch (host_id) {
case CHROME_EXTENSIONS_SUPPORT:
handled = OnExtensionsSupport(action);
break;
case CHROME_LICENSE:
handled = OnLicense(action);
break;
@ -535,6 +544,61 @@ class Delegate : public InternalHandlerDelegate {
return handled;
}
bool OnExtensionsSupport(Action* action) {
static const char kDevURL[] = "https://developer.chrome.com/extensions/";
std::string html =
"<html>\n<head><title>Extensions Support</title></head>\n"
"<body bgcolor=\"white\"><h3>Supported Chrome Extensions "
"APIs</h3>\nFollow <a "
"href=\"https://bitbucket.org/chromiumembedded/cef/issues/1947\" "
"target=\"new\">issue #1947</a> for development progress.\n<ul>\n";
bool has_top_level_name = false;
for (size_t i = 0; kSupportedAPIs[i] != nullptr; ++i) {
const std::string& api_name = kSupportedAPIs[i];
if (api_name.find("Private") != std::string::npos) {
// Don't list private APIs.
continue;
}
const size_t dot_pos = api_name.find('.');
if (dot_pos == std::string::npos) {
if (has_top_level_name) {
// End the previous top-level API entry.
html += "</ul></li>\n";
} else {
has_top_level_name = true;
}
// Start a new top-level API entry.
html += "<li><a href=\"" + std::string(kDevURL) + api_name +
"\" target=\"new\">" + api_name + "</a><ul>\n";
} else {
// Function name.
const std::string& group_name = api_name.substr(0, dot_pos);
const std::string& function_name = api_name.substr(dot_pos + 1);
html += "\t<li><a href=\"" + std::string(kDevURL) + group_name +
"#method-" + function_name + "\" target=\"new\">" + api_name +
"</a></li>\n";
}
}
if (has_top_level_name) {
// End the last top-level API entry.
html += "</ul></li>\n";
}
html += "</ul>\n</body>\n</html>";
action->mime_type = "text/html";
action->stream = CefStreamReader::CreateForData(
const_cast<char*>(html.c_str()), html.length());
action->stream_size = html.length();
return true;
}
bool OnLicense(Action* action) {
base::StringPiece piece = CefContentClient::Get()->GetDataResource(
IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE);

View File

@ -6,6 +6,7 @@
#define CEF_LIBCEF_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_PROXY_H_
#pragma once
#include "include/cef_request_context.h"
#include "include/cef_request_context_handler.h"
#include "libcef/browser/net/url_request_context_getter.h"
#include "libcef/browser/net/url_request_context_getter_impl.h"

View File

@ -6,6 +6,7 @@
#define CEF_LIBCEF_BROWSER_NET_URL_REQUEST_CONTEXT_PROXY_H_
#pragma once
#include "include/cef_request_context.h"
#include "include/cef_request_context_handler.h"
#include "libcef/browser/net/url_request_context.h"

View File

@ -38,6 +38,9 @@ bool CefGetPath(PathKey key, CefString& path) {
case PK_USER_DATA:
pref_key = chrome::DIR_USER_DATA;
break;
case PK_DIR_RESOURCES:
pref_key = chrome::DIR_RESOURCES;
break;
default:
NOTREACHED() << "invalid argument";
return false;

View File

@ -8,7 +8,9 @@
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/extensions/extension_system.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/extensions/extensions_util.h"
#include "libcef/common/values_impl.h"
#include "base/atomic_sequence_num.h"
@ -132,6 +134,8 @@ CefRefPtr<CefRequestContext> CefRequestContext::CreateContext(
// CefRequestContextImpl
CefRequestContextImpl::~CefRequestContextImpl() {
CEF_REQUIRE_UIT();
// Delete the proxy first because it also references |browser_context_impl_|.
if (browser_context_proxy_)
browser_context_proxy_.reset(nullptr);
@ -501,6 +505,80 @@ cef_errorcode_t CefRequestContextImpl::ResolveHostCached(
return static_cast<cef_errorcode_t>(retval);
}
void CefRequestContextImpl::LoadExtension(
const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefRequestContextImpl::LoadExtension, this,
root_directory, manifest, handler));
return;
}
if (!extensions::ExtensionsEnabled()) {
if (handler)
handler->OnExtensionLoadFailed(ERR_ABORTED);
return;
}
if (manifest && manifest->GetSize() > 0) {
CefDictionaryValueImpl* value_impl =
static_cast<CefDictionaryValueImpl*>(manifest.get());
GetBrowserContext()->extension_system()->LoadExtension(
base::WrapUnique(value_impl->CopyValue()), root_directory,
false /* builtin */, this, handler);
} else {
GetBrowserContext()->extension_system()->LoadExtension(
root_directory, false /* builtin */, this, handler);
}
}
bool CefRequestContextImpl::DidLoadExtension(const CefString& extension_id) {
CefRefPtr<CefExtension> extension = GetExtension(extension_id);
// GetLoaderContext() will return NULL for internal extensions.
return extension && IsSame(extension->GetLoaderContext());
}
bool CefRequestContextImpl::HasExtension(const CefString& extension_id) {
return !!GetExtension(extension_id);
}
bool CefRequestContextImpl::GetExtensions(
std::vector<CefString>& extension_ids) {
extension_ids.clear();
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return false;
}
if (!extensions::ExtensionsEnabled())
return false;
extensions::CefExtensionSystem::ExtensionMap extension_map =
GetBrowserContext()->extension_system()->GetExtensions();
extensions::CefExtensionSystem::ExtensionMap::const_iterator it =
extension_map.begin();
for (; it != extension_map.end(); ++it)
extension_ids.push_back(it->second->GetIdentifier());
return true;
}
CefRefPtr<CefExtension> CefRequestContextImpl::GetExtension(
const CefString& extension_id) {
if (!CEF_CURRENTLY_ON_UIT()) {
NOTREACHED() << "called on invalid thread";
return nullptr;
}
if (!extensions::ExtensionsEnabled())
return nullptr;
return GetBrowserContext()->extension_system()->GetExtension(extension_id);
}
// static
CefRefPtr<CefRequestContextImpl>
CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) {
@ -581,9 +659,13 @@ void CefRequestContextImpl::Initialize() {
// IsSharedWith().
config_.other = NULL;
}
if (config_.handler)
config_.handler->OnRequestContextInitialized(this);
}
void CefRequestContextImpl::EnsureBrowserContext() {
CEF_REQUIRE_UIT();
if (!browser_context())
Initialize();
DCHECK(browser_context());

View File

@ -80,6 +80,13 @@ class CefRequestContextImpl : public CefRequestContext {
cef_errorcode_t ResolveHostCached(
const CefString& origin,
std::vector<CefString>& resolved_ips) override;
void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler) override;
bool DidLoadExtension(const CefString& extension_id) override;
bool HasExtension(const CefString& extension_id) override;
bool GetExtensions(std::vector<CefString>& extension_ids) override;
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
const CefRequestContextSettings& settings() const { return config_.settings; }

View File

@ -6,6 +6,7 @@
#define CEF_LIBCEF_BROWSER_RESOURCE_CONTEXT_H_
#pragma once
#include "include/cef_request_context.h"
#include "include/cef_request_context_handler.h"
#include "base/files/file_path.h"

View File

@ -174,7 +174,7 @@ void CefBrowserViewImpl::SetPendingBrowserCreateParams(
DCHECK(!pending_browser_create_params_);
pending_browser_create_params_.reset(new CefBrowserHostImpl::CreateParams());
pending_browser_create_params_->client = client;
pending_browser_create_params_->url = url;
pending_browser_create_params_->url = GURL(url.ToString());
pending_browser_create_params_->settings = settings;
pending_browser_create_params_->request_context = request_context;
}

View File

@ -49,8 +49,25 @@ CEF_BUTTON_IMPL_T class CefButtonImpl : public CEF_VIEW_IMPL_D {
CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetState(cef_button_state_t state) {
CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::root_view()->SetState(
static_cast<views::Button::ButtonState>(state));
views::Button::ButtonState old_state = ParentClass::root_view()->state();
views::Button::ButtonState new_state =
static_cast<views::Button::ButtonState>(state);
if (ParentClass::root_view()->ink_drop_mode() !=
views::CustomButton::InkDropMode::OFF &&
!ParentClass::root_view()->IsFocusable()) {
// Ink drop state does not get set properly on state change when the button
// is non-focusable.
views::InkDropState ink_state = views::InkDropState::HIDDEN;
if (new_state == views::Button::STATE_PRESSED) {
ink_state = views::InkDropState::ACTIVATED;
} else if (old_state == views::Button::STATE_PRESSED) {
ink_state = views::InkDropState::DEACTIVATED;
}
ParentClass::root_view()->AnimateInkDrop(ink_state, nullptr);
}
ParentClass::root_view()->SetState(new_state);
}
CEF_BUTTON_IMPL_T cef_button_state_t CEF_BUTTON_IMPL_D::GetState() {

View File

@ -56,12 +56,16 @@ CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::StateChanged(
CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::ButtonPressed(
views::Button* sender,
const ui::Event& event) {
// Callback may trigger new animation state.
if (ParentClass::cef_delegate())
ParentClass::cef_delegate()->OnButtonPressed(GetCefButton());
if (ParentClass::ink_drop_mode() != views::CustomButton::InkDropMode::OFF &&
!ParentClass::IsFocusable()) {
// When ink drop is enabled for non-focusable buttons the ink drop state
// does not get reset properly on click, so we do it here explicitly.
!ParentClass::IsFocusable() &&
ParentClass::state() != views::CustomButton::STATE_PRESSED) {
// Ink drop state does not get reset properly on click when the button is
// non-focusable. Reset the ink drop state here if the state has not been
// explicitly set to pressed by the OnButtonPressed callback calling
// SetState (which also sets the ink drop state).
ParentClass::AnimateInkDrop(views::InkDropState::HIDDEN,
ui::LocatedEvent::FromIfValid(&event));
}

View File

@ -4,9 +4,27 @@
#include "libcef/browser/views/menu_button_view.h"
#include "libcef/browser/thread_util.h"
#include "ui/gfx/canvas.h"
#include "ui/views/controls/menu/menu_config.h"
namespace {
class ButtonPressedLock : public CefMenuButtonPressedLock {
public:
explicit ButtonPressedLock(views::MenuButton* menu_button)
: pressed_lock_(menu_button) {}
private:
views::MenuButton::PressedLock pressed_lock_;
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(ButtonPressedLock);
DISALLOW_COPY_AND_ASSIGN(ButtonPressedLock);
};
} // namespace
CefMenuButtonView::CefMenuButtonView(CefMenuButtonDelegate* cef_delegate)
: ParentClass(cef_delegate) {
DCHECK(cef_delegate);
@ -36,5 +54,6 @@ void CefMenuButtonView::OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point,
const ui::Event* event) {
cef_delegate()->OnMenuButtonPressed(GetCefMenuButton(),
CefPoint(point.x(), point.y()));
CefPoint(point.x(), point.y()),
new ButtonPressedLock(source));
}

View File

@ -122,6 +122,8 @@ class CefWindowImpl
cef_menu_anchor_position_t anchor_position);
void MenuClosed();
views::Widget* widget() const { return widget_; }
private:
// Create a new implementation object.
// Always call Initialize() after creation.

View File

@ -5,6 +5,7 @@
#include "libcef/browser/views/window_view.h"
#include "libcef/browser/image_impl.h"
#include "libcef/browser/views/window_impl.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/aura/window.h"
@ -249,9 +250,29 @@ void CefWindowView::CreateWidget() {
views::Widget::InitParams params;
params.delegate = this;
params.type = views::Widget::InitParams::TYPE_WINDOW;
bool can_activate = true;
if (cef_delegate())
is_frameless_ = cef_delegate()->IsFrameless(GetCefWindow());
if (cef_delegate()) {
CefRefPtr<CefWindow> cef_window = GetCefWindow();
is_frameless_ = cef_delegate()->IsFrameless(cef_window);
bool is_menu = false;
bool can_activate_menu = true;
CefRefPtr<CefWindow> parent_window = cef_delegate()->GetParentWindow(
cef_window, &is_menu, &can_activate_menu);
if (parent_window && !parent_window->IsSame(cef_window)) {
CefWindowImpl* parent_window_impl =
static_cast<CefWindowImpl*>(parent_window.get());
params.parent = view_util::GetNativeWindow(parent_window_impl->widget());
if (is_menu) {
// Don't clip the window to parent bounds.
params.type = views::Widget::InitParams::TYPE_MENU;
can_activate = can_activate_menu;
if (can_activate_menu)
params.activatable = views::Widget::InitParams::ACTIVATABLE_YES;
}
}
}
#if defined(OS_WIN)
if (is_frameless_) {
@ -267,8 +288,11 @@ void CefWindowView::CreateWidget() {
DCHECK_EQ(widget, GetWidget());
// |widget| must be top-level for focus handling to work correctly.
DCHECK(widget->is_top_level());
// |widget| must be activatable for focus handling to work correctly.
DCHECK(widget->widget_delegate()->CanActivate());
if (can_activate) {
// |widget| must be activatable for focus handling to work correctly.
DCHECK(widget->widget_delegate()->CanActivate());
}
#if defined(OS_LINUX)
if (is_frameless_) {

View File

@ -9,12 +9,13 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1c14ea52e06cca6ef0ad5e82797b9b1cda7141b4$
// $hash=e2d8f32f84e5995d892da25cf13e09c194d5b6a5$
//
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
#include "libcef_dll/cpptoc/extension_cpptoc.h"
#include "libcef_dll/cpptoc/navigation_entry_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/ctocpp/client_ctocpp.h"
@ -1010,6 +1011,66 @@ browser_host_set_accessibility_state(struct _cef_browser_host_t* self,
CefBrowserHostCppToC::Get(self)->SetAccessibilityState(accessibility_state);
}
void CEF_CALLBACK
browser_host_set_auto_resize_enabled(struct _cef_browser_host_t* self,
int enabled,
const cef_size_t* min_size,
const cef_size_t* max_size) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: min_size; type: simple_byref_const
DCHECK(min_size);
if (!min_size)
return;
// Verify param: max_size; type: simple_byref_const
DCHECK(max_size);
if (!max_size)
return;
// Translate param: min_size; type: simple_byref_const
CefSize min_sizeVal = min_size ? *min_size : CefSize();
// Translate param: max_size; type: simple_byref_const
CefSize max_sizeVal = max_size ? *max_size : CefSize();
// Execute
CefBrowserHostCppToC::Get(self)->SetAutoResizeEnabled(
enabled ? true : false, min_sizeVal, max_sizeVal);
}
struct _cef_extension_t* CEF_CALLBACK
browser_host_get_extension(struct _cef_browser_host_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefExtension> _retval =
CefBrowserHostCppToC::Get(self)->GetExtension();
// Return type: refptr_same
return CefExtensionCppToC::Wrap(_retval);
}
int CEF_CALLBACK
browser_host_is_background_host(struct _cef_browser_host_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefBrowserHostCppToC::Get(self)->IsBackgroundHost();
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@ -1077,6 +1138,9 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() {
GetStruct()->get_visible_navigation_entry =
browser_host_get_visible_navigation_entry;
GetStruct()->set_accessibility_state = browser_host_set_accessibility_state;
GetStruct()->set_auto_resize_enabled = browser_host_set_auto_resize_enabled;
GetStruct()->get_extension = browser_host_get_extension;
GetStruct()->is_background_host = browser_host_is_background_host;
}
template <>

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ae4395cea3553abdea6394d37325c40454505477$
// $hash=b52f437f558356645aaf45ee20cf4f3983e03891$
//
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
@ -184,6 +184,35 @@ display_handler_on_console_message(struct _cef_display_handler_t* self,
return _retval;
}
int CEF_CALLBACK
display_handler_on_auto_resize(struct _cef_display_handler_t* self,
cef_browser_t* browser,
const cef_size_t* new_size) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: new_size; type: simple_byref_const
DCHECK(new_size);
if (!new_size)
return 0;
// Translate param: new_size; type: simple_byref_const
CefSize new_sizeVal = new_size ? *new_size : CefSize();
// Execute
bool _retval = CefDisplayHandlerCppToC::Get(self)->OnAutoResize(
CefBrowserCToCpp::Wrap(browser), new_sizeVal);
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@ -197,6 +226,7 @@ CefDisplayHandlerCppToC::CefDisplayHandlerCppToC() {
GetStruct()->on_tooltip = display_handler_on_tooltip;
GetStruct()->on_status_message = display_handler_on_status_message;
GetStruct()->on_console_message = display_handler_on_console_message;
GetStruct()->on_auto_resize = display_handler_on_auto_resize;
}
template <>

View 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;

View File

@ -0,0 +1,40 @@
// 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=a3c31e0a1f6ee88b5d5f908f95bc326a08baecf1$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_EXTENSION_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_EXTENSION_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_request_context_capi.h"
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_request_context.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 CefExtensionCppToC : public CefCppToCRefCounted<CefExtensionCppToC,
CefExtension,
cef_extension_t> {
public:
CefExtensionCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_EXTENSION_CPPTOC_H_

View File

@ -0,0 +1,274 @@
// 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=a4c5733b13d0513946314faf2ac0745c86419df7$
//
#include "libcef_dll/cpptoc/extension_handler_cpptoc.h"
#include "libcef_dll/cpptoc/client_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/extension_ctocpp.h"
#include "libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK extension_handler_on_extension_load_failed(
struct _cef_extension_handler_t* self,
cef_errorcode_t result) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefExtensionHandlerCppToC::Get(self)->OnExtensionLoadFailed(result);
}
void CEF_CALLBACK
extension_handler_on_extension_loaded(struct _cef_extension_handler_t* self,
cef_extension_t* extension) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: extension; type: refptr_diff
DCHECK(extension);
if (!extension)
return;
// Execute
CefExtensionHandlerCppToC::Get(self)->OnExtensionLoaded(
CefExtensionCToCpp::Wrap(extension));
}
void CEF_CALLBACK
extension_handler_on_extension_unloaded(struct _cef_extension_handler_t* self,
cef_extension_t* extension) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: extension; type: refptr_diff
DCHECK(extension);
if (!extension)
return;
// Execute
CefExtensionHandlerCppToC::Get(self)->OnExtensionUnloaded(
CefExtensionCToCpp::Wrap(extension));
}
int CEF_CALLBACK extension_handler_on_before_background_browser(
struct _cef_extension_handler_t* self,
cef_extension_t* extension,
const cef_string_t* url,
cef_client_t** client,
struct _cef_browser_settings_t* settings) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: extension; type: refptr_diff
DCHECK(extension);
if (!extension)
return 0;
// Verify param: url; type: string_byref_const
DCHECK(url);
if (!url)
return 0;
// Verify param: client; type: refptr_same_byref
DCHECK(client);
if (!client)
return 0;
// Verify param: settings; type: struct_byref
DCHECK(settings);
if (!settings)
return 0;
// Translate param: client; type: refptr_same_byref
CefRefPtr<CefClient> clientPtr;
if (client && *client)
clientPtr = CefClientCppToC::Unwrap(*client);
CefClient* clientOrig = clientPtr.get();
// Translate param: settings; type: struct_byref
CefBrowserSettings settingsObj;
if (settings)
settingsObj.AttachTo(*settings);
// Execute
bool _retval =
CefExtensionHandlerCppToC::Get(self)->OnBeforeBackgroundBrowser(
CefExtensionCToCpp::Wrap(extension), CefString(url), clientPtr,
settingsObj);
// Restore param: client; type: refptr_same_byref
if (client) {
if (clientPtr.get()) {
if (clientPtr.get() != clientOrig) {
*client = CefClientCppToC::Wrap(clientPtr);
}
} else {
*client = NULL;
}
}
// Restore param: settings; type: struct_byref
if (settings)
settingsObj.DetachTo(*settings);
// Return type: bool
return _retval;
}
cef_browser_t* CEF_CALLBACK
extension_handler_get_active_browser(struct _cef_extension_handler_t* self,
cef_extension_t* extension,
cef_browser_t* browser,
int include_incognito) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: extension; type: refptr_diff
DCHECK(extension);
if (!extension)
return NULL;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return NULL;
// Execute
CefRefPtr<CefBrowser> _retval =
CefExtensionHandlerCppToC::Get(self)->GetActiveBrowser(
CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
include_incognito ? true : false);
// Return type: refptr_diff
return CefBrowserCToCpp::Unwrap(_retval);
}
int CEF_CALLBACK
extension_handler_can_access_browser(struct _cef_extension_handler_t* self,
cef_extension_t* extension,
cef_browser_t* browser,
int include_incognito,
cef_browser_t* target_browser) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: extension; type: refptr_diff
DCHECK(extension);
if (!extension)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: target_browser; type: refptr_diff
DCHECK(target_browser);
if (!target_browser)
return 0;
// Execute
bool _retval = CefExtensionHandlerCppToC::Get(self)->CanAccessBrowser(
CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
include_incognito ? true : false, CefBrowserCToCpp::Wrap(target_browser));
// Return type: bool
return _retval;
}
int CEF_CALLBACK extension_handler_get_extension_resource(
struct _cef_extension_handler_t* self,
cef_extension_t* extension,
cef_browser_t* browser,
const cef_string_t* file,
cef_get_extension_resource_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: extension; type: refptr_diff
DCHECK(extension);
if (!extension)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: file; type: string_byref_const
DCHECK(file);
if (!file)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return 0;
// Execute
bool _retval = CefExtensionHandlerCppToC::Get(self)->GetExtensionResource(
CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
CefString(file), CefGetExtensionResourceCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefExtensionHandlerCppToC::CefExtensionHandlerCppToC() {
GetStruct()->on_extension_load_failed =
extension_handler_on_extension_load_failed;
GetStruct()->on_extension_loaded = extension_handler_on_extension_loaded;
GetStruct()->on_extension_unloaded = extension_handler_on_extension_unloaded;
GetStruct()->on_before_background_browser =
extension_handler_on_before_background_browser;
GetStruct()->get_active_browser = extension_handler_get_active_browser;
GetStruct()->can_access_browser = extension_handler_can_access_browser;
GetStruct()->get_extension_resource =
extension_handler_get_extension_resource;
}
template <>
CefRefPtr<CefExtensionHandler> CefCppToCRefCounted<
CefExtensionHandlerCppToC,
CefExtensionHandler,
cef_extension_handler_t>::UnwrapDerived(CefWrapperType type,
cef_extension_handler_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCppToCRefCounted<CefExtensionHandlerCppToC,
CefExtensionHandler,
cef_extension_handler_t>::DebugObjCt
ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType CefCppToCRefCounted<CefExtensionHandlerCppToC,
CefExtensionHandler,
cef_extension_handler_t>::kWrapperType =
WT_EXTENSION_HANDLER;

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=a366d32d99f319bec553d0f3cee2c98fd6ab4501$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_EXTENSION_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_EXTENSION_HANDLER_CPPTOC_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/cef_client.h"
#include "include/cef_extension_handler.h"
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefExtensionHandlerCppToC
: public CefCppToCRefCounted<CefExtensionHandlerCppToC,
CefExtensionHandler,
cef_extension_handler_t> {
public:
CefExtensionHandlerCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_EXTENSION_HANDLER_CPPTOC_H_

View File

@ -0,0 +1,82 @@
// 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=a14686b53e028382d8dc537009d7a18263f753d6$
//
#include "libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h"
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK get_extension_resource_callback_cont(
struct _cef_get_extension_resource_callback_t* self,
struct _cef_stream_reader_t* stream) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Unverified params: stream
// Execute
CefGetExtensionResourceCallbackCppToC::Get(self)->Continue(
CefStreamReaderCppToC::Unwrap(stream));
}
void CEF_CALLBACK get_extension_resource_callback_cancel(
struct _cef_get_extension_resource_callback_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefGetExtensionResourceCallbackCppToC::Get(self)->Cancel();
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefGetExtensionResourceCallbackCppToC::CefGetExtensionResourceCallbackCppToC() {
GetStruct()->cont = get_extension_resource_callback_cont;
GetStruct()->cancel = get_extension_resource_callback_cancel;
}
template <>
CefRefPtr<CefGetExtensionResourceCallback>
CefCppToCRefCounted<CefGetExtensionResourceCallbackCppToC,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t>::
UnwrapDerived(CefWrapperType type,
cef_get_extension_resource_callback_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCppToCRefCounted<
CefGetExtensionResourceCallbackCppToC,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t>::DebugObjCt ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType
CefCppToCRefCounted<CefGetExtensionResourceCallbackCppToC,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t>::kWrapperType =
WT_GET_EXTENSION_RESOURCE_CALLBACK;

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=f8084e34f58eafa157202cfa06d946b09b18e289$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_GET_EXTENSION_RESOURCE_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_GET_EXTENSION_RESOURCE_CALLBACK_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/cef_client.h"
#include "include/cef_extension_handler.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 CefGetExtensionResourceCallbackCppToC
: public CefCppToCRefCounted<CefGetExtensionResourceCallbackCppToC,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t> {
public:
CefGetExtensionResourceCallbackCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_GET_EXTENSION_RESOURCE_CALLBACK_CPPTOC_H_

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 <>

View File

@ -9,17 +9,36 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=9f8701b130114d4d36b9df1045dc65b899f7141c$
// $hash=fef1959b9f8b96573de134769406f9eed4eeefc5$
//
#include "libcef_dll/cpptoc/request_context_handler_cpptoc.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK request_context_handler_on_request_context_initialized(
struct _cef_request_context_handler_t* self,
cef_request_context_t* request_context) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: request_context; type: refptr_diff
DCHECK(request_context);
if (!request_context)
return;
// Execute
CefRequestContextHandlerCppToC::Get(self)->OnRequestContextInitialized(
CefRequestContextCToCpp::Wrap(request_context));
}
cef_cookie_manager_t* CEF_CALLBACK request_context_handler_get_cookie_manager(
struct _cef_request_context_handler_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -78,6 +97,8 @@ int CEF_CALLBACK request_context_handler_on_before_plugin_load(
// CONSTRUCTOR - Do not edit by hand.
CefRequestContextHandlerCppToC::CefRequestContextHandlerCppToC() {
GetStruct()->on_request_context_initialized =
request_context_handler_on_request_context_initialized;
GetStruct()->get_cookie_manager = request_context_handler_get_cookie_manager;
GetStruct()->on_before_plugin_load =
request_context_handler_on_before_plugin_load;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=2ccdc811cf83c44925c3600c0dda1e98b869690f$
// $hash=265d7e41e1c27a09d82000c236e264bad092eabd$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_REQUEST_CONTEXT_HANDLER_CPPTOC_H_
@ -20,7 +20,9 @@
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_request_context_capi.h"
#include "include/capi/cef_request_context_handler_capi.h"
#include "include/cef_request_context.h"
#include "include/cef_request_context_handler.h"
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"

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;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=aff3b781529dd68e4a26208c7ab116e8ecd8cca5$
// $hash=068f8e238672b955b7f648002c80e364e24a936a$
//
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
@ -20,6 +20,7 @@
#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/drag_data_ctocpp.h"
#include "libcef_dll/ctocpp/extension_ctocpp.h"
#include "libcef_dll/ctocpp/navigation_entry_ctocpp.h"
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@ -820,6 +821,47 @@ void CefBrowserHostCToCpp::SetAccessibilityState(
_struct->set_accessibility_state(_struct, accessibility_state);
}
void CefBrowserHostCToCpp::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) {
cef_browser_host_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, set_auto_resize_enabled))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->set_auto_resize_enabled(_struct, enabled, &min_size, &max_size);
}
CefRefPtr<CefExtension> CefBrowserHostCToCpp::GetExtension() {
cef_browser_host_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_extension))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_extension_t* _retval = _struct->get_extension(_struct);
// Return type: refptr_same
return CefExtensionCToCpp::Wrap(_retval);
}
bool CefBrowserHostCToCpp::IsBackgroundHost() {
cef_browser_host_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, is_background_host))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = _struct->is_background_host(_struct);
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefBrowserHostCToCpp::CefBrowserHostCToCpp() {}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=589466ca4bd3e901d903764a71a4e8b1ee10003f$
// $hash=2e9c65525e5d95bd4293d0529b0ff302cf96ed12$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
@ -120,6 +120,11 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted<CefBrowserHostCToCpp,
void DragSourceSystemDragEnded() OVERRIDE;
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() OVERRIDE;
void SetAccessibilityState(cef_state_t accessibility_state) OVERRIDE;
void SetAutoResizeEnabled(bool enabled,
const CefSize& min_size,
const CefSize& max_size) OVERRIDE;
CefRefPtr<CefExtension> GetExtension() OVERRIDE;
bool IsBackgroundHost() OVERRIDE;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=3326b8685ef95a87e31c06ed4b2b7c1072e8dda2$
// $hash=1948d2651fc5f7fd6aab7878da869b5d231b9cde$
//
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
@ -180,6 +180,27 @@ bool CefDisplayHandlerCToCpp::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
return _retval ? true : false;
}
bool CefDisplayHandlerCToCpp::OnAutoResize(CefRefPtr<CefBrowser> browser,
const CefSize& new_size) {
cef_display_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_auto_resize))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Execute
int _retval = _struct->on_auto_resize(
_struct, CefBrowserCppToC::Wrap(browser), &new_size);
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefDisplayHandlerCToCpp::CefDisplayHandlerCToCpp() {}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=309e3816e3daba60c7809230fdecb59d01e41847$
// $hash=6d8ab7f2086373de52eb178cc640d2d553d43c58$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_
@ -51,6 +51,8 @@ class CefDisplayHandlerCToCpp
const CefString& message,
const CefString& source,
int line) override;
bool OnAutoResize(CefRefPtr<CefBrowser> browser,
const CefSize& new_size) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_DISPLAY_HANDLER_CTOCPP_H_

View File

@ -0,0 +1,163 @@
// 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=03f1fdb03fe9164e965e62d3e703d1b5a548ffdd$
//
#include "libcef_dll/ctocpp/extension_ctocpp.h"
#include "libcef_dll/cpptoc/extension_handler_cpptoc.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
CefString CefExtensionCToCpp::GetIdentifier() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_identifier))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = _struct->get_identifier(_struct);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefExtensionCToCpp::GetPath() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_path))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = _struct->get_path(_struct);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefRefPtr<CefDictionaryValue> CefExtensionCToCpp::GetManifest() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_manifest))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_dictionary_value_t* _retval = _struct->get_manifest(_struct);
// Return type: refptr_same
return CefDictionaryValueCToCpp::Wrap(_retval);
}
bool CefExtensionCToCpp::IsSame(CefRefPtr<CefExtension> that) {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, is_same))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: that; type: refptr_same
DCHECK(that.get());
if (!that.get())
return false;
// Execute
int _retval = _struct->is_same(_struct, CefExtensionCToCpp::Unwrap(that));
// Return type: bool
return _retval ? true : false;
}
CefRefPtr<CefExtensionHandler> CefExtensionCToCpp::GetHandler() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_handler))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_extension_handler_t* _retval = _struct->get_handler(_struct);
// Return type: refptr_diff
return CefExtensionHandlerCppToC::Unwrap(_retval);
}
CefRefPtr<CefRequestContext> CefExtensionCToCpp::GetLoaderContext() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_loader_context))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_request_context_t* _retval = _struct->get_loader_context(_struct);
// Return type: refptr_same
return CefRequestContextCToCpp::Wrap(_retval);
}
bool CefExtensionCToCpp::IsLoaded() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, is_loaded))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = _struct->is_loaded(_struct);
// Return type: bool
return _retval ? true : false;
}
void CefExtensionCToCpp::Unload() {
cef_extension_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, unload))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->unload(_struct);
}
// CONSTRUCTOR - Do not edit by hand.
CefExtensionCToCpp::CefExtensionCToCpp() {}
template <>
cef_extension_t*
CefCToCppRefCounted<CefExtensionCToCpp, CefExtension, cef_extension_t>::
UnwrapDerived(CefWrapperType type, CefExtension* c) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount
CefCToCppRefCounted<CefExtensionCToCpp, CefExtension, cef_extension_t>::
DebugObjCt ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType CefCToCppRefCounted<CefExtensionCToCpp,
CefExtension,
cef_extension_t>::kWrapperType =
WT_EXTENSION;

View File

@ -0,0 +1,50 @@
// 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=b130e6a0c2cc23cb6eaa06b46a6bdb2bebf550b4$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_EXTENSION_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_EXTENSION_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_extension_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/capi/cef_request_context_capi.h"
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_request_context.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 CefExtensionCToCpp : public CefCToCppRefCounted<CefExtensionCToCpp,
CefExtension,
cef_extension_t> {
public:
CefExtensionCToCpp();
// CefExtension methods.
CefString GetIdentifier() OVERRIDE;
CefString GetPath() OVERRIDE;
CefRefPtr<CefDictionaryValue> GetManifest() OVERRIDE;
bool IsSame(CefRefPtr<CefExtension> that) OVERRIDE;
CefRefPtr<CefExtensionHandler> GetHandler() OVERRIDE;
CefRefPtr<CefRequestContext> GetLoaderContext() OVERRIDE;
bool IsLoaded() OVERRIDE;
void Unload() OVERRIDE;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_EXTENSION_CTOCPP_H_

View File

@ -0,0 +1,238 @@
// 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=b8f2ada19624a72741d86b5d6ff5214a4b711dd6$
//
#include "libcef_dll/ctocpp/extension_handler_ctocpp.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/extension_cpptoc.h"
#include "libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h"
#include "libcef_dll/ctocpp/client_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefExtensionHandlerCToCpp::OnExtensionLoadFailed(cef_errorcode_t result) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_extension_load_failed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->on_extension_load_failed(_struct, result);
}
void CefExtensionHandlerCToCpp::OnExtensionLoaded(
CefRefPtr<CefExtension> extension) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_extension_loaded))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension; type: refptr_diff
DCHECK(extension.get());
if (!extension.get())
return;
// Execute
_struct->on_extension_loaded(_struct, CefExtensionCppToC::Wrap(extension));
}
void CefExtensionHandlerCToCpp::OnExtensionUnloaded(
CefRefPtr<CefExtension> extension) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_extension_unloaded))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension; type: refptr_diff
DCHECK(extension.get());
if (!extension.get())
return;
// Execute
_struct->on_extension_unloaded(_struct, CefExtensionCppToC::Wrap(extension));
}
bool CefExtensionHandlerCToCpp::OnBeforeBackgroundBrowser(
CefRefPtr<CefExtension> extension,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_before_background_browser))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension; type: refptr_diff
DCHECK(extension.get());
if (!extension.get())
return false;
// Verify param: url; type: string_byref_const
DCHECK(!url.empty());
if (url.empty())
return false;
// Translate param: client; type: refptr_same_byref
cef_client_t* clientStruct = NULL;
if (client.get())
clientStruct = CefClientCToCpp::Unwrap(client);
cef_client_t* clientOrig = clientStruct;
// Execute
int _retval = _struct->on_before_background_browser(
_struct, CefExtensionCppToC::Wrap(extension), url.GetStruct(),
&clientStruct, &settings);
// Restore param:client; type: refptr_same_byref
if (clientStruct) {
if (clientStruct != clientOrig) {
client = CefClientCToCpp::Wrap(clientStruct);
}
} else {
client = NULL;
}
// Return type: bool
return _retval ? true : false;
}
CefRefPtr<CefBrowser> CefExtensionHandlerCToCpp::GetActiveBrowser(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_active_browser))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension; type: refptr_diff
DCHECK(extension.get());
if (!extension.get())
return NULL;
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return NULL;
// Execute
cef_browser_t* _retval = _struct->get_active_browser(
_struct, CefExtensionCppToC::Wrap(extension),
CefBrowserCppToC::Wrap(browser), include_incognito);
// Return type: refptr_diff
return CefBrowserCppToC::Unwrap(_retval);
}
bool CefExtensionHandlerCToCpp::CanAccessBrowser(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito,
CefRefPtr<CefBrowser> target_browser) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, can_access_browser))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension; type: refptr_diff
DCHECK(extension.get());
if (!extension.get())
return false;
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: target_browser; type: refptr_diff
DCHECK(target_browser.get());
if (!target_browser.get())
return false;
// Execute
int _retval = _struct->can_access_browser(
_struct, CefExtensionCppToC::Wrap(extension),
CefBrowserCppToC::Wrap(browser), include_incognito,
CefBrowserCppToC::Wrap(target_browser));
// Return type: bool
return _retval ? true : false;
}
bool CefExtensionHandlerCToCpp::GetExtensionResource(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
const CefString& file,
CefRefPtr<CefGetExtensionResourceCallback> callback) {
cef_extension_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_extension_resource))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension; type: refptr_diff
DCHECK(extension.get());
if (!extension.get())
return false;
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: file; type: string_byref_const
DCHECK(!file.empty());
if (file.empty())
return false;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
return false;
// Execute
int _retval = _struct->get_extension_resource(
_struct, CefExtensionCppToC::Wrap(extension),
CefBrowserCppToC::Wrap(browser), file.GetStruct(),
CefGetExtensionResourceCallbackCppToC::Wrap(callback));
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefExtensionHandlerCToCpp::CefExtensionHandlerCToCpp() {}
template <>
cef_extension_handler_t* CefCToCppRefCounted<
CefExtensionHandlerCToCpp,
CefExtensionHandler,
cef_extension_handler_t>::UnwrapDerived(CefWrapperType type,
CefExtensionHandler* c) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCToCppRefCounted<CefExtensionHandlerCToCpp,
CefExtensionHandler,
cef_extension_handler_t>::DebugObjCt
ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType CefCToCppRefCounted<CefExtensionHandlerCToCpp,
CefExtensionHandler,
cef_extension_handler_t>::kWrapperType =
WT_EXTENSION_HANDLER;

View File

@ -0,0 +1,60 @@
// 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=369179037f2f6abc4d30e25099b52acf2f71e1e2$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_EXTENSION_HANDLER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_EXTENSION_HANDLER_CTOCPP_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/cef_client.h"
#include "include/cef_extension_handler.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefExtensionHandlerCToCpp
: public CefCToCppRefCounted<CefExtensionHandlerCToCpp,
CefExtensionHandler,
cef_extension_handler_t> {
public:
CefExtensionHandlerCToCpp();
// CefExtensionHandler methods.
void OnExtensionLoadFailed(cef_errorcode_t result) override;
void OnExtensionLoaded(CefRefPtr<CefExtension> extension) override;
void OnExtensionUnloaded(CefRefPtr<CefExtension> extension) override;
bool OnBeforeBackgroundBrowser(CefRefPtr<CefExtension> extension,
const CefString& url,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) override;
CefRefPtr<CefBrowser> GetActiveBrowser(CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito) override;
bool CanAccessBrowser(CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
bool include_incognito,
CefRefPtr<CefBrowser> target_browser) override;
bool GetExtensionResource(
CefRefPtr<CefExtension> extension,
CefRefPtr<CefBrowser> browser,
const CefString& file,
CefRefPtr<CefGetExtensionResourceCallback> callback) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_EXTENSION_HANDLER_CTOCPP_H_

View File

@ -0,0 +1,73 @@
// 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=9ce6ac777c6afb7f0c015c3ad5c1e73c176af0d0$
//
#include "libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h"
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefGetExtensionResourceCallbackCToCpp::Continue(
CefRefPtr<CefStreamReader> stream) {
cef_get_extension_resource_callback_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, cont))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: stream
// Execute
_struct->cont(_struct, CefStreamReaderCToCpp::Unwrap(stream));
}
void CefGetExtensionResourceCallbackCToCpp::Cancel() {
cef_get_extension_resource_callback_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, cancel))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->cancel(_struct);
}
// CONSTRUCTOR - Do not edit by hand.
CefGetExtensionResourceCallbackCToCpp::CefGetExtensionResourceCallbackCToCpp() {
}
template <>
cef_get_extension_resource_callback_t*
CefCToCppRefCounted<CefGetExtensionResourceCallbackCToCpp,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t>::
UnwrapDerived(CefWrapperType type, CefGetExtensionResourceCallback* c) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCToCppRefCounted<
CefGetExtensionResourceCallbackCToCpp,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t>::DebugObjCt ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType
CefCToCppRefCounted<CefGetExtensionResourceCallbackCToCpp,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t>::kWrapperType =
WT_GET_EXTENSION_RESOURCE_CALLBACK;

View File

@ -0,0 +1,43 @@
// 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=a30c4e51250f312d20fff853063eb78fb23fc3c2$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_GET_EXTENSION_RESOURCE_CALLBACK_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_GET_EXTENSION_RESOURCE_CALLBACK_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_client_capi.h"
#include "include/capi/cef_extension_handler_capi.h"
#include "include/cef_client.h"
#include "include/cef_extension_handler.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 CefGetExtensionResourceCallbackCToCpp
: public CefCToCppRefCounted<CefGetExtensionResourceCallbackCToCpp,
CefGetExtensionResourceCallback,
cef_get_extension_resource_callback_t> {
public:
CefGetExtensionResourceCallbackCToCpp();
// CefGetExtensionResourceCallback methods.
void Continue(CefRefPtr<CefStreamReader> stream) OVERRIDE;
void Cancel() OVERRIDE;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_GET_EXTENSION_RESOURCE_CALLBACK_CTOCPP_H_

View File

@ -9,16 +9,18 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=eb7605c00ee71d056306cd6b9d0e7eb55112927a$
// $hash=7199bc96d7ab4c07229d7d8cb078a9b64621042c$
//
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
#include "libcef_dll/cpptoc/completion_callback_cpptoc.h"
#include "libcef_dll/cpptoc/extension_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_handler_cpptoc.h"
#include "libcef_dll/cpptoc/resolve_callback_cpptoc.h"
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
#include "libcef_dll/ctocpp/extension_ctocpp.h"
#include "libcef_dll/ctocpp/value_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@ -410,6 +412,115 @@ cef_errorcode_t CefRequestContextCToCpp::ResolveHostCached(
return _retval;
}
void CefRequestContextCToCpp::LoadExtension(
const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, load_extension))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: root_directory; type: string_byref_const
DCHECK(!root_directory.empty());
if (root_directory.empty())
return;
// Unverified params: manifest, handler
// Execute
_struct->load_extension(_struct, root_directory.GetStruct(),
CefDictionaryValueCToCpp::Unwrap(manifest),
CefExtensionHandlerCppToC::Wrap(handler));
}
bool CefRequestContextCToCpp::DidLoadExtension(const CefString& extension_id) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, did_load_extension))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension_id; type: string_byref_const
DCHECK(!extension_id.empty());
if (extension_id.empty())
return false;
// Execute
int _retval = _struct->did_load_extension(_struct, extension_id.GetStruct());
// Return type: bool
return _retval ? true : false;
}
bool CefRequestContextCToCpp::HasExtension(const CefString& extension_id) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, has_extension))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension_id; type: string_byref_const
DCHECK(!extension_id.empty());
if (extension_id.empty())
return false;
// Execute
int _retval = _struct->has_extension(_struct, extension_id.GetStruct());
// Return type: bool
return _retval ? true : false;
}
bool CefRequestContextCToCpp::GetExtensions(
std::vector<CefString>& extension_ids) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_extensions))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: extension_ids; type: string_vec_byref
cef_string_list_t extension_idsList = cef_string_list_alloc();
DCHECK(extension_idsList);
if (extension_idsList)
transfer_string_list_contents(extension_ids, extension_idsList);
// Execute
int _retval = _struct->get_extensions(_struct, extension_idsList);
// Restore param:extension_ids; type: string_vec_byref
if (extension_idsList) {
extension_ids.clear();
transfer_string_list_contents(extension_idsList, extension_ids);
cef_string_list_free(extension_idsList);
}
// Return type: bool
return _retval ? true : false;
}
CefRefPtr<CefExtension> CefRequestContextCToCpp::GetExtension(
const CefString& extension_id) {
cef_request_context_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_extension))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: extension_id; type: string_byref_const
DCHECK(!extension_id.empty());
if (extension_id.empty())
return NULL;
// Execute
cef_extension_t* _retval =
_struct->get_extension(_struct, extension_id.GetStruct());
// Return type: refptr_same
return CefExtensionCToCpp::Wrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand.
CefRequestContextCToCpp::CefRequestContextCToCpp() {}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=007659e858fb2ce87b3974d8d304d850434bac8b$
// $hash=4e86aeaf1eea5a2357e094952219ec6dd8f956bb$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
@ -66,6 +66,13 @@ class CefRequestContextCToCpp
cef_errorcode_t ResolveHostCached(
const CefString& origin,
std::vector<CefString>& resolved_ips) OVERRIDE;
void LoadExtension(const CefString& root_directory,
CefRefPtr<CefDictionaryValue> manifest,
CefRefPtr<CefExtensionHandler> handler) OVERRIDE;
bool DidLoadExtension(const CefString& extension_id) OVERRIDE;
bool HasExtension(const CefString& extension_id) OVERRIDE;
bool GetExtensions(std::vector<CefString>& extension_ids) OVERRIDE;
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) OVERRIDE;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_

View File

@ -9,15 +9,34 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=06dd198c1341ffa14ae98b3937df025322ed5510$
// $hash=aeb8be6019f69c4271ae0e35c4a6759dc46cc33d$
//
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefRequestContextHandlerCToCpp::OnRequestContextInitialized(
CefRefPtr<CefRequestContext> request_context) {
cef_request_context_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_request_context_initialized))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: request_context; type: refptr_diff
DCHECK(request_context.get());
if (!request_context.get())
return;
// Execute
_struct->on_request_context_initialized(
_struct, CefRequestContextCppToC::Wrap(request_context));
}
CefRefPtr<CefCookieManager> CefRequestContextHandlerCToCpp::GetCookieManager() {
cef_request_context_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_cookie_manager))

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f51e1ceef8535c2d81dd7a9918da5e3b9861376f$
// $hash=e2ff660c7baffdce4c00f6ae132a770e13bd9358$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_HANDLER_CTOCPP_H_
@ -20,7 +20,9 @@
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_request_context_capi.h"
#include "include/capi/cef_request_context_handler_capi.h"
#include "include/cef_request_context.h"
#include "include/cef_request_context_handler.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
@ -34,6 +36,8 @@ class CefRequestContextHandlerCToCpp
CefRequestContextHandlerCToCpp();
// CefRequestContextHandler methods.
void OnRequestContextInitialized(
CefRefPtr<CefRequestContext> request_context) override;
CefRefPtr<CefCookieManager> GetCookieManager() override;
bool OnBeforePluginLoad(const CefString& mime_type,
const CefString& plugin_url,

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;

Some files were not shown because too many files have changed in this diff Show More