mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Delete Alloy bootstrap (fixes #3685)
This commit is contained in:
127
BUILD.gn
127
BUILD.gn
@ -844,10 +844,6 @@ source_set("libcef_static") {
|
|||||||
"libcef/renderer/dom_document_impl.h",
|
"libcef/renderer/dom_document_impl.h",
|
||||||
"libcef/renderer/dom_node_impl.cc",
|
"libcef/renderer/dom_node_impl.cc",
|
||||||
"libcef/renderer/dom_node_impl.h",
|
"libcef/renderer/dom_node_impl.h",
|
||||||
"libcef/renderer/extensions/extensions_renderer_api_provider.cc",
|
|
||||||
"libcef/renderer/extensions/extensions_renderer_api_provider.h",
|
|
||||||
"libcef/renderer/extensions/extensions_renderer_client.cc",
|
|
||||||
"libcef/renderer/extensions/extensions_renderer_client.h",
|
|
||||||
"libcef/renderer/frame_impl.cc",
|
"libcef/renderer/frame_impl.cc",
|
||||||
"libcef/renderer/frame_impl.h",
|
"libcef/renderer/frame_impl.h",
|
||||||
"libcef/renderer/render_frame_observer.cc",
|
"libcef/renderer/render_frame_observer.cc",
|
||||||
@ -865,121 +861,6 @@ source_set("libcef_static") {
|
|||||||
"//chrome/app/chrome_main_delegate.h",
|
"//chrome/app/chrome_main_delegate.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (enable_alloy_bootstrap) {
|
|
||||||
sources += [
|
|
||||||
"libcef/browser/alloy/alloy_browser_context.cc",
|
|
||||||
"libcef/browser/alloy/alloy_browser_context.h",
|
|
||||||
"libcef/browser/alloy/alloy_browser_main.cc",
|
|
||||||
"libcef/browser/alloy/alloy_browser_main.h",
|
|
||||||
"libcef/browser/alloy/alloy_content_browser_client.cc",
|
|
||||||
"libcef/browser/alloy/alloy_content_browser_client.h",
|
|
||||||
"libcef/browser/alloy/alloy_download_manager_delegate.cc",
|
|
||||||
"libcef/browser/alloy/alloy_download_manager_delegate.h",
|
|
||||||
"libcef/browser/alloy/alloy_download_util.cc",
|
|
||||||
"libcef/browser/alloy/alloy_download_util.h",
|
|
||||||
"libcef/browser/alloy/alloy_web_contents_view_delegate.cc",
|
|
||||||
"libcef/browser/alloy/alloy_web_contents_view_delegate.h",
|
|
||||||
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.cc",
|
|
||||||
"libcef/browser/alloy/devtools/alloy_devtools_window_runner.h",
|
|
||||||
"libcef/browser/alloy/devtools/devtools_file_manager.cc",
|
|
||||||
"libcef/browser/alloy/devtools/devtools_file_manager.h",
|
|
||||||
"libcef/browser/alloy/devtools/devtools_frontend.cc",
|
|
||||||
"libcef/browser/alloy/devtools/devtools_frontend.h",
|
|
||||||
"libcef/browser/alloy/devtools/devtools_manager_delegate.cc",
|
|
||||||
"libcef/browser/alloy/devtools/devtools_manager_delegate.h",
|
|
||||||
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.cc",
|
|
||||||
"libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h",
|
|
||||||
"libcef/browser/alloy/chrome_browser_process_alloy.cc",
|
|
||||||
"libcef/browser/alloy/chrome_browser_process_alloy.h",
|
|
||||||
"libcef/browser/alloy/chrome_profile_manager_alloy.cc",
|
|
||||||
"libcef/browser/alloy/chrome_profile_manager_alloy.h",
|
|
||||||
"libcef/browser/alloy/chrome_profile_alloy.cc",
|
|
||||||
"libcef/browser/alloy/chrome_profile_alloy.h",
|
|
||||||
"libcef/browser/browser_context_keyed_service_factories.cc",
|
|
||||||
"libcef/browser/browser_context_keyed_service_factories.h",
|
|
||||||
"libcef/browser/extension_impl.cc",
|
|
||||||
"libcef/browser/extension_impl.h",
|
|
||||||
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc",
|
|
||||||
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.h",
|
|
||||||
"libcef/browser/extensions/api/storage/sync_value_store_cache.cc",
|
|
||||||
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
|
|
||||||
"libcef/browser/extensions/api/tabs/tabs_api.cc",
|
|
||||||
"libcef/browser/extensions/api/tabs/tabs_api.h",
|
|
||||||
"libcef/browser/extensions/alloy_extensions_util.cc",
|
|
||||||
"libcef/browser/extensions/alloy_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",
|
|
||||||
"libcef/browser/extensions/component_extension_resource_manager.h",
|
|
||||||
"libcef/browser/extensions/extensions_api_client.cc",
|
|
||||||
"libcef/browser/extensions/extensions_api_client.h",
|
|
||||||
"libcef/browser/extensions/extensions_browser_api_provider.cc",
|
|
||||||
"libcef/browser/extensions/extensions_browser_api_provider.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",
|
|
||||||
"libcef/browser/extensions/mime_handler_view_guest_delegate.h",
|
|
||||||
"libcef/browser/extensions/value_store/cef_value_store.cc",
|
|
||||||
"libcef/browser/extensions/value_store/cef_value_store.h",
|
|
||||||
"libcef/browser/extensions/value_store/cef_value_store_factory.cc",
|
|
||||||
"libcef/browser/extensions/value_store/cef_value_store_factory.h",
|
|
||||||
"libcef/browser/media_capture_devices_dispatcher.cc",
|
|
||||||
"libcef/browser/media_capture_devices_dispatcher.h",
|
|
||||||
"libcef/browser/net/devtools_scheme_handler.cc",
|
|
||||||
"libcef/browser/net/devtools_scheme_handler.h",
|
|
||||||
"libcef/browser/net/internal_scheme_handler.cc",
|
|
||||||
"libcef/browser/net/internal_scheme_handler.h",
|
|
||||||
"libcef/browser/net/scheme_handler.cc",
|
|
||||||
"libcef/browser/net/scheme_handler.h",
|
|
||||||
"libcef/browser/prefs/pref_store.cc",
|
|
||||||
"libcef/browser/prefs/pref_store.h",
|
|
||||||
"libcef/browser/speech_recognition_manager_delegate.cc",
|
|
||||||
"libcef/browser/speech_recognition_manager_delegate.h",
|
|
||||||
"libcef/browser/ssl_host_state_delegate.cc",
|
|
||||||
"libcef/browser/ssl_host_state_delegate.h",
|
|
||||||
"libcef/common/alloy/alloy_content_client.cc",
|
|
||||||
"libcef/common/alloy/alloy_content_client.h",
|
|
||||||
"libcef/common/alloy/alloy_main_delegate.cc",
|
|
||||||
"libcef/common/alloy/alloy_main_delegate.h",
|
|
||||||
"libcef/common/alloy/alloy_main_runner_delegate.cc",
|
|
||||||
"libcef/common/alloy/alloy_main_runner_delegate.h",
|
|
||||||
"libcef/common/extensions/chrome_generated_schemas.cc",
|
|
||||||
"libcef/common/extensions/chrome_generated_schemas.h",
|
|
||||||
"libcef/common/extensions/extensions_api_provider.cc",
|
|
||||||
"libcef/common/extensions/extensions_api_provider.h",
|
|
||||||
"libcef/common/extensions/extensions_client.cc",
|
|
||||||
"libcef/common/extensions/extensions_client.h",
|
|
||||||
"libcef/common/extensions/extensions_util.cc",
|
|
||||||
"libcef/common/extensions/extensions_util.h",
|
|
||||||
"libcef/common/net/net_resource_provider.cc",
|
|
||||||
"libcef/common/net/net_resource_provider.h",
|
|
||||||
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
|
|
||||||
"libcef/renderer/alloy/alloy_content_renderer_client.h",
|
|
||||||
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
|
|
||||||
"libcef/renderer/alloy/alloy_render_frame_observer.h",
|
|
||||||
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
|
|
||||||
"libcef/renderer/alloy/alloy_render_thread_observer.h",
|
|
||||||
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
|
|
||||||
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
configs += [
|
configs += [
|
||||||
"libcef/features:config",
|
"libcef/features:config",
|
||||||
"//build/config:precompiled_headers",
|
"//build/config:precompiled_headers",
|
||||||
@ -1008,13 +889,6 @@ source_set("libcef_static") {
|
|||||||
|
|
||||||
":libcef_static_unittested",
|
":libcef_static_unittested",
|
||||||
|
|
||||||
# Generate API bindings for extensions.
|
|
||||||
# TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
|
|
||||||
# libcef/common/extensions/api/README.txt for details.
|
|
||||||
#"libcef/common/extensions/api",
|
|
||||||
#"libcef/common/extensions/api:api_registration",
|
|
||||||
"libcef/common/extensions/api:extensions_features",
|
|
||||||
|
|
||||||
# Normal build dependencies. Should be sorted alphabetically.
|
# Normal build dependencies. Should be sorted alphabetically.
|
||||||
"//base:base_static",
|
"//base:base_static",
|
||||||
"//cc",
|
"//cc",
|
||||||
@ -1111,7 +985,6 @@ source_set("libcef_static") {
|
|||||||
|
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
sources += includes_win + [
|
sources += includes_win + [
|
||||||
"libcef/browser/alloy/alloy_browser_main_win.cc",
|
|
||||||
"libcef/browser/native/browser_platform_delegate_native_win.cc",
|
"libcef/browser/native/browser_platform_delegate_native_win.cc",
|
||||||
"libcef/browser/native/browser_platform_delegate_native_win.h",
|
"libcef/browser/native/browser_platform_delegate_native_win.h",
|
||||||
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
|
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# by hand. See the translator.README.txt file in the tools directory for
|
# by hand. See the translator.README.txt file in the tools directory for
|
||||||
# more information.
|
# more information.
|
||||||
#
|
#
|
||||||
# $hash=3b28f3236c16d2b776a44674ae3bae0a070e9f27$
|
# $hash=29c508f2fb23e0ed2899163039384fb0a230be70$
|
||||||
#
|
#
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -35,8 +35,6 @@
|
|||||||
'include/cef_download_item.h',
|
'include/cef_download_item.h',
|
||||||
'include/cef_drag_data.h',
|
'include/cef_drag_data.h',
|
||||||
'include/cef_drag_handler.h',
|
'include/cef_drag_handler.h',
|
||||||
'include/cef_extension.h',
|
|
||||||
'include/cef_extension_handler.h',
|
|
||||||
'include/cef_file_util.h',
|
'include/cef_file_util.h',
|
||||||
'include/cef_find_handler.h',
|
'include/cef_find_handler.h',
|
||||||
'include/cef_focus_handler.h',
|
'include/cef_focus_handler.h',
|
||||||
@ -140,8 +138,6 @@
|
|||||||
'include/capi/cef_download_item_capi.h',
|
'include/capi/cef_download_item_capi.h',
|
||||||
'include/capi/cef_drag_data_capi.h',
|
'include/capi/cef_drag_data_capi.h',
|
||||||
'include/capi/cef_drag_handler_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_file_util_capi.h',
|
||||||
'include/capi/cef_find_handler_capi.h',
|
'include/capi/cef_find_handler_capi.h',
|
||||||
'include/capi/cef_focus_handler_capi.h',
|
'include/capi/cef_focus_handler_capi.h',
|
||||||
@ -304,10 +300,6 @@
|
|||||||
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
|
'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.cc',
|
||||||
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
|
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
|
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
|
||||||
@ -320,8 +312,6 @@
|
|||||||
'libcef_dll/cpptoc/frame_cpptoc.h',
|
'libcef_dll/cpptoc/frame_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
|
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/image_cpptoc.cc',
|
'libcef_dll/cpptoc/image_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/image_cpptoc.h',
|
'libcef_dll/cpptoc/image_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
|
||||||
@ -634,10 +624,6 @@
|
|||||||
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
|
'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.cc',
|
||||||
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
|
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
|
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
|
||||||
@ -650,8 +636,6 @@
|
|||||||
'libcef_dll/ctocpp/frame_ctocpp.h',
|
'libcef_dll/ctocpp/frame_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
|
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/image_ctocpp.cc',
|
'libcef_dll/ctocpp/image_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/image_ctocpp.h',
|
'libcef_dll/ctocpp/image_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
|
||||||
|
@ -84,10 +84,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#define DISABLE_ALLOY_BOOTSTRAP 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
#include "include/cef_config.h"
|
#include "include/cef_config.h"
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=dfa0d4d2da319b2fd5e92324fd14301b500ceb5c$
|
// $hash=608f4520d7901b6e18bf9164c9460f1b75bad8f4$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||||
@ -91,11 +91,9 @@ typedef struct _cef_app_t {
|
|||||||
struct _cef_scheme_registrar_t* registrar);
|
struct _cef_scheme_registrar_t* registrar);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Return the handler for resource bundle events. If
|
/// Return the handler for resource bundle events. If no handler is returned
|
||||||
/// cef_settings_t.pack_loading_disabled is true (1) a handler must be
|
/// resources will be loaded from pack files. This function is called by the
|
||||||
/// returned. If no handler is returned resources will be loaded from pack
|
/// browser and render processes on multiple threads.
|
||||||
/// files. This function is called by the browser and render processes on
|
|
||||||
/// multiple threads.
|
|
||||||
///
|
///
|
||||||
struct _cef_resource_bundle_handler_t*(
|
struct _cef_resource_bundle_handler_t*(
|
||||||
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=6ee74f31d37a1b5ab3c9c5ccbe2dce9841329b38$
|
// $hash=7c786570b1c7af912a31c6f0c3d742e8aeb38fd8$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||||
@ -381,8 +381,7 @@ typedef struct _cef_browser_host_t {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Get the default zoom level. This value will be 0.0 by default but can be
|
/// Get the default zoom level. This value will be 0.0 by default but can be
|
||||||
/// configured with the Chrome runtime. This function can only be called on
|
/// configured. This function can only be called on the UI thread.
|
||||||
/// the UI thread.
|
|
||||||
///
|
///
|
||||||
double(CEF_CALLBACK* get_default_zoom_level)(
|
double(CEF_CALLBACK* get_default_zoom_level)(
|
||||||
struct _cef_browser_host_t* self);
|
struct _cef_browser_host_t* self);
|
||||||
@ -907,24 +906,6 @@ typedef struct _cef_browser_host_t {
|
|||||||
const cef_size_t* min_size,
|
const cef_size_t* min_size,
|
||||||
const cef_size_t* max_size);
|
const cef_size_t* max_size);
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the extension hosted in this browser or NULL if no extension is
|
|
||||||
/// hosted. See cef_request_context_t::LoadExtension for details.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
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_context_t::LoadExtension for details.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set whether the browser's audio is muted.
|
/// Set whether the browser's audio is muted.
|
||||||
///
|
///
|
||||||
@ -948,12 +929,12 @@ typedef struct _cef_browser_host_t {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Requests the renderer to exit browser fullscreen. In most cases exiting
|
/// Requests the renderer to exit browser fullscreen. In most cases exiting
|
||||||
/// window fullscreen should also exit browser fullscreen. With the Alloy
|
/// window fullscreen should also exit browser fullscreen. With Alloy style
|
||||||
/// runtime this function should be called in response to a user action such
|
/// this function should be called in response to a user action such as
|
||||||
/// as clicking the green traffic light button on MacOS
|
/// clicking the green traffic light button on MacOS
|
||||||
/// (cef_window_delegate_t::OnWindowFullscreenTransition callback) or pressing
|
/// (cef_window_delegate_t::OnWindowFullscreenTransition callback) or pressing
|
||||||
/// the "ESC" key (cef_keyboard_handler_t::OnPreKeyEvent callback). With the
|
/// the "ESC" key (cef_keyboard_handler_t::OnPreKeyEvent callback). With
|
||||||
/// Chrome runtime these standard exit actions are handled internally but
|
/// Chrome style these standard exit actions are handled internally but
|
||||||
/// new/additional user actions can use this function. Set |will_cause_resize|
|
/// new/additional user actions can use this function. Set |will_cause_resize|
|
||||||
/// to true (1) if exiting browser fullscreen will cause a view resize.
|
/// to true (1) if exiting browser fullscreen will cause a view resize.
|
||||||
///
|
///
|
||||||
@ -963,7 +944,7 @@ typedef struct _cef_browser_host_t {
|
|||||||
///
|
///
|
||||||
/// Returns true (1) if a Chrome command is supported and enabled. Values for
|
/// Returns true (1) if a Chrome command is supported and enabled. Values for
|
||||||
/// |command_id| can be found in the cef_command_ids.h file. This function can
|
/// |command_id| can be found in the cef_command_ids.h file. This function can
|
||||||
/// only be called on the UI thread. Only used with the Chrome runtime.
|
/// only be called on the UI thread. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* can_execute_chrome_command)(
|
int(CEF_CALLBACK* can_execute_chrome_command)(
|
||||||
struct _cef_browser_host_t* self,
|
struct _cef_browser_host_t* self,
|
||||||
@ -972,7 +953,7 @@ typedef struct _cef_browser_host_t {
|
|||||||
///
|
///
|
||||||
/// Execute a Chrome command. Values for |command_id| can be found in the
|
/// Execute a Chrome command. Values for |command_id| can be found in the
|
||||||
/// cef_command_ids.h file. |disposition| provides information about the
|
/// cef_command_ids.h file. |disposition| provides information about the
|
||||||
/// intended command target. Only used with the Chrome runtime.
|
/// intended command target. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* execute_chrome_command)(
|
void(CEF_CALLBACK* execute_chrome_command)(
|
||||||
struct _cef_browser_host_t* self,
|
struct _cef_browser_host_t* self,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=d958d5bed7f909f6313facef3440fb8ba07a5c01$
|
// $hash=56ad161a75ca5083812e11959053abbcafbb9a5d$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||||
@ -69,8 +69,8 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||||
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
|
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
|
||||||
/// OnContextInitialized is called. Global preferences are registered a single
|
/// OnContextInitialized is called. Global preferences are registered a single
|
||||||
/// time at application startup. See related cef_settings_t.cache_path and
|
/// time at application startup. See related cef_settings_t.cache_path
|
||||||
/// cef_settings_t.persist_user_preferences configuration.
|
/// configuration.
|
||||||
///
|
///
|
||||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||||
/// accessed via the cef_request_context_t after
|
/// accessed via the cef_request_context_t after
|
||||||
@ -78,8 +78,7 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
/// Request context preferences are registered each time a new
|
/// Request context preferences are registered each time a new
|
||||||
/// cef_request_context_t is created. It is intended but not required that all
|
/// cef_request_context_t is created. It is intended but not required that all
|
||||||
/// request contexts have the same registered preferences. See related
|
/// request contexts have the same registered preferences. See related
|
||||||
/// cef_request_context_settings_t.cache_path and
|
/// cef_request_context_settings_t.cache_path configuration.
|
||||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
|
||||||
///
|
///
|
||||||
/// Do not keep a reference to the |registrar| object. This function is called
|
/// Do not keep a reference to the |registrar| object. This function is called
|
||||||
/// on the browser process UI thread.
|
/// on the browser process UI thread.
|
||||||
@ -152,8 +151,8 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
/// (cef_browser_t object). If null is returned the cef_browser_t will be
|
/// (cef_browser_t object). If null is returned the cef_browser_t will be
|
||||||
/// unmanaged (no callbacks will be executed for that cef_browser_t) and
|
/// unmanaged (no callbacks will be executed for that cef_browser_t) and
|
||||||
/// application shutdown will be blocked until the browser window is closed
|
/// application shutdown will be blocked until the browser window is closed
|
||||||
/// manually. This function is currently only used with the Chrome runtime
|
/// manually. This function is currently only used with Chrome style when
|
||||||
/// when creating new browser windows via Chrome UI.
|
/// creating new browser windows via Chrome UI.
|
||||||
///
|
///
|
||||||
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
|
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
|
||||||
struct _cef_browser_process_handler_t* self);
|
struct _cef_browser_process_handler_t* self);
|
||||||
@ -162,8 +161,8 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
/// Return the default handler for use with a new user or incognito profile
|
/// Return the default handler for use with a new user or incognito profile
|
||||||
/// (cef_request_context_t object). If null is returned the
|
/// (cef_request_context_t object). If null is returned the
|
||||||
/// cef_request_context_t will be unmanaged (no callbacks will be executed for
|
/// cef_request_context_t will be unmanaged (no callbacks will be executed for
|
||||||
/// that cef_request_context_t). This function is currently only used with the
|
/// that cef_request_context_t). This function is currently only used with
|
||||||
/// Chrome runtime when creating new browser windows via Chrome UI.
|
/// Chrome style when creating new browser windows via Chrome UI.
|
||||||
///
|
///
|
||||||
struct _cef_request_context_handler_t*(
|
struct _cef_request_context_handler_t*(
|
||||||
CEF_CALLBACK* get_default_request_context_handler)(
|
CEF_CALLBACK* get_default_request_context_handler)(
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=dd183a473b1e8c5ee8bdcf99949fc5274c4cc892$
|
// $hash=9c7d613d1256bd6353f5102ece5a04e572f20627$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||||
@ -64,7 +64,7 @@ typedef struct _cef_command_handler_t {
|
|||||||
/// intended command target. Return true (1) if the command was handled or
|
/// intended command target. Return true (1) if the command was handled or
|
||||||
/// false (0) for the default implementation. For context menu commands this
|
/// false (0) for the default implementation. For context menu commands this
|
||||||
/// will be called after cef_context_menu_handler_t::OnContextMenuCommand.
|
/// will be called after cef_context_menu_handler_t::OnContextMenuCommand.
|
||||||
/// Only used with the Chrome runtime.
|
/// Only used with Chrome style.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_chrome_command)(
|
int(CEF_CALLBACK* on_chrome_command)(
|
||||||
struct _cef_command_handler_t* self,
|
struct _cef_command_handler_t* self,
|
||||||
@ -75,8 +75,7 @@ typedef struct _cef_command_handler_t {
|
|||||||
///
|
///
|
||||||
/// Called to check if a Chrome app menu item should be visible. Values for
|
/// Called to check if a Chrome app menu item should be visible. Values for
|
||||||
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||||
/// menu items that would be visible by default. Only used with the Chrome
|
/// menu items that would be visible by default. Only used with Chrome style.
|
||||||
/// runtime.
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_chrome_app_menu_item_visible)(
|
int(CEF_CALLBACK* is_chrome_app_menu_item_visible)(
|
||||||
struct _cef_command_handler_t* self,
|
struct _cef_command_handler_t* self,
|
||||||
@ -86,8 +85,7 @@ typedef struct _cef_command_handler_t {
|
|||||||
///
|
///
|
||||||
/// Called to check if a Chrome app menu item should be enabled. Values for
|
/// Called to check if a Chrome app menu item should be enabled. Values for
|
||||||
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||||
/// menu items that would be enabled by default. Only used with the Chrome
|
/// menu items that would be enabled by default. Only used with Chrome style.
|
||||||
/// runtime.
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_chrome_app_menu_item_enabled)(
|
int(CEF_CALLBACK* is_chrome_app_menu_item_enabled)(
|
||||||
struct _cef_command_handler_t* self,
|
struct _cef_command_handler_t* self,
|
||||||
@ -97,7 +95,7 @@ typedef struct _cef_command_handler_t {
|
|||||||
///
|
///
|
||||||
/// Called during browser creation to check if a Chrome page action icon
|
/// Called during browser creation to check if a Chrome page action icon
|
||||||
/// should be visible. Only called for icons that would be visible by default.
|
/// should be visible. Only called for icons that would be visible by default.
|
||||||
/// Only used with the Chrome runtime.
|
/// Only used with Chrome style.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_chrome_page_action_icon_visible)(
|
int(CEF_CALLBACK* is_chrome_page_action_icon_visible)(
|
||||||
struct _cef_command_handler_t* self,
|
struct _cef_command_handler_t* self,
|
||||||
@ -106,7 +104,7 @@ typedef struct _cef_command_handler_t {
|
|||||||
///
|
///
|
||||||
/// Called during browser creation to check if a Chrome toolbar button should
|
/// Called during browser creation to check if a Chrome toolbar button should
|
||||||
/// be visible. Only called for buttons that would be visible by default. Only
|
/// be visible. Only called for buttons that would be visible by default. Only
|
||||||
/// used with the Chrome runtime.
|
/// used with Chrome style.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_chrome_toolbar_button_visible)(
|
int(CEF_CALLBACK* is_chrome_toolbar_button_visible)(
|
||||||
struct _cef_command_handler_t* self,
|
struct _cef_command_handler_t* self,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=5a99c5e88ea0e123087234b2795fa625fed183f2$
|
// $hash=b42d9e5a03f6ef5444e8037b8dc4de08ee6b0834$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||||
@ -84,13 +84,12 @@ typedef struct _cef_display_handler_t {
|
|||||||
/// Called when web content in the page has toggled fullscreen mode. If
|
/// Called when web content in the page has toggled fullscreen mode. If
|
||||||
/// |fullscreen| is true (1) the content will automatically be sized to fill
|
/// |fullscreen| is true (1) the content will automatically be sized to fill
|
||||||
/// the browser content area. If |fullscreen| is false (0) the content will
|
/// the browser content area. If |fullscreen| is false (0) the content will
|
||||||
/// automatically return to its original size and position. With the Alloy
|
/// automatically return to its original size and position. With Alloy style
|
||||||
/// runtime the client is responsible for triggering the fullscreen transition
|
/// the client is responsible for triggering the fullscreen transition (for
|
||||||
/// (for example, by calling cef_window_t::SetFullscreen when using Views).
|
/// example, by calling cef_window_t::SetFullscreen when using Views). With
|
||||||
/// With the Chrome runtime the fullscreen transition will be triggered
|
/// Chrome style the fullscreen transition will be triggered automatically.
|
||||||
/// automatically. The cef_window_delegate_t::OnWindowFullscreenTransition
|
/// The cef_window_delegate_t::OnWindowFullscreenTransition function will be
|
||||||
/// function will be called during the fullscreen transition for notification
|
/// called during the fullscreen transition for notification purposes.
|
||||||
/// purposes.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_fullscreen_mode_change)(
|
void(CEF_CALLBACK* on_fullscreen_mode_change)(
|
||||||
struct _cef_display_handler_t* self,
|
struct _cef_display_handler_t* self,
|
||||||
|
@ -1,132 +0,0 @@
|
|||||||
// Copyright (c) 2024 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=634054ad25154c30fb4ec630fe7fb79b0cf1f9b3$
|
|
||||||
//
|
|
||||||
|
|
||||||
#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.
|
|
||||||
///
|
|
||||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
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_context_t::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_context_t::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_context_t::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_handler_t::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_
|
|
@ -1,214 +0,0 @@
|
|||||||
// Copyright (c) 2024 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=ebac34c9b85de780ce7524211c5dd61a80d4576c$
|
|
||||||
//
|
|
||||||
|
|
||||||
#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_handler_t::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_context_t::LoadExtension for information about extension
|
|
||||||
/// loading.
|
|
||||||
///
|
|
||||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
typedef struct _cef_extension_handler_t {
|
|
||||||
///
|
|
||||||
/// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Called if the cef_request_context_t::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_context_t::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 an extension API (e.g. chrome.tabs.create) requests creation
|
|
||||||
/// of a new browser. |extension| and |browser| are the source of the API
|
|
||||||
/// call. |active_browser| may optionally be specified via the windowId
|
|
||||||
/// property or returned via the get_active_browser() callback and provides
|
|
||||||
/// the default |client| and |settings| values for the new browser. |index| is
|
|
||||||
/// the position value optionally specified via the index property. |url| is
|
|
||||||
/// the URL that will be loaded in the browser. |active| is true (1) if the
|
|
||||||
/// new browser should be active when opened. To allow creation of the
|
|
||||||
/// browser optionally modify |windowInfo|, |client| and |settings| and return
|
|
||||||
/// false (0). To cancel creation of the browser return true (1). Successful
|
|
||||||
/// creation will be indicated by a call to
|
|
||||||
/// cef_life_span_handler_t::OnAfterCreated. Any modifications to |windowInfo|
|
|
||||||
/// will be ignored if |active_browser| is wrapped in a cef_browser_view_t.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* on_before_browser)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_browser_t* active_browser,
|
|
||||||
int index,
|
|
||||||
const cef_string_t* url,
|
|
||||||
int active,
|
|
||||||
struct _cef_window_info_t* windowInfo,
|
|
||||||
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_context_t 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_
|
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=54edf9e9c2a12acdc4cab55079a4a5cb8e2a1e43$
|
// $hash=5232dd6bf16af9b6d195a47bb41de0dfb880a65e$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
|
||||||
@ -117,7 +117,7 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
/// Views-hosted source browsers will create Views-hosted DevTools popups
|
/// Views-hosted source browsers will create Views-hosted DevTools popups
|
||||||
/// unless |use_default_window| is set to to true (1). DevTools popups can be
|
/// unless |use_default_window| is set to to true (1). DevTools popups can be
|
||||||
/// blocked by returning true (1) from cef_command_handler_t::OnChromeCommand
|
/// blocked by returning true (1) from cef_command_handler_t::OnChromeCommand
|
||||||
/// for IDC_DEV_TOOLS. Only used with the Chrome runtime.
|
/// for IDC_DEV_TOOLS. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_dev_tools_popup)(
|
void(CEF_CALLBACK* on_before_dev_tools_popup)(
|
||||||
struct _cef_life_span_handler_t* self,
|
struct _cef_life_span_handler_t* self,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=c9b3913701581cd6a1077fa3a39d197f338a2507$
|
// $hash=66aebf0e910224fb8eaa7f847feeccac73378374$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_PERMISSION_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_PERMISSION_HANDLER_CAPI_H_
|
||||||
@ -108,11 +108,11 @@ typedef struct _cef_permission_handler_t {
|
|||||||
/// cef_media_access_permission_types_t that represent the requested
|
/// cef_media_access_permission_types_t that represent the requested
|
||||||
/// permissions. Return true (1) and call cef_media_access_callback_t
|
/// permissions. Return true (1) and call cef_media_access_callback_t
|
||||||
/// functions either in this function or at a later time to continue or cancel
|
/// functions either in this function or at a later time to continue or cancel
|
||||||
/// the request. Return false (0) to proceed with default handling. With the
|
/// the request. Return false (0) to proceed with default handling. With
|
||||||
/// Chrome runtime, default handling will display the permission request UI.
|
/// Chrome style, default handling will display the permission request UI.
|
||||||
/// With the Alloy runtime, default handling will deny the request. This
|
/// With Alloy style, default handling will deny the request. This function
|
||||||
/// function will not be called if the "--enable-media-stream" command-line
|
/// will not be called if the "--enable-media-stream" command-line switch is
|
||||||
/// switch is used to grant all permissions.
|
/// used to grant all permissions.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_request_media_access_permission)(
|
int(CEF_CALLBACK* on_request_media_access_permission)(
|
||||||
struct _cef_permission_handler_t* self,
|
struct _cef_permission_handler_t* self,
|
||||||
@ -129,9 +129,9 @@ typedef struct _cef_permission_handler_t {
|
|||||||
/// cef_permission_request_types_t that represent the requested permissions.
|
/// cef_permission_request_types_t that represent the requested permissions.
|
||||||
/// Return true (1) and call cef_permission_prompt_callback_t::Continue either
|
/// Return true (1) and call cef_permission_prompt_callback_t::Continue either
|
||||||
/// in this function or at a later time to continue or cancel the request.
|
/// in this function or at a later time to continue or cancel the request.
|
||||||
/// Return false (0) to proceed with default handling. With the Chrome
|
/// Return false (0) to proceed with default handling. With Chrome style,
|
||||||
/// runtime, default handling will display the permission prompt UI. With the
|
/// default handling will display the permission prompt UI. With Alloy style,
|
||||||
/// Alloy runtime, default handling is CEF_PERMISSION_RESULT_IGNORE.
|
/// default handling is CEF_PERMISSION_RESULT_IGNORE.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_show_permission_prompt)(
|
int(CEF_CALLBACK* on_show_permission_prompt)(
|
||||||
struct _cef_permission_handler_t* self,
|
struct _cef_permission_handler_t* self,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=2c496139ca9a59303b1493ee93d2c3ae96a956c0$
|
// $hash=c63fac0c620ead3525405feb5cc9db561e1a508a$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
|
||||||
@ -42,8 +42,6 @@
|
|||||||
|
|
||||||
#include "include/capi/cef_callback_capi.h"
|
#include "include/capi/cef_callback_capi.h"
|
||||||
#include "include/capi/cef_cookie_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_media_router_capi.h"
|
#include "include/capi/cef_media_router_capi.h"
|
||||||
#include "include/capi/cef_preference_capi.h"
|
#include "include/capi/cef_preference_capi.h"
|
||||||
#include "include/capi/cef_values_capi.h"
|
#include "include/capi/cef_values_capi.h"
|
||||||
@ -205,105 +203,6 @@ typedef struct _cef_request_context_t {
|
|||||||
const cef_string_t* origin,
|
const cef_string_t* origin,
|
||||||
struct _cef_resolve_callback_t* callback);
|
struct _cef_resolve_callback_t* callback);
|
||||||
|
|
||||||
///
|
|
||||||
/// 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_handler_t
|
|
||||||
/// and/or cef_extension_handler_t) 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_context_handler_t callbacks for the extension.
|
|
||||||
///
|
|
||||||
/// cef_extension_handler_t::OnExtensionLoaded will be called on load success
|
|
||||||
/// or cef_extension_handler_t::OnExtensionLoadFailed will be called on load
|
|
||||||
/// failure.
|
|
||||||
///
|
|
||||||
/// If the extension specifies a background script via the "background"
|
|
||||||
/// manifest key then cef_extension_handler_t::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.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
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.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
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.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
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.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
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.
|
|
||||||
///
|
|
||||||
/// WARNING: This function is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
|
||||||
struct _cef_request_context_t* self,
|
|
||||||
const cef_string_t* extension_id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the MediaRouter object associated with this context. If
|
/// Returns the MediaRouter object associated with this context. If
|
||||||
/// |callback| is non-NULL it will be executed asnychronously on the UI thread
|
/// |callback| is non-NULL it will be executed asnychronously on the UI thread
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=2e8b5c5107f61e3d4c333dc02c76a9f30cd0cf83$
|
// $hash=db7cfb76483d6ab73eba74deaefafa7700ad1988$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_HANDLER_CAPI_H_
|
||||||
@ -227,20 +227,19 @@ typedef struct _cef_request_handler_t {
|
|||||||
/// Called on the browser process UI thread when the render process is
|
/// Called on the browser process UI thread when the render process is
|
||||||
/// unresponsive as indicated by a lack of input event processing for at least
|
/// unresponsive as indicated by a lack of input event processing for at least
|
||||||
/// 15 seconds. Return false (0) for the default behavior which is an
|
/// 15 seconds. Return false (0) for the default behavior which is an
|
||||||
/// indefinite wait with the Alloy runtime or display of the "Page
|
/// indefinite wait with Alloy style or display of the "Page unresponsive"
|
||||||
/// unresponsive" dialog with the Chrome runtime. Return true (1) and don't
|
/// dialog with Chrome style. Return true (1) and don't execute the callback
|
||||||
/// execute the callback for an indefinite wait without display of the Chrome
|
/// for an indefinite wait without display of the Chrome style dialog. Return
|
||||||
/// runtime dialog. Return true (1) and call
|
/// true (1) and call cef_unresponsive_process_callback_t::Wait either in this
|
||||||
/// cef_unresponsive_process_callback_t::Wait either in this function or at a
|
/// function or at a later time to reset the wait timer, potentially
|
||||||
/// later time to reset the wait timer, potentially triggering another call to
|
/// triggering another call to this function if the process remains
|
||||||
/// this function if the process remains unresponsive. Return true (1) and
|
/// unresponsive. Return true (1) and call
|
||||||
/// call cef_unresponsive_process_callback_t:: Terminate either in this
|
/// cef_unresponsive_process_callback_t:: Terminate either in this function or
|
||||||
/// function or at a later time to terminate the unresponsive process,
|
/// at a later time to terminate the unresponsive process, resulting in a call
|
||||||
/// resulting in a call to OnRenderProcessTerminated.
|
/// to OnRenderProcessTerminated. OnRenderProcessResponsive will be called if
|
||||||
/// OnRenderProcessResponsive will be called if the process becomes responsive
|
/// the process becomes responsive after this function is called. This
|
||||||
/// after this function is called. This functionality depends on the hang
|
/// functionality depends on the hang monitor which can be disabled by passing
|
||||||
/// monitor which can be disabled by passing the `--disable-hang-monitor`
|
/// the `--disable-hang-monitor` command-line flag.
|
||||||
/// command-line flag.
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_render_process_unresponsive)(
|
int(CEF_CALLBACK* on_render_process_unresponsive)(
|
||||||
struct _cef_request_handler_t* self,
|
struct _cef_request_handler_t* self,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=1c2fbbffaf51e90a2d55bfa7eb3fa3a4e315f4ac$
|
// $hash=76897eedc7c858601fd7d98cb55b8808810f8493$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
|
||||||
@ -67,7 +67,7 @@ typedef struct _cef_browser_view_t {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the Chrome toolbar associated with this BrowserView. Only
|
/// Returns the Chrome toolbar associated with this BrowserView. Only
|
||||||
/// supported when using the Chrome runtime. The cef_browser_view_delegate_t::
|
/// supported when using Chrome style. The cef_browser_view_delegate_t::
|
||||||
/// get_chrome_toolbar_type() function must return a value other than
|
/// get_chrome_toolbar_type() function must return a value other than
|
||||||
/// CEF_CTT_NONE and the toolbar will not be available until after this
|
/// CEF_CTT_NONE and the toolbar will not be available until after this
|
||||||
/// BrowserView is added to a cef_window_t and
|
/// BrowserView is added to a cef_window_t and
|
||||||
@ -81,8 +81,8 @@ typedef struct _cef_browser_view_t {
|
|||||||
/// content (`keydown` event handler) or cef_keyboard_handler_t. Normal
|
/// content (`keydown` event handler) or cef_keyboard_handler_t. Normal
|
||||||
/// priority accelerators can be registered via cef_window_t::SetAccelerator
|
/// priority accelerators can be registered via cef_window_t::SetAccelerator
|
||||||
/// (with |high_priority|=false (0)) or internally for standard accelerators
|
/// (with |high_priority|=false (0)) or internally for standard accelerators
|
||||||
/// supported by the Chrome runtime. If |prefer_accelerators| is true (1) then
|
/// supported by Chrome style. If |prefer_accelerators| is true (1) then the
|
||||||
/// the matching accelerator will be triggered immediately (calling
|
/// matching accelerator will be triggered immediately (calling
|
||||||
/// cef_window_delegate_t::OnAccelerator or
|
/// cef_window_delegate_t::OnAccelerator or
|
||||||
/// cef_command_handler_t::OnChromeCommand respectively) and the event will
|
/// cef_command_handler_t::OnChromeCommand respectively) and the event will
|
||||||
/// not be forwarded to the web content or cef_keyboard_handler_t first. If
|
/// not be forwarded to the web content or cef_keyboard_handler_t first. If
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=a0a9f2bfcdf8e05d3d1114fcd8860caaa726ec98$
|
// $hash=f8e8992eedf254a60e2875715c3adfa23ca4ae20$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
|
||||||
@ -134,7 +134,7 @@ typedef struct _cef_browser_view_delegate_t {
|
|||||||
///
|
///
|
||||||
/// Called when |browser_view| receives a gesture command. Return true (1) to
|
/// Called when |browser_view| receives a gesture command. Return true (1) to
|
||||||
/// handle (or disable) a |gesture_command| or false (0) to propagate the
|
/// handle (or disable) a |gesture_command| or false (0) to propagate the
|
||||||
/// gesture to the browser for default handling. With the Chrome runtime these
|
/// gesture to the browser for default handling. With Chrome style these
|
||||||
/// commands can also be handled via cef_command_handler_t::OnChromeCommand.
|
/// commands can also be handled via cef_command_handler_t::OnChromeCommand.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_gesture_command)(
|
int(CEF_CALLBACK* on_gesture_command)(
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=e8c9e32caa8d317a7cb6ff2f0ad6be49cf1b7ad1$
|
// $hash=a2e5caf4dc0ed5b43a6075678e3b7b7ae83834ae$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
|
||||||
@ -101,9 +101,9 @@ typedef struct _cef_window_delegate_t {
|
|||||||
/// the transition occurs asynchronously with |is_competed| set to false (0)
|
/// the transition occurs asynchronously with |is_competed| set to false (0)
|
||||||
/// when the transition starts and true (1) after the transition completes. On
|
/// when the transition starts and true (1) after the transition completes. On
|
||||||
/// other platforms the transition occurs synchronously with |is_completed|
|
/// other platforms the transition occurs synchronously with |is_completed|
|
||||||
/// set to true (1) after the transition completes. With the Alloy runtime you
|
/// set to true (1) after the transition completes. With Alloy style you must
|
||||||
/// must also implement cef_display_handler_t::OnFullscreenModeChange to
|
/// also implement cef_display_handler_t::OnFullscreenModeChange to handle
|
||||||
/// handle fullscreen transitions initiated by browser content.
|
/// fullscreen transitions initiated by browser content.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_window_fullscreen_transition)(
|
void(CEF_CALLBACK* on_window_fullscreen_transition)(
|
||||||
struct _cef_window_delegate_t* self,
|
struct _cef_window_delegate_t* self,
|
||||||
@ -253,12 +253,10 @@ typedef struct _cef_window_delegate_t {
|
|||||||
/// Chrome theme colors will be applied and this callback will be triggered
|
/// Chrome theme colors will be applied and this callback will be triggered
|
||||||
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
|
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
|
||||||
/// theme colors can be configured on a per-RequestContext basis using
|
/// theme colors can be configured on a per-RequestContext basis using
|
||||||
/// cef_request_context_t::SetChromeColorScheme or (Chrome runtime only) by
|
/// cef_request_context_t::SetChromeColorScheme or (Chrome style only) by
|
||||||
/// visiting chrome://settings/manageProfile. Any theme changes using those
|
/// visiting chrome://settings/manageProfile. Any theme changes using those
|
||||||
/// mechanisms will also trigger this callback. Chrome theme colors will be
|
/// mechanisms will also trigger this callback. Chrome theme colors will be
|
||||||
/// persisted and restored from disk cache with the Chrome runtime, and with
|
/// persisted and restored from disk cache.
|
||||||
/// the Alloy runtime if persist_user_preferences is set to true (1) via
|
|
||||||
/// CefSettings or cef_request_context_tSettings.
|
|
||||||
///
|
///
|
||||||
/// This callback is not triggered on Window creation so clients that wish to
|
/// This callback is not triggered on Window creation so clients that wish to
|
||||||
/// customize the initial native/OS theme must call
|
/// customize the initial native/OS theme must call
|
||||||
|
@ -42,13 +42,13 @@
|
|||||||
// way that may cause binary incompatibility with other builds. The universal
|
// way that may cause binary incompatibility with other builds. The universal
|
||||||
// hash value will change if any platform is affected whereas the platform hash
|
// hash value will change if any platform is affected whereas the platform hash
|
||||||
// values will change only if that particular platform is affected.
|
// values will change only if that particular platform is affected.
|
||||||
#define CEF_API_HASH_UNIVERSAL "ed1dfa5ff8a041241f8fb72eb7454811f358f0d3"
|
#define CEF_API_HASH_UNIVERSAL "9c6ab9977da5debe35d54d14d1ef27e880e702f1"
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "0d99d1b9b85b2efab91a39d6fc325bb6d56fd524"
|
#define CEF_API_HASH_PLATFORM "d380724b425dd0a26253d93fbff6d98cde701835"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "e585e190387e31a71267207b66d175e213991470"
|
#define CEF_API_HASH_PLATFORM "84b1cbbab962186b04157f7584203008a3d52c97"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "09d3e280ed38f7a082b794c56ff71c52f86f0ea8"
|
#define CEF_API_HASH_PLATFORM "a5e140f4266d52538620cb2a82ec49c0ae84a025"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -174,10 +174,9 @@ class CefApp : public virtual CefBaseRefCounted {
|
|||||||
CefRawPtr<CefSchemeRegistrar> registrar) {}
|
CefRawPtr<CefSchemeRegistrar> registrar) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Return the handler for resource bundle events. If
|
/// Return the handler for resource bundle events. If no handler is returned
|
||||||
/// cef_settings_t.pack_loading_disabled is true a handler must be returned.
|
/// resources will be loaded from pack files. This method is called by the
|
||||||
/// If no handler is returned resources will be loaded from pack files. This
|
/// browser and render processes on multiple threads.
|
||||||
/// method is called by the browser and render processes on multiple threads.
|
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
|
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
|
||||||
|
@ -414,8 +414,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Get the default zoom level. This value will be 0.0 by default but can be
|
/// Get the default zoom level. This value will be 0.0 by default but can be
|
||||||
/// configured with the Chrome runtime. This method can only be called on the
|
/// configured. This method can only be called on the UI thread.
|
||||||
/// UI thread.
|
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual double GetDefaultZoomLevel() = 0;
|
virtual double GetDefaultZoomLevel() = 0;
|
||||||
@ -939,25 +938,6 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
const CefSize& min_size,
|
const CefSize& min_size,
|
||||||
const CefSize& max_size) = 0;
|
const CefSize& max_size) = 0;
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the extension hosted in this browser or NULL if no extension is
|
|
||||||
/// hosted. See CefRequestContext::LoadExtension for details.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--cef()--*/
|
|
||||||
virtual bool IsBackgroundHost() = 0;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set whether the browser's audio is muted.
|
/// Set whether the browser's audio is muted.
|
||||||
///
|
///
|
||||||
@ -983,12 +963,12 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Requests the renderer to exit browser fullscreen. In most cases exiting
|
/// Requests the renderer to exit browser fullscreen. In most cases exiting
|
||||||
/// window fullscreen should also exit browser fullscreen. With the Alloy
|
/// window fullscreen should also exit browser fullscreen. With Alloy
|
||||||
/// runtime this method should be called in response to a user action such as
|
/// style this method should be called in response to a user action such as
|
||||||
/// clicking the green traffic light button on MacOS
|
/// clicking the green traffic light button on MacOS
|
||||||
/// (CefWindowDelegate::OnWindowFullscreenTransition callback) or pressing the
|
/// (CefWindowDelegate::OnWindowFullscreenTransition callback) or pressing the
|
||||||
/// "ESC" key (CefKeyboardHandler::OnPreKeyEvent callback). With the Chrome
|
/// "ESC" key (CefKeyboardHandler::OnPreKeyEvent callback). With Chrome
|
||||||
/// runtime these standard exit actions are handled internally but
|
/// style these standard exit actions are handled internally but
|
||||||
/// new/additional user actions can use this method. Set |will_cause_resize|
|
/// new/additional user actions can use this method. Set |will_cause_resize|
|
||||||
/// to true if exiting browser fullscreen will cause a view resize.
|
/// to true if exiting browser fullscreen will cause a view resize.
|
||||||
///
|
///
|
||||||
@ -998,7 +978,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/// Returns true if a Chrome command is supported and enabled. Values for
|
/// Returns true if a Chrome command is supported and enabled. Values for
|
||||||
/// |command_id| can be found in the cef_command_ids.h file. This method can
|
/// |command_id| can be found in the cef_command_ids.h file. This method can
|
||||||
/// only be called on the UI thread. Only used with the Chrome runtime.
|
/// only be called on the UI thread. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool CanExecuteChromeCommand(int command_id) = 0;
|
virtual bool CanExecuteChromeCommand(int command_id) = 0;
|
||||||
@ -1006,7 +986,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/// Execute a Chrome command. Values for |command_id| can be found in the
|
/// Execute a Chrome command. Values for |command_id| can be found in the
|
||||||
/// cef_command_ids.h file. |disposition| provides information about the
|
/// cef_command_ids.h file. |disposition| provides information about the
|
||||||
/// intended command target. Only used with the Chrome runtime.
|
/// intended command target. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void ExecuteChromeCommand(
|
virtual void ExecuteChromeCommand(
|
||||||
|
@ -60,8 +60,8 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
|||||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||||
/// accessed via CefPreferenceManager::GetGlobalPreferences after
|
/// accessed via CefPreferenceManager::GetGlobalPreferences after
|
||||||
/// OnContextInitialized is called. Global preferences are registered a single
|
/// OnContextInitialized is called. Global preferences are registered a single
|
||||||
/// time at application startup. See related cef_settings_t.cache_path and
|
/// time at application startup. See related cef_settings_t.cache_path
|
||||||
/// cef_settings_t.persist_user_preferences configuration.
|
/// configuration.
|
||||||
///
|
///
|
||||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||||
/// accessed via the CefRequestContext after
|
/// accessed via the CefRequestContext after
|
||||||
@ -69,8 +69,7 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
|||||||
/// context preferences are registered each time a new CefRequestContext is
|
/// context preferences are registered each time a new CefRequestContext is
|
||||||
/// created. It is intended but not required that all request contexts have
|
/// created. It is intended but not required that all request contexts have
|
||||||
/// the same registered preferences. See related
|
/// the same registered preferences. See related
|
||||||
/// cef_request_context_settings_t.cache_path and
|
/// cef_request_context_settings_t.cache_path configuration.
|
||||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
|
||||||
///
|
///
|
||||||
/// Do not keep a reference to the |registrar| object. This method is called
|
/// Do not keep a reference to the |registrar| object. This method is called
|
||||||
/// on the browser process UI thread.
|
/// on the browser process UI thread.
|
||||||
@ -144,8 +143,8 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
|||||||
/// (CefBrowser object). If null is returned the CefBrowser will be unmanaged
|
/// (CefBrowser object). If null is returned the CefBrowser will be unmanaged
|
||||||
/// (no callbacks will be executed for that CefBrowser) and application
|
/// (no callbacks will be executed for that CefBrowser) and application
|
||||||
/// shutdown will be blocked until the browser window is closed manually. This
|
/// shutdown will be blocked until the browser window is closed manually. This
|
||||||
/// method is currently only used with the Chrome runtime when creating new
|
/// method is currently only used with Chrome style when creating new browser
|
||||||
/// browser windows via Chrome UI.
|
/// windows via Chrome UI.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefClient> GetDefaultClient() { return nullptr; }
|
virtual CefRefPtr<CefClient> GetDefaultClient() { return nullptr; }
|
||||||
@ -154,8 +153,8 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
|||||||
/// Return the default handler for use with a new user or incognito profile
|
/// Return the default handler for use with a new user or incognito profile
|
||||||
/// (CefRequestContext object). If null is returned the CefRequestContext will
|
/// (CefRequestContext object). If null is returned the CefRequestContext will
|
||||||
/// be unmanaged (no callbacks will be executed for that CefRequestContext).
|
/// be unmanaged (no callbacks will be executed for that CefRequestContext).
|
||||||
/// This method is currently only used with the Chrome runtime when creating
|
/// This method is currently only used with Chrome style when creating new
|
||||||
/// new browser windows via Chrome UI.
|
/// browser windows via Chrome UI.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefRefPtr<CefRequestContextHandler>
|
virtual CefRefPtr<CefRequestContextHandler>
|
||||||
|
@ -55,7 +55,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
|
|||||||
/// intended command target. Return true if the command was handled or false
|
/// intended command target. Return true if the command was handled or false
|
||||||
/// for the default implementation. For context menu commands this will be
|
/// for the default implementation. For context menu commands this will be
|
||||||
/// called after CefContextMenuHandler::OnContextMenuCommand. Only used with
|
/// called after CefContextMenuHandler::OnContextMenuCommand. Only used with
|
||||||
/// the Chrome runtime.
|
/// Chrome style.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool OnChromeCommand(CefRefPtr<CefBrowser> browser,
|
virtual bool OnChromeCommand(CefRefPtr<CefBrowser> browser,
|
||||||
@ -67,8 +67,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/// Called to check if a Chrome app menu item should be visible. Values for
|
/// Called to check if a Chrome app menu item should be visible. Values for
|
||||||
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||||
/// menu items that would be visible by default. Only used with the Chrome
|
/// menu items that would be visible by default. Only used with Chrome style.
|
||||||
/// runtime.
|
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool IsChromeAppMenuItemVisible(CefRefPtr<CefBrowser> browser,
|
virtual bool IsChromeAppMenuItemVisible(CefRefPtr<CefBrowser> browser,
|
||||||
@ -79,8 +78,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/// Called to check if a Chrome app menu item should be enabled. Values for
|
/// Called to check if a Chrome app menu item should be enabled. Values for
|
||||||
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||||
/// menu items that would be enabled by default. Only used with the Chrome
|
/// menu items that would be enabled by default. Only used with Chrome style.
|
||||||
/// runtime.
|
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool IsChromeAppMenuItemEnabled(CefRefPtr<CefBrowser> browser,
|
virtual bool IsChromeAppMenuItemEnabled(CefRefPtr<CefBrowser> browser,
|
||||||
@ -91,7 +89,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/// Called during browser creation to check if a Chrome page action icon
|
/// Called during browser creation to check if a Chrome page action icon
|
||||||
/// should be visible. Only called for icons that would be visible by default.
|
/// should be visible. Only called for icons that would be visible by default.
|
||||||
/// Only used with the Chrome runtime.
|
/// Only used with Chrome style.
|
||||||
///
|
///
|
||||||
/*--cef(optional_param=browser)--*/
|
/*--cef(optional_param=browser)--*/
|
||||||
virtual bool IsChromePageActionIconVisible(
|
virtual bool IsChromePageActionIconVisible(
|
||||||
@ -102,7 +100,7 @@ class CefCommandHandler : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/// Called during browser creation to check if a Chrome toolbar button
|
/// Called during browser creation to check if a Chrome toolbar button
|
||||||
/// should be visible. Only called for buttons that would be visible by
|
/// should be visible. Only called for buttons that would be visible by
|
||||||
/// default. Only used with the Chrome runtime.
|
/// default. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
/*--cef(optional_param=browser)--*/
|
/*--cef(optional_param=browser)--*/
|
||||||
virtual bool IsChromeToolbarButtonVisible(
|
virtual bool IsChromeToolbarButtonVisible(
|
||||||
|
@ -75,12 +75,12 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
|
|||||||
/// Called when web content in the page has toggled fullscreen mode. If
|
/// Called when web content in the page has toggled fullscreen mode. If
|
||||||
/// |fullscreen| is true the content will automatically be sized to fill the
|
/// |fullscreen| is true the content will automatically be sized to fill the
|
||||||
/// browser content area. If |fullscreen| is false the content will
|
/// browser content area. If |fullscreen| is false the content will
|
||||||
/// automatically return to its original size and position. With the Alloy
|
/// automatically return to its original size and position. With Alloy style
|
||||||
/// runtime the client is responsible for triggering the fullscreen transition
|
/// the client is responsible for triggering the fullscreen transition (for
|
||||||
/// (for example, by calling CefWindow::SetFullscreen when using Views). With
|
/// example, by calling CefWindow::SetFullscreen when using Views). With
|
||||||
/// the Chrome runtime the fullscreen transition will be triggered
|
/// Chrome style the fullscreen transition will be triggered automatically.
|
||||||
/// automatically. The CefWindowDelegate::OnWindowFullscreenTransition method
|
/// The CefWindowDelegate::OnWindowFullscreenTransition method will be called
|
||||||
/// will be called during the fullscreen transition for notification purposes.
|
/// during the fullscreen transition for notification purposes.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser,
|
virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser,
|
||||||
|
@ -1,120 +0,0 @@
|
|||||||
// 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.
|
|
||||||
///
|
|
||||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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_
|
|
@ -1,202 +0,0 @@
|
|||||||
// 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.
|
|
||||||
///
|
|
||||||
/// WARNING: This API is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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 an extension API (e.g. chrome.tabs.create) requests creation
|
|
||||||
/// of a new browser. |extension| and |browser| are the source of the API
|
|
||||||
/// call. |active_browser| may optionally be specified via the windowId
|
|
||||||
/// property or returned via the GetActiveBrowser() callback and provides the
|
|
||||||
/// default |client| and |settings| values for the new browser. |index| is the
|
|
||||||
/// position value optionally specified via the index property. |url| is the
|
|
||||||
/// URL that will be loaded in the browser. |active| is true if the new
|
|
||||||
/// browser should be active when opened. To allow creation of the browser
|
|
||||||
/// optionally modify |windowInfo|, |client| and |settings| and return false.
|
|
||||||
/// To cancel creation of the browser return true. Successful creation will be
|
|
||||||
/// indicated by a call to CefLifeSpanHandler::OnAfterCreated. Any
|
|
||||||
/// modifications to |windowInfo| will be ignored if |active_browser| is
|
|
||||||
/// wrapped in a CefBrowserView.
|
|
||||||
///
|
|
||||||
/*--cef()--*/
|
|
||||||
virtual bool OnBeforeBrowser(CefRefPtr<CefExtension> extension,
|
|
||||||
CefRefPtr<CefBrowser> browser,
|
|
||||||
CefRefPtr<CefBrowser> active_browser,
|
|
||||||
int index,
|
|
||||||
const CefString& url,
|
|
||||||
bool active,
|
|
||||||
CefWindowInfo& windowInfo,
|
|
||||||
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 nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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_
|
|
@ -111,7 +111,7 @@ class CefLifeSpanHandler : public virtual CefBaseRefCounted {
|
|||||||
/// Views-hosted source browsers will create Views-hosted DevTools popups
|
/// Views-hosted source browsers will create Views-hosted DevTools popups
|
||||||
/// unless |use_default_window| is set to to true. DevTools popups can be
|
/// unless |use_default_window| is set to to true. DevTools popups can be
|
||||||
/// blocked by returning true from CefCommandHandler::OnChromeCommand for
|
/// blocked by returning true from CefCommandHandler::OnChromeCommand for
|
||||||
/// IDC_DEV_TOOLS. Only used with the Chrome runtime.
|
/// IDC_DEV_TOOLS. Only used with Chrome style.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void OnBeforeDevToolsPopup(CefRefPtr<CefBrowser> browser,
|
virtual void OnBeforeDevToolsPopup(CefRefPtr<CefBrowser> browser,
|
||||||
|
@ -93,8 +93,8 @@ class CefPermissionHandler : public virtual CefBaseRefCounted {
|
|||||||
/// cef_media_access_permission_types_t that represent the requested
|
/// cef_media_access_permission_types_t that represent the requested
|
||||||
/// permissions. Return true and call CefMediaAccessCallback methods either in
|
/// permissions. Return true and call CefMediaAccessCallback methods either in
|
||||||
/// this method or at a later time to continue or cancel the request. Return
|
/// this method or at a later time to continue or cancel the request. Return
|
||||||
/// false to proceed with default handling. With the Chrome runtime, default
|
/// false to proceed with default handling. With Chrome style, default
|
||||||
/// handling will display the permission request UI. With the Alloy runtime,
|
/// handling will display the permission request UI. With Alloy style,
|
||||||
/// default handling will deny the request. This method will not be called if
|
/// default handling will deny the request. This method will not be called if
|
||||||
/// the "--enable-media-stream" command-line switch is used to grant all
|
/// the "--enable-media-stream" command-line switch is used to grant all
|
||||||
/// permissions.
|
/// permissions.
|
||||||
@ -116,9 +116,9 @@ class CefPermissionHandler : public virtual CefBaseRefCounted {
|
|||||||
/// cef_permission_request_types_t that represent the requested permissions.
|
/// cef_permission_request_types_t that represent the requested permissions.
|
||||||
/// Return true and call CefPermissionPromptCallback::Continue either in this
|
/// Return true and call CefPermissionPromptCallback::Continue either in this
|
||||||
/// method or at a later time to continue or cancel the request. Return false
|
/// method or at a later time to continue or cancel the request. Return false
|
||||||
/// to proceed with default handling. With the Chrome runtime, default
|
/// to proceed with default handling. With Chrome style, default handling will
|
||||||
/// handling will display the permission prompt UI. With the Alloy runtime,
|
/// display the permission prompt UI. With Alloy style, default handling is
|
||||||
/// default handling is CEF_PERMISSION_RESULT_IGNORE.
|
/// CEF_PERMISSION_RESULT_IGNORE.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool OnShowPermissionPrompt(
|
virtual bool OnShowPermissionPrompt(
|
||||||
|
@ -42,8 +42,6 @@
|
|||||||
|
|
||||||
#include "include/cef_callback.h"
|
#include "include/cef_callback.h"
|
||||||
#include "include/cef_cookie.h"
|
#include "include/cef_cookie.h"
|
||||||
#include "include/cef_extension.h"
|
|
||||||
#include "include/cef_extension_handler.h"
|
|
||||||
#include "include/cef_media_router.h"
|
#include "include/cef_media_router.h"
|
||||||
#include "include/cef_preference.h"
|
#include "include/cef_preference.h"
|
||||||
#include "include/cef_values.h"
|
#include "include/cef_values.h"
|
||||||
@ -219,104 +217,6 @@ class CefRequestContext : public CefPreferenceManager {
|
|||||||
virtual void ResolveHost(const CefString& origin,
|
virtual void ResolveHost(const CefString& origin,
|
||||||
CefRefPtr<CefResolveCallback> callback) = 0;
|
CefRefPtr<CefResolveCallback> callback) = 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.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--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.
|
|
||||||
///
|
|
||||||
/// WARNING: This method is deprecated and will be removed in ~M127.
|
|
||||||
///
|
|
||||||
/*--cef()--*/
|
|
||||||
virtual CefRefPtr<CefExtension> GetExtension(
|
|
||||||
const CefString& extension_id) = 0;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the MediaRouter object associated with this context. If
|
/// Returns the MediaRouter object associated with this context. If
|
||||||
/// |callback| is non-NULL it will be executed asnychronously on the UI thread
|
/// |callback| is non-NULL it will be executed asnychronously on the UI thread
|
||||||
|
@ -226,10 +226,10 @@ class CefRequestHandler : public virtual CefBaseRefCounted {
|
|||||||
/// Called on the browser process UI thread when the render process is
|
/// Called on the browser process UI thread when the render process is
|
||||||
/// unresponsive as indicated by a lack of input event processing for at
|
/// unresponsive as indicated by a lack of input event processing for at
|
||||||
/// least 15 seconds. Return false for the default behavior which is an
|
/// least 15 seconds. Return false for the default behavior which is an
|
||||||
/// indefinite wait with the Alloy runtime or display of the "Page
|
/// indefinite wait with Alloy style or display of the "Page
|
||||||
/// unresponsive" dialog with the Chrome runtime. Return true and don't
|
/// unresponsive" dialog with Chrome style. Return true and don't
|
||||||
/// execute the callback for an indefinite wait without display of the Chrome
|
/// execute the callback for an indefinite wait without display of the Chrome
|
||||||
/// runtime dialog. Return true and call CefUnresponsiveProcessCallback::Wait
|
/// style dialog. Return true and call CefUnresponsiveProcessCallback::Wait
|
||||||
/// either in this method or at a later time to reset the wait timer,
|
/// either in this method or at a later time to reset the wait timer,
|
||||||
/// potentially triggering another call to this method if the process remains
|
/// potentially triggering another call to this method if the process remains
|
||||||
/// unresponsive. Return true and call CefUnresponsiveProcessCallback::
|
/// unresponsive. Return true and call CefUnresponsiveProcessCallback::
|
||||||
|
@ -235,15 +235,6 @@ typedef struct _cef_settings_t {
|
|||||||
///
|
///
|
||||||
cef_string_t main_bundle_path;
|
cef_string_t main_bundle_path;
|
||||||
|
|
||||||
#if !defined(DISABLE_ALLOY_BOOTSTRAP)
|
|
||||||
///
|
|
||||||
/// Set to true (1) to enable use of the Chrome runtime in CEF. This feature
|
|
||||||
/// is considered experimental and is not recommended for most users at this
|
|
||||||
/// time. See issue #2969 for details.
|
|
||||||
///
|
|
||||||
int chrome_runtime;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set to true (1) to have the browser process message loop run in a separate
|
/// Set to true (1) to have the browser process message loop run in a separate
|
||||||
/// thread. If false (0) then the CefDoMessageLoopWork() function must be
|
/// thread. If false (0) then the CefDoMessageLoopWork() function must be
|
||||||
@ -290,9 +281,9 @@ typedef struct _cef_settings_t {
|
|||||||
/// in root_cache_path). HTML5 databases such as localStorage will only
|
/// in root_cache_path). HTML5 databases such as localStorage will only
|
||||||
/// persist across sessions if a cache path is specified. Can be overridden
|
/// persist across sessions if a cache path is specified. Can be overridden
|
||||||
/// for individual CefRequestContext instances via the
|
/// for individual CefRequestContext instances via the
|
||||||
/// CefRequestContextSettings.cache_path value. When using the Chrome runtime
|
/// CefRequestContextSettings.cache_path value. Any child directory value will
|
||||||
/// any child directory value will be ignored and the "default" profile (also
|
/// be ignored and the "default" profile (also a child directory) will be used
|
||||||
/// a child directory) will be used instead.
|
/// instead.
|
||||||
///
|
///
|
||||||
cef_string_t cache_path;
|
cef_string_t cache_path;
|
||||||
|
|
||||||
@ -336,16 +327,6 @@ typedef struct _cef_settings_t {
|
|||||||
///
|
///
|
||||||
int persist_session_cookies;
|
int persist_session_cookies;
|
||||||
|
|
||||||
///
|
|
||||||
/// To persist user preferences as a JSON file in the cache path directory set
|
|
||||||
/// this value to true (1). A |cache_path| value must also be specified
|
|
||||||
/// to enable this feature. Also configurable using the
|
|
||||||
/// "persist-user-preferences" command-line switch. Can be overridden for
|
|
||||||
/// individual CefRequestContext instances via the
|
|
||||||
/// CefRequestContextSettings.persist_user_preferences value.
|
|
||||||
///
|
|
||||||
int persist_user_preferences;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Value that will be returned as the User-Agent HTTP header. If empty the
|
/// Value that will be returned as the User-Agent HTTP header. If empty the
|
||||||
/// default User-Agent string will be used. Also configurable using the
|
/// default User-Agent string will be used. Also configurable using the
|
||||||
@ -423,15 +404,6 @@ typedef struct _cef_settings_t {
|
|||||||
///
|
///
|
||||||
cef_string_t locales_dir_path;
|
cef_string_t locales_dir_path;
|
||||||
|
|
||||||
///
|
|
||||||
/// Set to true (1) to disable loading of pack files for resources and
|
|
||||||
/// locales. A resource bundle handler must be provided for the browser and
|
|
||||||
/// render processes via CefApp::GetResourceBundleHandler() if loading of pack
|
|
||||||
/// files is disabled. Also configurable using the "disable-pack-loading"
|
|
||||||
/// command- line switch.
|
|
||||||
///
|
|
||||||
int pack_loading_disabled;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set to a value between 1024 and 65535 to enable remote debugging on the
|
/// Set to a value between 1024 and 65535 to enable remote debugging on the
|
||||||
/// specified port. Also configurable using the "remote-debugging-port"
|
/// specified port. Also configurable using the "remote-debugging-port"
|
||||||
@ -496,7 +468,7 @@ typedef struct _cef_settings_t {
|
|||||||
/// policies. On Windows, this is a registry key like
|
/// policies. On Windows, this is a registry key like
|
||||||
/// "SOFTWARE\\Policies\\Google\\Chrome". On MacOS, this is a bundle ID like
|
/// "SOFTWARE\\Policies\\Google\\Chrome". On MacOS, this is a bundle ID like
|
||||||
/// "com.google.Chrome". On Linux, this is an absolute directory path like
|
/// "com.google.Chrome". On Linux, this is an absolute directory path like
|
||||||
/// "/etc/opt/chrome/policies". Only supported with the Chrome runtime. See
|
/// "/etc/opt/chrome/policies". Only supported with Chrome style. See
|
||||||
/// https://support.google.com/chrome/a/answer/9037717 for details.
|
/// https://support.google.com/chrome/a/answer/9037717 for details.
|
||||||
///
|
///
|
||||||
/// Chrome Browser Cloud Management integration, when enabled via the
|
/// Chrome Browser Cloud Management integration, when enabled via the
|
||||||
@ -510,8 +482,8 @@ typedef struct _cef_settings_t {
|
|||||||
/// Specify an ID for an ICON resource that can be loaded from the main
|
/// Specify an ID for an ICON resource that can be loaded from the main
|
||||||
/// executable and used when creating default Chrome windows such as DevTools
|
/// executable and used when creating default Chrome windows such as DevTools
|
||||||
/// and Task Manager. If unspecified the default Chromium ICON (IDR_MAINFRAME
|
/// and Task Manager. If unspecified the default Chromium ICON (IDR_MAINFRAME
|
||||||
/// [101]) will be loaded from libcef.dll. Only supported with the Chrome
|
/// [101]) will be loaded from libcef.dll. Only supported with Chrome style on
|
||||||
/// runtime on Windows.
|
/// Windows.
|
||||||
///
|
///
|
||||||
int chrome_app_icon_id;
|
int chrome_app_icon_id;
|
||||||
} cef_settings_t;
|
} cef_settings_t;
|
||||||
@ -550,14 +522,6 @@ typedef struct _cef_request_context_settings_t {
|
|||||||
///
|
///
|
||||||
int persist_session_cookies;
|
int persist_session_cookies;
|
||||||
|
|
||||||
///
|
|
||||||
/// To persist user preferences as a JSON file in the cache path directory set
|
|
||||||
/// this value to true (1). Can be set globally using the
|
|
||||||
/// CefSettings.persist_user_preferences value. This value will be ignored if
|
|
||||||
/// |cache_path| is empty or if it matches the CefSettings.cache_path value.
|
|
||||||
///
|
|
||||||
int persist_user_preferences;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Comma delimited ordered list of language codes without any whitespace that
|
/// Comma delimited ordered list of language codes without any whitespace that
|
||||||
/// will be used in the "Accept-Language" HTTP request header and
|
/// will be used in the "Accept-Language" HTTP request header and
|
||||||
@ -720,14 +684,14 @@ typedef struct _cef_browser_settings_t {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Controls whether the Chrome status bubble will be used. Only supported
|
/// Controls whether the Chrome status bubble will be used. Only supported
|
||||||
/// with the Chrome runtime. For details about the status bubble see
|
/// with Chrome style. For details about the status bubble see
|
||||||
/// https://www.chromium.org/user-experience/status-bubble/
|
/// https://www.chromium.org/user-experience/status-bubble/
|
||||||
///
|
///
|
||||||
cef_state_t chrome_status_bubble;
|
cef_state_t chrome_status_bubble;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Controls whether the Chrome zoom bubble will be shown when zooming. Only
|
/// Controls whether the Chrome zoom bubble will be shown when zooming. Only
|
||||||
/// supported with the Chrome runtime.
|
/// supported with Chrome style.
|
||||||
///
|
///
|
||||||
cef_state_t chrome_zoom_bubble;
|
cef_state_t chrome_zoom_bubble;
|
||||||
} cef_browser_settings_t;
|
} cef_browser_settings_t;
|
||||||
@ -1401,7 +1365,7 @@ typedef enum {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// User got to this page through a suggestion in the UI (for example, via the
|
/// User got to this page through a suggestion in the UI (for example, via the
|
||||||
/// destinations page). Chrome runtime only.
|
/// destinations page). Chrome style only.
|
||||||
///
|
///
|
||||||
TT_AUTO_BOOKMARK = 2,
|
TT_AUTO_BOOKMARK = 2,
|
||||||
|
|
||||||
@ -1428,7 +1392,7 @@ typedef enum {
|
|||||||
/// that did not look like a URL. For example, a match might have the URL
|
/// that did not look like a URL. For example, a match might have the URL
|
||||||
/// of a Google search result page, but appear like "Search Google for ...".
|
/// of a Google search result page, but appear like "Search Google for ...".
|
||||||
/// These are not quite the same as EXPLICIT navigations because the user
|
/// These are not quite the same as EXPLICIT navigations because the user
|
||||||
/// didn't type or see the destination URL. Chrome runtime only.
|
/// didn't type or see the destination URL. Chrome style only.
|
||||||
/// See also TT_KEYWORD.
|
/// See also TT_KEYWORD.
|
||||||
///
|
///
|
||||||
TT_GENERATED = 5,
|
TT_GENERATED = 5,
|
||||||
@ -1438,7 +1402,7 @@ typedef enum {
|
|||||||
/// loaded in a toplevel frame. For example, opening a tab to show the ASH
|
/// loaded in a toplevel frame. For example, opening a tab to show the ASH
|
||||||
/// screen saver, opening the devtools window, opening the NTP after the safe
|
/// screen saver, opening the devtools window, opening the NTP after the safe
|
||||||
/// browsing warning, opening web-based dialog boxes are examples of
|
/// browsing warning, opening web-based dialog boxes are examples of
|
||||||
/// AUTO_TOPLEVEL navigations. Chrome runtime only.
|
/// AUTO_TOPLEVEL navigations. Chrome style only.
|
||||||
///
|
///
|
||||||
TT_AUTO_TOPLEVEL = 6,
|
TT_AUTO_TOPLEVEL = 6,
|
||||||
|
|
||||||
@ -1465,13 +1429,13 @@ typedef enum {
|
|||||||
/// the url 'http://' + keyword. For example, if you do a tab-to-search
|
/// the url 'http://' + keyword. For example, if you do a tab-to-search
|
||||||
/// against wikipedia the generated url has a transition qualifer of
|
/// against wikipedia the generated url has a transition qualifer of
|
||||||
/// TT_KEYWORD, and TemplateURLModel generates a visit for 'wikipedia.org'
|
/// TT_KEYWORD, and TemplateURLModel generates a visit for 'wikipedia.org'
|
||||||
/// with a transition type of TT_KEYWORD_GENERATED. Chrome runtime only.
|
/// with a transition type of TT_KEYWORD_GENERATED. Chrome style only.
|
||||||
///
|
///
|
||||||
TT_KEYWORD = 9,
|
TT_KEYWORD = 9,
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Corresponds to a visit generated for a keyword. See description of
|
/// Corresponds to a visit generated for a keyword. See description of
|
||||||
/// TT_KEYWORD for more details. Chrome runtime only.
|
/// TT_KEYWORD for more details. Chrome style only.
|
||||||
///
|
///
|
||||||
TT_KEYWORD_GENERATED = 10,
|
TT_KEYWORD_GENERATED = 10,
|
||||||
|
|
||||||
@ -1501,14 +1465,13 @@ typedef enum {
|
|||||||
TT_DIRECT_LOAD_FLAG = 0x02000000,
|
TT_DIRECT_LOAD_FLAG = 0x02000000,
|
||||||
|
|
||||||
///
|
///
|
||||||
/// User is navigating to the home page. Chrome runtime only.
|
/// User is navigating to the home page. Chrome style only.
|
||||||
///
|
///
|
||||||
TT_HOME_PAGE_FLAG = 0x04000000,
|
TT_HOME_PAGE_FLAG = 0x04000000,
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The transition originated from an external application; the exact
|
/// The transition originated from an external application; the exact
|
||||||
/// definition of this is embedder dependent. Chrome runtime and
|
/// definition of this is embedder dependent. Chrome style only.
|
||||||
/// extension system only.
|
|
||||||
///
|
///
|
||||||
TT_FROM_API_FLAG = 0x08000000,
|
TT_FROM_API_FLAG = 0x08000000,
|
||||||
|
|
||||||
@ -3613,7 +3576,7 @@ typedef enum {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Permission types used with OnShowPermissionPrompt. Some types are
|
/// Permission types used with OnShowPermissionPrompt. Some types are
|
||||||
/// platform-specific or only supported with the Chrome runtime. Should be kept
|
/// platform-specific or only supported with Chrome style. Should be kept
|
||||||
/// in sync with Chromium's permissions::RequestType type.
|
/// in sync with Chromium's permissions::RequestType type.
|
||||||
///
|
///
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -37,7 +37,7 @@ extern "C" {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Supported content setting types. Some types are platform-specific or only
|
/// Supported content setting types. Some types are platform-specific or only
|
||||||
/// supported with the Chrome runtime. Should be kept in sync with Chromium's
|
/// supported with Chrome style. Should be kept in sync with Chromium's
|
||||||
/// ContentSettingsType type.
|
/// ContentSettingsType type.
|
||||||
///
|
///
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -36,20 +36,16 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// CEF supports both a Chrome runtime (based on the Chrome UI layer) and an
|
/// CEF supports both a Chrome runtime style (based on the Chrome UI layer) and
|
||||||
/// Alloy runtime (based on the Chromium content layer). The Chrome runtime
|
/// an Alloy runtime style (based on the Chromium content layer). Chrome style
|
||||||
/// provides the full Chrome UI and browser functionality whereas the Alloy
|
/// provides the full Chrome UI and browser functionality whereas Alloy style
|
||||||
/// runtime provides less default browser functionality but adds additional
|
/// provides less default browser functionality but adds additional client
|
||||||
/// client callbacks and support for windowless (off-screen) rendering. For
|
/// callbacks and support for windowless (off-screen) rendering. The style type
|
||||||
/// additional comparative details on runtime types see
|
/// is individually configured for each window/browser at creation time and
|
||||||
|
/// different styles can be mixed during runtime. For additional comparative
|
||||||
|
/// details on runtime styles see
|
||||||
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
|
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
|
||||||
///
|
///
|
||||||
/// Each runtime is composed of a bootstrap component and a style component. The
|
|
||||||
/// bootstrap component is configured via CefSettings.chrome_runtime and cannot
|
|
||||||
/// be changed after CefInitialize. The style component is individually
|
|
||||||
/// configured for each window/browser at creation time and, in combination with
|
|
||||||
/// the Chrome bootstrap, different styles can be mixed during runtime.
|
|
||||||
///
|
|
||||||
/// Windowless rendering will always use Alloy style. Windowed rendering with a
|
/// Windowless rendering will always use Alloy style. Windowed rendering with a
|
||||||
/// default window or client-provided parent window can configure the style via
|
/// default window or client-provided parent window can configure the style via
|
||||||
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
|
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
|
||||||
@ -63,20 +59,17 @@ extern "C" {
|
|||||||
///
|
///
|
||||||
typedef enum {
|
typedef enum {
|
||||||
///
|
///
|
||||||
/// Use the default runtime style. The default style will match the
|
/// Use the default style. See above documentation for exceptions.
|
||||||
/// CefSettings.chrome_runtime value in most cases. See above documentation
|
|
||||||
/// for exceptions.
|
|
||||||
///
|
///
|
||||||
CEF_RUNTIME_STYLE_DEFAULT,
|
CEF_RUNTIME_STYLE_DEFAULT,
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Use the Chrome runtime style. Only supported with the Chrome runtime.
|
/// Use Chrome style.
|
||||||
///
|
///
|
||||||
CEF_RUNTIME_STYLE_CHROME,
|
CEF_RUNTIME_STYLE_CHROME,
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Use the Alloy runtime style. Supported with both the Alloy and Chrome
|
/// Use Alloy style.
|
||||||
/// runtime.
|
|
||||||
///
|
///
|
||||||
CEF_RUNTIME_STYLE_ALLOY,
|
CEF_RUNTIME_STYLE_ALLOY,
|
||||||
} cef_runtime_style_t;
|
} cef_runtime_style_t;
|
||||||
|
@ -387,9 +387,6 @@ struct CefSettingsTraits {
|
|||||||
&target->framework_dir_path, copy);
|
&target->framework_dir_path, copy);
|
||||||
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
|
cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length,
|
||||||
&target->main_bundle_path, copy);
|
&target->main_bundle_path, copy);
|
||||||
#if !defined(DISABLE_ALLOY_BOOTSTRAP)
|
|
||||||
target->chrome_runtime = src->chrome_runtime;
|
|
||||||
#endif
|
|
||||||
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
|
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
|
||||||
target->external_message_pump = src->external_message_pump;
|
target->external_message_pump = src->external_message_pump;
|
||||||
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
|
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
|
||||||
@ -400,7 +397,6 @@ struct CefSettingsTraits {
|
|||||||
cef_string_set(src->root_cache_path.str, src->root_cache_path.length,
|
cef_string_set(src->root_cache_path.str, src->root_cache_path.length,
|
||||||
&target->root_cache_path, copy);
|
&target->root_cache_path, copy);
|
||||||
target->persist_session_cookies = src->persist_session_cookies;
|
target->persist_session_cookies = src->persist_session_cookies;
|
||||||
target->persist_user_preferences = src->persist_user_preferences;
|
|
||||||
|
|
||||||
cef_string_set(src->user_agent.str, src->user_agent.length,
|
cef_string_set(src->user_agent.str, src->user_agent.length,
|
||||||
&target->user_agent, copy);
|
&target->user_agent, copy);
|
||||||
@ -419,7 +415,6 @@ struct CefSettingsTraits {
|
|||||||
&target->resources_dir_path, copy);
|
&target->resources_dir_path, copy);
|
||||||
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
|
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
|
||||||
&target->locales_dir_path, copy);
|
&target->locales_dir_path, copy);
|
||||||
target->pack_loading_disabled = src->pack_loading_disabled;
|
|
||||||
target->remote_debugging_port = src->remote_debugging_port;
|
target->remote_debugging_port = src->remote_debugging_port;
|
||||||
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
|
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
|
||||||
target->background_color = src->background_color;
|
target->background_color = src->background_color;
|
||||||
@ -462,7 +457,6 @@ struct CefRequestContextSettingsTraits {
|
|||||||
cef_string_set(src->cache_path.str, src->cache_path.length,
|
cef_string_set(src->cache_path.str, src->cache_path.length,
|
||||||
&target->cache_path, copy);
|
&target->cache_path, copy);
|
||||||
target->persist_session_cookies = src->persist_session_cookies;
|
target->persist_session_cookies = src->persist_session_cookies;
|
||||||
target->persist_user_preferences = src->persist_user_preferences;
|
|
||||||
cef_string_set(src->accept_language_list.str,
|
cef_string_set(src->accept_language_list.str,
|
||||||
src->accept_language_list.length,
|
src->accept_language_list.length,
|
||||||
&target->accept_language_list, copy);
|
&target->accept_language_list, copy);
|
||||||
|
@ -82,7 +82,7 @@ class CefBrowserView : public CefView {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the Chrome toolbar associated with this BrowserView. Only
|
/// Returns the Chrome toolbar associated with this BrowserView. Only
|
||||||
/// supported when using the Chrome runtime. The CefBrowserViewDelegate::
|
/// supported when using Chrome style. The CefBrowserViewDelegate::
|
||||||
/// GetChromeToolbarType() method must return a value other than
|
/// GetChromeToolbarType() method must return a value other than
|
||||||
/// CEF_CTT_NONE and the toolbar will not be available until after this
|
/// CEF_CTT_NONE and the toolbar will not be available until after this
|
||||||
/// BrowserView is added to a CefWindow and CefViewDelegate::OnWindowChanged()
|
/// BrowserView is added to a CefWindow and CefViewDelegate::OnWindowChanged()
|
||||||
@ -96,7 +96,7 @@ class CefBrowserView : public CefView {
|
|||||||
/// content (`keydown` event handler) or CefKeyboardHandler. Normal priority
|
/// content (`keydown` event handler) or CefKeyboardHandler. Normal priority
|
||||||
/// accelerators can be registered via CefWindow::SetAccelerator (with
|
/// accelerators can be registered via CefWindow::SetAccelerator (with
|
||||||
/// |high_priority|=false) or internally for standard accelerators supported
|
/// |high_priority|=false) or internally for standard accelerators supported
|
||||||
/// by the Chrome runtime. If |prefer_accelerators| is true then the matching
|
/// by Chrome style. If |prefer_accelerators| is true then the matching
|
||||||
/// accelerator will be triggered immediately (calling
|
/// accelerator will be triggered immediately (calling
|
||||||
/// CefWindowDelegate::OnAccelerator or CefCommandHandler::OnChromeCommand
|
/// CefWindowDelegate::OnAccelerator or CefCommandHandler::OnChromeCommand
|
||||||
/// respectively) and the event will not be forwarded to the web content or
|
/// respectively) and the event will not be forwarded to the web content or
|
||||||
|
@ -132,8 +132,8 @@ class CefBrowserViewDelegate : public CefViewDelegate {
|
|||||||
///
|
///
|
||||||
/// Called when |browser_view| receives a gesture command. Return true to
|
/// Called when |browser_view| receives a gesture command. Return true to
|
||||||
/// handle (or disable) a |gesture_command| or false to propagate the gesture
|
/// handle (or disable) a |gesture_command| or false to propagate the gesture
|
||||||
/// to the browser for default handling. With the Chrome runtime these
|
/// to the browser for default handling. With Chrome style these commands can
|
||||||
/// commands can also be handled via CefCommandHandler::OnChromeCommand.
|
/// also be handled via CefCommandHandler::OnChromeCommand.
|
||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool OnGestureCommand(CefRefPtr<CefBrowserView> browser_view,
|
virtual bool OnGestureCommand(CefRefPtr<CefBrowserView> browser_view,
|
||||||
|
@ -89,7 +89,7 @@ class CefWindowDelegate : public CefPanelDelegate {
|
|||||||
/// the transition occurs asynchronously with |is_competed| set to false when
|
/// the transition occurs asynchronously with |is_competed| set to false when
|
||||||
/// the transition starts and true after the transition completes. On other
|
/// the transition starts and true after the transition completes. On other
|
||||||
/// platforms the transition occurs synchronously with |is_completed| set to
|
/// platforms the transition occurs synchronously with |is_completed| set to
|
||||||
/// true after the transition completes. With the Alloy runtime you must also
|
/// true after the transition completes. With Alloy style you must also
|
||||||
/// implement CefDisplayHandler::OnFullscreenModeChange to handle fullscreen
|
/// implement CefDisplayHandler::OnFullscreenModeChange to handle fullscreen
|
||||||
/// transitions initiated by browser content.
|
/// transitions initiated by browser content.
|
||||||
///
|
///
|
||||||
@ -251,12 +251,10 @@ class CefWindowDelegate : public CefPanelDelegate {
|
|||||||
/// Chrome theme colors will be applied and this callback will be triggered
|
/// Chrome theme colors will be applied and this callback will be triggered
|
||||||
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
|
/// if/when a BrowserView is added to the Window's component hierarchy. Chrome
|
||||||
/// theme colors can be configured on a per-RequestContext basis using
|
/// theme colors can be configured on a per-RequestContext basis using
|
||||||
/// CefRequestContext::SetChromeColorScheme or (Chrome runtime only) by
|
/// CefRequestContext::SetChromeColorScheme or (Chrome style only) by
|
||||||
/// visiting chrome://settings/manageProfile. Any theme changes using those
|
/// visiting chrome://settings/manageProfile. Any theme changes using those
|
||||||
/// mechanisms will also trigger this callback. Chrome theme colors will be
|
/// mechanisms will also trigger this callback. Chrome theme colors will be
|
||||||
/// persisted and restored from disk cache with the Chrome runtime, and with
|
/// persisted and restored from disk cache.
|
||||||
/// the Alloy runtime if persist_user_preferences is set to true via
|
|
||||||
/// CefSettings or CefRequestContextSettings.
|
|
||||||
///
|
///
|
||||||
/// This callback is not triggered on Window creation so clients that wish to
|
/// This callback is not triggered on Window creation so clients that wish to
|
||||||
/// customize the initial native/OS theme must call CefWindow::SetThemeColor
|
/// customize the initial native/OS theme must call CefWindow::SetThemeColor
|
||||||
|
@ -1,486 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "base/command_line.h"
|
|
||||||
#include "base/files/file_util.h"
|
|
||||||
#include "base/lazy_instance.h"
|
|
||||||
#include "base/logging.h"
|
|
||||||
#include "base/strings/string_util.h"
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_download_manager_delegate.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extension_system.h"
|
|
||||||
#include "cef/libcef/browser/prefs/browser_prefs.h"
|
|
||||||
#include "cef/libcef/browser/ssl_host_state_delegate.h"
|
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
|
||||||
#include "cef/libcef/common/cef_switches.h"
|
|
||||||
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
||||||
#include "chrome/browser/font_family_cache.h"
|
|
||||||
#include "chrome/browser/permissions/permission_manager_factory.h"
|
|
||||||
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
|
|
||||||
#include "chrome/browser/profiles/profile_key.h"
|
|
||||||
#include "chrome/browser/reduce_accept_language/reduce_accept_language_factory.h"
|
|
||||||
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
|
|
||||||
#include "chrome/common/pref_names.h"
|
|
||||||
#include "components/guest_view/browser/guest_view_manager.h"
|
|
||||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
|
||||||
#include "components/keyed_service/core/simple_dependency_manager.h"
|
|
||||||
#include "components/keyed_service/core/simple_key_map.h"
|
|
||||||
#include "components/permissions/permission_manager.h"
|
|
||||||
#include "components/prefs/pref_service.h"
|
|
||||||
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
|
||||||
#include "components/user_prefs/user_prefs.h"
|
|
||||||
#include "components/visitedlink/browser/visitedlink_event_listener.h"
|
|
||||||
#include "components/visitedlink/browser/visitedlink_writer.h"
|
|
||||||
#include "components/zoom/zoom_event_manager.h"
|
|
||||||
#include "content/public/browser/browser_task_traits.h"
|
|
||||||
#include "content/public/browser/browser_thread.h"
|
|
||||||
#include "content/public/browser/download_manager.h"
|
|
||||||
#include "content/public/browser/resource_context.h"
|
|
||||||
#include "content/public/browser/storage_partition.h"
|
|
||||||
#include "extensions/browser/extension_protocols.h"
|
|
||||||
#include "extensions/browser/process_manager.h"
|
|
||||||
#include "extensions/common/constants.h"
|
|
||||||
#include "net/proxy_resolution/proxy_config_service.h"
|
|
||||||
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
|
||||||
|
|
||||||
// Creates and manages VisitedLinkEventListener objects for each
|
|
||||||
// AlloyBrowserContext sharing the same VisitedLinkWriter.
|
|
||||||
class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
|
|
||||||
public:
|
|
||||||
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
|
|
||||||
|
|
||||||
CefVisitedLinkListener(const CefVisitedLinkListener&) = delete;
|
|
||||||
CefVisitedLinkListener& operator=(const CefVisitedLinkListener&) = delete;
|
|
||||||
|
|
||||||
void CreateListenerForContext(content::BrowserContext* context) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
auto listener =
|
|
||||||
std::make_unique<visitedlink::VisitedLinkEventListener>(context);
|
|
||||||
listener_map_.insert(std::make_pair(context, std::move(listener)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveListenerForContext(content::BrowserContext* context) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
ListenerMap::iterator it = listener_map_.find(context);
|
|
||||||
DCHECK(it != listener_map_.end());
|
|
||||||
listener_map_.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
// visitedlink::VisitedLinkWriter::Listener methods.
|
|
||||||
|
|
||||||
void NewTable(base::ReadOnlySharedMemoryRegion* table_region) override {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
ListenerMap::iterator it = listener_map_.begin();
|
|
||||||
for (; it != listener_map_.end(); ++it) {
|
|
||||||
it->second->NewTable(table_region);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Add(visitedlink::VisitedLinkCommon::Fingerprint fingerprint) override {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
ListenerMap::iterator it = listener_map_.begin();
|
|
||||||
for (; it != listener_map_.end(); ++it) {
|
|
||||||
it->second->Add(fingerprint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Reset(bool invalidate_hashes) override {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
ListenerMap::iterator it = listener_map_.begin();
|
|
||||||
for (; it != listener_map_.end(); ++it) {
|
|
||||||
it->second->Reset(invalidate_hashes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Map of AlloyBrowserContext to the associated VisitedLinkEventListener.
|
|
||||||
using ListenerMap =
|
|
||||||
std::map<const content::BrowserContext*,
|
|
||||||
std::unique_ptr<visitedlink::VisitedLinkEventListener>>;
|
|
||||||
ListenerMap listener_map_;
|
|
||||||
};
|
|
||||||
|
|
||||||
AlloyBrowserContext::AlloyBrowserContext(
|
|
||||||
const CefRequestContextSettings& settings)
|
|
||||||
: CefBrowserContext(settings) {}
|
|
||||||
|
|
||||||
AlloyBrowserContext::~AlloyBrowserContext() = default;
|
|
||||||
|
|
||||||
bool AlloyBrowserContext::IsInitialized() const {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
return !!key_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::StoreOrTriggerInitCallback(
|
|
||||||
base::OnceClosure callback) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
// Initialization is always synchronous.
|
|
||||||
std::move(callback).Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::Initialize() {
|
|
||||||
CefBrowserContext::Initialize();
|
|
||||||
|
|
||||||
key_ = std::make_unique<ProfileKey>(cache_path_);
|
|
||||||
SimpleKeyMap::GetInstance()->Associate(this, key_.get());
|
|
||||||
|
|
||||||
// Initialize the PrefService object.
|
|
||||||
pref_service_ = browser_prefs::CreatePrefService(
|
|
||||||
this, cache_path_, !!settings_.persist_user_preferences);
|
|
||||||
|
|
||||||
// This must be called before creating any services to avoid hitting
|
|
||||||
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
|
|
||||||
// multiple browser contexts (due to pointer address reuse).
|
|
||||||
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
|
|
||||||
this);
|
|
||||||
|
|
||||||
const bool extensions_enabled = extensions::ExtensionsEnabled();
|
|
||||||
if (extensions_enabled) {
|
|
||||||
// Create the custom ExtensionSystem first because other KeyedServices
|
|
||||||
// depend on it.
|
|
||||||
extension_system_ = static_cast<extensions::CefExtensionSystem*>(
|
|
||||||
extensions::ExtensionSystem::Get(this));
|
|
||||||
extension_system_->InitForRegularProfile(true);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize visited links management.
|
|
||||||
base::FilePath visited_link_path;
|
|
||||||
if (!cache_path_.empty()) {
|
|
||||||
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
|
|
||||||
}
|
|
||||||
visitedlink_listener_ = new CefVisitedLinkListener;
|
|
||||||
visitedlink_master_ = std::make_unique<visitedlink::VisitedLinkWriter>(
|
|
||||||
visitedlink_listener_, this, !visited_link_path.empty(), false,
|
|
||||||
visited_link_path, 0);
|
|
||||||
visitedlink_listener_->CreateListenerForContext(this);
|
|
||||||
visitedlink_master_->Init();
|
|
||||||
|
|
||||||
// Initialize proxy configuration tracker.
|
|
||||||
pref_proxy_config_tracker_ = std::make_unique<PrefProxyConfigTrackerImpl>(
|
|
||||||
GetPrefs(), content::GetIOThreadTaskRunner({}));
|
|
||||||
|
|
||||||
// Spell checking support and possibly other subsystems retrieve the
|
|
||||||
// PrefService associated with a BrowserContext via UserPrefs::Get().
|
|
||||||
PrefService* pref_service = GetPrefs();
|
|
||||||
DCHECK(pref_service);
|
|
||||||
user_prefs::UserPrefs::Set(this, pref_service);
|
|
||||||
key_->SetPrefs(pref_service);
|
|
||||||
|
|
||||||
if (extensions_enabled) {
|
|
||||||
extension_system_->Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChromePluginServiceFilter::GetInstance()->RegisterProfile(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::Shutdown() {
|
|
||||||
CefBrowserContext::Shutdown();
|
|
||||||
|
|
||||||
// Send notifications to clean up objects associated with this Profile.
|
|
||||||
MaybeSendDestroyedNotification();
|
|
||||||
|
|
||||||
ChromePluginServiceFilter::GetInstance()->UnregisterProfile(this);
|
|
||||||
|
|
||||||
// Clear this reference before the associated KeyedServiceFactory is destroyed
|
|
||||||
// by PerformInterlockedTwoPhaseShutdown().
|
|
||||||
extension_system_ = nullptr;
|
|
||||||
|
|
||||||
// Remove any BrowserContextKeyedServiceFactory associations. This must be
|
|
||||||
// called before the ProxyService owned by AlloyBrowserContext is destroyed.
|
|
||||||
// The SimpleDependencyManager should always be passed after the
|
|
||||||
// BrowserContextDependencyManager. This is because the KeyedService instances
|
|
||||||
// in the BrowserContextDependencyManager's dependency graph can depend on the
|
|
||||||
// ones in the SimpleDependencyManager's graph.
|
|
||||||
DependencyManager::PerformInterlockedTwoPhaseShutdown(
|
|
||||||
BrowserContextDependencyManager::GetInstance(), this,
|
|
||||||
SimpleDependencyManager::GetInstance(), key_.get());
|
|
||||||
|
|
||||||
key_.reset();
|
|
||||||
SimpleKeyMap::GetInstance()->Dissociate(this);
|
|
||||||
|
|
||||||
// Shuts down the storage partitions associated with this browser context.
|
|
||||||
// This must be called before the browser context is actually destroyed
|
|
||||||
// and before a clean-up task for its corresponding IO thread residents
|
|
||||||
// (e.g. ResourceContext) is posted, so that the classes that hung on
|
|
||||||
// StoragePartition can have time to do necessary cleanups on IO thread.
|
|
||||||
ShutdownStoragePartitions();
|
|
||||||
|
|
||||||
visitedlink_listener_->RemoveListenerForContext(this);
|
|
||||||
|
|
||||||
// The FontFamilyCache references the ProxyService so delete it before the
|
|
||||||
// ProxyService is deleted.
|
|
||||||
SetUserData(&kFontFamilyCacheKey, nullptr);
|
|
||||||
|
|
||||||
pref_proxy_config_tracker_->DetachFromPrefService();
|
|
||||||
|
|
||||||
// Delete the download manager delegate here because otherwise we'll crash
|
|
||||||
// when it's accessed from the content::BrowserContext destructor.
|
|
||||||
if (download_manager_delegate_) {
|
|
||||||
download_manager_delegate_.reset(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::RemoveCefRequestContext(
|
|
||||||
CefRequestContextImpl* context) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
|
|
||||||
if (extensions::ExtensionsEnabled()) {
|
|
||||||
extension_system()->OnRequestContextDeleted(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
// May result in |this| being deleted.
|
|
||||||
CefBrowserContext::RemoveCefRequestContext(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::LoadExtension(
|
|
||||||
const CefString& root_directory,
|
|
||||||
CefRefPtr<CefDictionaryValue> manifest,
|
|
||||||
CefRefPtr<CefExtensionHandler> handler,
|
|
||||||
CefRefPtr<CefRequestContext> loader_context) {
|
|
||||||
if (!extensions::ExtensionsEnabled()) {
|
|
||||||
if (handler) {
|
|
||||||
handler->OnExtensionLoadFailed(ERR_ABORTED);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manifest && manifest->GetSize() > 0) {
|
|
||||||
CefDictionaryValueImpl* value_impl =
|
|
||||||
static_cast<CefDictionaryValueImpl*>(manifest.get());
|
|
||||||
auto value = value_impl->CopyValue();
|
|
||||||
extension_system()->LoadExtension(std::move(value.GetDict()),
|
|
||||||
root_directory, false /* builtin */,
|
|
||||||
loader_context, handler);
|
|
||||||
} else {
|
|
||||||
extension_system()->LoadExtension(root_directory, false /* builtin */,
|
|
||||||
loader_context, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlloyBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
|
|
||||||
if (!extensions::ExtensionsEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions::CefExtensionSystem::ExtensionMap extension_map =
|
|
||||||
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> AlloyBrowserContext::GetExtension(
|
|
||||||
const CefString& extension_id) {
|
|
||||||
if (!extensions::ExtensionsEnabled()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return extension_system()->GetExtension(extension_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlloyBrowserContext::UnloadExtension(const CefString& extension_id) {
|
|
||||||
DCHECK(extensions::ExtensionsEnabled());
|
|
||||||
return extension_system()->UnloadExtension(extension_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
content::ClientHintsControllerDelegate*
|
|
||||||
AlloyBrowserContext::GetClientHintsControllerDelegate() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChromeZoomLevelPrefs* AlloyBrowserContext::GetZoomLevelPrefs() {
|
|
||||||
return static_cast<ChromeZoomLevelPrefs*>(
|
|
||||||
GetStoragePartition(nullptr)->GetZoomLevelDelegate());
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<network::SharedURLLoaderFactory>
|
|
||||||
AlloyBrowserContext::GetURLLoaderFactory() {
|
|
||||||
return GetDefaultStoragePartition()->GetURLLoaderFactoryForBrowserProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
base::FilePath AlloyBrowserContext::GetPath() {
|
|
||||||
return cache_path_;
|
|
||||||
}
|
|
||||||
|
|
||||||
base::FilePath AlloyBrowserContext::GetPath() const {
|
|
||||||
return cache_path_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<content::ZoomLevelDelegate>
|
|
||||||
AlloyBrowserContext::CreateZoomLevelDelegate(
|
|
||||||
const base::FilePath& partition_path) {
|
|
||||||
if (cache_path_.empty()) {
|
|
||||||
return std::unique_ptr<content::ZoomLevelDelegate>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return base::WrapUnique(new ChromeZoomLevelPrefs(
|
|
||||||
GetPrefs(), cache_path_, partition_path,
|
|
||||||
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
|
|
||||||
}
|
|
||||||
|
|
||||||
content::DownloadManagerDelegate*
|
|
||||||
AlloyBrowserContext::GetDownloadManagerDelegate() {
|
|
||||||
if (!download_manager_delegate_) {
|
|
||||||
download_manager_delegate_ =
|
|
||||||
std::make_unique<AlloyDownloadManagerDelegate>(GetDownloadManager());
|
|
||||||
}
|
|
||||||
return download_manager_delegate_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
content::BrowserPluginGuestManager* AlloyBrowserContext::GetGuestManager() {
|
|
||||||
if (!extensions::ExtensionsEnabled()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return guest_view::GuestViewManager::FromBrowserContext(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
storage::SpecialStoragePolicy* AlloyBrowserContext::GetSpecialStoragePolicy() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::PlatformNotificationService*
|
|
||||||
AlloyBrowserContext::GetPlatformNotificationService() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::PushMessagingService* AlloyBrowserContext::GetPushMessagingService() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::StorageNotificationService*
|
|
||||||
AlloyBrowserContext::GetStorageNotificationService() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::SSLHostStateDelegate* AlloyBrowserContext::GetSSLHostStateDelegate() {
|
|
||||||
if (!ssl_host_state_delegate_) {
|
|
||||||
ssl_host_state_delegate_ = std::make_unique<CefSSLHostStateDelegate>();
|
|
||||||
}
|
|
||||||
return ssl_host_state_delegate_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
content::PermissionControllerDelegate*
|
|
||||||
AlloyBrowserContext::GetPermissionControllerDelegate() {
|
|
||||||
return PermissionManagerFactory::GetForProfile(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
content::BackgroundFetchDelegate*
|
|
||||||
AlloyBrowserContext::GetBackgroundFetchDelegate() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::BackgroundSyncController*
|
|
||||||
AlloyBrowserContext::GetBackgroundSyncController() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::BrowsingDataRemoverDelegate*
|
|
||||||
AlloyBrowserContext::GetBrowsingDataRemoverDelegate() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::ReduceAcceptLanguageControllerDelegate*
|
|
||||||
AlloyBrowserContext::GetReduceAcceptLanguageControllerDelegate() {
|
|
||||||
return ReduceAcceptLanguageFactory::GetForProfile(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefService* AlloyBrowserContext::GetPrefs() {
|
|
||||||
return pref_service_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
const PrefService* AlloyBrowserContext::GetPrefs() const {
|
|
||||||
return pref_service_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfileKey* AlloyBrowserContext::GetProfileKey() const {
|
|
||||||
DCHECK(key_);
|
|
||||||
return key_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::SchemaRegistryService*
|
|
||||||
AlloyBrowserContext::GetPolicySchemaRegistryService() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::UserCloudPolicyManager*
|
|
||||||
AlloyBrowserContext::GetUserCloudPolicyManager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::ProfileCloudPolicyManager*
|
|
||||||
AlloyBrowserContext::GetProfileCloudPolicyManager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::CloudPolicyManager* AlloyBrowserContext::GetCloudPolicyManager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::ProfilePolicyConnector*
|
|
||||||
AlloyBrowserContext::GetProfilePolicyConnector() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const policy::ProfilePolicyConnector*
|
|
||||||
AlloyBrowserContext::GetProfilePolicyConnector() const {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlloyBrowserContext::IsNewProfile() const {
|
|
||||||
DCHECK(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::RebuildTable(
|
|
||||||
const scoped_refptr<URLEnumerator>& enumerator) {
|
|
||||||
// Called when visited links will not or cannot be loaded from disk.
|
|
||||||
enumerator->OnComplete(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::BuildVisitedLinkTable(
|
|
||||||
const scoped_refptr<VisitedLinkEnumerator>& enumerator) {
|
|
||||||
// Called when visited links will not or cannot be loaded from disk.
|
|
||||||
enumerator->OnVisitedLinkComplete(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
if (!download_prefs_) {
|
|
||||||
download_prefs_ = std::make_unique<DownloadPrefs>(this);
|
|
||||||
}
|
|
||||||
return download_prefs_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserContext::AddVisitedURLs(
|
|
||||||
const GURL& url,
|
|
||||||
const std::vector<GURL>& redirect_chain,
|
|
||||||
ui::PageTransition /*transition*/) {
|
|
||||||
if (!redirect_chain.empty()) {
|
|
||||||
visitedlink_master_->AddURLs(redirect_chain);
|
|
||||||
} else {
|
|
||||||
visitedlink_master_->AddURL(url);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,148 +0,0 @@
|
|||||||
// Copyright (c) 2011 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_ALLOY_ALLOY_BROWSER_CONTEXT_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "cef/include/cef_request_context_handler.h"
|
|
||||||
#include "cef/libcef/browser/alloy/chrome_profile_alloy.h"
|
|
||||||
#include "cef/libcef/browser/browser_context.h"
|
|
||||||
#include "cef/libcef/browser/request_context_handler_map.h"
|
|
||||||
#include "chrome/browser/download/download_prefs.h"
|
|
||||||
#include "components/proxy_config/pref_proxy_config_tracker.h"
|
|
||||||
#include "components/visitedlink/browser/visitedlink_delegate.h"
|
|
||||||
|
|
||||||
class AlloyDownloadManagerDelegate;
|
|
||||||
class CefSSLHostStateDelegate;
|
|
||||||
class CefVisitedLinkListener;
|
|
||||||
class PrefService;
|
|
||||||
|
|
||||||
namespace extensions {
|
|
||||||
class CefExtensionSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace visitedlink {
|
|
||||||
class VisitedLinkWriter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
|
|
||||||
// unless otherwise indicated. ChromeProfileAlloy must be the first listed base
|
|
||||||
// class to avoid issues when casting between void* and content::BrowserContext*
|
|
||||||
// in Chromium code.
|
|
||||||
class AlloyBrowserContext : public ChromeProfileAlloy,
|
|
||||||
public CefBrowserContext,
|
|
||||||
public visitedlink::VisitedLinkDelegate {
|
|
||||||
public:
|
|
||||||
explicit AlloyBrowserContext(const CefRequestContextSettings& settings);
|
|
||||||
|
|
||||||
AlloyBrowserContext(const AlloyBrowserContext&) = delete;
|
|
||||||
AlloyBrowserContext& operator=(const AlloyBrowserContext&) = delete;
|
|
||||||
|
|
||||||
// CefBrowserContext overrides.
|
|
||||||
content::BrowserContext* AsBrowserContext() override { return this; }
|
|
||||||
Profile* AsProfile() override { return this; }
|
|
||||||
bool IsInitialized() const override;
|
|
||||||
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
|
|
||||||
void Initialize() override;
|
|
||||||
void Shutdown() override;
|
|
||||||
void RemoveCefRequestContext(CefRequestContextImpl* context) override;
|
|
||||||
void LoadExtension(const CefString& root_directory,
|
|
||||||
CefRefPtr<CefDictionaryValue> manifest,
|
|
||||||
CefRefPtr<CefExtensionHandler> handler,
|
|
||||||
CefRefPtr<CefRequestContext> loader_context) override;
|
|
||||||
bool GetExtensions(std::vector<CefString>& extension_ids) override;
|
|
||||||
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
|
|
||||||
bool UnloadExtension(const CefString& extension_id) override;
|
|
||||||
void AddVisitedURLs(const GURL& url,
|
|
||||||
const std::vector<GURL>& redirect_chain,
|
|
||||||
ui::PageTransition transition) override;
|
|
||||||
|
|
||||||
// content::BrowserContext overrides.
|
|
||||||
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
|
||||||
override;
|
|
||||||
base::FilePath GetPath() override;
|
|
||||||
base::FilePath GetPath() const override;
|
|
||||||
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
|
|
||||||
const base::FilePath& partition_path) override;
|
|
||||||
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
|
||||||
content::BrowserPluginGuestManager* GetGuestManager() override;
|
|
||||||
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
|
||||||
content::PlatformNotificationService* GetPlatformNotificationService()
|
|
||||||
override;
|
|
||||||
content::PushMessagingService* GetPushMessagingService() override;
|
|
||||||
content::StorageNotificationService* GetStorageNotificationService() override;
|
|
||||||
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
|
||||||
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
|
|
||||||
override;
|
|
||||||
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
|
|
||||||
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
|
||||||
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
|
|
||||||
override;
|
|
||||||
content::ReduceAcceptLanguageControllerDelegate*
|
|
||||||
GetReduceAcceptLanguageControllerDelegate() override;
|
|
||||||
|
|
||||||
// Profile overrides.
|
|
||||||
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
|
|
||||||
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
|
|
||||||
PrefService* GetPrefs() override;
|
|
||||||
bool AllowsBrowserWindows() const override { return false; }
|
|
||||||
const PrefService* GetPrefs() const override;
|
|
||||||
ProfileKey* GetProfileKey() const override;
|
|
||||||
policy::SchemaRegistryService* GetPolicySchemaRegistryService() override;
|
|
||||||
policy::UserCloudPolicyManager* GetUserCloudPolicyManager() override;
|
|
||||||
policy::ProfileCloudPolicyManager* GetProfileCloudPolicyManager() override;
|
|
||||||
policy::CloudPolicyManager* GetCloudPolicyManager() override;
|
|
||||||
policy::ProfilePolicyConnector* GetProfilePolicyConnector() override;
|
|
||||||
const policy::ProfilePolicyConnector* GetProfilePolicyConnector()
|
|
||||||
const override;
|
|
||||||
bool IsNewProfile() const override;
|
|
||||||
|
|
||||||
// Values checked in ProfileNetworkContextService::CreateNetworkContextParams
|
|
||||||
// when creating the NetworkContext.
|
|
||||||
bool ShouldRestoreOldSessionCookies() override {
|
|
||||||
return ShouldPersistSessionCookies();
|
|
||||||
}
|
|
||||||
bool ShouldPersistSessionCookies() const override {
|
|
||||||
return !!settings_.persist_session_cookies;
|
|
||||||
}
|
|
||||||
|
|
||||||
// visitedlink::VisitedLinkDelegate methods.
|
|
||||||
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
|
|
||||||
void BuildVisitedLinkTable(
|
|
||||||
const scoped_refptr<VisitedLinkEnumerator>& enumerator) override;
|
|
||||||
|
|
||||||
// Manages extensions.
|
|
||||||
extensions::CefExtensionSystem* extension_system() const {
|
|
||||||
return extension_system_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called from DownloadPrefs::FromBrowserContext via
|
|
||||||
// alloy::GetDownloadPrefsFromBrowserContext.
|
|
||||||
DownloadPrefs* GetDownloadPrefs();
|
|
||||||
|
|
||||||
private:
|
|
||||||
~AlloyBrowserContext() override;
|
|
||||||
|
|
||||||
std::unique_ptr<PrefService> pref_service_;
|
|
||||||
std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
|
|
||||||
|
|
||||||
std::unique_ptr<AlloyDownloadManagerDelegate> download_manager_delegate_;
|
|
||||||
std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_;
|
|
||||||
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_master_;
|
|
||||||
// |visitedlink_listener_| is owned by visitedlink_master_.
|
|
||||||
raw_ptr<CefVisitedLinkListener> visitedlink_listener_ = nullptr;
|
|
||||||
|
|
||||||
// Owned by the KeyedService system.
|
|
||||||
raw_ptr<extensions::CefExtensionSystem> extension_system_ = nullptr;
|
|
||||||
|
|
||||||
// The key to index KeyedService instances created by
|
|
||||||
// SimpleKeyedServiceFactory.
|
|
||||||
std::unique_ptr<ProfileKey> key_;
|
|
||||||
|
|
||||||
std::unique_ptr<DownloadPrefs> download_prefs_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_CONTEXT_H_
|
|
@ -31,7 +31,6 @@
|
|||||||
#include "cef/libcef/common/net/url_util.h"
|
#include "cef/libcef/common/net/url_util.h"
|
||||||
#include "cef/libcef/common/request_impl.h"
|
#include "cef/libcef/common/request_impl.h"
|
||||||
#include "cef/libcef/common/values_impl.h"
|
#include "cef/libcef/common/values_impl.h"
|
||||||
#include "cef/libcef/features/runtime.h"
|
|
||||||
#include "chrome/browser/file_select_helper.h"
|
#include "chrome/browser/file_select_helper.h"
|
||||||
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
|
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
|
||||||
#include "components/input/native_web_keyboard_event.h"
|
#include "components/input/native_web_keyboard_event.h"
|
||||||
@ -52,10 +51,6 @@
|
|||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
#include "ui/events/base_event_utils.h"
|
#include "ui/events/base_event_utils.h"
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "extensions/common/extension.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using content::KeyboardEventProcessingResult;
|
using content::KeyboardEventProcessingResult;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -77,15 +72,9 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
|||||||
// Expect runtime style to match.
|
// Expect runtime style to match.
|
||||||
CHECK(platform_delegate->IsAlloyStyle());
|
CHECK(platform_delegate->IsAlloyStyle());
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
const bool is_devtools_popup = !!create_params.devtools_opener;
|
|
||||||
#else
|
|
||||||
const bool is_devtools_popup = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
scoped_refptr<CefBrowserInfo> info =
|
scoped_refptr<CefBrowserInfo> info =
|
||||||
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
||||||
is_devtools_popup, platform_delegate->IsWindowless(),
|
/*is_devtools_popup=*/false, platform_delegate->IsWindowless(),
|
||||||
platform_delegate->IsPrintPreviewSupported(),
|
platform_delegate->IsPrintPreviewSupported(),
|
||||||
create_params.extra_info);
|
create_params.extra_info);
|
||||||
|
|
||||||
@ -98,46 +87,17 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
|||||||
auto request_context_impl =
|
auto request_context_impl =
|
||||||
static_cast<CefRequestContextImpl*>(create_params.request_context.get());
|
static_cast<CefRequestContextImpl*>(create_params.request_context.get());
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||||
CefRefPtr<CefExtension> cef_extension;
|
CreateInternal(create_params.settings, create_params.client, web_contents,
|
||||||
if (create_params.extension) {
|
|
||||||
auto cef_browser_context = request_context_impl->GetBrowserContext();
|
|
||||||
cef_extension =
|
|
||||||
cef_browser_context->GetExtension(create_params.extension->id());
|
|
||||||
CHECK(cef_extension);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
auto platform_delegate_ptr = platform_delegate.get();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
|
|
||||||
create_params.settings, create_params.client, web_contents,
|
|
||||||
own_web_contents, info,
|
own_web_contents, info,
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
/*opener=*/nullptr, /*is_devtools_popup=*/false,
|
||||||
FromBaseChecked(create_params.devtools_opener),
|
request_context_impl, std::move(platform_delegate));
|
||||||
#else
|
|
||||||
/*opener=*/nullptr,
|
|
||||||
#endif
|
|
||||||
is_devtools_popup, request_context_impl, std::move(platform_delegate)
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
cef_extension
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
if (!browser) {
|
if (!browser) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GURL url = url_util::MakeGURL(create_params.url, /*fixup=*/true);
|
GURL url = url_util::MakeGURL(create_params.url, /*fixup=*/true);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (create_params.extension) {
|
|
||||||
platform_delegate_ptr->CreateExtensionHost(
|
|
||||||
create_params.extension, url, create_params.extension_host_type);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
if (!url.is_empty()) {
|
if (!url.is_empty()) {
|
||||||
content::OpenURLParams params(url, content::Referrer(),
|
content::OpenURLParams params(url, content::Referrer(),
|
||||||
WindowOpenDisposition::CURRENT_TAB,
|
WindowOpenDisposition::CURRENT_TAB,
|
||||||
@ -159,12 +119,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
|
|||||||
CefRefPtr<AlloyBrowserHostImpl> opener,
|
CefRefPtr<AlloyBrowserHostImpl> opener,
|
||||||
bool is_devtools_popup,
|
bool is_devtools_popup,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context,
|
CefRefPtr<CefRequestContextImpl> request_context,
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
CefRefPtr<CefExtension> extension
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
DCHECK(web_contents);
|
DCHECK(web_contents);
|
||||||
DCHECK(browser_info);
|
DCHECK(browser_info);
|
||||||
@ -195,12 +150,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
|
|||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser = new AlloyBrowserHostImpl(
|
CefRefPtr<AlloyBrowserHostImpl> browser = new AlloyBrowserHostImpl(
|
||||||
settings, client, web_contents, browser_info, opener, request_context,
|
settings, client, web_contents, browser_info, opener, request_context,
|
||||||
std::move(platform_delegate)
|
std::move(platform_delegate));
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
extension
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
browser->InitializeBrowser();
|
browser->InitializeBrowser();
|
||||||
|
|
||||||
if (!browser->CreateHostWindow()) {
|
if (!browser->CreateHostWindow()) {
|
||||||
@ -213,7 +163,7 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::CreateInternal(
|
|||||||
if (opener && opener->platform_delegate_) {
|
if (opener && opener->platform_delegate_) {
|
||||||
// 1. Notify the opener browser's platform delegate. With Views this will
|
// 1. Notify the opener browser's platform delegate. With Views this will
|
||||||
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
|
// result in a call to CefBrowserViewDelegate::OnPopupBrowserViewCreated().
|
||||||
// Do this first for consistency with the Chrome runtime.
|
// Do this first for consistency with Chrome style.
|
||||||
opener->platform_delegate_->PopupBrowserCreated(
|
opener->platform_delegate_->PopupBrowserCreated(
|
||||||
browser->platform_delegate(), browser.get(), is_devtools_popup);
|
browser->platform_delegate(), browser.get(), is_devtools_popup);
|
||||||
}
|
}
|
||||||
@ -383,16 +333,6 @@ void AlloyBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
CefRefPtr<CefExtension> AlloyBrowserHostImpl::GetExtension() {
|
|
||||||
return extension_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::IsBackgroundHost() {
|
|
||||||
return is_background_host_;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::CanExecuteChromeCommand(int command_id) {
|
bool AlloyBrowserHostImpl::CanExecuteChromeCommand(int command_id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -640,14 +580,6 @@ bool AlloyBrowserHostImpl::MaybeAllowNavigation(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
extensions::ExtensionHost* AlloyBrowserHostImpl::GetExtensionHost() const {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
DCHECK(platform_delegate_);
|
|
||||||
return platform_delegate_->GetExtensionHost();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::OnSetFocus,
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::OnSetFocus,
|
||||||
@ -958,14 +890,6 @@ content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool AlloyBrowserHostImpl::ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
bool is_main_frame_navigation) {
|
|
||||||
return platform_delegate_->ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
is_main_frame_navigation);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::AddNewContents(
|
void AlloyBrowserHostImpl::AddNewContents(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
std::unique_ptr<content::WebContents> new_contents,
|
std::unique_ptr<content::WebContents> new_contents,
|
||||||
@ -1106,14 +1030,6 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool AlloyBrowserHostImpl::PreHandleGestureEvent(
|
|
||||||
content::WebContents* source,
|
|
||||||
const blink::WebGestureEvent& event) {
|
|
||||||
return platform_delegate_->PreHandleGestureEvent(source, event);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::CanDragEnter(content::WebContents* source,
|
bool AlloyBrowserHostImpl::CanDragEnter(content::WebContents* source,
|
||||||
const content::DropData& data,
|
const content::DropData& data,
|
||||||
blink::DragOperationsMask mask) {
|
blink::DragOperationsMask mask) {
|
||||||
@ -1186,12 +1102,8 @@ void AlloyBrowserHostImpl::WebContentsCreated(
|
|||||||
// However, we need to install observers/delegates here.
|
// However, we need to install observers/delegates here.
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
|
CefRefPtr<AlloyBrowserHostImpl> browser = CreateInternal(
|
||||||
settings, client, new_contents, /*own_web_contents=*/false, info, opener,
|
settings, client, new_contents, /*own_web_contents=*/false, info, opener,
|
||||||
/*is_devtools_popup=*/false, request_context, std::move(platform_delegate)
|
/*is_devtools_popup=*/false, request_context,
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
std::move(platform_delegate));
|
||||||
,
|
|
||||||
/*extension=*/nullptr
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::RendererUnresponsive(
|
void AlloyBrowserHostImpl::RendererUnresponsive(
|
||||||
@ -1275,13 +1187,6 @@ bool AlloyBrowserHostImpl::CheckMediaAccessPermission(
|
|||||||
security_origin, type);
|
security_origin, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool AlloyBrowserHostImpl::IsNeverComposited(
|
|
||||||
content::WebContents* web_contents) {
|
|
||||||
return platform_delegate_->IsNeverComposited(web_contents);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
content::PictureInPictureResult AlloyBrowserHostImpl::EnterPictureInPicture(
|
content::PictureInPictureResult AlloyBrowserHostImpl::EnterPictureInPicture(
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
if (!IsPictureInPictureSupported()) {
|
if (!IsPictureInPictureSupported()) {
|
||||||
@ -1299,12 +1204,7 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
|
|||||||
|
|
||||||
bool AlloyBrowserHostImpl::IsBackForwardCacheSupported(
|
bool AlloyBrowserHostImpl::IsBackForwardCacheSupported(
|
||||||
content::WebContents& web_contents) {
|
content::WebContents& web_contents) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
// Disabled with Alloy bootstrap due to issue #3237.
|
|
||||||
return cef::IsChromeRuntimeEnabled();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
|
content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported(
|
||||||
@ -1438,12 +1338,7 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
|
|||||||
scoped_refptr<CefBrowserInfo> browser_info,
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
CefRefPtr<AlloyBrowserHostImpl> opener,
|
CefRefPtr<AlloyBrowserHostImpl> opener,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context,
|
CefRefPtr<CefRequestContextImpl> request_context,
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate)
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
CefRefPtr<CefExtension> extension
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
: CefBrowserHostBase(settings,
|
: CefBrowserHostBase(settings,
|
||||||
client,
|
client,
|
||||||
std::move(platform_delegate),
|
std::move(platform_delegate),
|
||||||
@ -1451,12 +1346,7 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
|
|||||||
request_context),
|
request_context),
|
||||||
content::WebContentsObserver(web_contents),
|
content::WebContentsObserver(web_contents),
|
||||||
opener_(kNullWindowHandle),
|
opener_(kNullWindowHandle),
|
||||||
is_windowless_(platform_delegate_->IsWindowless())
|
is_windowless_(platform_delegate_->IsWindowless()) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
extension_(extension)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
contents_delegate_->ObserveWebContents(web_contents);
|
contents_delegate_->ObserveWebContents(web_contents);
|
||||||
|
|
||||||
if (opener.get() && !is_views_hosted_) {
|
if (opener.get() && !is_views_hosted_) {
|
||||||
|
@ -24,16 +24,12 @@
|
|||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "extensions/common/mojom/view_type.mojom-forward.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class CefAudioCapturer;
|
class CefAudioCapturer;
|
||||||
class CefBrowserInfo;
|
class CefBrowserInfo;
|
||||||
class SiteInstance;
|
class SiteInstance;
|
||||||
|
|
||||||
// CefBrowser implementation for the alloy runtime. Method calls are delegated
|
// CefBrowser implementation for Alloy style. Method calls are delegated to the
|
||||||
// to the CefPlatformDelegate or the WebContents as appropriate. All methods are
|
// CefPlatformDelegate or the WebContents as appropriate. All methods are
|
||||||
// thread-safe unless otherwise indicated.
|
// thread-safe unless otherwise indicated.
|
||||||
//
|
//
|
||||||
// WebContentsDelegate: Interface for handling WebContents delegations. There is
|
// WebContentsDelegate: Interface for handling WebContents delegations. There is
|
||||||
@ -124,10 +120,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
void SetAutoResizeEnabled(bool enabled,
|
void SetAutoResizeEnabled(bool enabled,
|
||||||
const CefSize& min_size,
|
const CefSize& min_size,
|
||||||
const CefSize& max_size) override;
|
const CefSize& max_size) override;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
CefRefPtr<CefExtension> GetExtension() override;
|
|
||||||
bool IsBackgroundHost() override;
|
|
||||||
#endif
|
|
||||||
bool CanExecuteChromeCommand(int command_id) override;
|
bool CanExecuteChromeCommand(int command_id) override;
|
||||||
void ExecuteChromeCommand(int command_id,
|
void ExecuteChromeCommand(int command_id,
|
||||||
cef_window_open_disposition_t disposition) override;
|
cef_window_open_disposition_t disposition) override;
|
||||||
@ -169,11 +161,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
void UpdateDragOperation(ui::mojom::DragOperation operation,
|
void UpdateDragOperation(ui::mojom::DragOperation operation,
|
||||||
bool document_is_handling_drag);
|
bool document_is_handling_drag);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Accessors that must be called on the UI thread.
|
|
||||||
extensions::ExtensionHost* GetExtensionHost() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void OnSetFocus(cef_focus_source_t source) override;
|
void OnSetFocus(cef_focus_source_t source) override;
|
||||||
|
|
||||||
bool ShowContextMenu(const content::ContextMenuParams& params);
|
bool ShowContextMenu(const content::ContextMenuParams& params);
|
||||||
@ -192,10 +179,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
const content::OpenURLParams& params,
|
const content::OpenURLParams& params,
|
||||||
base::OnceCallback<void(content::NavigationHandle&)>
|
base::OnceCallback<void(content::NavigationHandle&)>
|
||||||
navigation_handle_callback) override;
|
navigation_handle_callback) override;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
bool is_main_frame_navigation) override;
|
|
||||||
#endif
|
|
||||||
void AddNewContents(content::WebContents* source,
|
void AddNewContents(content::WebContents* source,
|
||||||
std::unique_ptr<content::WebContents> new_contents,
|
std::unique_ptr<content::WebContents> new_contents,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
@ -225,10 +208,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
const input::NativeWebKeyboardEvent& event) override;
|
const input::NativeWebKeyboardEvent& event) override;
|
||||||
bool HandleKeyboardEvent(content::WebContents* source,
|
bool HandleKeyboardEvent(content::WebContents* source,
|
||||||
const input::NativeWebKeyboardEvent& event) override;
|
const input::NativeWebKeyboardEvent& event) override;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool PreHandleGestureEvent(content::WebContents* source,
|
|
||||||
const blink::WebGestureEvent& event) override;
|
|
||||||
#endif
|
|
||||||
bool CanDragEnter(content::WebContents* source,
|
bool CanDragEnter(content::WebContents* source,
|
||||||
const content::DropData& data,
|
const content::DropData& data,
|
||||||
blink::DragOperationsMask operations_allowed) override;
|
blink::DragOperationsMask operations_allowed) override;
|
||||||
@ -282,9 +261,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
|
||||||
const url::Origin& security_origin,
|
const url::Origin& security_origin,
|
||||||
blink::mojom::MediaStreamType type) override;
|
blink::mojom::MediaStreamType type) override;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool IsNeverComposited(content::WebContents* web_contents) override;
|
|
||||||
#endif
|
|
||||||
content::PictureInPictureResult EnterPictureInPicture(
|
content::PictureInPictureResult EnterPictureInPicture(
|
||||||
content::WebContents* web_contents) override;
|
content::WebContents* web_contents) override;
|
||||||
void ExitPictureInPicture() override;
|
void ExitPictureInPicture() override;
|
||||||
@ -318,12 +294,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
CefRefPtr<AlloyBrowserHostImpl> opener,
|
CefRefPtr<AlloyBrowserHostImpl> opener,
|
||||||
bool is_devtools_popup,
|
bool is_devtools_popup,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context,
|
CefRefPtr<CefRequestContextImpl> request_context,
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
CefRefPtr<CefExtension> extension
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
AlloyBrowserHostImpl(
|
AlloyBrowserHostImpl(
|
||||||
const CefBrowserSettings& settings,
|
const CefBrowserSettings& settings,
|
||||||
@ -332,12 +303,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
scoped_refptr<CefBrowserInfo> browser_info,
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
CefRefPtr<AlloyBrowserHostImpl> opener,
|
CefRefPtr<AlloyBrowserHostImpl> opener,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context,
|
CefRefPtr<CefRequestContextImpl> request_context,
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
,
|
|
||||||
CefRefPtr<CefExtension> extension
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
// Give the platform delegate an opportunity to create the host window.
|
// Give the platform delegate an opportunity to create the host window.
|
||||||
bool CreateHostWindow();
|
bool CreateHostWindow();
|
||||||
@ -348,10 +314,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
CefWindowHandle opener_;
|
CefWindowHandle opener_;
|
||||||
const bool is_windowless_;
|
const bool is_windowless_;
|
||||||
CefWindowHandle host_window_handle_ = kNullWindowHandle;
|
CefWindowHandle host_window_handle_ = kNullWindowHandle;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
CefRefPtr<CefExtension> extension_;
|
|
||||||
bool is_background_host_ = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Represents the current browser destruction state. Only accessed on the UI
|
// Represents the current browser destruction state. Only accessed on the UI
|
||||||
// thread.
|
// thread.
|
||||||
|
@ -1,426 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "base/feature_list.h"
|
|
||||||
#include "base/functional/bind.h"
|
|
||||||
#include "base/strings/string_number_conversions.h"
|
|
||||||
#include "base/task/thread_pool.h"
|
|
||||||
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
|
||||||
#include "cef/libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
|
|
||||||
#include "cef/libcef/browser/browser_context.h"
|
|
||||||
#include "cef/libcef/browser/browser_context_keyed_service_factories.h"
|
|
||||||
#include "cef/libcef/browser/context.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extension_system_factory.h"
|
|
||||||
#include "cef/libcef/browser/file_dialog_runner.h"
|
|
||||||
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
|
|
||||||
#include "cef/libcef/browser/permission_prompt.h"
|
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
|
||||||
#include "cef/libcef/common/app_manager.h"
|
|
||||||
#include "cef/libcef/common/command_line_impl.h"
|
|
||||||
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
||||||
#include "cef/libcef/common/net/net_resource_provider.h"
|
|
||||||
#include "chrome/browser/browser_process.h"
|
|
||||||
#include "chrome/browser/chrome_process_singleton.h"
|
|
||||||
#include "chrome/browser/media/router/chrome_media_router_factory.h"
|
|
||||||
#include "chrome/browser/net/system_network_context_manager.h"
|
|
||||||
#include "chrome/browser/ui/color/chrome_color_mixers.h"
|
|
||||||
#include "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h"
|
|
||||||
#include "chrome/browser/ui/ui_features.h"
|
|
||||||
#include "chrome/common/chrome_paths.h"
|
|
||||||
#include "chrome/common/chrome_switches.h"
|
|
||||||
#include "components/color/color_mixers.h"
|
|
||||||
#include "components/constrained_window/constrained_window_views.h"
|
|
||||||
#include "content/public/browser/gpu_data_manager.h"
|
|
||||||
#include "content/public/browser/network_service_instance.h"
|
|
||||||
#include "content/public/common/result_codes.h"
|
|
||||||
#include "extensions/browser/extensions_browser_client.h"
|
|
||||||
#include "extensions/common/constants.h"
|
|
||||||
#include "net/base/net_module.h"
|
|
||||||
#include "third_party/widevine/cdm/buildflags.h"
|
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
|
||||||
#include "ui/color/color_provider_manager.h"
|
|
||||||
#include "ui/native_theme/native_theme.h"
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
#include "components/password_manager/core/browser/password_manager_switches.h"
|
|
||||||
#include "ui/base/ozone_buildflags.h"
|
|
||||||
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
|
|
||||||
#include "ui/events/devices/x11/touch_factory_x11.h"
|
|
||||||
#endif
|
|
||||||
#if defined(USE_DBUS)
|
|
||||||
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
#include "ui/aura/env.h"
|
|
||||||
#include "ui/views/widget/desktop_aura/desktop_screen.h"
|
|
||||||
#include "ui/wm/core/wm_state.h"
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
#include "base/enterprise_util.h"
|
|
||||||
#include "base/files/file_util.h"
|
|
||||||
#include "chrome/browser/chrome_browser_main_win.h"
|
|
||||||
#include "chrome/browser/win/parental_controls.h"
|
|
||||||
#endif
|
|
||||||
#endif // defined(USE_AURA)
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
|
||||||
#include "chrome/browser/ui/views/chrome_views_delegate.h"
|
|
||||||
#else
|
|
||||||
#include "ui/views/test/desktop_test_views_delegate.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USE_AURA) && BUILDFLAG(IS_LINUX)
|
|
||||||
#include "ui/base/ime/init/input_method_initializer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
|
||||||
#include "components/os_crypt/sync/os_crypt.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
#include "base/path_service.h"
|
|
||||||
#include "cef/libcef/browser/printing/print_dialog_linux.h"
|
|
||||||
#include "chrome/browser/themes/theme_service_aura_linux.h"
|
|
||||||
#include "chrome/browser/ui/views/theme_profile_key.h"
|
|
||||||
#include "chrome/grit/branded_strings.h"
|
|
||||||
#include "components/os_crypt/sync/key_storage_config_linux.h"
|
|
||||||
#include "ui/base/cursor/cursor_factory.h"
|
|
||||||
#include "ui/base/ime/input_method.h"
|
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
|
||||||
#include "ui/linux/linux_ui.h"
|
|
||||||
#include "ui/linux/linux_ui_delegate.h"
|
|
||||||
#include "ui/linux/linux_ui_factory.h"
|
|
||||||
#include "ui/linux/linux_ui_getter.h"
|
|
||||||
#include "ui/ozone/public/ozone_platform.h"
|
|
||||||
#endif // BUILDFLAG(IS_LINUX)
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM)
|
|
||||||
#include "chrome/browser/component_updater/media_foundation_widevine_cdm_component_installer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
|
||||||
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
|
|
||||||
class LinuxUiGetterImpl : public ui::LinuxUiGetter {
|
|
||||||
public:
|
|
||||||
LinuxUiGetterImpl() = default;
|
|
||||||
~LinuxUiGetterImpl() override = default;
|
|
||||||
ui::LinuxUiTheme* GetForWindow(aura::Window* window) override {
|
|
||||||
return window ? GetForProfile(GetThemeProfileForWindow(window)) : nullptr;
|
|
||||||
}
|
|
||||||
ui::LinuxUiTheme* GetForProfile(Profile* profile) override {
|
|
||||||
return ui::GetLinuxUiTheme(
|
|
||||||
ThemeServiceAuraLinux::GetSystemThemeForProfile(profile));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // BUILDFLAG(IS_LINUX)
|
|
||||||
|
|
||||||
void ProcessSingletonNotificationCallbackImpl(
|
|
||||||
base::CommandLine command_line,
|
|
||||||
const base::FilePath& current_directory) {
|
|
||||||
// Drop the request if the browser process is already shutting down.
|
|
||||||
if (!CONTEXT_STATE_VALID()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool handled = false;
|
|
||||||
|
|
||||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
|
||||||
if (auto handler = app->GetBrowserProcessHandler()) {
|
|
||||||
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
|
||||||
new CefCommandLineImpl(command_line));
|
|
||||||
handled = handler->OnAlreadyRunningAppRelaunch(commandLinePtr.get(),
|
|
||||||
current_directory.value());
|
|
||||||
std::ignore = commandLinePtr->Detach(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handled) {
|
|
||||||
LOG(WARNING) << "Unhandled app relaunch; implement "
|
|
||||||
"CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Based on ChromeBrowserMainParts::ProcessSingletonNotificationCallback.
|
|
||||||
bool ProcessSingletonNotificationCallback(
|
|
||||||
base::CommandLine command_line,
|
|
||||||
const base::FilePath& current_directory) {
|
|
||||||
// Drop the request if the browser process is already shutting down.
|
|
||||||
// Note that we're going to post an async task below. Even if the browser
|
|
||||||
// process isn't shutting down right now, it could be by the time the task
|
|
||||||
// starts running. So, an additional check needs to happen when it starts.
|
|
||||||
// But regardless of any future check, there is no reason to post the task
|
|
||||||
// now if we know we're already shutting down.
|
|
||||||
if (!CONTEXT_STATE_VALID()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In order to handle this request on Windows, there is platform specific
|
|
||||||
// code in browser_finder.cc that requires making outbound COM calls to
|
|
||||||
// cross-apartment shell objects (via IVirtualDesktopManager). That is not
|
|
||||||
// allowed within a SendMessage handler, which this function is a part of.
|
|
||||||
// So, we post a task to asynchronously finish the command line processing.
|
|
||||||
return base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
|
||||||
FROM_HERE, base::BindOnce(&ProcessSingletonNotificationCallbackImpl,
|
|
||||||
std::move(command_line), current_directory));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
AlloyBrowserMainParts::AlloyBrowserMainParts() = default;
|
|
||||||
|
|
||||||
AlloyBrowserMainParts::~AlloyBrowserMainParts() {
|
|
||||||
constrained_window::SetConstrainedWindowViewsClient(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::ToolkitInitialized() {
|
|
||||||
SetConstrainedWindowViewsClient(
|
|
||||||
CreateAlloyConstrainedWindowViewsClient(nullptr));
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
CHECK(aura::Env::GetInstance());
|
|
||||||
|
|
||||||
wm_state_ = std::make_unique<wm::WMState>();
|
|
||||||
#endif // defined(USE_AURA)
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
views_delegate_ = std::make_unique<ChromeViewsDelegate>();
|
|
||||||
layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider();
|
|
||||||
#else
|
|
||||||
views_delegate_ = std::make_unique<views::DesktopTestViewsDelegate>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
// Based on chrome_browser_main_extra_parts_views_linux.cc
|
|
||||||
// |linux_ui| will be nullptr with multi-threaded-message-loop. See
|
|
||||||
// CefUiThread::InitializeBrowserRunner.
|
|
||||||
if (auto linux_ui = ui::GetDefaultLinuxUi()) {
|
|
||||||
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
|
|
||||||
ui::LinuxUi::SetInstance(linux_ui);
|
|
||||||
|
|
||||||
// Cursor theme changes are tracked by LinuxUI (via a CursorThemeManager
|
|
||||||
// implementation). Start observing them once it's initialized.
|
|
||||||
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USE_DBUS)
|
|
||||||
if (!ui::NativeTheme::IsForcedDarkMode() &&
|
|
||||||
!ui::NativeTheme::IsForcedLightMode()) {
|
|
||||||
dark_mode_manager_ = std::make_unique<ui::DarkModeManagerLinux>();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto printing_delegate = new CefPrintingContextLinuxDelegate();
|
|
||||||
auto default_delegate =
|
|
||||||
ui::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
|
|
||||||
printing_delegate->SetDefaultDelegate(default_delegate);
|
|
||||||
#endif // BUILDFLAG(IS_LINUX)
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
if (base::FeatureList::IsEnabled(features::kViewsJSAppModalDialog)) {
|
|
||||||
InstallChromeJavaScriptAppModalDialogViewFactory();
|
|
||||||
} else {
|
|
||||||
InstallChromeJavaScriptAppModalDialogViewCocoaFactory();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
InstallChromeJavaScriptAppModalDialogViewFactory();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// On GTK that builds the native theme that, in turn, adds the GTK core color
|
|
||||||
// mixer; core mixers should all be added before we add chrome mixers.
|
|
||||||
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
|
|
||||||
base::BindRepeating(color::AddComponentsColorMixers));
|
|
||||||
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
|
|
||||||
base::BindRepeating(AddChromeColorMixers));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
|
|
||||||
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
// Initialize the OSCrypt.
|
|
||||||
PrefService* local_state = g_browser_process->local_state();
|
|
||||||
DCHECK(local_state);
|
|
||||||
bool os_crypt_init = OSCrypt::Init(local_state);
|
|
||||||
DCHECK(os_crypt_init);
|
|
||||||
|
|
||||||
// installer_util references strings that are normally compiled into
|
|
||||||
// setup.exe. In Chrome, these strings are in the locale files.
|
|
||||||
ChromeBrowserMainPartsWin::SetupInstallerUtilStrings();
|
|
||||||
#endif // BUILDFLAG(IS_WIN)
|
|
||||||
|
|
||||||
media_router::ChromeMediaRouterFactory::DoPlatformInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
const base::CommandLine* command_line =
|
|
||||||
base::CommandLine::ForCurrentProcess();
|
|
||||||
|
|
||||||
// Set up crypt config. This needs to be done before anything starts the
|
|
||||||
// network service, as the raw encryption key needs to be shared with the
|
|
||||||
// network service for encrypted cookie storage.
|
|
||||||
// Based on ChromeBrowserMainPartsLinux::PostCreateMainMessageLoop.
|
|
||||||
std::unique_ptr<os_crypt::Config> config =
|
|
||||||
std::make_unique<os_crypt::Config>();
|
|
||||||
// Forward to os_crypt the flag to use a specific password store.
|
|
||||||
config->store =
|
|
||||||
command_line->GetSwitchValueASCII(password_manager::kPasswordStore);
|
|
||||||
// Forward the product name
|
|
||||||
config->product_name = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
|
|
||||||
// OSCrypt can be disabled in a special settings file.
|
|
||||||
config->should_use_preference =
|
|
||||||
command_line->HasSwitch(password_manager::kEnableEncryptionSelection);
|
|
||||||
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
|
|
||||||
DCHECK(!config->user_data_path.empty());
|
|
||||||
OSCrypt::SetConfig(std::move(config));
|
|
||||||
#endif // BUILDFLAG(IS_LINUX)
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
base::SetExtraNoExecuteAllowedPath(chrome::DIR_USER_DATA);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int AlloyBrowserMainParts::PreCreateThreads() {
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
PlatformInitialize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
net::NetModule::SetResourceProvider(&NetResourceProvider);
|
|
||||||
|
|
||||||
// Initialize these objects before IO access restrictions are applied and
|
|
||||||
// before the IO thread is started.
|
|
||||||
content::GpuDataManager::GetInstance();
|
|
||||||
SystemNetworkContextManager::CreateInstance(g_browser_process->local_state());
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::PostCreateThreads() {
|
|
||||||
ChromeProcessSingleton::GetInstance()->StartWatching();
|
|
||||||
}
|
|
||||||
|
|
||||||
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
screen_ = views::CreateDesktopScreen();
|
|
||||||
#endif
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
screen_ = std::make_unique<display::ScopedNativeScreen>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (extensions::ExtensionsEnabled()) {
|
|
||||||
// This should be set in ChromeBrowserProcessAlloy::Initialize.
|
|
||||||
DCHECK(extensions::ExtensionsBrowserClient::Get());
|
|
||||||
// Initialize extension global objects before creating the global
|
|
||||||
// BrowserContext.
|
|
||||||
extensions::CefExtensionSystemFactory::GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register additional KeyedService factories here. See
|
|
||||||
// ChromeBrowserMainExtraPartsProfiles for details.
|
|
||||||
cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
|
|
||||||
|
|
||||||
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
||||||
{base::TaskPriority::BEST_EFFORT,
|
|
||||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
||||||
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
||||||
{base::TaskPriority::USER_VISIBLE,
|
|
||||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
||||||
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
||||||
{base::TaskPriority::USER_BLOCKING,
|
|
||||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
||||||
|
|
||||||
CefRequestContextSettings settings;
|
|
||||||
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
|
|
||||||
|
|
||||||
// Create the global RequestContext.
|
|
||||||
global_request_context_ =
|
|
||||||
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
|
||||||
auto browser_context =
|
|
||||||
global_request_context_->GetBrowserContext()->AsBrowserContext();
|
|
||||||
|
|
||||||
CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
// Windows parental controls calls can be slow, so we do an early init here
|
|
||||||
// that calculates this value off of the UI thread.
|
|
||||||
InitializeWinParentalControls();
|
|
||||||
|
|
||||||
// These methods may call LoadLibrary and could trigger
|
|
||||||
// AssertBlockingAllowed() failures if executed at a later time on the UI
|
|
||||||
// thread.
|
|
||||||
base::IsManagedDevice();
|
|
||||||
base::IsEnterpriseDevice();
|
|
||||||
#endif // BUILDFLAG(IS_WIN)
|
|
||||||
|
|
||||||
scheme::RegisterWebUIControllerFactory();
|
|
||||||
file_dialog_runner::RegisterFactory();
|
|
||||||
permission_prompt::RegisterCreateCallback();
|
|
||||||
|
|
||||||
// Initialize theme configuration (high contrast, dark mode, etc).
|
|
||||||
ui::NativeTheme::GetInstanceForNativeUi();
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM) || \
|
|
||||||
BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
|
||||||
const base::CommandLine* command_line =
|
|
||||||
base::CommandLine::ForCurrentProcess();
|
|
||||||
if (!command_line->HasSwitch(switches::kDisableComponentUpdate)) {
|
|
||||||
auto* const cus = g_browser_process->component_updater();
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM)
|
|
||||||
RegisterMediaFoundationWidevineCdmComponent(cus);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
|
||||||
RegisterWidevineCdmComponent(cus);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Allow ProcessSingleton to process messages.
|
|
||||||
// This is done here instead of just relying on the main message loop's start
|
|
||||||
// to avoid rendezvous in RunLoops that may precede MainMessageLoopRun.
|
|
||||||
ChromeProcessSingleton::GetInstance()->Unlock(
|
|
||||||
base::BindRepeating(&ProcessSingletonNotificationCallback));
|
|
||||||
|
|
||||||
return content::RESULT_CODE_NORMAL_EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::PostMainMessageLoopRun() {
|
|
||||||
// NOTE: Destroy objects in reverse order of creation.
|
|
||||||
CefDevToolsManagerDelegate::StopHttpHandler();
|
|
||||||
|
|
||||||
ChromeProcessSingleton::GetInstance()->Cleanup();
|
|
||||||
|
|
||||||
// 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_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::PostDestroyThreads() {
|
|
||||||
views_delegate_.reset();
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
layout_provider_.reset();
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
// Copyright (c) 2011 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_ALLOY_ALLOY_BROWSER_MAIN_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
#include "base/command_line.h"
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "build/build_config.h"
|
|
||||||
#include "cef/libcef/browser/request_context_impl.h"
|
|
||||||
#include "components/prefs/pref_service.h"
|
|
||||||
#include "content/public/browser/browser_main_parts.h"
|
|
||||||
#include "ui/display/screen.h"
|
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
namespace wm {
|
|
||||||
class WMState;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace views {
|
|
||||||
class ViewsDelegate;
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
class LayoutProvider;
|
|
||||||
#endif
|
|
||||||
} // namespace views
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
namespace ui {
|
|
||||||
class LinuxUiGetter;
|
|
||||||
#if defined(USE_DBUS)
|
|
||||||
class DarkModeManagerLinux;
|
|
||||||
#endif
|
|
||||||
} // namespace ui
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class CefDevToolsDelegate;
|
|
||||||
|
|
||||||
class AlloyBrowserMainParts : public content::BrowserMainParts {
|
|
||||||
public:
|
|
||||||
AlloyBrowserMainParts();
|
|
||||||
|
|
||||||
AlloyBrowserMainParts(const AlloyBrowserMainParts&) = delete;
|
|
||||||
AlloyBrowserMainParts& operator=(const AlloyBrowserMainParts&) = delete;
|
|
||||||
|
|
||||||
~AlloyBrowserMainParts() override;
|
|
||||||
|
|
||||||
void ToolkitInitialized() override;
|
|
||||||
void PreCreateMainMessageLoop() override;
|
|
||||||
void PostCreateMainMessageLoop() override;
|
|
||||||
int PreCreateThreads() override;
|
|
||||||
void PostCreateThreads() override;
|
|
||||||
int PreMainMessageLoopRun() override;
|
|
||||||
void PostMainMessageLoopRun() override;
|
|
||||||
void PostDestroyThreads() override;
|
|
||||||
|
|
||||||
CefRefPtr<CefRequestContextImpl> request_context() const {
|
|
||||||
return global_request_context_;
|
|
||||||
}
|
|
||||||
CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
|
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const {
|
|
||||||
return background_task_runner_;
|
|
||||||
}
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const {
|
|
||||||
return user_visible_task_runner_;
|
|
||||||
}
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner()
|
|
||||||
const {
|
|
||||||
return user_blocking_task_runner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
void PlatformInitialize();
|
|
||||||
#endif // BUILDFLAG(IS_WIN)
|
|
||||||
|
|
||||||
CefRefPtr<CefRequestContextImpl> global_request_context_;
|
|
||||||
raw_ptr<CefDevToolsDelegate> devtools_delegate_ = nullptr; // Deletes itself.
|
|
||||||
|
|
||||||
// Blocking task runners exposed via CefTaskRunner. For consistency with
|
|
||||||
// previous named thread behavior always execute all pending tasks before
|
|
||||||
// shutdown (e.g. to make sure critical data is saved to disk).
|
|
||||||
// |background_task_runner_| is also passed to SQLitePersistentCookieStore.
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner_;
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
|
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
std::unique_ptr<display::Screen> screen_;
|
|
||||||
std::unique_ptr<wm::WMState> wm_state_;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::unique_ptr<views::ViewsDelegate> views_delegate_;
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
|
||||||
std::unique_ptr<display::ScopedNativeScreen> screen_;
|
|
||||||
std::unique_ptr<views::LayoutProvider> layout_provider_;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
|
||||||
std::unique_ptr<ui::LinuxUiGetter> linux_ui_getter_;
|
|
||||||
#if defined(USE_DBUS)
|
|
||||||
std::unique_ptr<ui::DarkModeManagerLinux> dark_mode_manager_;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
|
|
@ -1,29 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
|
|
||||||
|
|
||||||
#include <Objbase.h>
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <commctrl.h>
|
|
||||||
|
|
||||||
#include "base/logging.h"
|
|
||||||
|
|
||||||
void AlloyBrowserMainParts::PlatformInitialize() {
|
|
||||||
HRESULT res;
|
|
||||||
|
|
||||||
// Initialize common controls.
|
|
||||||
res = CoInitialize(nullptr);
|
|
||||||
DCHECK(SUCCEEDED(res));
|
|
||||||
INITCOMMONCONTROLSEX InitCtrlEx;
|
|
||||||
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
|
||||||
InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
|
|
||||||
InitCommonControlsEx(&InitCtrlEx);
|
|
||||||
|
|
||||||
// Start COM stuff.
|
|
||||||
res = OleInitialize(nullptr);
|
|
||||||
DCHECK(SUCCEEDED(res));
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,287 +0,0 @@
|
|||||||
// Copyright (c) 2011 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_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "base/memory/ref_counted.h"
|
|
||||||
#include "build/build_config.h"
|
|
||||||
#include "cef/include/cef_request_context_handler.h"
|
|
||||||
#include "cef/libcef/browser/request_context_impl.h"
|
|
||||||
#include "content/public/browser/content_browser_client.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
|
||||||
|
|
||||||
class AlloyBrowserMainParts;
|
|
||||||
class CefDevToolsDelegate;
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class SiteInstance;
|
|
||||||
} // namespace content
|
|
||||||
|
|
||||||
namespace extensions {
|
|
||||||
class Extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
|
||||||
public:
|
|
||||||
AlloyContentBrowserClient();
|
|
||||||
~AlloyContentBrowserClient() override;
|
|
||||||
|
|
||||||
void CleanupOnUIThread();
|
|
||||||
|
|
||||||
// ContentBrowserClient implementation.
|
|
||||||
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
|
|
||||||
bool is_integration_test) override;
|
|
||||||
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
|
||||||
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
|
||||||
const GURL& site_url) override;
|
|
||||||
bool ShouldUseSpareRenderProcessHost(content::BrowserContext* browser_context,
|
|
||||||
const GURL& site_url) override;
|
|
||||||
bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context,
|
|
||||||
const GURL& effective_site_url) override;
|
|
||||||
bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
|
||||||
std::string_view scheme,
|
|
||||||
bool is_embedded_origin_secure) override;
|
|
||||||
bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
|
||||||
std::string_view scheme,
|
|
||||||
bool is_embedded_origin_secure) override;
|
|
||||||
void OverrideURLLoaderFactoryParams(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const url::Origin& origin,
|
|
||||||
bool is_for_isolated_world,
|
|
||||||
network::mojom::URLLoaderFactoryParams* factory_params) override;
|
|
||||||
void GetAdditionalWebUISchemes(
|
|
||||||
std::vector<std::string>* additional_schemes) override;
|
|
||||||
void GetAdditionalViewSourceSchemes(
|
|
||||||
std::vector<std::string>* additional_schemes) override;
|
|
||||||
std::unique_ptr<ui::SelectFilePolicy> CreateSelectFilePolicy(
|
|
||||||
content::WebContents* web_contents) override;
|
|
||||||
void GetAdditionalAllowedSchemesForFileSystem(
|
|
||||||
std::vector<std::string>* additional_allowed_schemes) override;
|
|
||||||
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
|
|
||||||
bool IsHandledURL(const GURL& url) override;
|
|
||||||
void SiteInstanceGotProcessAndSite(
|
|
||||||
content::SiteInstance* site_instance) override;
|
|
||||||
void BindHostReceiverForRenderer(
|
|
||||||
content::RenderProcessHost* render_process_host,
|
|
||||||
mojo::GenericPendingReceiver receiver) override;
|
|
||||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
|
||||||
int child_process_id) override;
|
|
||||||
std::string GetApplicationLocale() override;
|
|
||||||
scoped_refptr<network::SharedURLLoaderFactory>
|
|
||||||
GetSystemSharedURLLoaderFactory() override;
|
|
||||||
network::mojom::NetworkContext* GetSystemNetworkContext() override;
|
|
||||||
content::MediaObserver* GetMediaObserver() override;
|
|
||||||
content::SpeechRecognitionManagerDelegate*
|
|
||||||
CreateSpeechRecognitionManagerDelegate() override;
|
|
||||||
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
|
|
||||||
content::BrowserContext* context) override;
|
|
||||||
void AllowCertificateError(
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
int cert_error,
|
|
||||||
const net::SSLInfo& ssl_info,
|
|
||||||
const GURL& request_url,
|
|
||||||
bool is_main_frame_request,
|
|
||||||
bool strict_enforcement,
|
|
||||||
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
|
|
||||||
override;
|
|
||||||
base::OnceClosure SelectClientCertificate(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
net::SSLCertRequestInfo* cert_request_info,
|
|
||||||
net::ClientCertIdentityList client_certs,
|
|
||||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
|
||||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
|
||||||
const GURL& opener_url,
|
|
||||||
const GURL& opener_top_level_frame_url,
|
|
||||||
const url::Origin& source_origin,
|
|
||||||
content::mojom::WindowContainerType container_type,
|
|
||||||
const GURL& target_url,
|
|
||||||
const content::Referrer& referrer,
|
|
||||||
const std::string& frame_name,
|
|
||||||
WindowOpenDisposition disposition,
|
|
||||||
const blink::mojom::WindowFeatures& features,
|
|
||||||
bool user_gesture,
|
|
||||||
bool opener_suppressed,
|
|
||||||
bool* no_javascript_access) override;
|
|
||||||
void OverrideWebkitPrefs(content::WebContents* web_contents,
|
|
||||||
blink::web_pref::WebPreferences* prefs) override;
|
|
||||||
bool OverrideWebPreferencesAfterNavigation(
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
blink::web_pref::WebPreferences* prefs) override;
|
|
||||||
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
|
|
||||||
std::string GetDefaultDownloadName() override;
|
|
||||||
std::unique_ptr<content::DevToolsManagerDelegate>
|
|
||||||
CreateDevToolsManagerDelegate() override;
|
|
||||||
void ExposeInterfacesToRenderer(
|
|
||||||
service_manager::BinderRegistry* registry,
|
|
||||||
blink::AssociatedInterfaceRegistry* associated_registry,
|
|
||||||
content::RenderProcessHost* render_process_host) override;
|
|
||||||
void RegisterAssociatedInterfaceBindersForServiceWorker(
|
|
||||||
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
|
|
||||||
blink::AssociatedInterfaceRegistry& associated_registry) override;
|
|
||||||
void RegisterAssociatedInterfaceBindersForRenderFrameHost(
|
|
||||||
content::RenderFrameHost& render_frame_host,
|
|
||||||
blink::AssociatedInterfaceRegistry& associated_registry) override;
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationHandle* navigation_handle) override;
|
|
||||||
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
|
||||||
CreateURLLoaderThrottles(
|
|
||||||
const network::ResourceRequest& request,
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
|
|
||||||
content::NavigationUIData* navigation_ui_data,
|
|
||||||
int frame_tree_node_id,
|
|
||||||
std::optional<int64_t> navigation_id) override;
|
|
||||||
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
|
||||||
CreateURLLoaderThrottlesForKeepAlive(
|
|
||||||
const network::ResourceRequest& request,
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
|
|
||||||
int frame_tree_node_id) override;
|
|
||||||
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
|
||||||
WillCreateURLLoaderRequestInterceptors(
|
|
||||||
content::NavigationUIData* navigation_ui_data,
|
|
||||||
int frame_tree_node_id,
|
|
||||||
int64_t navigation_id,
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner)
|
|
||||||
override;
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
|
||||||
void GetAdditionalMappedFilesForChildProcess(
|
|
||||||
const base::CommandLine& command_line,
|
|
||||||
int child_process_id,
|
|
||||||
content::PosixFileDescriptorInfo* mappings) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
|
||||||
content::BrowserContext* browser_context) override;
|
|
||||||
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
|
|
||||||
const net::AuthChallengeInfo& auth_info,
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const content::GlobalRequestID& request_id,
|
|
||||||
bool is_request_for_main_frame,
|
|
||||||
const GURL& url,
|
|
||||||
scoped_refptr<net::HttpResponseHeaders> response_headers,
|
|
||||||
bool first_auth_attempt,
|
|
||||||
LoginAuthRequiredCallback auth_required_callback) override;
|
|
||||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>
|
|
||||||
CreateNonNetworkNavigationURLLoaderFactory(const std::string& scheme,
|
|
||||||
int frame_tree_node_id) override;
|
|
||||||
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
|
||||||
int render_process_id,
|
|
||||||
int render_frame_id,
|
|
||||||
const std::optional<url::Origin>& request_initiator_origin,
|
|
||||||
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
||||||
void WillCreateURLLoaderFactory(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
content::RenderFrameHost* frame,
|
|
||||||
int render_process_id,
|
|
||||||
URLLoaderFactoryType type,
|
|
||||||
const url::Origin& request_initiator,
|
|
||||||
const net::IsolationInfo& isolation_info,
|
|
||||||
std::optional<int64_t> navigation_id,
|
|
||||||
ukm::SourceIdObj ukm_source_id,
|
|
||||||
network::URLLoaderFactoryBuilder& factory_builder,
|
|
||||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
|
||||||
header_client,
|
|
||||||
bool* bypass_redirect_checks,
|
|
||||||
bool* disable_secure_dns,
|
|
||||||
network::mojom::URLLoaderFactoryOverridePtr* factory_override,
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner)
|
|
||||||
override;
|
|
||||||
void OnNetworkServiceCreated(
|
|
||||||
network::mojom::NetworkService* network_service) override;
|
|
||||||
bool ConfigureNetworkContextParams(
|
|
||||||
content::BrowserContext* context,
|
|
||||||
bool in_memory,
|
|
||||||
const base::FilePath& relative_partition_path,
|
|
||||||
network::mojom::NetworkContextParams* network_context_params,
|
|
||||||
cert_verifier::mojom::CertVerifierCreationParams*
|
|
||||||
cert_verifier_creation_params) override;
|
|
||||||
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
|
||||||
bool HandleExternalProtocol(
|
|
||||||
const GURL& url,
|
|
||||||
content::WebContents::Getter web_contents_getter,
|
|
||||||
int frame_tree_node_id,
|
|
||||||
content::NavigationUIData* navigation_data,
|
|
||||||
bool is_primary_main_frame,
|
|
||||||
bool is_in_fenced_frame_tree,
|
|
||||||
network::mojom::WebSandboxFlags sandbox_flags,
|
|
||||||
ui::PageTransition page_transition,
|
|
||||||
bool has_user_gesture,
|
|
||||||
const std::optional<url::Origin>& initiating_origin,
|
|
||||||
content::RenderFrameHost* initiator_document,
|
|
||||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
|
||||||
override;
|
|
||||||
bool HandleExternalProtocol(
|
|
||||||
content::WebContents::Getter web_contents_getter,
|
|
||||||
int frame_tree_node_id,
|
|
||||||
content::NavigationUIData* navigation_data,
|
|
||||||
bool is_primary_main_frame,
|
|
||||||
bool is_in_fenced_frame_tree,
|
|
||||||
network::mojom::WebSandboxFlags sandbox_flags,
|
|
||||||
const network::ResourceRequest& request,
|
|
||||||
const std::optional<url::Origin>& initiating_origin,
|
|
||||||
content::RenderFrameHost* initiator_document,
|
|
||||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
|
||||||
override;
|
|
||||||
std::unique_ptr<content::VideoOverlayWindow>
|
|
||||||
CreateWindowForVideoPictureInPicture(
|
|
||||||
content::VideoPictureInPictureWindowController* controller) override;
|
|
||||||
void RegisterBrowserInterfaceBindersForFrame(
|
|
||||||
content::RenderFrameHost* render_frame_host,
|
|
||||||
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
|
|
||||||
void RegisterBrowserInterfaceBindersForServiceWorker(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
|
|
||||||
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
|
|
||||||
map) override;
|
|
||||||
base::FilePath GetSandboxedStorageServiceDataDirectory() override;
|
|
||||||
base::FilePath GetShaderDiskCacheDirectory() override;
|
|
||||||
base::FilePath GetGrShaderDiskCacheDirectory() override;
|
|
||||||
base::FilePath GetGraphiteDawnDiskCacheDirectory() override;
|
|
||||||
base::FilePath GetNetLogDefaultDirectory() override;
|
|
||||||
base::FilePath GetFirstPartySetsDirectory() override;
|
|
||||||
std::optional<base::FilePath> GetLocalTracesDirectory() override;
|
|
||||||
std::string GetProduct() override;
|
|
||||||
std::string GetChromeProduct() override;
|
|
||||||
std::string GetUserAgent() override;
|
|
||||||
std::unique_ptr<content::WebContentsViewDelegate> GetWebContentsViewDelegate(
|
|
||||||
content::WebContents* web_contents) override;
|
|
||||||
blink::UserAgentMetadata GetUserAgentMetadata() override;
|
|
||||||
base::flat_set<std::string> GetPluginMimeTypesWithExternalHandlers(
|
|
||||||
content::BrowserContext* browser_context) override;
|
|
||||||
void GetMediaDeviceIDSalt(
|
|
||||||
content::RenderFrameHost* rfh,
|
|
||||||
const net::SiteForCookies& site_for_cookies,
|
|
||||||
const blink::StorageKey& storage_key,
|
|
||||||
base::OnceCallback<void(bool, const std::string&)> callback) override;
|
|
||||||
void OnWebContentsCreated(content::WebContents* web_contents) override;
|
|
||||||
bool IsFindInPageDisabledForOrigin(const url::Origin& origin) override;
|
|
||||||
|
|
||||||
CefRefPtr<CefRequestContextImpl> request_context() const;
|
|
||||||
CefDevToolsDelegate* devtools_delegate() const;
|
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const;
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const;
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Returns the extension or app associated with |site_instance| or NULL.
|
|
||||||
const extensions::Extension* GetExtension(
|
|
||||||
content::SiteInstance* site_instance);
|
|
||||||
|
|
||||||
raw_ptr<AlloyBrowserMainParts> browser_main_parts_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_CONTENT_BROWSER_CLIENT_H_
|
|
@ -1,22 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_download_manager_delegate.h"
|
|
||||||
|
|
||||||
#include "chrome/common/chrome_constants.h"
|
|
||||||
#include "components/download/public/common/download_item.h"
|
|
||||||
|
|
||||||
AlloyDownloadManagerDelegate::AlloyDownloadManagerDelegate(
|
|
||||||
content::DownloadManager* manager)
|
|
||||||
: CefDownloadManagerDelegateImpl(manager, /*alloy_bootstrap=*/true) {}
|
|
||||||
|
|
||||||
void AlloyDownloadManagerDelegate::GetNextId(
|
|
||||||
content::DownloadIdCallback callback) {
|
|
||||||
static uint32_t next_id = download::DownloadItem::kInvalidId + 1;
|
|
||||||
std::move(callback).Run(next_id++);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AlloyDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
|
|
||||||
return std::string(chrome::kApplicationClientIDStringForAVScanning);
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/download_manager_delegate_impl.h"
|
|
||||||
|
|
||||||
// Specialization for the Alloy bootstrap.
|
|
||||||
class AlloyDownloadManagerDelegate : public CefDownloadManagerDelegateImpl {
|
|
||||||
public:
|
|
||||||
explicit AlloyDownloadManagerDelegate(content::DownloadManager* manager);
|
|
||||||
|
|
||||||
AlloyDownloadManagerDelegate(const AlloyDownloadManagerDelegate&) = delete;
|
|
||||||
AlloyDownloadManagerDelegate& operator=(const AlloyDownloadManagerDelegate&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// DownloadManagerDelegate methods.
|
|
||||||
void GetNextId(content::DownloadIdCallback callback) override;
|
|
||||||
std::string ApplicationClientIdForFileScanning() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_MANAGER_DELEGATE_H_
|
|
@ -1,18 +0,0 @@
|
|||||||
// Copyright 2021 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 "cef/libcef/browser/alloy/alloy_download_util.h"
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_context.h"
|
|
||||||
|
|
||||||
namespace alloy {
|
|
||||||
|
|
||||||
DownloadPrefs* GetDownloadPrefsFromBrowserContext(
|
|
||||||
content::BrowserContext* context) {
|
|
||||||
// This function is only called with Alloy bootstrap, so the static_cast is
|
|
||||||
// safe.
|
|
||||||
return static_cast<AlloyBrowserContext*>(context)->GetDownloadPrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace alloy
|
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright 2021 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_ALLOY_ALLOY_DOWNLOAD_UTIL_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_UTIL_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "cef/libcef/features/features.h"
|
|
||||||
|
|
||||||
class DownloadPrefs;
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class BrowserContext;
|
|
||||||
} // namespace content
|
|
||||||
|
|
||||||
namespace alloy {
|
|
||||||
|
|
||||||
// Called from DownloadPrefs::FromBrowserContext.
|
|
||||||
DownloadPrefs* GetDownloadPrefsFromBrowserContext(
|
|
||||||
content::BrowserContext* context);
|
|
||||||
|
|
||||||
} // namespace alloy
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_DOWNLOAD_UTIL_H_
|
|
@ -1,21 +0,0 @@
|
|||||||
// Copyright 2022 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 "cef/libcef/browser/alloy/alloy_web_contents_view_delegate.h"
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
|
|
||||||
AlloyWebContentsViewDelegate::AlloyWebContentsViewDelegate(
|
|
||||||
content::WebContents* web_contents)
|
|
||||||
: web_contents_(web_contents) {}
|
|
||||||
|
|
||||||
void AlloyWebContentsViewDelegate::ShowContextMenu(
|
|
||||||
content::RenderFrameHost& render_frame_host,
|
|
||||||
const content::ContextMenuParams& params) {
|
|
||||||
if (auto browser =
|
|
||||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_)) {
|
|
||||||
browser->ShowContextMenu(params);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
// Copyright 2022 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_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "cef/include/internal/cef_ptr.h"
|
|
||||||
#include "content/public/browser/web_contents_view_delegate.h"
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class WebContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AlloyWebContentsViewDelegate : public content::WebContentsViewDelegate {
|
|
||||||
public:
|
|
||||||
explicit AlloyWebContentsViewDelegate(content::WebContents* web_contents);
|
|
||||||
|
|
||||||
AlloyWebContentsViewDelegate(const AlloyWebContentsViewDelegate&) = delete;
|
|
||||||
AlloyWebContentsViewDelegate& operator=(const AlloyWebContentsViewDelegate&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
// WebContentsViewDelegate methods:
|
|
||||||
void ShowContextMenu(content::RenderFrameHost& render_frame_host,
|
|
||||||
const content::ContextMenuParams& params) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const raw_ptr<content::WebContents> web_contents_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_WEB_CONTENTS_VIEW_DELEGATE_H_
|
|
@ -8,13 +8,7 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||||
#include "cef/libcef/browser/extensions/extension_background_host.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extension_system.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extension_view_host.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extension_web_contents_observer.h"
|
|
||||||
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
||||||
#include "cef/libcef/common/net/url_util.h"
|
#include "cef/libcef/common/net/url_util.h"
|
||||||
#include "cef/libcef/features/features.h"
|
|
||||||
#include "chrome/browser/task_manager/web_contents_tags.h"
|
#include "chrome/browser/task_manager/web_contents_tags.h"
|
||||||
#include "chrome/browser/ui/tab_helpers.h"
|
#include "chrome/browser/ui/tab_helpers.h"
|
||||||
#include "components/find_in_page/find_tab_helper.h"
|
#include "components/find_in_page/find_tab_helper.h"
|
||||||
@ -26,34 +20,10 @@
|
|||||||
#include "pdf/pdf_features.h"
|
#include "pdf/pdf_features.h"
|
||||||
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
|
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "cef/libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
|
|
||||||
#include "cef/libcef/features/runtime_checks.h"
|
|
||||||
#include "chrome/browser/printing/printing_init.h"
|
|
||||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
|
||||||
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
|
|
||||||
#include "components/permissions/permission_request_manager.h"
|
|
||||||
#include "components/zoom/zoom_controller.h"
|
|
||||||
#include "extensions/browser/extension_registry.h"
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char kAttachedHelpersUserDataKey[] = "CefAttachedHelpers";
|
const char kAttachedHelpersUserDataKey[] = "CefAttachedHelpers";
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
const extensions::Extension* GetExtensionForUrl(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const GURL& url) {
|
|
||||||
auto* registry = extensions::ExtensionRegistry::Get(browser_context);
|
|
||||||
if (!registry) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
std::string extension_id = url.host();
|
|
||||||
return registry->enabled_extensions().GetByID(extension_id);
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
|
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
|
||||||
@ -73,38 +43,7 @@ content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
|
|||||||
CefRequestContextImpl::GetBrowserContext(create_params.request_context);
|
CefRequestContextImpl::GetBrowserContext(create_params.request_context);
|
||||||
CHECK(browser_context);
|
CHECK(browser_context);
|
||||||
|
|
||||||
scoped_refptr<content::SiteInstance> site_instance;
|
content::WebContents::CreateParams wc_create_params(browser_context, nullptr);
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (extensions::ExtensionsEnabled() && !create_params.url.empty()) {
|
|
||||||
GURL gurl = url_util::MakeGURL(create_params.url, /*fixup=*/true);
|
|
||||||
if (!create_params.extension) {
|
|
||||||
// We might be loading an extension app view where the extension URL is
|
|
||||||
// provided by the client.
|
|
||||||
create_params.extension = GetExtensionForUrl(browser_context, gurl);
|
|
||||||
}
|
|
||||||
if (create_params.extension) {
|
|
||||||
if (create_params.extension_host_type ==
|
|
||||||
extensions::mojom::ViewType::kInvalid) {
|
|
||||||
// Default to popup behavior.
|
|
||||||
create_params.extension_host_type =
|
|
||||||
extensions::mojom::ViewType::kExtensionPopup;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extension resources will fail to load if we don't use a SiteInstance
|
|
||||||
// associated with the extension.
|
|
||||||
// (AlloyContentBrowserClient::SiteInstanceGotProcessAndSite 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(gurl);
|
|
||||||
DCHECK(site_instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
content::WebContents::CreateParams wc_create_params(browser_context,
|
|
||||||
site_instance);
|
|
||||||
|
|
||||||
if (IsWindowless()) {
|
if (IsWindowless()) {
|
||||||
// Create the OSR view for the WebContents.
|
// Create the OSR view for the WebContents.
|
||||||
@ -154,27 +93,7 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
|
|||||||
->SetOwnedWebContents(new_contents.release());
|
->SetOwnedWebContents(new_contents.release());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (extension_host_) {
|
|
||||||
extension_host_->AddNewContents(source, std::move(new_contents), target_url,
|
|
||||||
disposition, window_features, user_gesture,
|
|
||||||
was_blocked);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool CefBrowserPlatformDelegateAlloy::
|
|
||||||
ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
bool is_main_frame_navigation) {
|
|
||||||
if (extension_host_) {
|
|
||||||
return extension_host_->ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
is_main_frame_navigation);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
|
void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
|
||||||
ConfigureAutoResize();
|
ConfigureAutoResize();
|
||||||
@ -200,55 +119,9 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
|||||||
std::make_unique<AlloyWebContentsDialogHelper>(web_contents_, this);
|
std::make_unique<AlloyWebContentsDialogHelper>(web_contents_, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
|
|
||||||
const extensions::Extension* extension,
|
|
||||||
const GURL& url,
|
|
||||||
extensions::mojom::ViewType host_type) {
|
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
|
||||||
DCHECK(primary_);
|
|
||||||
|
|
||||||
// Should get WebContentsCreated and BrowserCreated calls first.
|
|
||||||
DCHECK(web_contents_);
|
|
||||||
DCHECK(browser_);
|
|
||||||
DCHECK(!extension_host_);
|
|
||||||
|
|
||||||
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(browser_.get());
|
|
||||||
|
|
||||||
if (host_type == extensions::mojom::ViewType::kExtensionPopup) {
|
|
||||||
// Create an extension host that we own.
|
|
||||||
extension_host_ = new extensions::CefExtensionViewHost(
|
|
||||||
alloy_browser.get(), extension, web_contents_, url, host_type);
|
|
||||||
// Trigger load of the extension URL.
|
|
||||||
extension_host_->CreateRendererSoon();
|
|
||||||
} else if (host_type ==
|
|
||||||
extensions::mojom::ViewType::kExtensionBackgroundPage) {
|
|
||||||
is_background_host_ = true;
|
|
||||||
alloy_browser->is_background_host_ = true;
|
|
||||||
// Create an extension host that will be owned by ProcessManager.
|
|
||||||
extension_host_ = new extensions::CefExtensionBackgroundHost(
|
|
||||||
alloy_browser.get(),
|
|
||||||
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
|
|
||||||
weak_ptr_factory_.GetWeakPtr()),
|
|
||||||
extension, web_contents_, url, host_type);
|
|
||||||
// Load will be triggered by ProcessManager::CreateBackgroundHost.
|
|
||||||
} else {
|
|
||||||
DCHECK(false) << " Unsupported extension host type: " << host_type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
|
|
||||||
const {
|
|
||||||
return extension_host_;
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
|
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
|
||||||
CefBrowserHostBase* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
if (primary_) {
|
if (primary_) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
DestroyExtensionHost();
|
|
||||||
#endif
|
|
||||||
owned_web_contents_.reset();
|
owned_web_contents_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,25 +163,6 @@ void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool CefBrowserPlatformDelegateAlloy::PreHandleGestureEvent(
|
|
||||||
content::WebContents* source,
|
|
||||||
const blink::WebGestureEvent& event) {
|
|
||||||
if (extension_host_) {
|
|
||||||
return extension_host_->PreHandleGestureEvent(source, event);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateAlloy::IsNeverComposited(
|
|
||||||
content::WebContents* web_contents) {
|
|
||||||
if (extension_host_) {
|
|
||||||
return extension_host_->IsNeverComposited(web_contents);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled(
|
void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled(
|
||||||
bool enabled,
|
bool enabled,
|
||||||
const CefSize& min_size,
|
const CefSize& min_size,
|
||||||
@ -404,34 +258,6 @@ void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
|
|||||||
owned_web_contents_.reset(owned_contents);
|
owned_web_contents_.reset(owned_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() {
|
|
||||||
if (!extension_host_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (extension_host_->extension_host_type() ==
|
|
||||||
extensions::mojom::ViewType::kExtensionBackgroundPage) {
|
|
||||||
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 CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() {
|
|
||||||
DCHECK(is_background_host_);
|
|
||||||
DCHECK(extension_host_);
|
|
||||||
extension_host_ = nullptr;
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::AttachHelpers(
|
void CefBrowserPlatformDelegateAlloy::AttachHelpers(
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
// If already attached, nothing to be done.
|
// If already attached, nothing to be done.
|
||||||
@ -445,21 +271,6 @@ void CefBrowserPlatformDelegateAlloy::AttachHelpers(
|
|||||||
web_contents->SetUserData(&kAttachedHelpersUserDataKey,
|
web_contents->SetUserData(&kAttachedHelpersUserDataKey,
|
||||||
std::make_unique<base::SupportsUserData::Data>());
|
std::make_unique<base::SupportsUserData::Data>());
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Create all the helpers.
|
|
||||||
if (cef::IsAlloyRuntimeEnabled()) {
|
|
||||||
find_in_page::FindTabHelper::CreateForWebContents(web_contents);
|
|
||||||
permissions::PermissionRequestManager::CreateForWebContents(web_contents);
|
|
||||||
PrefsTabHelper::CreateForWebContents(web_contents);
|
|
||||||
printing::InitializePrintingForWebContents(web_contents);
|
|
||||||
zoom::ZoomController::CreateForWebContents(web_contents);
|
|
||||||
|
|
||||||
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
|
|
||||||
web_contents, CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
|
|
||||||
web_contents));
|
|
||||||
} else
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
{
|
|
||||||
if (IsWindowless()) {
|
if (IsWindowless()) {
|
||||||
// Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate
|
// Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate
|
||||||
// which is not called for windowless browsers. Needs to be done before
|
// which is not called for windowless browsers. Needs to be done before
|
||||||
@ -477,4 +288,3 @@ void CefBrowserPlatformDelegateAlloy::AttachHelpers(
|
|||||||
// Make the tab show up in the task manager.
|
// Make the tab show up in the task manager.
|
||||||
task_manager::WebContentsTags::CreateForTabContents(web_contents);
|
task_manager::WebContentsTags::CreateForTabContents(web_contents);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -33,29 +33,14 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|||||||
const blink::mojom::WindowFeatures& window_features,
|
const blink::mojom::WindowFeatures& window_features,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool* was_blocked) override;
|
bool* was_blocked) override;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
bool is_main_frame_navigation) override;
|
|
||||||
#endif
|
|
||||||
void RenderViewReady() override;
|
void RenderViewReady() override;
|
||||||
void BrowserCreated(CefBrowserHostBase* browser) override;
|
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
void CreateExtensionHost(const extensions::Extension* extension,
|
|
||||||
const GURL& url,
|
|
||||||
extensions::mojom::ViewType host_type) override;
|
|
||||||
extensions::ExtensionHost* GetExtensionHost() const override;
|
|
||||||
#endif
|
|
||||||
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
|
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
|
||||||
const override;
|
const override;
|
||||||
void SendCaptureLostEvent() override;
|
void SendCaptureLostEvent() override;
|
||||||
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
|
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
|
||||||
void NotifyMoveOrResizeStarted() override;
|
void NotifyMoveOrResizeStarted() override;
|
||||||
#endif
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool PreHandleGestureEvent(content::WebContents* source,
|
|
||||||
const blink::WebGestureEvent& event) override;
|
|
||||||
bool IsNeverComposited(content::WebContents* web_contents) override;
|
|
||||||
#endif
|
#endif
|
||||||
bool IsAlloyStyle() const override { return true; }
|
bool IsAlloyStyle() const override { return true; }
|
||||||
void SetAutoResizeEnabled(bool enabled,
|
void SetAutoResizeEnabled(bool enabled,
|
||||||
@ -89,11 +74,6 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|||||||
private:
|
private:
|
||||||
void SetOwnedWebContents(content::WebContents* owned_contents);
|
void SetOwnedWebContents(content::WebContents* owned_contents);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
void DestroyExtensionHost();
|
|
||||||
void OnExtensionHostDeleted();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ConfigureAutoResize();
|
void ConfigureAutoResize();
|
||||||
|
|
||||||
// Attach all the associated helpers that are needed for the WebContents. It
|
// Attach all the associated helpers that are needed for the WebContents. It
|
||||||
@ -113,12 +93,6 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|||||||
// matches, the find selection rectangle, etc.
|
// matches, the find selection rectangle, etc.
|
||||||
find_in_page::FindNotificationDetails last_search_result_;
|
find_in_page::FindNotificationDetails last_search_result_;
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Used when the browser is hosting an extension.
|
|
||||||
raw_ptr<extensions::ExtensionHost> extension_host_ = nullptr;
|
|
||||||
bool is_background_host_ = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Used with auto-resize.
|
// Used with auto-resize.
|
||||||
bool auto_resize_enabled_ = false;
|
bool auto_resize_enabled_ = false;
|
||||||
gfx::Size auto_resize_min_;
|
gfx::Size auto_resize_min_;
|
||||||
|
@ -1,468 +0,0 @@
|
|||||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions (c) 2011 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 "cef/libcef/browser/alloy/chrome_browser_process_alloy.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "base/command_line.h"
|
|
||||||
#include "base/path_service.h"
|
|
||||||
#include "cef/libcef/browser/alloy/chrome_profile_manager_alloy.h"
|
|
||||||
#include "cef/libcef/browser/browser_context.h"
|
|
||||||
#include "cef/libcef/browser/context.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extensions_browser_client.h"
|
|
||||||
#include "cef/libcef/browser/prefs/browser_prefs.h"
|
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
|
||||||
#include "cef/libcef/common/cef_switches.h"
|
|
||||||
#include "cef/libcef/common/extensions/extensions_client.h"
|
|
||||||
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
||||||
#include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
|
|
||||||
#include "chrome/browser/net/system_network_context_manager.h"
|
|
||||||
#include "chrome/browser/permissions/chrome_permissions_client.h"
|
|
||||||
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
|
|
||||||
#include "chrome/browser/printing/background_printing_manager.h"
|
|
||||||
#include "chrome/browser/printing/print_job_manager.h"
|
|
||||||
#include "chrome/browser/printing/print_preview_dialog_controller.h"
|
|
||||||
#include "chrome/browser/ui/prefs/pref_watcher.h"
|
|
||||||
#include "chrome/common/chrome_paths.h"
|
|
||||||
#include "components/component_updater/component_updater_service.h"
|
|
||||||
#include "components/component_updater/timer_update_scheduler.h"
|
|
||||||
#include "components/net_log/chrome_net_log.h"
|
|
||||||
#include "components/os_crypt/async/browser/os_crypt_async.h"
|
|
||||||
#include "components/prefs/pref_service.h"
|
|
||||||
#include "content/browser/startup_helper.h"
|
|
||||||
#include "content/public/browser/network_service_instance.h"
|
|
||||||
#include "content/public/common/content_switches.h"
|
|
||||||
#include "net/log/net_log_capture_mode.h"
|
|
||||||
#include "services/network/public/cpp/network_switches.h"
|
|
||||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
#include "components/os_crypt/async/browser/dpapi_key_provider.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy() : locale_("en-US") {}
|
|
||||||
|
|
||||||
ChromeBrowserProcessAlloy::~ChromeBrowserProcessAlloy() {
|
|
||||||
DCHECK((!initialized_ && !context_initialized_) || shutdown_);
|
|
||||||
|
|
||||||
if (extensions::ExtensionsEnabled()) {
|
|
||||||
extensions::ExtensionsBrowserClient::Set(nullptr);
|
|
||||||
extensions_browser_client_.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::Initialize() {
|
|
||||||
DCHECK(!initialized_);
|
|
||||||
DCHECK(!context_initialized_);
|
|
||||||
DCHECK(!shutdown_);
|
|
||||||
DCHECK(!field_trial_list_);
|
|
||||||
|
|
||||||
// Initialize this early before any code tries to check feature flags.
|
|
||||||
field_trial_list_ = content::SetUpFieldTrialsAndFeatureList();
|
|
||||||
|
|
||||||
if (extensions::ExtensionsEnabled()) {
|
|
||||||
// Initialize extension global objects before creating the global
|
|
||||||
// BrowserContext.
|
|
||||||
extensions_client_ = std::make_unique<extensions::CefExtensionsClient>();
|
|
||||||
extensions::ExtensionsClient::Set(extensions_client_.get());
|
|
||||||
extensions_browser_client_ =
|
|
||||||
std::make_unique<extensions::CefExtensionsBrowserClient>();
|
|
||||||
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure permissions client has been set.
|
|
||||||
ChromePermissionsClient::GetInstance();
|
|
||||||
|
|
||||||
initialized_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::OnContextInitialized() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
DCHECK(initialized_);
|
|
||||||
DCHECK(!context_initialized_);
|
|
||||||
DCHECK(!shutdown_);
|
|
||||||
|
|
||||||
// OSCryptAsync provider configuration. If empty, this delegates all
|
|
||||||
// encryption operations to OSCrypt.
|
|
||||||
std::vector<std::pair<size_t, std::unique_ptr<os_crypt_async::KeyProvider>>>
|
|
||||||
providers;
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
// The DPAPI key provider requires OSCrypt::Init to have already been called
|
|
||||||
// to initialize the key storage. This happens in
|
|
||||||
// AlloyBrowserMainParts::PreCreateMainMessageLoop.
|
|
||||||
providers.emplace_back(std::make_pair(
|
|
||||||
/*precedence=*/10u,
|
|
||||||
std::make_unique<os_crypt_async::DPAPIKeyProvider>(local_state())));
|
|
||||||
#endif // BUILDFLAG(IS_WIN)
|
|
||||||
|
|
||||||
os_crypt_async_ =
|
|
||||||
std::make_unique<os_crypt_async::OSCryptAsync>(std::move(providers));
|
|
||||||
|
|
||||||
// Trigger async initialization of OSCrypt key providers.
|
|
||||||
std::ignore = os_crypt_async_->GetInstance(base::DoNothing());
|
|
||||||
|
|
||||||
// Must be created after the NotificationService.
|
|
||||||
print_job_manager_ = std::make_unique<printing::PrintJobManager>();
|
|
||||||
profile_manager_ = std::make_unique<ChromeProfileManagerAlloy>();
|
|
||||||
event_router_forwarder_ = new extensions::EventRouterForwarder();
|
|
||||||
context_initialized_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::CleanupOnUIThread() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
DCHECK(initialized_);
|
|
||||||
DCHECK(context_initialized_);
|
|
||||||
DCHECK(!shutdown_);
|
|
||||||
|
|
||||||
// Wait for the pending print jobs to finish. Don't do this later, since
|
|
||||||
// this might cause a nested message loop to run, and we don't want pending
|
|
||||||
// tasks to run once teardown has started.
|
|
||||||
print_job_manager_->Shutdown();
|
|
||||||
print_job_manager_.reset(nullptr);
|
|
||||||
print_preview_dialog_controller_ = nullptr;
|
|
||||||
|
|
||||||
profile_manager_.reset();
|
|
||||||
event_router_forwarder_ = nullptr;
|
|
||||||
|
|
||||||
if (SystemNetworkContextManager::GetInstance()) {
|
|
||||||
SystemNetworkContextManager::DeleteInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release any references held by objects associated with a Profile. The
|
|
||||||
// Profile will be deleted later.
|
|
||||||
for (const auto& browser_context : CefBrowserContext::GetAll()) {
|
|
||||||
// Release any references to |local_state_|.
|
|
||||||
auto profile = browser_context->AsProfile();
|
|
||||||
PrefWatcher* pref_watcher = PrefWatcher::Get(profile);
|
|
||||||
if (pref_watcher) {
|
|
||||||
pref_watcher->Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unregister observers for |background_printing_manager_|.
|
|
||||||
if (background_printing_manager_) {
|
|
||||||
background_printing_manager_->DeletePreviewContentsForBrowserContext(
|
|
||||||
profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
os_crypt_async_.reset();
|
|
||||||
local_state_.reset();
|
|
||||||
browser_policy_connector_.reset();
|
|
||||||
background_printing_manager_.reset();
|
|
||||||
field_trial_list_.reset();
|
|
||||||
component_updater_.reset();
|
|
||||||
|
|
||||||
shutdown_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::EndSession() {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::FlushLocalStateAndReply(
|
|
||||||
base::OnceClosure reply) {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
metrics_services_manager::MetricsServicesManager*
|
|
||||||
ChromeBrowserProcessAlloy::GetMetricsServicesManager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
metrics::MetricsService* ChromeBrowserProcessAlloy::metrics_service() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemNetworkContextManager*
|
|
||||||
ChromeBrowserProcessAlloy::system_network_context_manager() {
|
|
||||||
DCHECK(SystemNetworkContextManager::GetInstance());
|
|
||||||
return SystemNetworkContextManager::GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
network::NetworkQualityTracker*
|
|
||||||
ChromeBrowserProcessAlloy::network_quality_tracker() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
embedder_support::OriginTrialsSettingsStorage*
|
|
||||||
ChromeBrowserProcessAlloy::GetOriginTrialsSettingsStorage() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfileManager* ChromeBrowserProcessAlloy::profile_manager() {
|
|
||||||
DCHECK(context_initialized_);
|
|
||||||
return profile_manager_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefService* ChromeBrowserProcessAlloy::local_state() {
|
|
||||||
DCHECK(initialized_);
|
|
||||||
if (!local_state_) {
|
|
||||||
base::FilePath user_data_path;
|
|
||||||
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
|
|
||||||
DCHECK(!user_data_path.empty());
|
|
||||||
|
|
||||||
// Used for very early NetworkService initialization.
|
|
||||||
// Always persist preferences for this PrefService if possible because it
|
|
||||||
// contains the cookie encryption key on Windows.
|
|
||||||
local_state_ =
|
|
||||||
browser_prefs::CreatePrefService(nullptr /* profile */, user_data_path,
|
|
||||||
true /* persist_user_preferences */);
|
|
||||||
}
|
|
||||||
return local_state_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<network::SharedURLLoaderFactory>
|
|
||||||
ChromeBrowserProcessAlloy::shared_url_loader_factory() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
variations::VariationsService* ChromeBrowserProcessAlloy::variations_service() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
BrowserProcessPlatformPart* ChromeBrowserProcessAlloy::platform_part() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions::EventRouterForwarder*
|
|
||||||
ChromeBrowserProcessAlloy::extension_event_router_forwarder() {
|
|
||||||
DCHECK(context_initialized_);
|
|
||||||
return event_router_forwarder_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationUIManager* ChromeBrowserProcessAlloy::notification_ui_manager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationPlatformBridge*
|
|
||||||
ChromeBrowserProcessAlloy::notification_platform_bridge() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::ChromeBrowserPolicyConnector*
|
|
||||||
ChromeBrowserProcessAlloy::browser_policy_connector() {
|
|
||||||
if (!browser_policy_connector_) {
|
|
||||||
browser_policy_connector_ =
|
|
||||||
std::make_unique<policy::ChromeBrowserPolicyConnector>();
|
|
||||||
}
|
|
||||||
return browser_policy_connector_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
policy::PolicyService* ChromeBrowserProcessAlloy::policy_service() {
|
|
||||||
return browser_policy_connector()->GetPolicyService();
|
|
||||||
}
|
|
||||||
|
|
||||||
IconManager* ChromeBrowserProcessAlloy::icon_manager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpuModeManager* ChromeBrowserProcessAlloy::gpu_mode_manager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::CreateDevToolsProtocolHandler() {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::CreateDevToolsAutoOpener() {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeBrowserProcessAlloy::IsShuttingDown() {
|
|
||||||
DCHECK(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
printing::PrintJobManager* ChromeBrowserProcessAlloy::print_job_manager() {
|
|
||||||
DCHECK(context_initialized_);
|
|
||||||
return print_job_manager_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
printing::PrintPreviewDialogController*
|
|
||||||
ChromeBrowserProcessAlloy::print_preview_dialog_controller() {
|
|
||||||
if (!print_preview_dialog_controller_) {
|
|
||||||
print_preview_dialog_controller_ =
|
|
||||||
std::make_unique<printing::PrintPreviewDialogController>();
|
|
||||||
}
|
|
||||||
return print_preview_dialog_controller_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
printing::BackgroundPrintingManager*
|
|
||||||
ChromeBrowserProcessAlloy::background_printing_manager() {
|
|
||||||
if (!background_printing_manager_.get()) {
|
|
||||||
background_printing_manager_ =
|
|
||||||
std::make_unique<printing::BackgroundPrintingManager>();
|
|
||||||
}
|
|
||||||
return background_printing_manager_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
IntranetRedirectDetector*
|
|
||||||
ChromeBrowserProcessAlloy::intranet_redirect_detector() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& ChromeBrowserProcessAlloy::GetApplicationLocale() {
|
|
||||||
DCHECK(!locale_.empty());
|
|
||||||
return locale_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::SetApplicationLocale(
|
|
||||||
const std::string& locale) {
|
|
||||||
locale_ = locale;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadStatusUpdater* ChromeBrowserProcessAlloy::download_status_updater() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadRequestLimiter* ChromeBrowserProcessAlloy::download_request_limiter() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
||||||
BackgroundModeManager* ChromeBrowserProcessAlloy::background_mode_manager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::set_background_mode_manager_for_test(
|
|
||||||
std::unique_ptr<BackgroundModeManager> manager) {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
StatusTray* ChromeBrowserProcessAlloy::status_tray() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_browsing::SafeBrowsingService*
|
|
||||||
ChromeBrowserProcessAlloy::safe_browsing_service() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
subresource_filter::RulesetService*
|
|
||||||
ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
subresource_filter::RulesetService*
|
|
||||||
ChromeBrowserProcessAlloy::fingerprinting_protection_ruleset_service() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
StartupData* ChromeBrowserProcessAlloy::startup_data() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
|
||||||
void ChromeBrowserProcessAlloy::StartAutoupdateTimer() {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
component_updater::ComponentUpdateService*
|
|
||||||
ChromeBrowserProcessAlloy::component_updater() {
|
|
||||||
if (component_updater_) {
|
|
||||||
return component_updater_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<component_updater::UpdateScheduler> scheduler =
|
|
||||||
std::make_unique<component_updater::TimerUpdateScheduler>();
|
|
||||||
|
|
||||||
component_updater_ = component_updater::ComponentUpdateServiceFactory(
|
|
||||||
component_updater::MakeChromeComponentUpdaterConfigurator(
|
|
||||||
base::CommandLine::ForCurrentProcess(),
|
|
||||||
g_browser_process->local_state()),
|
|
||||||
std::move(scheduler), /*brand=*/std::string());
|
|
||||||
|
|
||||||
return component_updater_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaFileSystemRegistry*
|
|
||||||
ChromeBrowserProcessAlloy::media_file_system_registry() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtcLogUploader* ChromeBrowserProcessAlloy::webrtc_log_uploader() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
network_time::NetworkTimeTracker*
|
|
||||||
ChromeBrowserProcessAlloy::network_time_tracker() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
gcm::GCMDriver* ChromeBrowserProcessAlloy::gcm_driver() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
resource_coordinator::TabManager* ChromeBrowserProcessAlloy::GetTabManager() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
resource_coordinator::ResourceCoordinatorParts*
|
|
||||||
ChromeBrowserProcessAlloy::resource_coordinator_parts() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
os_crypt_async::OSCryptAsync* ChromeBrowserProcessAlloy::os_crypt_async() {
|
|
||||||
DCHECK(os_crypt_async_);
|
|
||||||
return os_crypt_async_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserProcessAlloy::set_additional_os_crypt_async_provider_for_test(
|
|
||||||
size_t precedence,
|
|
||||||
std::unique_ptr<os_crypt_async::KeyProvider> provider) {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildState* ChromeBrowserProcessAlloy::GetBuildState() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SerialPolicyAllowedPorts*
|
|
||||||
ChromeBrowserProcessAlloy::serial_policy_allowed_ports() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
HidSystemTrayIcon* ChromeBrowserProcessAlloy::hid_system_tray_icon() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
UsbSystemTrayIcon* ChromeBrowserProcessAlloy::usb_system_tray_icon() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions (c) 2011 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.
|
|
||||||
|
|
||||||
// This file provides a stub implementation of Chrome's BrowserProcess object
|
|
||||||
// for use as an interop layer between CEF and files that live in chrome/.
|
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "base/metrics/field_trial.h"
|
|
||||||
#include "chrome/browser/browser_process.h"
|
|
||||||
#include "chrome/browser/extensions/event_router_forwarder.h"
|
|
||||||
#include "media/media_buildflags.h"
|
|
||||||
|
|
||||||
namespace extensions {
|
|
||||||
class ExtensionsBrowserClient;
|
|
||||||
class ExtensionsClient;
|
|
||||||
} // namespace extensions
|
|
||||||
|
|
||||||
class ChromeProfileManagerAlloy;
|
|
||||||
|
|
||||||
class BackgroundModeManager {
|
|
||||||
public:
|
|
||||||
BackgroundModeManager();
|
|
||||||
|
|
||||||
BackgroundModeManager(const BackgroundModeManager&) = delete;
|
|
||||||
BackgroundModeManager& operator=(const BackgroundModeManager&) = delete;
|
|
||||||
|
|
||||||
virtual ~BackgroundModeManager();
|
|
||||||
};
|
|
||||||
|
|
||||||
class ChromeBrowserProcessAlloy : public BrowserProcess {
|
|
||||||
public:
|
|
||||||
ChromeBrowserProcessAlloy();
|
|
||||||
|
|
||||||
ChromeBrowserProcessAlloy(const ChromeBrowserProcessAlloy&) = delete;
|
|
||||||
ChromeBrowserProcessAlloy& operator=(const ChromeBrowserProcessAlloy&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
~ChromeBrowserProcessAlloy() override;
|
|
||||||
|
|
||||||
void Initialize();
|
|
||||||
void OnContextInitialized();
|
|
||||||
void CleanupOnUIThread();
|
|
||||||
|
|
||||||
// BrowserProcess implementation.
|
|
||||||
void EndSession() override;
|
|
||||||
void FlushLocalStateAndReply(base::OnceClosure reply) override;
|
|
||||||
metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
|
|
||||||
override;
|
|
||||||
metrics::MetricsService* metrics_service() override;
|
|
||||||
SystemNetworkContextManager* system_network_context_manager() override;
|
|
||||||
network::NetworkQualityTracker* network_quality_tracker() override;
|
|
||||||
embedder_support::OriginTrialsSettingsStorage*
|
|
||||||
GetOriginTrialsSettingsStorage() override;
|
|
||||||
ProfileManager* profile_manager() override;
|
|
||||||
PrefService* local_state() override;
|
|
||||||
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory()
|
|
||||||
override;
|
|
||||||
variations::VariationsService* variations_service() override;
|
|
||||||
BrowserProcessPlatformPart* platform_part() override;
|
|
||||||
extensions::EventRouterForwarder* extension_event_router_forwarder() override;
|
|
||||||
NotificationUIManager* notification_ui_manager() override;
|
|
||||||
NotificationPlatformBridge* notification_platform_bridge() override;
|
|
||||||
policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
|
|
||||||
policy::PolicyService* policy_service() override;
|
|
||||||
IconManager* icon_manager() override;
|
|
||||||
GpuModeManager* gpu_mode_manager() override;
|
|
||||||
void CreateDevToolsProtocolHandler() override;
|
|
||||||
void CreateDevToolsAutoOpener() override;
|
|
||||||
bool IsShuttingDown() override;
|
|
||||||
printing::PrintJobManager* print_job_manager() override;
|
|
||||||
printing::PrintPreviewDialogController* print_preview_dialog_controller()
|
|
||||||
override;
|
|
||||||
printing::BackgroundPrintingManager* background_printing_manager() override;
|
|
||||||
IntranetRedirectDetector* intranet_redirect_detector() override;
|
|
||||||
const std::string& GetApplicationLocale() override;
|
|
||||||
void SetApplicationLocale(const std::string& locale) override;
|
|
||||||
DownloadStatusUpdater* download_status_updater() override;
|
|
||||||
DownloadRequestLimiter* download_request_limiter() override;
|
|
||||||
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
||||||
BackgroundModeManager* background_mode_manager() override;
|
|
||||||
void set_background_mode_manager_for_test(
|
|
||||||
std::unique_ptr<BackgroundModeManager> manager) override;
|
|
||||||
#endif
|
|
||||||
StatusTray* status_tray() override;
|
|
||||||
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
|
|
||||||
subresource_filter::RulesetService* subresource_filter_ruleset_service()
|
|
||||||
override;
|
|
||||||
subresource_filter::RulesetService*
|
|
||||||
fingerprinting_protection_ruleset_service() override;
|
|
||||||
StartupData* startup_data() override;
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
|
||||||
void StartAutoupdateTimer() override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
component_updater::ComponentUpdateService* component_updater() override;
|
|
||||||
MediaFileSystemRegistry* media_file_system_registry() override;
|
|
||||||
WebRtcLogUploader* webrtc_log_uploader() override;
|
|
||||||
network_time::NetworkTimeTracker* network_time_tracker() override;
|
|
||||||
gcm::GCMDriver* gcm_driver() override;
|
|
||||||
resource_coordinator::TabManager* GetTabManager() override;
|
|
||||||
resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
|
|
||||||
override;
|
|
||||||
os_crypt_async::OSCryptAsync* os_crypt_async() override;
|
|
||||||
void set_additional_os_crypt_async_provider_for_test(
|
|
||||||
size_t precedence,
|
|
||||||
std::unique_ptr<os_crypt_async::KeyProvider> provider) override;
|
|
||||||
BuildState* GetBuildState() override;
|
|
||||||
SerialPolicyAllowedPorts* serial_policy_allowed_ports() override;
|
|
||||||
HidSystemTrayIcon* hid_system_tray_icon() override;
|
|
||||||
UsbSystemTrayIcon* usb_system_tray_icon() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool initialized_ = false;
|
|
||||||
bool context_initialized_ = false;
|
|
||||||
bool shutdown_ = false;
|
|
||||||
|
|
||||||
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
|
||||||
std::unique_ptr<extensions::ExtensionsBrowserClient>
|
|
||||||
extensions_browser_client_;
|
|
||||||
|
|
||||||
std::string locale_;
|
|
||||||
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
|
|
||||||
std::unique_ptr<ChromeProfileManagerAlloy> profile_manager_;
|
|
||||||
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
|
|
||||||
std::unique_ptr<printing::PrintPreviewDialogController>
|
|
||||||
print_preview_dialog_controller_;
|
|
||||||
std::unique_ptr<printing::BackgroundPrintingManager>
|
|
||||||
background_printing_manager_;
|
|
||||||
std::unique_ptr<PrefService> local_state_;
|
|
||||||
|
|
||||||
// Must be destroyed after |local_state_|.
|
|
||||||
std::unique_ptr<policy::ChromeBrowserPolicyConnector>
|
|
||||||
browser_policy_connector_;
|
|
||||||
std::unique_ptr<base::FieldTrialList> field_trial_list_;
|
|
||||||
|
|
||||||
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
|
|
||||||
|
|
||||||
std::unique_ptr<os_crypt_async::OSCryptAsync> os_crypt_async_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_BROWSER_PROCESS_ALLOY_H_
|
|
@ -1,156 +0,0 @@
|
|||||||
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions 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.
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/chrome_profile_alloy.h"
|
|
||||||
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "base/no_destructor.h"
|
|
||||||
#include "components/profile_metrics/browser_profile_type.h"
|
|
||||||
#include "components/variations/variations_client.h"
|
|
||||||
#include "components/variations/variations_ids_provider.h"
|
|
||||||
#include "net/url_request/url_request_context.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class CefVariationsClient : public variations::VariationsClient {
|
|
||||||
public:
|
|
||||||
explicit CefVariationsClient(content::BrowserContext* browser_context)
|
|
||||||
: browser_context_(browser_context) {}
|
|
||||||
|
|
||||||
~CefVariationsClient() override = default;
|
|
||||||
|
|
||||||
bool IsOffTheRecord() const override {
|
|
||||||
return browser_context_->IsOffTheRecord();
|
|
||||||
}
|
|
||||||
|
|
||||||
variations::mojom::VariationsHeadersPtr GetVariationsHeaders()
|
|
||||||
const override {
|
|
||||||
return variations::VariationsIdsProvider::GetInstance()
|
|
||||||
->GetClientDataHeaders(false /* is_signed_in */);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
raw_ptr<content::BrowserContext> browser_context_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ChromeProfileAlloy::ChromeProfileAlloy() : Profile(nullptr) {
|
|
||||||
// Alloy contexts are never flagged as off-the-record. It causes problems
|
|
||||||
// for the extension system.
|
|
||||||
DCHECK(!IsOffTheRecord());
|
|
||||||
|
|
||||||
profile_metrics::SetBrowserProfileType(
|
|
||||||
this, profile_metrics::BrowserProfileType::kRegular);
|
|
||||||
}
|
|
||||||
|
|
||||||
ChromeProfileAlloy::~ChromeProfileAlloy() = default;
|
|
||||||
|
|
||||||
variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() {
|
|
||||||
if (!variations_client_) {
|
|
||||||
variations_client_ = std::make_unique<CefVariationsClient>(this);
|
|
||||||
}
|
|
||||||
return variations_client_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() {
|
|
||||||
DCHECK(false);
|
|
||||||
return scoped_refptr<base::SequencedTaskRunner>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ChromeProfileAlloy::GetProfileUserName() const {
|
|
||||||
DCHECK(false);
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
|
|
||||||
const Profile::OTRProfileID& otr_profile_id,
|
|
||||||
bool create_if_needed) {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileAlloy::HasOffTheRecordProfile(
|
|
||||||
const Profile::OTRProfileID& otr_profile_id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileAlloy::HasAnyOffTheRecordProfile() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Profile* ChromeProfileAlloy::GetOriginalProfile() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Profile* ChromeProfileAlloy::GetOriginalProfile() const {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileAlloy::IsChild() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionSpecialStoragePolicy*
|
|
||||||
ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
|
|
||||||
DCHECK(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
base::Time ChromeProfileAlloy::GetStartTime() const {
|
|
||||||
DCHECK(false);
|
|
||||||
return base::Time();
|
|
||||||
}
|
|
||||||
|
|
||||||
base::FilePath ChromeProfileAlloy::last_selected_directory() {
|
|
||||||
return last_selected_directory_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeProfileAlloy::set_last_selected_directory(
|
|
||||||
const base::FilePath& path) {
|
|
||||||
last_selected_directory_ = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
GURL ChromeProfileAlloy::GetHomePage() {
|
|
||||||
DCHECK(false);
|
|
||||||
return GURL();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileAlloy::WasCreatedByVersionOrLater(
|
|
||||||
const std::string& version) {
|
|
||||||
DCHECK(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
base::Time ChromeProfileAlloy::GetCreationTime() const {
|
|
||||||
DCHECK(false);
|
|
||||||
return base::Time();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeProfileAlloy::RecordPrimaryMainFrameNavigation() {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileAlloy::IsSignedIn() {
|
|
||||||
DCHECK(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions 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.
|
|
||||||
|
|
||||||
// This class gathers state related to a single user profile.
|
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
|
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
|
||||||
#include "chrome/browser/profiles/profile.h"
|
|
||||||
|
|
||||||
// This file provides a stub implementation of Chrome's Profile object for use
|
|
||||||
// as an interop layer between CEF and files that live in chrome/.
|
|
||||||
|
|
||||||
class ChromeProfileAlloy : public Profile {
|
|
||||||
public:
|
|
||||||
ChromeProfileAlloy();
|
|
||||||
|
|
||||||
ChromeProfileAlloy(const ChromeProfileAlloy&) = delete;
|
|
||||||
ChromeProfileAlloy& operator=(const ChromeProfileAlloy&) = delete;
|
|
||||||
|
|
||||||
~ChromeProfileAlloy() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Profile methods.
|
|
||||||
variations::VariationsClient* GetVariationsClient() override;
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override;
|
|
||||||
std::string GetProfileUserName() const override;
|
|
||||||
Profile* GetOffTheRecordProfile(const Profile::OTRProfileID& otr_profile_id,
|
|
||||||
bool create_if_needed) override;
|
|
||||||
std::vector<Profile*> GetAllOffTheRecordProfiles() override;
|
|
||||||
void DestroyOffTheRecordProfile(Profile* otr_profile) override;
|
|
||||||
bool HasOffTheRecordProfile(
|
|
||||||
const Profile::OTRProfileID& otr_profile_id) override;
|
|
||||||
bool HasAnyOffTheRecordProfile() override;
|
|
||||||
Profile* GetOriginalProfile() override;
|
|
||||||
const Profile* GetOriginalProfile() const override;
|
|
||||||
bool IsChild() const override;
|
|
||||||
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
|
|
||||||
bool IsSameOrParent(Profile* profile) override;
|
|
||||||
base::Time GetStartTime() const override;
|
|
||||||
base::FilePath last_selected_directory() override;
|
|
||||||
void set_last_selected_directory(const base::FilePath& path) override;
|
|
||||||
GURL GetHomePage() override;
|
|
||||||
bool WasCreatedByVersionOrLater(const std::string& version) override;
|
|
||||||
base::Time GetCreationTime() const override;
|
|
||||||
void SetCreationTimeForTesting(base::Time creation_time) override;
|
|
||||||
void RecordPrimaryMainFrameNavigation() override;
|
|
||||||
bool IsSignedIn() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<variations::VariationsClient> variations_client_;
|
|
||||||
base::FilePath last_selected_directory_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_ALLOY_H_
|
|
@ -1,59 +0,0 @@
|
|||||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions 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.
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/chrome_profile_manager_alloy.h"
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/browser_context.h"
|
|
||||||
#include "cef/libcef/browser/request_context_impl.h"
|
|
||||||
#include "cef/libcef/common/app_manager.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// Return the active browser context. This is primarily called from Chrome code
|
|
||||||
// that handles WebUI views and wishes to associate the view's data with a
|
|
||||||
// particular context (profile). Chrome stores multiple profiles in sub-
|
|
||||||
// directories of |user_data_dir| and then uses ProfileManager to track which
|
|
||||||
// profile (sub-directory name) was last active.
|
|
||||||
//
|
|
||||||
// TODO(cef): To most closely match Chrome behavior this should return the
|
|
||||||
// context for the currently active browser (e.g. the browser with input focus).
|
|
||||||
// Return the main context for now since we don't currently have a good way to
|
|
||||||
// determine that.
|
|
||||||
CefBrowserContext* GetActiveBrowserContext() {
|
|
||||||
auto request_context = static_cast<CefRequestContextImpl*>(
|
|
||||||
CefAppManager::Get()->GetGlobalRequestContext().get());
|
|
||||||
return request_context->GetBrowserContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ChromeProfileManagerAlloy::ChromeProfileManagerAlloy()
|
|
||||||
: ProfileManager(base::FilePath()) {}
|
|
||||||
|
|
||||||
ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() = default;
|
|
||||||
|
|
||||||
Profile* ChromeProfileManagerAlloy::GetProfile(
|
|
||||||
const base::FilePath& profile_dir) {
|
|
||||||
CefBrowserContext* browser_context =
|
|
||||||
CefBrowserContext::FromCachePath(profile_dir);
|
|
||||||
if (!browser_context) {
|
|
||||||
// ProfileManager makes assumptions about profile directory paths that do
|
|
||||||
// not match CEF usage. For example, the default Chrome profile name is
|
|
||||||
// "Default" so it will append that sub-directory name to an empty
|
|
||||||
// |user_data_dir| value and then call this method. Use the active context
|
|
||||||
// in cases such as this where we don't understand what ProfileManager is
|
|
||||||
// asking for.
|
|
||||||
browser_context = GetActiveBrowserContext();
|
|
||||||
}
|
|
||||||
return browser_context->AsProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChromeProfileManagerAlloy::IsValidProfile(const void* profile) {
|
|
||||||
if (!profile) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !!CefBrowserContext::FromBrowserContext(
|
|
||||||
static_cast<const content::BrowserContext*>(profile));
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
// Copyright (c) 2016 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions 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.
|
|
||||||
|
|
||||||
// This file provides a stub implementation of Chrome's ProfileManager object
|
|
||||||
// for use as an interop layer between CEF and files that live in chrome/.
|
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
|
|
||||||
|
|
||||||
#include "chrome/browser/profiles/profile_manager.h"
|
|
||||||
|
|
||||||
class ChromeProfileManagerAlloy : public ProfileManager {
|
|
||||||
public:
|
|
||||||
ChromeProfileManagerAlloy();
|
|
||||||
|
|
||||||
ChromeProfileManagerAlloy(const ChromeProfileManagerAlloy&) = delete;
|
|
||||||
ChromeProfileManagerAlloy& operator=(const ChromeProfileManagerAlloy&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
~ChromeProfileManagerAlloy() override;
|
|
||||||
|
|
||||||
Profile* GetProfile(const base::FilePath& profile_dir) override;
|
|
||||||
bool IsValidProfile(const void* profile) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_CHROME_PROFILE_MANAGER_ALLOY_H_
|
|
@ -1,46 +0,0 @@
|
|||||||
// Copyright 2024 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 "cef/libcef/browser/alloy/devtools/alloy_devtools_window_runner.h"
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/devtools/devtools_frontend.h"
|
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
|
||||||
|
|
||||||
void AlloyDevToolsWindowRunner::ShowDevTools(
|
|
||||||
CefBrowserHostBase* opener,
|
|
||||||
std::unique_ptr<CefShowDevToolsParams> params) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
if (devtools_frontend_) {
|
|
||||||
if (!params->inspect_element_at_.IsEmpty()) {
|
|
||||||
devtools_frontend_->InspectElementAt(params->inspect_element_at_.x,
|
|
||||||
params->inspect_element_at_.y);
|
|
||||||
}
|
|
||||||
devtools_frontend_->Focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto alloy_browser = AlloyBrowserHostImpl::FromBaseChecked(opener);
|
|
||||||
devtools_frontend_ = CefDevToolsFrontend::Show(
|
|
||||||
alloy_browser.get(), params->window_info_, params->client_,
|
|
||||||
params->settings_, params->inspect_element_at_,
|
|
||||||
base::BindOnce(&AlloyDevToolsWindowRunner::OnFrontEndDestroyed,
|
|
||||||
weak_ptr_factory_.GetWeakPtr()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyDevToolsWindowRunner::CloseDevTools() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
if (devtools_frontend_) {
|
|
||||||
devtools_frontend_->Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AlloyDevToolsWindowRunner::HasDevTools() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
return !!devtools_frontend_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyDevToolsWindowRunner::OnFrontEndDestroyed() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
devtools_frontend_ = nullptr;
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
// Copyright 2024 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_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "base/memory/weak_ptr.h"
|
|
||||||
#include "cef/libcef/browser/devtools/devtools_window_runner.h"
|
|
||||||
|
|
||||||
class CefDevToolsFrontend;
|
|
||||||
|
|
||||||
// Creates and runs a DevTools window instance. Only accessed on the UI thread.
|
|
||||||
class AlloyDevToolsWindowRunner : public CefDevToolsWindowRunner {
|
|
||||||
public:
|
|
||||||
AlloyDevToolsWindowRunner() = default;
|
|
||||||
|
|
||||||
AlloyDevToolsWindowRunner(const AlloyDevToolsWindowRunner&) = delete;
|
|
||||||
AlloyDevToolsWindowRunner& operator=(const AlloyDevToolsWindowRunner&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
// CefDevToolsWindowRunner methods:
|
|
||||||
void ShowDevTools(CefBrowserHostBase* opener,
|
|
||||||
std::unique_ptr<CefShowDevToolsParams> params) override;
|
|
||||||
void CloseDevTools() override;
|
|
||||||
bool HasDevTools() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void OnFrontEndDestroyed();
|
|
||||||
|
|
||||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
|
||||||
// destroyed.
|
|
||||||
raw_ptr<CefDevToolsFrontend> devtools_frontend_ = nullptr;
|
|
||||||
|
|
||||||
base::WeakPtrFactory<AlloyDevToolsWindowRunner> weak_ptr_factory_{this};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_ALLOY_DEVTOOLS_WINDOW_RUNNER_H_
|
|
@ -1,206 +0,0 @@
|
|||||||
// Copyright 2019 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 "cef/libcef/browser/alloy/devtools/devtools_file_manager.h"
|
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
|
||||||
#include "base/files/file_util.h"
|
|
||||||
#include "base/functional/bind.h"
|
|
||||||
#include "base/functional/callback.h"
|
|
||||||
#include "base/hash/md5.h"
|
|
||||||
#include "base/json/json_writer.h"
|
|
||||||
#include "base/json/values_util.h"
|
|
||||||
#include "base/lazy_instance.h"
|
|
||||||
#include "base/path_service.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
|
||||||
#include "base/task/sequenced_task_runner.h"
|
|
||||||
#include "base/task/thread_pool.h"
|
|
||||||
#include "base/values.h"
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
#include "chrome/common/pref_names.h"
|
|
||||||
#include "components/prefs/scoped_user_pref_update.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
base::LazyInstance<base::FilePath>::Leaky g_last_save_path =
|
|
||||||
LAZY_INSTANCE_INITIALIZER;
|
|
||||||
|
|
||||||
void WriteToFile(const base::FilePath& path, const std::string& content) {
|
|
||||||
DCHECK(!path.empty());
|
|
||||||
base::WriteFile(path, content.c_str(), content.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppendToFile(const base::FilePath& path, const std::string& content) {
|
|
||||||
DCHECK(!path.empty());
|
|
||||||
base::AppendToFile(path, std::string_view(content));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
CefDevToolsFileManager::CefDevToolsFileManager(
|
|
||||||
AlloyBrowserHostImpl* browser_impl,
|
|
||||||
PrefService* prefs)
|
|
||||||
: browser_impl_(browser_impl),
|
|
||||||
prefs_(prefs),
|
|
||||||
file_task_runner_(
|
|
||||||
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})),
|
|
||||||
weak_factory_(this) {}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::SaveToFile(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
bool save_as) {
|
|
||||||
Save(url, content, save_as,
|
|
||||||
base::BindOnce(&CefDevToolsFileManager::FileSavedAs,
|
|
||||||
weak_factory_.GetWeakPtr(), url),
|
|
||||||
base::BindOnce(&CefDevToolsFileManager::CanceledFileSaveAs,
|
|
||||||
weak_factory_.GetWeakPtr(), url));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::AppendToFile(const std::string& url,
|
|
||||||
const std::string& content) {
|
|
||||||
Append(url, content,
|
|
||||||
base::BindOnce(&CefDevToolsFileManager::AppendedTo,
|
|
||||||
weak_factory_.GetWeakPtr(), url));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::Save(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
bool save_as,
|
|
||||||
SaveCallback saveCallback,
|
|
||||||
CancelCallback cancelCallback) {
|
|
||||||
auto it = saved_files_.find(url);
|
|
||||||
if (it != saved_files_.end() && !save_as) {
|
|
||||||
SaveAsFileSelected(url, content, std::move(saveCallback), it->second);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const base::Value::Dict& file_map =
|
|
||||||
prefs_->GetDict(prefs::kDevToolsEditedFiles);
|
|
||||||
base::FilePath initial_path;
|
|
||||||
|
|
||||||
if (const base::Value* path_value = file_map.Find(base::MD5String(url))) {
|
|
||||||
std::optional<base::FilePath> path = base::ValueToFilePath(*path_value);
|
|
||||||
if (path) {
|
|
||||||
initial_path = std::move(*path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initial_path.empty()) {
|
|
||||||
GURL gurl(url);
|
|
||||||
std::string suggested_file_name =
|
|
||||||
gurl.is_valid() ? gurl.ExtractFileName() : url;
|
|
||||||
|
|
||||||
if (suggested_file_name.length() > 64) {
|
|
||||||
suggested_file_name = suggested_file_name.substr(0, 64);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_last_save_path.Pointer()->empty()) {
|
|
||||||
initial_path = g_last_save_path.Pointer()->DirName().AppendASCII(
|
|
||||||
suggested_file_name);
|
|
||||||
} else {
|
|
||||||
// Use the temp directory. It may be an empty value.
|
|
||||||
base::PathService::Get(base::DIR_TEMP, &initial_path);
|
|
||||||
initial_path = initial_path.AppendASCII(suggested_file_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
blink::mojom::FileChooserParams params;
|
|
||||||
params.mode = blink::mojom::FileChooserParams::Mode::kSave;
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
params.default_file_name = initial_path;
|
|
||||||
if (!initial_path.Extension().empty()) {
|
|
||||||
params.accept_types.push_back(CefString(initial_path.Extension()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
browser_impl_->RunFileChooserForBrowser(
|
|
||||||
params,
|
|
||||||
base::BindOnce(&CefDevToolsFileManager::SaveAsDialogDismissed,
|
|
||||||
weak_factory_.GetWeakPtr(), url, content,
|
|
||||||
std::move(saveCallback), std::move(cancelCallback)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::SaveAsDialogDismissed(
|
|
||||||
const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
SaveCallback saveCallback,
|
|
||||||
CancelCallback cancelCallback,
|
|
||||||
const std::vector<base::FilePath>& file_paths) {
|
|
||||||
if (file_paths.size() == 1) {
|
|
||||||
SaveAsFileSelected(url, content, std::move(saveCallback), file_paths[0]);
|
|
||||||
} else {
|
|
||||||
std::move(cancelCallback).Run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::SaveAsFileSelected(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
SaveCallback callback,
|
|
||||||
const base::FilePath& path) {
|
|
||||||
*g_last_save_path.Pointer() = path;
|
|
||||||
saved_files_[url] = path;
|
|
||||||
|
|
||||||
ScopedDictPrefUpdate update(prefs_, prefs::kDevToolsEditedFiles);
|
|
||||||
update->Set(base::MD5String(url), base::FilePathToValue(path));
|
|
||||||
std::string file_system_path = path.AsUTF8Unsafe();
|
|
||||||
std::move(callback).Run(file_system_path);
|
|
||||||
file_task_runner_->PostTask(FROM_HERE,
|
|
||||||
base::BindOnce(&::WriteToFile, path, content));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::FileSavedAs(const std::string& url,
|
|
||||||
const std::string& file_system_path) {
|
|
||||||
base::Value url_value(url);
|
|
||||||
base::Value file_system_path_value(file_system_path);
|
|
||||||
CallClientFunction("DevToolsAPI.savedURL", &url_value,
|
|
||||||
&file_system_path_value, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::CanceledFileSaveAs(const std::string& url) {
|
|
||||||
base::Value url_value(url);
|
|
||||||
CallClientFunction("DevToolsAPI.canceledSaveURL", &url_value, nullptr,
|
|
||||||
nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::Append(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
AppendCallback callback) {
|
|
||||||
auto it = saved_files_.find(url);
|
|
||||||
if (it == saved_files_.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::move(callback).Run();
|
|
||||||
file_task_runner_->PostTask(
|
|
||||||
FROM_HERE, base::BindOnce(&::AppendToFile, it->second, content));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::AppendedTo(const std::string& url) {
|
|
||||||
base::Value url_value(url);
|
|
||||||
CallClientFunction("DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFileManager::CallClientFunction(
|
|
||||||
const std::string& function_name,
|
|
||||||
const base::Value* arg1,
|
|
||||||
const base::Value* arg2,
|
|
||||||
const base::Value* arg3) {
|
|
||||||
std::string javascript = function_name + "(";
|
|
||||||
if (arg1) {
|
|
||||||
std::string json;
|
|
||||||
base::JSONWriter::Write(*arg1, &json);
|
|
||||||
javascript.append(json);
|
|
||||||
if (arg2) {
|
|
||||||
base::JSONWriter::Write(*arg2, &json);
|
|
||||||
javascript.append(", ").append(json);
|
|
||||||
if (arg3) {
|
|
||||||
base::JSONWriter::Write(*arg3, &json);
|
|
||||||
javascript.append(", ").append(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
javascript.append(");");
|
|
||||||
browser_impl_->web_contents()->GetPrimaryMainFrame()->ExecuteJavaScript(
|
|
||||||
base::UTF8ToUTF16(javascript), base::NullCallback());
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
// Copyright 2019 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_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "base/functional/callback_forward.h"
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "base/memory/weak_ptr.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
class FilePath;
|
|
||||||
class SequencedTaskRunner;
|
|
||||||
class Value;
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
class AlloyBrowserHostImpl;
|
|
||||||
class PrefService;
|
|
||||||
|
|
||||||
// File management helper for DevTools.
|
|
||||||
// Based on chrome/browser/devtools/devtools_ui_bindings.cc and
|
|
||||||
// chrome/browser/devtools/devtools_file_helper.cc.
|
|
||||||
class CefDevToolsFileManager {
|
|
||||||
public:
|
|
||||||
CefDevToolsFileManager(AlloyBrowserHostImpl* browser_impl,
|
|
||||||
PrefService* prefs);
|
|
||||||
|
|
||||||
CefDevToolsFileManager(const CefDevToolsFileManager&) = delete;
|
|
||||||
CefDevToolsFileManager& operator=(const CefDevToolsFileManager&) = delete;
|
|
||||||
|
|
||||||
void SaveToFile(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
bool save_as);
|
|
||||||
void AppendToFile(const std::string& url, const std::string& content);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// SaveToFile implementation:
|
|
||||||
using SaveCallback = base::OnceCallback<void(const std::string&)>;
|
|
||||||
using CancelCallback = base::OnceCallback<void()>;
|
|
||||||
void Save(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
bool save_as,
|
|
||||||
SaveCallback saveCallback,
|
|
||||||
CancelCallback cancelCallback);
|
|
||||||
void SaveAsDialogDismissed(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
SaveCallback saveCallback,
|
|
||||||
CancelCallback cancelCallback,
|
|
||||||
const std::vector<base::FilePath>& file_paths);
|
|
||||||
void SaveAsFileSelected(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
SaveCallback callback,
|
|
||||||
const base::FilePath& path);
|
|
||||||
void FileSavedAs(const std::string& url, const std::string& file_system_path);
|
|
||||||
void CanceledFileSaveAs(const std::string& url);
|
|
||||||
|
|
||||||
// AppendToFile implementation:
|
|
||||||
using AppendCallback = base::OnceCallback<void(void)>;
|
|
||||||
void Append(const std::string& url,
|
|
||||||
const std::string& content,
|
|
||||||
AppendCallback callback);
|
|
||||||
void AppendedTo(const std::string& url);
|
|
||||||
|
|
||||||
void CallClientFunction(const std::string& function_name,
|
|
||||||
const base::Value* arg1,
|
|
||||||
const base::Value* arg2,
|
|
||||||
const base::Value* arg3);
|
|
||||||
|
|
||||||
// Guaranteed to outlive this object.
|
|
||||||
raw_ptr<AlloyBrowserHostImpl> browser_impl_;
|
|
||||||
raw_ptr<PrefService> prefs_;
|
|
||||||
|
|
||||||
using PathsMap = std::map<std::string, base::FilePath>;
|
|
||||||
PathsMap saved_files_;
|
|
||||||
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
|
|
||||||
base::WeakPtrFactory<CefDevToolsFileManager> weak_factory_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FILE_MANAGER_H_
|
|
@ -1,673 +0,0 @@
|
|||||||
// 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 "cef/libcef/browser/alloy/devtools/devtools_frontend.h"
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <iomanip>
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "base/base64.h"
|
|
||||||
#include "base/command_line.h"
|
|
||||||
#include "base/files/file_util.h"
|
|
||||||
#include "base/json/json_reader.h"
|
|
||||||
#include "base/json/json_writer.h"
|
|
||||||
#include "base/json/string_escape.h"
|
|
||||||
#include "base/memory/ptr_util.h"
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "base/strings/string_number_conversions.h"
|
|
||||||
#include "base/strings/string_util.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
|
||||||
#include "base/uuid.h"
|
|
||||||
#include "base/values.h"
|
|
||||||
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
|
||||||
#include "cef/libcef/browser/browser_context.h"
|
|
||||||
#include "cef/libcef/browser/net/devtools_scheme_handler.h"
|
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
|
||||||
#include "cef/libcef/common/cef_switches.h"
|
|
||||||
#include "cef/libcef/common/task_runner_manager.h"
|
|
||||||
#include "cef/libcef/features/runtime_checks.h"
|
|
||||||
#include "chrome/browser/profiles/profile.h"
|
|
||||||
#include "chrome/common/pref_names.h"
|
|
||||||
#include "components/prefs/scoped_user_pref_update.h"
|
|
||||||
#include "content/public/browser/browser_context.h"
|
|
||||||
#include "content/public/browser/browser_task_traits.h"
|
|
||||||
#include "content/public/browser/browser_thread.h"
|
|
||||||
#include "content/public/browser/file_url_loader.h"
|
|
||||||
#include "content/public/browser/navigation_handle.h"
|
|
||||||
#include "content/public/browser/render_frame_host.h"
|
|
||||||
#include "content/public/browser/render_view_host.h"
|
|
||||||
#include "content/public/browser/shared_cors_origin_access_list.h"
|
|
||||||
#include "content/public/browser/storage_partition.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "content/public/common/content_client.h"
|
|
||||||
#include "content/public/common/url_constants.h"
|
|
||||||
#include "content/public/common/url_utils.h"
|
|
||||||
#include "ipc/ipc_channel.h"
|
|
||||||
#include "net/base/completion_once_callback.h"
|
|
||||||
#include "net/base/io_buffer.h"
|
|
||||||
#include "net/base/net_errors.h"
|
|
||||||
#include "net/http/http_response_headers.h"
|
|
||||||
#include "net/traffic_annotation/network_traffic_annotation.h"
|
|
||||||
#include "services/network/public/cpp/simple_url_loader.h"
|
|
||||||
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
|
|
||||||
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
|
|
||||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
|
||||||
#include "storage/browser/file_system/native_file_util.h"
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
#include <windows.h>
|
|
||||||
#elif BUILDFLAG(IS_POSIX)
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// This constant should be in sync with the constant in
|
|
||||||
// chrome/browser/devtools/devtools_ui_bindings.cc.
|
|
||||||
constexpr size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
|
||||||
|
|
||||||
constexpr int kMaxLogLineLength = 1024;
|
|
||||||
|
|
||||||
static std::string GetFrontendURL() {
|
|
||||||
return base::StringPrintf("%s://%s/devtools_app.html",
|
|
||||||
content::kChromeDevToolsScheme,
|
|
||||||
scheme::kChromeDevToolsHost);
|
|
||||||
}
|
|
||||||
|
|
||||||
base::Value::Dict BuildObjectForResponse(const net::HttpResponseHeaders* rh,
|
|
||||||
bool success,
|
|
||||||
int net_error) {
|
|
||||||
base::Value::Dict response;
|
|
||||||
int responseCode = 200;
|
|
||||||
if (rh) {
|
|
||||||
responseCode = rh->response_code();
|
|
||||||
} else if (!success) {
|
|
||||||
// In case of no headers, assume file:// URL and failed to load
|
|
||||||
responseCode = 404;
|
|
||||||
}
|
|
||||||
response.Set("statusCode", responseCode);
|
|
||||||
response.Set("netError", net_error);
|
|
||||||
response.Set("netErrorName", net::ErrorToString(net_error));
|
|
||||||
|
|
||||||
base::Value::Dict headers;
|
|
||||||
size_t iterator = 0;
|
|
||||||
std::string name;
|
|
||||||
std::string value;
|
|
||||||
// TODO(caseq): this probably needs to handle duplicate header names
|
|
||||||
// correctly by folding them.
|
|
||||||
while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) {
|
|
||||||
headers.Set(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Set("headers", std::move(headers));
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WriteTimestamp(std::stringstream& stream) {
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
SYSTEMTIME local_time;
|
|
||||||
GetLocalTime(&local_time);
|
|
||||||
stream << std::setfill('0') << std::setw(2) << local_time.wMonth
|
|
||||||
<< std::setw(2) << local_time.wDay << '/' << std::setw(2)
|
|
||||||
<< local_time.wHour << std::setw(2) << local_time.wMinute
|
|
||||||
<< std::setw(2) << local_time.wSecond << '.' << std::setw(3)
|
|
||||||
<< local_time.wMilliseconds;
|
|
||||||
#elif BUILDFLAG(IS_POSIX)
|
|
||||||
timeval tv;
|
|
||||||
gettimeofday(&tv, nullptr);
|
|
||||||
time_t t = tv.tv_sec;
|
|
||||||
struct tm local_time;
|
|
||||||
localtime_r(&t, &local_time);
|
|
||||||
struct tm* tm_time = &local_time;
|
|
||||||
stream << std::setfill('0') << std::setw(2) << 1 + tm_time->tm_mon
|
|
||||||
<< std::setw(2) << tm_time->tm_mday << '/' << std::setw(2)
|
|
||||||
<< tm_time->tm_hour << std::setw(2) << tm_time->tm_min << std::setw(2)
|
|
||||||
<< tm_time->tm_sec << '.' << std::setw(6) << tv.tv_usec;
|
|
||||||
#else
|
|
||||||
#error Unsupported platform
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void LogProtocolMessage(const base::FilePath& log_file,
|
|
||||||
ProtocolMessageType type,
|
|
||||||
std::string to_log) {
|
|
||||||
// Track if logging has failed, in which case we don't keep trying.
|
|
||||||
static bool log_error = false;
|
|
||||||
if (log_error) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (storage::NativeFileUtil::EnsureFileExists(log_file, nullptr) !=
|
|
||||||
base::File::FILE_OK) {
|
|
||||||
LOG(ERROR) << "Failed to create file " << log_file.value();
|
|
||||||
log_error = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string type_label;
|
|
||||||
switch (type) {
|
|
||||||
case ProtocolMessageType::METHOD:
|
|
||||||
type_label = "METHOD";
|
|
||||||
break;
|
|
||||||
case ProtocolMessageType::RESULT:
|
|
||||||
type_label = "RESULT";
|
|
||||||
break;
|
|
||||||
case ProtocolMessageType::EVENT:
|
|
||||||
type_label = "EVENT";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream stream;
|
|
||||||
WriteTimestamp(stream);
|
|
||||||
stream << ": " << type_label << ": " << to_log << "\n";
|
|
||||||
const std::string& str = stream.str();
|
|
||||||
if (!base::AppendToFile(log_file, std::string_view(str))) {
|
|
||||||
LOG(ERROR) << "Failed to write file " << log_file.value();
|
|
||||||
log_error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class CefDevToolsFrontend::NetworkResourceLoader
|
|
||||||
: public network::SimpleURLLoaderStreamConsumer {
|
|
||||||
public:
|
|
||||||
NetworkResourceLoader(int stream_id,
|
|
||||||
CefDevToolsFrontend* bindings,
|
|
||||||
std::unique_ptr<network::SimpleURLLoader> loader,
|
|
||||||
network::mojom::URLLoaderFactory* url_loader_factory,
|
|
||||||
int request_id)
|
|
||||||
: stream_id_(stream_id),
|
|
||||||
bindings_(bindings),
|
|
||||||
loader_(std::move(loader)),
|
|
||||||
request_id_(request_id) {
|
|
||||||
loader_->SetOnResponseStartedCallback(base::BindOnce(
|
|
||||||
&NetworkResourceLoader::OnResponseStarted, base::Unretained(this)));
|
|
||||||
loader_->DownloadAsStream(url_loader_factory, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkResourceLoader(const NetworkResourceLoader&) = delete;
|
|
||||||
NetworkResourceLoader& operator=(const NetworkResourceLoader&) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void OnResponseStarted(const GURL& final_url,
|
|
||||||
const network::mojom::URLResponseHead& response_head) {
|
|
||||||
response_headers_ = response_head.headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDataReceived(std::string_view chunk,
|
|
||||||
base::OnceClosure resume) override {
|
|
||||||
base::Value chunkValue;
|
|
||||||
|
|
||||||
bool encoded = !base::IsStringUTF8(chunk);
|
|
||||||
if (encoded) {
|
|
||||||
chunkValue = base::Value(base::Base64Encode(chunk));
|
|
||||||
} else {
|
|
||||||
chunkValue = base::Value(chunk);
|
|
||||||
}
|
|
||||||
base::Value id(stream_id_);
|
|
||||||
base::Value encodedValue(encoded);
|
|
||||||
|
|
||||||
bindings_->CallClientFunction("DevToolsAPI", "streamWrite", std::move(id),
|
|
||||||
std::move(chunkValue),
|
|
||||||
std::move(encodedValue));
|
|
||||||
std::move(resume).Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnComplete(bool success) override {
|
|
||||||
auto response = BuildObjectForResponse(response_headers_.get(), success,
|
|
||||||
loader_->NetError());
|
|
||||||
bindings_->SendMessageAck(request_id_, std::move(response));
|
|
||||||
|
|
||||||
bindings_->loaders_.erase(bindings_->loaders_.find(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnRetry(base::OnceClosure start_retry) override { DCHECK(false); }
|
|
||||||
|
|
||||||
const int stream_id_;
|
|
||||||
const raw_ptr<CefDevToolsFrontend> bindings_;
|
|
||||||
std::unique_ptr<network::SimpleURLLoader> loader_;
|
|
||||||
int request_id_;
|
|
||||||
scoped_refptr<net::HttpResponseHeaders> response_headers_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// static
|
|
||||||
CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
|
||||||
AlloyBrowserHostImpl* inspected_browser,
|
|
||||||
const CefWindowInfo& windowInfo,
|
|
||||||
CefRefPtr<CefClient> client,
|
|
||||||
const CefBrowserSettings& settings,
|
|
||||||
const CefPoint& inspect_element_at,
|
|
||||||
base::OnceClosure frontend_destroyed_callback) {
|
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
|
||||||
|
|
||||||
CefBrowserSettings new_settings = settings;
|
|
||||||
if (!windowInfo.windowless_rendering_enabled &&
|
|
||||||
CefColorGetA(new_settings.background_color) != SK_AlphaOPAQUE) {
|
|
||||||
// Use white as the default background color for windowed DevTools instead
|
|
||||||
// of the CefSettings.background_color value.
|
|
||||||
new_settings.background_color = SK_ColorWHITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefBrowserCreateParams create_params;
|
|
||||||
create_params.MaybeSetWindowInfo(windowInfo, /*allow_alloy_style=*/true,
|
|
||||||
/*allow_chrome_style=*/false);
|
|
||||||
|
|
||||||
if (inspected_browser->is_views_hosted()) {
|
|
||||||
create_params.popup_with_views_hosted_opener = true;
|
|
||||||
}
|
|
||||||
create_params.popup_with_alloy_style_opener = true;
|
|
||||||
|
|
||||||
create_params.client = client;
|
|
||||||
create_params.settings = new_settings;
|
|
||||||
create_params.devtools_opener = inspected_browser;
|
|
||||||
create_params.request_context = inspected_browser->GetRequestContext();
|
|
||||||
create_params.extra_info = inspected_browser->browser_info()->extra_info();
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> frontend_browser =
|
|
||||||
AlloyBrowserHostImpl::Create(create_params);
|
|
||||||
|
|
||||||
content::WebContents* inspected_contents = inspected_browser->web_contents();
|
|
||||||
|
|
||||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
|
||||||
// destroyed.
|
|
||||||
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
|
|
||||||
frontend_browser.get(), inspected_contents, inspect_element_at,
|
|
||||||
std::move(frontend_destroyed_callback));
|
|
||||||
|
|
||||||
// Need to load the URL after creating the DevTools objects.
|
|
||||||
frontend_browser->GetMainFrame()->LoadURL(GetFrontendURL());
|
|
||||||
|
|
||||||
return devtools_frontend;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::Activate() {
|
|
||||||
frontend_browser_->ActivateContents(web_contents());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::Focus() {
|
|
||||||
frontend_browser_->SetFocus(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::InspectElementAt(int x, int y) {
|
|
||||||
if (inspect_element_at_.x != x || inspect_element_at_.y != y) {
|
|
||||||
inspect_element_at_.Set(x, y);
|
|
||||||
}
|
|
||||||
if (agent_host_) {
|
|
||||||
agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(), x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::Close() {
|
|
||||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::CloseBrowser,
|
|
||||||
frontend_browser_.get(), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
CefDevToolsFrontend::CefDevToolsFrontend(
|
|
||||||
AlloyBrowserHostImpl* frontend_browser,
|
|
||||||
content::WebContents* inspected_contents,
|
|
||||||
const CefPoint& inspect_element_at,
|
|
||||||
base::OnceClosure frontend_destroyed_callback)
|
|
||||||
: content::WebContentsObserver(frontend_browser->web_contents()),
|
|
||||||
frontend_browser_(frontend_browser),
|
|
||||||
inspected_contents_(inspected_contents),
|
|
||||||
inspect_element_at_(inspect_element_at),
|
|
||||||
frontend_destroyed_callback_(std::move(frontend_destroyed_callback)),
|
|
||||||
file_manager_(frontend_browser, GetPrefs()),
|
|
||||||
protocol_log_file_(
|
|
||||||
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
|
||||||
switches::kDevToolsProtocolLogFile)),
|
|
||||||
weak_factory_(this) {
|
|
||||||
DCHECK(!frontend_destroyed_callback_.is_null());
|
|
||||||
}
|
|
||||||
|
|
||||||
CefDevToolsFrontend::~CefDevToolsFrontend() = default;
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::ReadyToCommitNavigation(
|
|
||||||
content::NavigationHandle* navigation_handle) {
|
|
||||||
content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost();
|
|
||||||
if (navigation_handle->IsInMainFrame()) {
|
|
||||||
frontend_host_ = content::DevToolsFrontendHost::Create(
|
|
||||||
frame, base::BindRepeating(
|
|
||||||
&CefDevToolsFrontend::HandleMessageFromDevToolsFrontend,
|
|
||||||
base::Unretained(this)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string origin =
|
|
||||||
navigation_handle->GetURL().DeprecatedGetOriginAsURL().spec();
|
|
||||||
auto it = extensions_api_.find(origin);
|
|
||||||
if (it == extensions_api_.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::string script = base::StringPrintf(
|
|
||||||
"%s(\"%s\")", it->second.c_str(),
|
|
||||||
base::Uuid::GenerateRandomV4().AsLowercaseString().c_str());
|
|
||||||
content::DevToolsFrontendHost::SetupExtensionsAPI(frame, script);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::PrimaryMainDocumentElementAvailable() {
|
|
||||||
// Don't call AttachClient multiple times for the same DevToolsAgentHost.
|
|
||||||
// Otherwise it will call AgentHostClosed which closes the DevTools window.
|
|
||||||
// This may happen in cases where the DevTools content fails to load.
|
|
||||||
scoped_refptr<content::DevToolsAgentHost> agent_host =
|
|
||||||
content::DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
|
|
||||||
if (agent_host != agent_host_) {
|
|
||||||
if (agent_host_) {
|
|
||||||
agent_host_->DetachClient(this);
|
|
||||||
}
|
|
||||||
agent_host_ = agent_host;
|
|
||||||
agent_host_->AttachClient(this);
|
|
||||||
if (!inspect_element_at_.IsEmpty()) {
|
|
||||||
agent_host_->InspectElement(inspected_contents_->GetFocusedFrame(),
|
|
||||||
inspect_element_at_.x, inspect_element_at_.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::WebContentsDestroyed() {
|
|
||||||
if (agent_host_) {
|
|
||||||
agent_host_->DetachClient(this);
|
|
||||||
agent_host_ = nullptr;
|
|
||||||
}
|
|
||||||
std::move(frontend_destroyed_callback_).Run();
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
|
||||||
base::Value::Dict message) {
|
|
||||||
const std::string* method = message.FindString("method");
|
|
||||||
if (!method) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int request_id = message.FindInt("id").value_or(0);
|
|
||||||
base::Value::List* params_value = message.FindList("params");
|
|
||||||
|
|
||||||
// Since we've received message by value, we can take the list.
|
|
||||||
base::Value::List params;
|
|
||||||
if (params_value) {
|
|
||||||
params = std::move(*params_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*method == "dispatchProtocolMessage") {
|
|
||||||
if (params.size() < 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const std::string* protocol_message = params[0].GetIfString();
|
|
||||||
if (!agent_host_ || !protocol_message) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ProtocolLoggingEnabled()) {
|
|
||||||
LogProtocolMessage(ProtocolMessageType::METHOD, *protocol_message);
|
|
||||||
}
|
|
||||||
agent_host_->DispatchProtocolMessage(
|
|
||||||
this, base::as_bytes(base::make_span(*protocol_message)));
|
|
||||||
} else if (*method == "loadCompleted") {
|
|
||||||
web_contents()->GetPrimaryMainFrame()->ExecuteJavaScriptForTests(
|
|
||||||
u"DevToolsAPI.setUseSoftMenu(true);", base::NullCallback());
|
|
||||||
} else if (*method == "loadNetworkResource") {
|
|
||||||
if (params.size() < 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(pfeldman): handle some of the embedder messages in content.
|
|
||||||
const std::string* url = params[0].GetIfString();
|
|
||||||
const std::string* headers = params[1].GetIfString();
|
|
||||||
std::optional<const int> stream_id = params[2].GetIfInt();
|
|
||||||
if (!url || !headers || !stream_id.has_value()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GURL gurl(*url);
|
|
||||||
if (!gurl.is_valid()) {
|
|
||||||
base::Value::Dict response;
|
|
||||||
response.Set("statusCode", 404);
|
|
||||||
response.Set("urlValid", false);
|
|
||||||
SendMessageAck(request_id, std::move(response));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
net::NetworkTrafficAnnotationTag traffic_annotation =
|
|
||||||
net::DefineNetworkTrafficAnnotation(
|
|
||||||
"devtools_handle_front_end_messages", R"(
|
|
||||||
semantics {
|
|
||||||
sender: "Developer Tools"
|
|
||||||
description:
|
|
||||||
"When user opens Developer Tools, the browser may fetch "
|
|
||||||
"additional resources from the network to enrich the debugging "
|
|
||||||
"experience (e.g. source map resources)."
|
|
||||||
trigger: "User opens Developer Tools to debug a web page."
|
|
||||||
data: "Any resources requested by Developer Tools."
|
|
||||||
destination: OTHER
|
|
||||||
}
|
|
||||||
policy {
|
|
||||||
cookies_allowed: YES
|
|
||||||
cookies_store: "user"
|
|
||||||
setting:
|
|
||||||
"It's not possible to disable this feature from settings."
|
|
||||||
chrome_policy {
|
|
||||||
DeveloperToolsAvailability {
|
|
||||||
policy_options {mode: MANDATORY}
|
|
||||||
DeveloperToolsAvailability: 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})");
|
|
||||||
|
|
||||||
// Based on DevToolsUIBindings::LoadNetworkResource.
|
|
||||||
auto resource_request = std::make_unique<network::ResourceRequest>();
|
|
||||||
resource_request->url = gurl;
|
|
||||||
// TODO(caseq): this preserves behavior of URLFetcher-based
|
|
||||||
// implementation. We really need to pass proper first party origin from
|
|
||||||
// the front-end.
|
|
||||||
resource_request->site_for_cookies = net::SiteForCookies::FromUrl(gurl);
|
|
||||||
resource_request->headers.AddHeadersFromString(*headers);
|
|
||||||
|
|
||||||
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory;
|
|
||||||
if (gurl.SchemeIsFile()) {
|
|
||||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote =
|
|
||||||
content::CreateFileURLLoaderFactory(
|
|
||||||
base::FilePath() /* profile_path */,
|
|
||||||
nullptr /* shared_cors_origin_access_list */);
|
|
||||||
url_loader_factory = network::SharedURLLoaderFactory::Create(
|
|
||||||
std::make_unique<network::WrapperPendingSharedURLLoaderFactory>(
|
|
||||||
std::move(pending_remote)));
|
|
||||||
} else if (content::HasWebUIScheme(gurl)) {
|
|
||||||
base::Value::Dict response;
|
|
||||||
response.Set("statusCode", 403);
|
|
||||||
SendMessageAck(request_id, std::move(response));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
auto* partition =
|
|
||||||
inspected_contents_->GetPrimaryMainFrame()->GetStoragePartition();
|
|
||||||
url_loader_factory = partition->GetURLLoaderFactoryForBrowserProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto simple_url_loader = network::SimpleURLLoader::Create(
|
|
||||||
std::move(resource_request), traffic_annotation);
|
|
||||||
auto resource_loader = std::make_unique<NetworkResourceLoader>(
|
|
||||||
*stream_id, this, std::move(simple_url_loader),
|
|
||||||
url_loader_factory.get(), request_id);
|
|
||||||
loaders_.insert(std::move(resource_loader));
|
|
||||||
return;
|
|
||||||
} else if (*method == "getHostConfig") {
|
|
||||||
SendMessageAck(request_id, {});
|
|
||||||
return;
|
|
||||||
} else if (*method == "getPreferences") {
|
|
||||||
SendMessageAck(request_id,
|
|
||||||
GetPrefs()->GetDict(prefs::kDevToolsPreferences).Clone());
|
|
||||||
return;
|
|
||||||
} else if (*method == "setPreference") {
|
|
||||||
if (params.size() < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const std::string* name = params[0].GetIfString();
|
|
||||||
|
|
||||||
// We're just setting params[1] as a value anyways, so just make sure it's
|
|
||||||
// the type we want, but don't worry about getting it.
|
|
||||||
if (!name || !params[1].is_string()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopedDictPrefUpdate update(GetPrefs(), prefs::kDevToolsPreferences);
|
|
||||||
update->Set(*name, std::move(params[1]));
|
|
||||||
} else if (*method == "removePreference") {
|
|
||||||
const std::string* name = params[0].GetIfString();
|
|
||||||
if (!name) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ScopedDictPrefUpdate update(GetPrefs(), prefs::kDevToolsPreferences);
|
|
||||||
update->Remove(*name);
|
|
||||||
} else if (*method == "requestFileSystems") {
|
|
||||||
web_contents()->GetPrimaryMainFrame()->ExecuteJavaScriptForTests(
|
|
||||||
u"DevToolsAPI.fileSystemsLoaded([]);", base::NullCallback());
|
|
||||||
} else if (*method == "reattach") {
|
|
||||||
if (!agent_host_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
agent_host_->DetachClient(this);
|
|
||||||
agent_host_->AttachClient(this);
|
|
||||||
} else if (*method == "registerExtensionsAPI") {
|
|
||||||
if (params.size() < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const std::string* origin = params[0].GetIfString();
|
|
||||||
const std::string* script = params[1].GetIfString();
|
|
||||||
if (!origin || !script) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
extensions_api_[*origin + "/"] = *script;
|
|
||||||
} else if (*method == "save") {
|
|
||||||
if (params.size() < 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const std::string* url = params[0].GetIfString();
|
|
||||||
const std::string* content = params[1].GetIfString();
|
|
||||||
std::optional<bool> save_as = params[2].GetIfBool();
|
|
||||||
if (!url || !content || !save_as.has_value()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
file_manager_.SaveToFile(*url, *content, *save_as);
|
|
||||||
} else if (*method == "append") {
|
|
||||||
if (params.size() < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const std::string* url = params[0].GetIfString();
|
|
||||||
const std::string* content = params[1].GetIfString();
|
|
||||||
if (!url || !content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
file_manager_.AppendToFile(*url, *content);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request_id) {
|
|
||||||
SendMessageAck(request_id, base::Value::Dict());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::DispatchProtocolMessage(
|
|
||||||
content::DevToolsAgentHost* agent_host,
|
|
||||||
base::span<const uint8_t> message) {
|
|
||||||
if (!frontend_browser_->GetWebContents() ||
|
|
||||||
frontend_browser_->GetWebContents()->IsBeingDestroyed()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
|
|
||||||
message.size());
|
|
||||||
if (ProtocolLoggingEnabled()) {
|
|
||||||
// Quick check to avoid parsing the JSON object. Events begin with a
|
|
||||||
// "method" value whereas method results begin with an "id" value.
|
|
||||||
LogProtocolMessage(base::StartsWith(str_message, "{\"method\":")
|
|
||||||
? ProtocolMessageType::EVENT
|
|
||||||
: ProtocolMessageType::RESULT,
|
|
||||||
str_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (str_message.length() < kMaxMessageChunkSize) {
|
|
||||||
CallClientFunction("DevToolsAPI", "dispatchMessage",
|
|
||||||
base::Value(std::string(str_message)));
|
|
||||||
} else {
|
|
||||||
size_t total_size = str_message.length();
|
|
||||||
for (size_t pos = 0; pos < str_message.length();
|
|
||||||
pos += kMaxMessageChunkSize) {
|
|
||||||
std::string_view str_message_chunk =
|
|
||||||
str_message.substr(pos, kMaxMessageChunkSize);
|
|
||||||
|
|
||||||
CallClientFunction(
|
|
||||||
"DevToolsAPI", "dispatchMessageChunk",
|
|
||||||
base::Value(std::string(str_message_chunk)),
|
|
||||||
base::Value(base::NumberToString(pos ? 0 : total_size)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::CallClientFunction(
|
|
||||||
const std::string& object_name,
|
|
||||||
const std::string& method_name,
|
|
||||||
base::Value arg1,
|
|
||||||
base::Value arg2,
|
|
||||||
base::Value arg3,
|
|
||||||
base::OnceCallback<void(base::Value)> cb) {
|
|
||||||
std::string javascript;
|
|
||||||
|
|
||||||
web_contents()->GetPrimaryMainFrame()->AllowInjectingJavaScript();
|
|
||||||
|
|
||||||
base::Value::List arguments;
|
|
||||||
if (!arg1.is_none()) {
|
|
||||||
arguments.Append(std::move(arg1));
|
|
||||||
if (!arg2.is_none()) {
|
|
||||||
arguments.Append(std::move(arg2));
|
|
||||||
if (!arg3.is_none()) {
|
|
||||||
arguments.Append(std::move(arg3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
web_contents()->GetPrimaryMainFrame()->ExecuteJavaScriptMethod(
|
|
||||||
base::ASCIIToUTF16(object_name), base::ASCIIToUTF16(method_name),
|
|
||||||
std::move(arguments), std::move(cb));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::SendMessageAck(int request_id,
|
|
||||||
base::Value::Dict arg) {
|
|
||||||
CallClientFunction("DevToolsAPI", "embedderMessageAck",
|
|
||||||
base::Value(request_id), base::Value(std::move(arg)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefDevToolsFrontend::ProtocolLoggingEnabled() const {
|
|
||||||
return !protocol_log_file_.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::LogProtocolMessage(ProtocolMessageType type,
|
|
||||||
const std::string_view& message) {
|
|
||||||
DCHECK(ProtocolLoggingEnabled());
|
|
||||||
|
|
||||||
std::string to_log(message.substr(0, kMaxLogLineLength));
|
|
||||||
|
|
||||||
// Execute in an ordered context that allows blocking.
|
|
||||||
auto task_runner = CefTaskRunnerManager::Get()->GetBackgroundTaskRunner();
|
|
||||||
task_runner->PostTask(
|
|
||||||
FROM_HERE, base::BindOnce(::LogProtocolMessage, protocol_log_file_, type,
|
|
||||||
std::move(to_log)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDevToolsFrontend::AgentHostClosed(
|
|
||||||
content::DevToolsAgentHost* agent_host) {
|
|
||||||
DCHECK(agent_host == agent_host_.get());
|
|
||||||
agent_host_ = nullptr;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefService* CefDevToolsFrontend::GetPrefs() const {
|
|
||||||
return CefBrowserContext::FromBrowserContext(
|
|
||||||
frontend_browser_->web_contents()->GetBrowserContext())
|
|
||||||
->AsProfile()
|
|
||||||
->GetPrefs();
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
// 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_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "base/memory/ref_counted.h"
|
|
||||||
#include "base/memory/weak_ptr.h"
|
|
||||||
#include "base/values.h"
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
#include "cef/libcef/browser/alloy/devtools/devtools_file_manager.h"
|
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
|
||||||
#include "content/public/browser/devtools_frontend_host.h"
|
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
class Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class NavigationHandle;
|
|
||||||
class RenderViewHost;
|
|
||||||
class WebContents;
|
|
||||||
} // namespace content
|
|
||||||
|
|
||||||
class PrefService;
|
|
||||||
|
|
||||||
enum class ProtocolMessageType {
|
|
||||||
METHOD,
|
|
||||||
RESULT,
|
|
||||||
EVENT,
|
|
||||||
};
|
|
||||||
|
|
||||||
class CefDevToolsFrontend : public content::WebContentsObserver,
|
|
||||||
public content::DevToolsAgentHostClient {
|
|
||||||
public:
|
|
||||||
CefDevToolsFrontend(const CefDevToolsFrontend&) = delete;
|
|
||||||
CefDevToolsFrontend& operator=(const CefDevToolsFrontend&) = delete;
|
|
||||||
|
|
||||||
static CefDevToolsFrontend* Show(
|
|
||||||
AlloyBrowserHostImpl* inspected_browser,
|
|
||||||
const CefWindowInfo& windowInfo,
|
|
||||||
CefRefPtr<CefClient> client,
|
|
||||||
const CefBrowserSettings& settings,
|
|
||||||
const CefPoint& inspect_element_at,
|
|
||||||
base::OnceClosure frontend_destroyed_callback);
|
|
||||||
|
|
||||||
void Activate();
|
|
||||||
void Focus();
|
|
||||||
void InspectElementAt(int x, int y);
|
|
||||||
void Close();
|
|
||||||
|
|
||||||
void CallClientFunction(
|
|
||||||
const std::string& object_name,
|
|
||||||
const std::string& method_name,
|
|
||||||
const base::Value arg1 = {},
|
|
||||||
const base::Value arg2 = {},
|
|
||||||
const base::Value arg3 = {},
|
|
||||||
base::OnceCallback<void(base::Value)> cb = base::NullCallback());
|
|
||||||
|
|
||||||
private:
|
|
||||||
CefDevToolsFrontend(AlloyBrowserHostImpl* frontend_browser,
|
|
||||||
content::WebContents* inspected_contents,
|
|
||||||
const CefPoint& inspect_element_at,
|
|
||||||
base::OnceClosure destroyed_callback);
|
|
||||||
~CefDevToolsFrontend() override;
|
|
||||||
|
|
||||||
// content::DevToolsAgentHostClient implementation.
|
|
||||||
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
|
|
||||||
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
|
|
||||||
base::span<const uint8_t> message) override;
|
|
||||||
void HandleMessageFromDevToolsFrontend(base::Value::Dict message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// WebContentsObserver overrides
|
|
||||||
void ReadyToCommitNavigation(
|
|
||||||
content::NavigationHandle* navigation_handle) override;
|
|
||||||
void PrimaryMainDocumentElementAvailable() override;
|
|
||||||
void WebContentsDestroyed() override;
|
|
||||||
|
|
||||||
void SendMessageAck(int request_id, base::Value::Dict arg);
|
|
||||||
|
|
||||||
bool ProtocolLoggingEnabled() const;
|
|
||||||
void LogProtocolMessage(ProtocolMessageType type,
|
|
||||||
const std::string_view& message);
|
|
||||||
|
|
||||||
PrefService* GetPrefs() const;
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> frontend_browser_;
|
|
||||||
raw_ptr<content::WebContents> inspected_contents_;
|
|
||||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
|
||||||
CefPoint inspect_element_at_;
|
|
||||||
base::OnceClosure frontend_destroyed_callback_;
|
|
||||||
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
|
|
||||||
|
|
||||||
class NetworkResourceLoader;
|
|
||||||
std::set<std::unique_ptr<NetworkResourceLoader>, base::UniquePtrComparator>
|
|
||||||
loaders_;
|
|
||||||
|
|
||||||
using ExtensionsAPIs = std::map<std::string, std::string>;
|
|
||||||
ExtensionsAPIs extensions_api_;
|
|
||||||
CefDevToolsFileManager file_manager_;
|
|
||||||
|
|
||||||
const base::FilePath protocol_log_file_;
|
|
||||||
|
|
||||||
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
|
@ -1,148 +0,0 @@
|
|||||||
// 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 "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "base/atomicops.h"
|
|
||||||
#include "base/command_line.h"
|
|
||||||
#include "base/files/file_path.h"
|
|
||||||
#include "base/functional/bind.h"
|
|
||||||
#include "base/memory/ptr_util.h"
|
|
||||||
#include "base/strings/string_number_conversions.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
|
||||||
#include "build/build_config.h"
|
|
||||||
#include "cef/grit/cef_resources.h"
|
|
||||||
#include "content/public/browser/browser_context.h"
|
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
|
||||||
#include "content/public/browser/devtools_frontend_host.h"
|
|
||||||
#include "content/public/browser/devtools_socket_factory.h"
|
|
||||||
#include "content/public/browser/favicon_status.h"
|
|
||||||
#include "content/public/browser/navigation_entry.h"
|
|
||||||
#include "content/public/browser/render_view_host.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "content/public/common/content_switches.h"
|
|
||||||
#include "content/public/common/url_constants.h"
|
|
||||||
#include "content/public/common/user_agent.h"
|
|
||||||
#include "net/base/net_errors.h"
|
|
||||||
#include "net/log/net_log_source.h"
|
|
||||||
#include "net/socket/tcp_server_socket.h"
|
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const int kBackLog = 10;
|
|
||||||
|
|
||||||
class TCPServerSocketFactory : public content::DevToolsSocketFactory {
|
|
||||||
public:
|
|
||||||
TCPServerSocketFactory(const std::string& address, uint16_t port)
|
|
||||||
: address_(address), port_(port) {}
|
|
||||||
|
|
||||||
TCPServerSocketFactory(const TCPServerSocketFactory&) = delete;
|
|
||||||
TCPServerSocketFactory& operator=(const TCPServerSocketFactory&) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// content::DevToolsSocketFactory.
|
|
||||||
std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
|
|
||||||
std::unique_ptr<net::ServerSocket> socket(
|
|
||||||
new net::TCPServerSocket(nullptr, net::NetLogSource()));
|
|
||||||
if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) !=
|
|
||||||
net::OK) {
|
|
||||||
return std::unique_ptr<net::ServerSocket>();
|
|
||||||
}
|
|
||||||
return socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<net::ServerSocket> CreateForTethering(
|
|
||||||
std::string* out_name) override {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string address_;
|
|
||||||
uint16_t port_;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
|
|
||||||
const base::CommandLine& command_line =
|
|
||||||
*base::CommandLine::ForCurrentProcess();
|
|
||||||
// See if the user specified a port on the command line. Specifying 0 will
|
|
||||||
// result in the selection of an ephemeral port and the port number will be
|
|
||||||
// printed as part of the WebSocket endpoint URL to stderr. If a cache
|
|
||||||
// directory path is provided the port will also be written to the
|
|
||||||
// <cache-dir>/DevToolsActivePort file.
|
|
||||||
//
|
|
||||||
// It's not allowed to bind ports between 0 and 1024 exclusive because
|
|
||||||
// they're normally restricted to root on Posix-based systems.
|
|
||||||
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
|
|
||||||
int port = 0;
|
|
||||||
std::string port_str =
|
|
||||||
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
|
|
||||||
|
|
||||||
if (base::StringToInt(port_str, &port) &&
|
|
||||||
(0 == port || (port >= 1024 && port < 65535))) {
|
|
||||||
return std::unique_ptr<content::DevToolsSocketFactory>(
|
|
||||||
new TCPServerSocketFactory("127.0.0.1", port));
|
|
||||||
} else {
|
|
||||||
DLOG(WARNING) << "Invalid http debugger port number '" << port_str << "'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// CefDevToolsManagerDelegate ----------------------------------------------
|
|
||||||
|
|
||||||
// static
|
|
||||||
void CefDevToolsManagerDelegate::StartHttpHandler(
|
|
||||||
content::BrowserContext* browser_context) {
|
|
||||||
std::unique_ptr<content::DevToolsSocketFactory> socket_factory =
|
|
||||||
CreateSocketFactory();
|
|
||||||
if (!socket_factory) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
content::DevToolsAgentHost::StartRemoteDebuggingServer(
|
|
||||||
std::move(socket_factory), browser_context->GetPath(), base::FilePath());
|
|
||||||
|
|
||||||
const base::CommandLine& command_line =
|
|
||||||
*base::CommandLine::ForCurrentProcess();
|
|
||||||
if (command_line.HasSwitch(switches::kRemoteDebuggingPipe)) {
|
|
||||||
content::DevToolsAgentHost::StartRemoteDebuggingPipeHandler(
|
|
||||||
base::OnceClosure());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
void CefDevToolsManagerDelegate::StopHttpHandler() {
|
|
||||||
// This is a no-op if the server was never started.
|
|
||||||
content::DevToolsAgentHost::StopRemoteDebuggingServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
CefDevToolsManagerDelegate::CefDevToolsManagerDelegate() = default;
|
|
||||||
|
|
||||||
CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() = default;
|
|
||||||
|
|
||||||
scoped_refptr<content::DevToolsAgentHost>
|
|
||||||
CefDevToolsManagerDelegate::CreateNewTarget(
|
|
||||||
const GURL& url,
|
|
||||||
content::DevToolsManagerDelegate::TargetType target_type) {
|
|
||||||
// This is reached when the user selects "Open link in new tab" from the
|
|
||||||
// DevTools interface.
|
|
||||||
// TODO(cef): Consider exposing new API to support this.
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CefDevToolsManagerDelegate::GetDiscoveryPageHTML() {
|
|
||||||
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
|
|
||||||
IDR_CEF_DEVTOOLS_DISCOVERY_PAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefDevToolsManagerDelegate::HasBundledFrontendResources() {
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
// 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_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
|
||||||
|
|
||||||
#include "content/public/browser/devtools_manager_delegate.h"
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class BrowserContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
|
||||||
public:
|
|
||||||
static void StartHttpHandler(content::BrowserContext* browser_context);
|
|
||||||
static void StopHttpHandler();
|
|
||||||
|
|
||||||
CefDevToolsManagerDelegate();
|
|
||||||
|
|
||||||
CefDevToolsManagerDelegate(const CefDevToolsManagerDelegate&) = delete;
|
|
||||||
CefDevToolsManagerDelegate& operator=(const CefDevToolsManagerDelegate&) =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
~CefDevToolsManagerDelegate() override;
|
|
||||||
|
|
||||||
// DevToolsManagerDelegate implementation.
|
|
||||||
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(
|
|
||||||
const GURL& url,
|
|
||||||
content::DevToolsManagerDelegate::TargetType target_type) override;
|
|
||||||
std::string GetDiscoveryPageHTML() override;
|
|
||||||
bool HasBundledFrontendResources() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DEVTOOLS_DEVTOOLS_MANAGER_DELEGATE_H_
|
|
@ -1,57 +0,0 @@
|
|||||||
// Copyright 2022 The Chromium Embedded Framework Authors.
|
|
||||||
// Portions copyright 2020 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 "cef/libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h"
|
|
||||||
|
|
||||||
#include "base/logging.h"
|
|
||||||
#include "cef/libcef/browser/browser_host_base.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class AlloyJavaScriptTabModalDialogManagerDelegateDesktop
|
|
||||||
: public JavaScriptTabModalDialogManagerDelegateDesktop {
|
|
||||||
public:
|
|
||||||
explicit AlloyJavaScriptTabModalDialogManagerDelegateDesktop(
|
|
||||||
content::WebContents* web_contents)
|
|
||||||
: JavaScriptTabModalDialogManagerDelegateDesktop(web_contents),
|
|
||||||
web_contents_(web_contents) {}
|
|
||||||
|
|
||||||
AlloyJavaScriptTabModalDialogManagerDelegateDesktop(
|
|
||||||
const AlloyJavaScriptTabModalDialogManagerDelegateDesktop&) = delete;
|
|
||||||
AlloyJavaScriptTabModalDialogManagerDelegateDesktop& operator=(
|
|
||||||
const AlloyJavaScriptTabModalDialogManagerDelegateDesktop&) = delete;
|
|
||||||
|
|
||||||
// javascript_dialogs::TabModalDialogManagerDelegate methods:
|
|
||||||
void WillRunDialog() override {}
|
|
||||||
|
|
||||||
void DidCloseDialog() override {}
|
|
||||||
|
|
||||||
void SetTabNeedsAttention(bool attention) override {}
|
|
||||||
|
|
||||||
bool IsWebContentsForemost() override {
|
|
||||||
if (auto browser =
|
|
||||||
CefBrowserHostBase::GetBrowserForContents(web_contents_)) {
|
|
||||||
return browser->IsVisible();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsApp() override { return false; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// The WebContents for the tab over which the dialog will be modal. This may
|
|
||||||
// be different from the WebContents that requested the dialog, such as with
|
|
||||||
// Chrome app <webview>s.
|
|
||||||
raw_ptr<content::WebContents> web_contents_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
std::unique_ptr<JavaScriptTabModalDialogManagerDelegateDesktop>
|
|
||||||
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
|
|
||||||
content::WebContents* web_contents) {
|
|
||||||
return std::make_unique<AlloyJavaScriptTabModalDialogManagerDelegateDesktop>(
|
|
||||||
web_contents);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
// Copyright 2022 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_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "chrome/browser/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_desktop.h"
|
|
||||||
|
|
||||||
// Creates a JavaScriptTabModalDialogManagerDelegateDesktop for the Chrome
|
|
||||||
// environment.
|
|
||||||
std::unique_ptr<JavaScriptTabModalDialogManagerDelegateDesktop>
|
|
||||||
CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(
|
|
||||||
content::WebContents* web_contents);
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_DIALOGS_ALLOY_JAVASCRIPT_DIALOG_MANAGER_DELEGATE_H_
|
|
@ -43,8 +43,8 @@ constexpr inline CefBrowserContentsState operator|(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tracks state and executes client callbacks based on WebContents callbacks.
|
// Tracks state and executes client callbacks based on WebContents callbacks.
|
||||||
// Includes functionality that is shared by the alloy and chrome runtimes.
|
// Includes functionality that is shared by Alloy and Chrome styles. Only
|
||||||
// Only accessed on the UI thread.
|
// accessed on the UI thread.
|
||||||
class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||||
public content::WebContentsObserver {
|
public content::WebContentsObserver {
|
||||||
public:
|
public:
|
||||||
|
@ -365,35 +365,6 @@ void CefBrowserContext::ClearSchemeHandlerFactories() {
|
|||||||
iothread_state_));
|
iothread_state_));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
void CefBrowserContext::LoadExtension(
|
|
||||||
const CefString& root_directory,
|
|
||||||
CefRefPtr<CefDictionaryValue> manifest,
|
|
||||||
CefRefPtr<CefExtensionHandler> handler,
|
|
||||||
CefRefPtr<CefRequestContext> loader_context) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
if (handler) {
|
|
||||||
handler->OnExtensionLoadFailed(ERR_ABORTED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRefPtr<CefExtension> CefBrowserContext::GetExtension(
|
|
||||||
const CefString& extension_id) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
|
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
auto browser_context = AsBrowserContext();
|
auto browser_context = AsBrowserContext();
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "cef/include/cef_request_context_handler.h"
|
#include "cef/include/cef_request_context_handler.h"
|
||||||
#include "cef/libcef/browser/iothread_state.h"
|
#include "cef/libcef/browser/iothread_state.h"
|
||||||
#include "cef/libcef/browser/request_context_handler_map.h"
|
#include "cef/libcef/browser/request_context_handler_map.h"
|
||||||
#include "cef/libcef/features/features.h"
|
|
||||||
#include "chrome/common/plugin.mojom.h"
|
#include "chrome/common/plugin.mojom.h"
|
||||||
#include "services/network/public/mojom/network_context.mojom.h"
|
#include "services/network/public/mojom/network_context.mojom.h"
|
||||||
#include "ui/base/page_transition_types.h"
|
#include "ui/base/page_transition_types.h"
|
||||||
@ -161,18 +160,6 @@ class CefBrowserContext {
|
|||||||
CefRefPtr<CefSchemeHandlerFactory> factory);
|
CefRefPtr<CefSchemeHandlerFactory> factory);
|
||||||
void ClearSchemeHandlerFactories();
|
void ClearSchemeHandlerFactories();
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
virtual void LoadExtension(const CefString& root_directory,
|
|
||||||
CefRefPtr<CefDictionaryValue> manifest,
|
|
||||||
CefRefPtr<CefExtensionHandler> handler,
|
|
||||||
CefRefPtr<CefRequestContext> loader_context);
|
|
||||||
virtual bool GetExtensions(std::vector<CefString>& extension_ids);
|
|
||||||
virtual CefRefPtr<CefExtension> GetExtension(const CefString& extension_id);
|
|
||||||
|
|
||||||
// Called from CefExtensionImpl::Unload().
|
|
||||||
virtual bool UnloadExtension(const CefString& extension_id);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
|
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
|
||||||
// of visited links.
|
// of visited links.
|
||||||
virtual void AddVisitedURLs(const GURL& url,
|
virtual void AddVisitedURLs(const GURL& url,
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
// Copyright 2015 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 "cef/libcef/browser/browser_context_keyed_service_factories.h"
|
|
||||||
|
|
||||||
#include "base/feature_list.h"
|
|
||||||
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
||||||
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
|
||||||
#include "chrome/browser/first_party_sets/first_party_sets_policy_service_factory.h"
|
|
||||||
#include "chrome/browser/media/router/chrome_media_router_factory.h"
|
|
||||||
#include "chrome/browser/media/webrtc/media_device_salt_service_factory.h"
|
|
||||||
#include "chrome/browser/plugins/plugin_prefs_factory.h"
|
|
||||||
#include "chrome/browser/profiles/renderer_updater_factory.h"
|
|
||||||
#include "chrome/browser/reduce_accept_language/reduce_accept_language_factory.h"
|
|
||||||
#include "chrome/browser/spellchecker/spellcheck_factory.h"
|
|
||||||
#include "chrome/browser/themes/theme_service_factory.h"
|
|
||||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
|
||||||
#include "components/permissions/features.h"
|
|
||||||
#include "extensions/browser/api/alarms/alarm_manager.h"
|
|
||||||
#include "extensions/browser/api/storage/storage_frontend.h"
|
|
||||||
#include "extensions/browser/renderer_startup_helper.h"
|
|
||||||
#include "services/network/public/cpp/features.h"
|
|
||||||
|
|
||||||
namespace cef {
|
|
||||||
|
|
||||||
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
|
|
||||||
CookieSettingsFactory::GetInstance();
|
|
||||||
first_party_sets::FirstPartySetsPolicyServiceFactory::GetInstance();
|
|
||||||
MediaDeviceSaltServiceFactory::GetInstance();
|
|
||||||
media_router::ChromeMediaRouterFactory::GetInstance();
|
|
||||||
PluginPrefsFactory::GetInstance();
|
|
||||||
PrefsTabHelper::GetServiceInstance();
|
|
||||||
RendererUpdaterFactory::GetInstance();
|
|
||||||
SpellcheckServiceFactory::GetInstance();
|
|
||||||
ThemeServiceFactory::GetInstance();
|
|
||||||
|
|
||||||
if (extensions::ExtensionsEnabled()) {
|
|
||||||
extensions::AlarmManager::GetFactoryInstance();
|
|
||||||
extensions::RendererStartupHelperFactory::GetInstance();
|
|
||||||
extensions::StorageFrontend::GetFactoryInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (base::FeatureList::IsEnabled(network::features::kReduceAcceptLanguage)) {
|
|
||||||
ReduceAcceptLanguageFactory::GetInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace cef
|
|
@ -1,17 +0,0 @@
|
|||||||
// Copyright 2015 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_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
|
||||||
|
|
||||||
namespace cef {
|
|
||||||
|
|
||||||
// Ensures the existence of any BrowserContextKeyedServiceFactory provided by
|
|
||||||
// the CEF extensions code or otherwise required by CEF. See
|
|
||||||
// libcef/common/extensions/api/README.txt for additional details.
|
|
||||||
void EnsureBrowserContextKeyedServiceFactoriesBuilt();
|
|
||||||
|
|
||||||
} // namespace cef
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
|
@ -764,15 +764,6 @@ void CefBrowserHostBase::NotifyMoveOrResizeStarted() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefExtension> CefBrowserHostBase::GetExtension() {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserHostBase::IsBackgroundHost() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserHostBase::IsFullscreen() {
|
bool CefBrowserHostBase::IsFullscreen() {
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
DCHECK(false) << "called on invalid thread";
|
DCHECK(false) << "called on invalid thread";
|
||||||
|
@ -23,15 +23,6 @@
|
|||||||
#include "cef/libcef/browser/javascript_dialog_manager.h"
|
#include "cef/libcef/browser/javascript_dialog_manager.h"
|
||||||
#include "cef/libcef/browser/media_stream_registrar.h"
|
#include "cef/libcef/browser/media_stream_registrar.h"
|
||||||
#include "cef/libcef/browser/request_context_impl.h"
|
#include "cef/libcef/browser/request_context_impl.h"
|
||||||
#include "cef/libcef/features/features.h"
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "extensions/common/mojom/view_type.mojom.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace extensions {
|
|
||||||
class Extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RenderViewContextMenuObserver;
|
class RenderViewContextMenuObserver;
|
||||||
|
|
||||||
@ -78,7 +69,7 @@ struct CefBrowserCreateParams {
|
|||||||
bool IsWindowless() const;
|
bool IsWindowless() const;
|
||||||
|
|
||||||
// Platform-specific window creation info. Will be nullptr for Views-hosted
|
// Platform-specific window creation info. Will be nullptr for Views-hosted
|
||||||
// browsers except when using the Chrome runtime with a native parent handle.
|
// browsers except when using Chrome style with a native parent handle.
|
||||||
std::unique_ptr<CefWindowInfo> window_info;
|
std::unique_ptr<CefWindowInfo> window_info;
|
||||||
|
|
||||||
// The BrowserView that will own a Views-hosted browser. Will be nullptr for
|
// The BrowserView that will own a Views-hosted browser. Will be nullptr for
|
||||||
@ -91,7 +82,7 @@ struct CefBrowserCreateParams {
|
|||||||
bool popup_with_views_hosted_opener = false;
|
bool popup_with_views_hosted_opener = false;
|
||||||
|
|
||||||
// True if this browser is a popup and has an Alloy style opener. Only used
|
// True if this browser is a popup and has an Alloy style opener. Only used
|
||||||
// with the Chrome runtime.
|
// with Chrome style.
|
||||||
bool popup_with_alloy_style_opener = false;
|
bool popup_with_alloy_style_opener = false;
|
||||||
|
|
||||||
// Client implementation. May be nullptr.
|
// Client implementation. May be nullptr.
|
||||||
@ -104,12 +95,6 @@ struct CefBrowserCreateParams {
|
|||||||
// Browser settings.
|
// Browser settings.
|
||||||
CefBrowserSettings settings;
|
CefBrowserSettings settings;
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Other browser that opened this DevTools browser. Will be nullptr for non-
|
|
||||||
// DevTools browsers. Currently used with the alloy runtime only.
|
|
||||||
CefRefPtr<CefBrowserHostBase> devtools_opener;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Request context to use when creating the browser. If nullptr the global
|
// Request context to use when creating the browser. If nullptr the global
|
||||||
// request context will be used.
|
// request context will be used.
|
||||||
CefRefPtr<CefRequestContext> request_context;
|
CefRefPtr<CefRequestContext> request_context;
|
||||||
@ -117,19 +102,10 @@ struct CefBrowserCreateParams {
|
|||||||
// Extra information that will be passed to
|
// Extra information that will be passed to
|
||||||
// CefRenderProcessHandler::OnBrowserCreated.
|
// CefRenderProcessHandler::OnBrowserCreated.
|
||||||
CefRefPtr<CefDictionaryValue> extra_info;
|
CefRefPtr<CefDictionaryValue> extra_info;
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Used when explicitly creating the browser as an extension host via
|
|
||||||
// ProcessManager::CreateBackgroundHost. Currently used with the alloy
|
|
||||||
// runtime only.
|
|
||||||
raw_ptr<const extensions::Extension> extension = nullptr;
|
|
||||||
extensions::mojom::ViewType extension_host_type =
|
|
||||||
extensions::mojom::ViewType::kInvalid;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base class for CefBrowserHost implementations. Includes functionality that is
|
// Base class for CefBrowserHost implementations. Includes functionality that is
|
||||||
// shared by the alloy and chrome runtimes. All methods are thread-safe unless
|
// shared by Alloy and Chrome styles. All methods are thread-safe unless
|
||||||
// otherwise indicated.
|
// otherwise indicated.
|
||||||
class CefBrowserHostBase : public CefBrowserHost,
|
class CefBrowserHostBase : public CefBrowserHost,
|
||||||
public CefBrowser,
|
public CefBrowser,
|
||||||
@ -283,8 +259,6 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
bool current_only) override;
|
bool current_only) override;
|
||||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||||
void NotifyMoveOrResizeStarted() override;
|
void NotifyMoveOrResizeStarted() override;
|
||||||
CefRefPtr<CefExtension> GetExtension() override;
|
|
||||||
bool IsBackgroundHost() override;
|
|
||||||
bool IsFullscreen() override;
|
bool IsFullscreen() override;
|
||||||
void ExitFullscreen(bool will_cause_resize) override;
|
void ExitFullscreen(bool will_cause_resize) override;
|
||||||
bool IsRenderProcessUnresponsive() override;
|
bool IsRenderProcessUnresponsive() override;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "cef/libcef/browser/chrome/views/chrome_child_window.h"
|
#include "cef/libcef/browser/chrome/views/chrome_child_window.h"
|
||||||
#include "cef/libcef/browser/context.h"
|
#include "cef/libcef/browser/context.h"
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
#include "cef/libcef/browser/thread_util.h"
|
||||||
#include "cef/libcef/features/runtime.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -154,11 +153,6 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
bool CefBrowserCreateParams::IsChromeStyle(const CefWindowInfo* window_info) {
|
bool CefBrowserCreateParams::IsChromeStyle(const CefWindowInfo* window_info) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (!cef::IsChromeRuntimeEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!window_info) {
|
if (!window_info) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -169,12 +163,6 @@ bool CefBrowserCreateParams::IsChromeStyle(const CefWindowInfo* window_info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserCreateParams::IsChromeStyle() const {
|
bool CefBrowserCreateParams::IsChromeStyle() const {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (!cef::IsChromeRuntimeEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const bool chrome_style_via_window_info = IsChromeStyle(window_info.get());
|
const bool chrome_style_via_window_info = IsChromeStyle(window_info.get());
|
||||||
|
|
||||||
if (popup_with_alloy_style_opener) {
|
if (popup_with_alloy_style_opener) {
|
||||||
@ -210,11 +198,7 @@ void CefBrowserCreateParams::InitWindowInfo(CefWindowInfo* window_info,
|
|||||||
window_info->SetAsPopup(nullptr, CefString());
|
window_info->SetAsPopup(nullptr, CefString());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (
|
if (opener->IsAlloyStyle()) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
cef::IsChromeRuntimeEnabled() &&
|
|
||||||
#endif
|
|
||||||
opener->IsAlloyStyle()) {
|
|
||||||
// Give the popup the same runtime style as the opener.
|
// Give the popup the same runtime style as the opener.
|
||||||
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
}
|
}
|
||||||
@ -224,13 +208,6 @@ void CefBrowserCreateParams::MaybeSetWindowInfo(
|
|||||||
const CefWindowInfo& new_window_info,
|
const CefWindowInfo& new_window_info,
|
||||||
bool allow_alloy_style,
|
bool allow_alloy_style,
|
||||||
bool allow_chrome_style) {
|
bool allow_chrome_style) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (!cef::IsChromeRuntimeEnabled()) {
|
|
||||||
// Chrome style is not supported wih the Alloy bootstrap.
|
|
||||||
allow_chrome_style = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (allow_chrome_style && new_window_info.windowless_rendering_enabled) {
|
if (allow_chrome_style && new_window_info.windowless_rendering_enabled) {
|
||||||
// Chrome style is not supported with windowles rendering.
|
// Chrome style is not supported with windowles rendering.
|
||||||
allow_chrome_style = false;
|
allow_chrome_style = false;
|
||||||
@ -263,11 +240,7 @@ void CefBrowserCreateParams::MaybeSetWindowInfo(
|
|||||||
if (!is_chrome_style ||
|
if (!is_chrome_style ||
|
||||||
chrome_child_window::HasParentHandle(new_window_info)) {
|
chrome_child_window::HasParentHandle(new_window_info)) {
|
||||||
window_info = std::make_unique<CefWindowInfo>(new_window_info);
|
window_info = std::make_unique<CefWindowInfo>(new_window_info);
|
||||||
if (
|
if (!allow_chrome_style) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
cef::IsChromeRuntimeEnabled() &&
|
|
||||||
#endif
|
|
||||||
!allow_chrome_style) {
|
|
||||||
// Only Alloy style is allowed.
|
// Only Alloy style is allowed.
|
||||||
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
window_info->runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||||
} else if (reset_style) {
|
} else if (reset_style) {
|
||||||
|
@ -14,10 +14,8 @@
|
|||||||
#include "cef/libcef/browser/extensions/browser_extensions_util.h"
|
#include "cef/libcef/browser/extensions/browser_extensions_util.h"
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
#include "cef/libcef/browser/thread_util.h"
|
||||||
#include "cef/libcef/common/cef_switches.h"
|
#include "cef/libcef/common/cef_switches.h"
|
||||||
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
||||||
#include "cef/libcef/common/frame_util.h"
|
#include "cef/libcef/common/frame_util.h"
|
||||||
#include "cef/libcef/common/values_impl.h"
|
#include "cef/libcef/common/values_impl.h"
|
||||||
#include "cef/libcef/features/runtime.h"
|
|
||||||
#include "content/public/browser/child_process_host.h"
|
#include "content/public/browser/child_process_host.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
@ -141,7 +139,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
|||||||
pending_popup->client = client;
|
pending_popup->client = client;
|
||||||
pending_popup->settings = browser->settings();
|
pending_popup->settings = browser->settings();
|
||||||
|
|
||||||
// With the Chrome runtime, we want to use default popup Browser creation
|
// With Chrome style, we want to use default popup Browser creation
|
||||||
// for document picture-in-picture.
|
// for document picture-in-picture.
|
||||||
pending_popup->use_default_browser_creation =
|
pending_popup->use_default_browser_creation =
|
||||||
disposition == WindowOpenDisposition::NEW_PICTURE_IN_PICTURE;
|
disposition == WindowOpenDisposition::NEW_PICTURE_IN_PICTURE;
|
||||||
@ -196,7 +194,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
|||||||
create_params.popup_with_views_hosted_opener = ShouldCreateViewsHostedPopup(
|
create_params.popup_with_views_hosted_opener = ShouldCreateViewsHostedPopup(
|
||||||
browser, pending_popup->use_default_browser_creation);
|
browser, pending_popup->use_default_browser_creation);
|
||||||
|
|
||||||
// Potentially use Alloy style with the Chrome runtime.
|
// Potentially use Alloy style.
|
||||||
create_params.popup_with_alloy_style_opener = browser->IsAlloyStyle();
|
create_params.popup_with_alloy_style_opener = browser->IsAlloyStyle();
|
||||||
|
|
||||||
create_params.settings = pending_popup->settings;
|
create_params.settings = pending_popup->settings;
|
||||||
@ -279,9 +277,6 @@ void CefBrowserInfoManager::WebContentsCreated(
|
|||||||
|
|
||||||
bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) {
|
bool CefBrowserInfoManager::AddWebContents(content::WebContents* new_contents) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
DCHECK(cef::IsChromeRuntimeEnabled());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Pending popup information may be missing in cases where
|
// Pending popup information may be missing in cases where
|
||||||
// chrome::AddWebContents is called directly from the Chrome UI (profile
|
// chrome::AddWebContents is called directly from the Chrome UI (profile
|
||||||
@ -334,7 +329,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
|
|||||||
std::make_pair(global_token, std::move(pending)));
|
std::make_pair(global_token, std::move(pending)));
|
||||||
|
|
||||||
// Register a timeout for the pending response so that the renderer process
|
// Register a timeout for the pending response so that the renderer process
|
||||||
// doesn't hang forever. With the Chrome runtime, timeouts may occur in cases
|
// doesn't hang forever. With Chrome style, timeouts may occur in cases
|
||||||
// where chrome::AddWebContents or WebContents::Create are called directly
|
// where chrome::AddWebContents or WebContents::Create are called directly
|
||||||
// from the Chrome UI (profile settings, etc).
|
// from the Chrome UI (profile settings, etc).
|
||||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
@ -478,8 +473,8 @@ bool CefBrowserInfoManager::ShouldCreateViewsHostedPopup(
|
|||||||
CefRefPtr<CefBrowserHostBase> opener,
|
CefRefPtr<CefBrowserHostBase> opener,
|
||||||
bool use_default_browser_creation) {
|
bool use_default_browser_creation) {
|
||||||
// In most cases, Views-hosted browsers should create Views-hosted popups
|
// In most cases, Views-hosted browsers should create Views-hosted popups
|
||||||
// and native browsers should use default popup handling. With the Chrome
|
// and native browsers should use default popup handling. With Chrome
|
||||||
// runtime, we should additionally use default handling (a) when using an
|
// style, we should additionally use default handling (a) when using an
|
||||||
// external parent and (b) when using default Browser creation.
|
// external parent and (b) when using default Browser creation.
|
||||||
return opener->HasView() &&
|
return opener->HasView() &&
|
||||||
!opener->platform_delegate()->HasExternalParent() &&
|
!opener->platform_delegate()->HasExternalParent() &&
|
||||||
@ -776,9 +771,9 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cases where we expect to time out are:
|
// Cases where we expect to time out are:
|
||||||
// - With the Chrome runtime when chrome::AddWebContents or
|
// - With Chrome style when chrome::AddWebContents or WebContents::Create
|
||||||
// WebContents::Create are called directly from the Chrome UI (profile
|
// are called directly from the Chrome UI (profile settings, etc). A RFH
|
||||||
// settings, etc). A RFH will exist without a matching CefBrowserHost.
|
// will exist without a matching CefBrowserHost.
|
||||||
// - When the PDF renderer is loaded in the print preview dialog. There will
|
// - When the PDF renderer is loaded in the print preview dialog. There will
|
||||||
// be no RFH in this case.
|
// be no RFH in this case.
|
||||||
// Any additional cases should be debugged and, if possible,
|
// Any additional cases should be debugged and, if possible,
|
||||||
|
@ -82,7 +82,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
bool opener_suppressed,
|
bool opener_suppressed,
|
||||||
bool* no_javascript_access);
|
bool* no_javascript_access);
|
||||||
|
|
||||||
// Called from WebContentsDelegate::GetCustomWebContentsView (alloy runtime
|
// Called from WebContentsDelegate::GetCustomWebContentsView (Alloy style
|
||||||
// only). See comments on PendingPopup for more information.
|
// only). See comments on PendingPopup for more information.
|
||||||
void GetCustomWebContentsView(
|
void GetCustomWebContentsView(
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
@ -169,11 +169,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
// WebContentsDelegate::OpenURLFromTab is called via the
|
// WebContentsDelegate::OpenURLFromTab is called via the
|
||||||
// CefBrowserHostBase::MaybeAllowNavigation implementation.
|
// CefBrowserHostBase::MaybeAllowNavigation implementation.
|
||||||
// And then the following calls may occur at the same time:
|
// And then the following calls may occur at the same time:
|
||||||
// - GetCustomWebContentsView (UIT) (alloy runtime only):
|
// - GetCustomWebContentsView (UIT) (Alloy style only):
|
||||||
// Creates the OSR views for windowless popups.
|
// Creates the OSR views for windowless popups.
|
||||||
// - WebContentsCreated (UIT):
|
// - WebContentsCreated (UIT):
|
||||||
// Creates the CefBrowserHost representation for the popup.
|
// Creates the CefBrowserHost representation for the popup.
|
||||||
// - AddWebContents (UIT) (chrome runtime only):
|
// - AddWebContents (UIT) (Chrome style only):
|
||||||
// Creates the Browser or tab representation for the popup.
|
// Creates the Browser or tab representation for the popup.
|
||||||
// - CefBrowserManager::GetNewBrowserInfo (IOT)
|
// - CefBrowserManager::GetNewBrowserInfo (IOT)
|
||||||
// Passes information about the popup to the renderer process.
|
// Passes information about the popup to the renderer process.
|
||||||
|
@ -117,14 +117,6 @@ void CefBrowserPlatformDelegate::WebContentsDestroyed(
|
|||||||
web_contents_ = nullptr;
|
web_contents_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool CefBrowserPlatformDelegate::
|
|
||||||
ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
bool is_main_frame_navigation) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::RenderViewCreated(
|
void CefBrowserPlatformDelegate::RenderViewCreated(
|
||||||
content::RenderViewHost* render_view_host) {
|
content::RenderViewHost* render_view_host) {
|
||||||
// Indicate that the view has an external parent (namely us). This setting is
|
// Indicate that the view has an external parent (namely us). This setting is
|
||||||
@ -145,21 +137,6 @@ void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* browser) {
|
|||||||
browser_ = browser;
|
browser_ = browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
void CefBrowserPlatformDelegate::CreateExtensionHost(
|
|
||||||
const extensions::Extension* extension,
|
|
||||||
const GURL& url,
|
|
||||||
extensions::mojom::ViewType host_type) {
|
|
||||||
DCHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions::ExtensionHost* CefBrowserPlatformDelegate::GetExtensionHost()
|
|
||||||
const {
|
|
||||||
DCHECK(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
|
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
||||||
@ -350,19 +327,6 @@ bool CefBrowserPlatformDelegate::HandleKeyboardEvent(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
|
|
||||||
content::WebContents* source,
|
|
||||||
const blink::WebGestureEvent& event) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegate::IsNeverComposited(
|
|
||||||
content::WebContents* web_contents) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {
|
void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {
|
||||||
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(ExecuteExternalProtocol, url));
|
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(ExecuteExternalProtocol, url));
|
||||||
|
@ -15,17 +15,12 @@
|
|||||||
#include "cef/include/cef_drag_data.h"
|
#include "cef/include/cef_drag_data.h"
|
||||||
#include "cef/include/internal/cef_types.h"
|
#include "cef/include/internal/cef_types.h"
|
||||||
#include "cef/include/views/cef_browser_view.h"
|
#include "cef/include/views/cef_browser_view.h"
|
||||||
#include "cef/libcef/features/features.h"
|
|
||||||
#include "third_party/blink/public/common/page/drag_operation.h"
|
#include "third_party/blink/public/common/page/drag_operation.h"
|
||||||
#include "third_party/blink/public/mojom/drag/drag.mojom-forward.h"
|
#include "third_party/blink/public/mojom/drag/drag.mojom-forward.h"
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
|
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
|
||||||
#include "ui/base/window_open_disposition.h"
|
#include "ui/base/window_open_disposition.h"
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "extensions/common/mojom/view_type.mojom-forward.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
@ -49,13 +44,6 @@ class WebContents;
|
|||||||
class WebContentsView;
|
class WebContentsView;
|
||||||
} // namespace content
|
} // namespace content
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
namespace extensions {
|
|
||||||
class Extension;
|
|
||||||
class ExtensionHost;
|
|
||||||
} // namespace extensions
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
class ImageSkia;
|
class ImageSkia;
|
||||||
class Point;
|
class Point;
|
||||||
@ -138,12 +126,6 @@ class CefBrowserPlatformDelegate {
|
|||||||
// BrowserDestroyed(). Will only be called a single time per instance.
|
// BrowserDestroyed(). Will only be called a single time per instance.
|
||||||
virtual void WebContentsDestroyed(content::WebContents* web_contents);
|
virtual void WebContentsDestroyed(content::WebContents* web_contents);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// See WebContentsDelegate documentation.
|
|
||||||
virtual bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
||||||
bool is_main_frame_navigation);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Called after the RenderViewHost is created.
|
// Called after the RenderViewHost is created.
|
||||||
virtual void RenderViewCreated(content::RenderViewHost* render_view_host);
|
virtual void RenderViewCreated(content::RenderViewHost* render_view_host);
|
||||||
|
|
||||||
@ -155,16 +137,6 @@ class CefBrowserPlatformDelegate {
|
|||||||
// from this method.
|
// from this method.
|
||||||
virtual void BrowserCreated(CefBrowserHostBase* browser);
|
virtual void BrowserCreated(CefBrowserHostBase* browser);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Called from BrowserHost::Create.
|
|
||||||
virtual void CreateExtensionHost(const extensions::Extension* extension,
|
|
||||||
const GURL& url,
|
|
||||||
extensions::mojom::ViewType host_type);
|
|
||||||
|
|
||||||
// Returns the current extension host.
|
|
||||||
virtual extensions::ExtensionHost* GetExtensionHost() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Send any notifications related to browser creation. Called after
|
// Send any notifications related to browser creation. Called after
|
||||||
// BrowserCreated().
|
// BrowserCreated().
|
||||||
virtual void NotifyBrowserCreated();
|
virtual void NotifyBrowserCreated();
|
||||||
@ -293,15 +265,6 @@ class CefBrowserPlatformDelegate {
|
|||||||
// processing of shortcut keys.
|
// processing of shortcut keys.
|
||||||
virtual bool HandleKeyboardEvent(const input::NativeWebKeyboardEvent& event);
|
virtual bool HandleKeyboardEvent(const input::NativeWebKeyboardEvent& event);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// See WebContentsDelegate documentation.
|
|
||||||
virtual bool PreHandleGestureEvent(content::WebContents* source,
|
|
||||||
const blink::WebGestureEvent& event);
|
|
||||||
|
|
||||||
// See WebContentsDelegate documentation.
|
|
||||||
virtual bool IsNeverComposited(content::WebContents* web_contents);
|
|
||||||
#endif // BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
|
|
||||||
// Invoke platform specific handling for the external protocol.
|
// Invoke platform specific handling for the external protocol.
|
||||||
static void HandleExternalProtocol(const GURL& url);
|
static void HandleExternalProtocol(const GURL& url);
|
||||||
|
|
||||||
|
@ -28,10 +28,6 @@
|
|||||||
#error A delegate implementation is not available for your platform.
|
#error A delegate implementation is not available for your platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "cef/libcef/browser/extensions/browser_platform_delegate_background.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
|
std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate(
|
||||||
@ -109,15 +105,6 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
|||||||
return std::make_unique<CefBrowserPlatformDelegateViews>(
|
return std::make_unique<CefBrowserPlatformDelegateViews>(
|
||||||
std::move(native_delegate),
|
std::move(native_delegate),
|
||||||
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
|
static_cast<CefBrowserViewImpl*>(create_params.browser_view.get()));
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
} else if (create_params.extension_host_type ==
|
|
||||||
extensions::mojom::ViewType::kExtensionBackgroundPage) {
|
|
||||||
// Creating a background extension host without a window.
|
|
||||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
|
||||||
CreateNativeDelegate(CefWindowInfo(), background_color);
|
|
||||||
return std::make_unique<CefBrowserPlatformDelegateBackground>(
|
|
||||||
std::move(native_delegate));
|
|
||||||
#endif
|
|
||||||
} else if (create_params.window_info) {
|
} else if (create_params.window_info) {
|
||||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||||
CreateNativeDelegate(*create_params.window_info, background_color);
|
CreateNativeDelegate(*create_params.window_info, background_color);
|
||||||
|
@ -121,8 +121,8 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start with the same extra info as the opener, for consistency with
|
// Start with the same extra info as the opener, for consistency with
|
||||||
// current Alloy runtime behavior (see CefDevToolsFrontend::Show). This
|
// previous Alloy runtime behavior. This value, if non-empty, will be
|
||||||
// value, if non-empty, will be read-only.
|
// read-only.
|
||||||
create_params.extra_info = opener_browser_host->browser_info()->extra_info();
|
create_params.extra_info = opener_browser_host->browser_info()->extra_info();
|
||||||
DCHECK(!create_params.extra_info || create_params.extra_info->IsReadOnly());
|
DCHECK(!create_params.extra_info || create_params.extra_info->IsReadOnly());
|
||||||
|
|
||||||
@ -789,12 +789,6 @@ std::unique_ptr<BrowserDelegate> BrowserDelegate::Create(
|
|||||||
Browser* browser,
|
Browser* browser,
|
||||||
scoped_refptr<CreateParams> cef_params,
|
scoped_refptr<CreateParams> cef_params,
|
||||||
const Browser* opener) {
|
const Browser* opener) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (!cef::IsChromeRuntimeEnabled()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CefBrowserCreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
|
|
||||||
// Parameters from ChromeBrowserHostImpl::Create, or nullptr if the Browser
|
// Parameters from ChromeBrowserHostImpl::Create, or nullptr if the Browser
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "cef/libcef/browser/thread_util.h"
|
#include "cef/libcef/browser/thread_util.h"
|
||||||
#include "cef/libcef/browser/views/browser_view_impl.h"
|
#include "cef/libcef/browser/views/browser_view_impl.h"
|
||||||
#include "cef/libcef/common/net/url_util.h"
|
#include "cef/libcef/common/net/url_util.h"
|
||||||
#include "cef/libcef/features/runtime_checks.h"
|
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
#include "chrome/browser/ui/browser_commands.h"
|
#include "chrome/browser/ui/browser_commands.h"
|
||||||
#include "chrome/browser/ui/browser_navigator.h"
|
#include "chrome/browser/ui/browser_navigator.h"
|
||||||
@ -67,45 +66,30 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::FromBaseChecked(
|
|||||||
// static
|
// static
|
||||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
||||||
const content::RenderViewHost* host) {
|
const content::RenderViewHost* host) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
REQUIRE_CHROME_RUNTIME();
|
|
||||||
#endif
|
|
||||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
||||||
const content::RenderFrameHost* host) {
|
const content::RenderFrameHost* host) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
REQUIRE_CHROME_RUNTIME();
|
|
||||||
#endif
|
|
||||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
return FromBaseChecked(CefBrowserHostBase::GetBrowserForHost(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForContents(
|
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForContents(
|
||||||
const content::WebContents* contents) {
|
const content::WebContents* contents) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
REQUIRE_CHROME_RUNTIME();
|
|
||||||
#endif
|
|
||||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForContents(contents));
|
return FromBaseChecked(CefBrowserHostBase::GetBrowserForContents(contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForGlobalId(
|
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForGlobalId(
|
||||||
const content::GlobalRenderFrameHostId& global_id) {
|
const content::GlobalRenderFrameHostId& global_id) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
REQUIRE_CHROME_RUNTIME();
|
|
||||||
#endif
|
|
||||||
return FromBaseChecked(CefBrowserHostBase::GetBrowserForGlobalId(global_id));
|
return FromBaseChecked(CefBrowserHostBase::GetBrowserForGlobalId(global_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForBrowser(
|
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForBrowser(
|
||||||
const Browser* browser) {
|
const Browser* browser) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
REQUIRE_CHROME_RUNTIME();
|
|
||||||
#endif
|
|
||||||
// Return the ChromeBrowserHostImpl that is currently active.
|
// Return the ChromeBrowserHostImpl that is currently active.
|
||||||
// Views-hosted Browsers will contain a single ChromeBrowserHostImpl.
|
// Views-hosted Browsers will contain a single ChromeBrowserHostImpl.
|
||||||
// Otherwise, there will be a ChromeBrowserHostImpl per Tab/WebContents.
|
// Otherwise, there will be a ChromeBrowserHostImpl per Tab/WebContents.
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
class ChromeBrowserDelegate;
|
class ChromeBrowserDelegate;
|
||||||
class ChromeBrowserView;
|
class ChromeBrowserView;
|
||||||
|
|
||||||
// CefBrowser implementation for the chrome runtime. Method calls are delegated
|
// CefBrowser implementation for Chrome style. Method calls are delegated
|
||||||
// to the chrome Browser object or the WebContents as appropriate. See the
|
// to the chrome Browser object or the WebContents as appropriate. See the
|
||||||
// ChromeBrowserDelegate documentation for additional details. All methods are
|
// ChromeBrowserDelegate documentation for additional details. All methods are
|
||||||
// thread-safe unless otherwise indicated.
|
// thread-safe unless otherwise indicated.
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "cef/libcef/common/app_manager.h"
|
#include "cef/libcef/common/app_manager.h"
|
||||||
#include "cef/libcef/common/cef_switches.h"
|
#include "cef/libcef/common/cef_switches.h"
|
||||||
#include "cef/libcef/common/command_line_impl.h"
|
#include "cef/libcef/common/command_line_impl.h"
|
||||||
#include "cef/libcef/features/features.h"
|
|
||||||
#include "chrome/browser/chrome_browser_main.h"
|
#include "chrome/browser/chrome_browser_main.h"
|
||||||
#include "chrome/browser/net/system_network_context_manager.h"
|
#include "chrome/browser/net/system_network_context_manager.h"
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
@ -107,11 +106,6 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
|
|||||||
ChromeContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
|
ChromeContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
|
||||||
child_process_id);
|
child_process_id);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
// Necessary to launch sub-processes in the correct mode.
|
|
||||||
command_line->AppendSwitch(switches::kEnableChromeRuntime);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Necessary to populate DIR_USER_DATA in sub-processes.
|
// Necessary to populate DIR_USER_DATA in sub-processes.
|
||||||
// See resource_util.cc GetUserDataPath.
|
// See resource_util.cc GetUserDataPath.
|
||||||
base::FilePath user_data_dir;
|
base::FilePath user_data_dir;
|
||||||
|
@ -96,7 +96,7 @@ class BrowserView;
|
|||||||
class CefWindowView;
|
class CefWindowView;
|
||||||
|
|
||||||
// Widget for a Views-hosted Chrome browser. Created in
|
// Widget for a Views-hosted Chrome browser. Created in
|
||||||
// CefWindowView::CreateWidget() when the Chrome runtime is enabled.
|
// CefWindowView::CreateWidget() with Chrome style.
|
||||||
class ChromeBrowserFrame : public BrowserFrame,
|
class ChromeBrowserFrame : public BrowserFrame,
|
||||||
public CefWidget,
|
public CefWidget,
|
||||||
public CefColorProviderTracker::Observer,
|
public CefColorProviderTracker::Observer,
|
||||||
|
@ -589,9 +589,6 @@ void CefContext::PopulateGlobalRequestContextSettings(
|
|||||||
settings->persist_session_cookies =
|
settings->persist_session_cookies =
|
||||||
settings_.persist_session_cookies ||
|
settings_.persist_session_cookies ||
|
||||||
command_line->HasSwitch(switches::kPersistSessionCookies);
|
command_line->HasSwitch(switches::kPersistSessionCookies);
|
||||||
settings->persist_user_preferences =
|
|
||||||
settings_.persist_user_preferences ||
|
|
||||||
command_line->HasSwitch(switches::kPersistUserPreferences);
|
|
||||||
|
|
||||||
CefString(&settings->cookieable_schemes_list) =
|
CefString(&settings->cookieable_schemes_list) =
|
||||||
CefString(&settings_.cookieable_schemes_list);
|
CefString(&settings_.cookieable_schemes_list);
|
||||||
|
@ -4,18 +4,8 @@
|
|||||||
|
|
||||||
#include "cef/libcef/browser/chrome/chrome_devtools_window_runner.h"
|
#include "cef/libcef/browser/chrome/chrome_devtools_window_runner.h"
|
||||||
#include "cef/libcef/browser/devtools/devtools_window_runner.h"
|
#include "cef/libcef/browser/devtools/devtools_window_runner.h"
|
||||||
#include "cef/libcef/features/runtime.h"
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
#include "cef/libcef/browser/alloy/devtools/alloy_devtools_window_runner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<CefDevToolsWindowRunner> CefDevToolsWindowRunner::Create() {
|
std::unique_ptr<CefDevToolsWindowRunner> CefDevToolsWindowRunner::Create() {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
if (cef::IsAlloyRuntimeEnabled()) {
|
|
||||||
return std::make_unique<AlloyDevToolsWindowRunner>();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return std::make_unique<ChromeDevToolsWindowRunner>();
|
return std::make_unique<ChromeDevToolsWindowRunner>();
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,12 @@
|
|||||||
#include "cef/libcef/browser/download_manager_delegate.h"
|
#include "cef/libcef/browser/download_manager_delegate.h"
|
||||||
|
|
||||||
#include "cef/libcef/browser/download_manager_delegate_impl.h"
|
#include "cef/libcef/browser/download_manager_delegate_impl.h"
|
||||||
#include "cef/libcef/features/runtime_checks.h"
|
|
||||||
|
|
||||||
namespace cef {
|
namespace cef {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<cef::DownloadManagerDelegate> DownloadManagerDelegate::Create(
|
std::unique_ptr<cef::DownloadManagerDelegate> DownloadManagerDelegate::Create(
|
||||||
content::DownloadManager* download_manager) {
|
content::DownloadManager* download_manager) {
|
||||||
#if BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP)
|
|
||||||
REQUIRE_CHROME_RUNTIME();
|
|
||||||
#endif
|
|
||||||
return std::make_unique<CefDownloadManagerDelegateImpl>(
|
return std::make_unique<CefDownloadManagerDelegateImpl>(
|
||||||
download_manager, /*alloy_bootstrap=*/false);
|
download_manager, /*alloy_bootstrap=*/false);
|
||||||
}
|
}
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
// 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 "cef/libcef/browser/extension_impl.h"
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/request_context_impl.h"
|
|
||||||
#include "cef/libcef/browser/thread_util.h"
|
|
||||||
#include "cef/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()->Clone(),
|
|
||||||
/*read_only=*/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()) {
|
|
||||||
DCHECK(false) << "called on invalid thread";
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return loader_context_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefExtensionImpl::IsLoaded() {
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
DCHECK(false) << "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;
|
|
||||||
|
|
||||||
[[maybe_unused]] const bool result =
|
|
||||||
static_cast<CefRequestContextImpl*>(loader_context_)
|
|
||||||
->GetBrowserContext()
|
|
||||||
->UnloadExtension(id_);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
// 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 "base/memory/raw_ptr.h"
|
|
||||||
#include "cef/include/cef_extension.h"
|
|
||||||
#include "cef/include/cef_extension_handler.h"
|
|
||||||
#include "cef/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);
|
|
||||||
|
|
||||||
CefExtensionImpl(const CefExtensionImpl&) = delete;
|
|
||||||
CefExtensionImpl& operator=(const CefExtensionImpl&) = delete;
|
|
||||||
|
|
||||||
// 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_;
|
|
||||||
|
|
||||||
raw_ptr<CefRequestContext> loader_context_;
|
|
||||||
CefRefPtr<CefExtensionHandler> handler_;
|
|
||||||
|
|
||||||
// Only accessed on the UI thread.
|
|
||||||
bool unloaded_ = false;
|
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(CefExtensionImpl);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_
|
|
@ -1,19 +0,0 @@
|
|||||||
// Copyright 2021 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 "cef/libcef/browser/extensions/alloy_extensions_util.h"
|
|
||||||
|
|
||||||
#include "cef/libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
|
|
||||||
namespace extensions::alloy {
|
|
||||||
|
|
||||||
int GetTabIdForWebContents(content::WebContents* web_contents) {
|
|
||||||
auto browser = AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
|
||||||
if (!browser) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return browser->GetIdentifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace extensions::alloy
|
|
@ -1,19 +0,0 @@
|
|||||||
// Copyright 2021 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_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class WebContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace extensions::alloy {
|
|
||||||
|
|
||||||
// Returns the tabId for |web_contents|, or -1 if not found.
|
|
||||||
int GetTabIdForWebContents(content::WebContents* web_contents);
|
|
||||||
|
|
||||||
} // namespace extensions::alloy
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_
|
|
@ -1,87 +0,0 @@
|
|||||||
// Copyright 2017 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 "cef/libcef/browser/extensions/api/file_system/cef_file_system_delegate.h"
|
|
||||||
|
|
||||||
#include "apps/saved_files_service.h"
|
|
||||||
#include "base/files/file_path.h"
|
|
||||||
#include "base/functional/callback.h"
|
|
||||||
#include "chrome/browser/extensions/api/file_system/file_entry_picker.h"
|
|
||||||
#include "chrome/grit/generated_resources.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "extensions/common/api/file_system.h"
|
|
||||||
#include "extensions/common/extension.h"
|
|
||||||
|
|
||||||
namespace extensions::cef {
|
|
||||||
|
|
||||||
CefFileSystemDelegate::CefFileSystemDelegate() = default;
|
|
||||||
|
|
||||||
CefFileSystemDelegate::~CefFileSystemDelegate() = default;
|
|
||||||
|
|
||||||
base::FilePath CefFileSystemDelegate::GetDefaultDirectory() {
|
|
||||||
return base::FilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
base::FilePath CefFileSystemDelegate::GetManagedSaveAsDirectory(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const Extension& extension) {
|
|
||||||
return base::FilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefFileSystemDelegate::ShowSelectFileDialog(
|
|
||||||
scoped_refptr<ExtensionFunction> extension_function,
|
|
||||||
ui::SelectFileDialog::Type type,
|
|
||||||
const base::FilePath& default_path,
|
|
||||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
|
||||||
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
|
||||||
base::OnceClosure file_selection_canceled_callback) {
|
|
||||||
auto web_contents = extension_function->GetSenderWebContents();
|
|
||||||
if (!web_contents) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The file picker will hold a reference to the ExtensionFunction
|
|
||||||
// instance, preventing its destruction (and subsequent sending of the
|
|
||||||
// function response) until the user has selected a file or cancelled the
|
|
||||||
// picker. At that point, the picker will delete itself, which will also free
|
|
||||||
// the function instance.
|
|
||||||
new FileEntryPicker(web_contents, default_path, *file_types, type,
|
|
||||||
std::move(files_selected_callback),
|
|
||||||
std::move(file_selection_canceled_callback));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess(
|
|
||||||
bool has_write_permission,
|
|
||||||
const std::u16string& app_name,
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
base::OnceClosure on_accept,
|
|
||||||
base::OnceClosure on_cancel) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
|
|
||||||
// Run the cancel callback by default.
|
|
||||||
std::move(on_cancel).Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Based on ChromeFileSystemDelegate::GetDescriptionIdForAcceptType.
|
|
||||||
int CefFileSystemDelegate::GetDescriptionIdForAcceptType(
|
|
||||||
const std::string& accept_type) {
|
|
||||||
if (accept_type == "image/*") {
|
|
||||||
return IDS_IMAGE_FILES;
|
|
||||||
}
|
|
||||||
if (accept_type == "audio/*") {
|
|
||||||
return IDS_AUDIO_FILES;
|
|
||||||
}
|
|
||||||
if (accept_type == "video/*") {
|
|
||||||
return IDS_VIDEO_FILES;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SavedFilesServiceInterface* CefFileSystemDelegate::GetSavedFilesService(
|
|
||||||
content::BrowserContext* browser_context) {
|
|
||||||
return apps::SavedFilesService::Get(browser_context);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace extensions::cef
|
|
@ -1,56 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
|
||||||
#include "base/functional/callback.h"
|
|
||||||
#include "base/memory/ref_counted.h"
|
|
||||||
#include "extensions/browser/api/execute_code_function.h"
|
|
||||||
#include "extensions/browser/api/file_system/file_system_delegate.h"
|
|
||||||
#include "extensions/browser/extension_function.h"
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class WebContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace extensions::cef {
|
|
||||||
|
|
||||||
class CefFileSystemDelegate : public FileSystemDelegate {
|
|
||||||
public:
|
|
||||||
CefFileSystemDelegate();
|
|
||||||
|
|
||||||
CefFileSystemDelegate(const CefFileSystemDelegate&) = delete;
|
|
||||||
CefFileSystemDelegate& operator=(const CefFileSystemDelegate&) = delete;
|
|
||||||
|
|
||||||
~CefFileSystemDelegate() override;
|
|
||||||
|
|
||||||
// FileSystemDelegate
|
|
||||||
base::FilePath GetDefaultDirectory() override;
|
|
||||||
base::FilePath GetManagedSaveAsDirectory(
|
|
||||||
content::BrowserContext* browser_context,
|
|
||||||
const Extension& extension) override;
|
|
||||||
bool ShowSelectFileDialog(
|
|
||||||
scoped_refptr<ExtensionFunction> extension_function,
|
|
||||||
ui::SelectFileDialog::Type type,
|
|
||||||
const base::FilePath& default_path,
|
|
||||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
|
||||||
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
|
||||||
base::OnceClosure file_selection_canceled_callback) override;
|
|
||||||
void ConfirmSensitiveDirectoryAccess(bool has_write_permission,
|
|
||||||
const std::u16string& app_name,
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
base::OnceClosure on_accept,
|
|
||||||
base::OnceClosure on_cancel) override;
|
|
||||||
int GetDescriptionIdForAcceptType(const std::string& accept_type) override;
|
|
||||||
SavedFilesServiceInterface* GetSavedFilesService(
|
|
||||||
content::BrowserContext* browser_context) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace extensions::cef
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
|
@ -1,102 +0,0 @@
|
|||||||
// 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 "cef/libcef/browser/extensions/api/storage/sync_value_store_cache.h"
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "components/value_store/value_store_factory.h"
|
|
||||||
#include "content/public/browser/browser_thread.h"
|
|
||||||
#include "extensions/browser/api/storage/backend_task_runner.h"
|
|
||||||
#include "extensions/browser/api/storage/value_store_util.h"
|
|
||||||
#include "extensions/browser/api/storage/weak_unlimited_settings_storage.h"
|
|
||||||
#include "extensions/common/api/storage.h"
|
|
||||||
#include "extensions/common/extension.h"
|
|
||||||
#include "extensions/common/permissions/permissions_data.h"
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
|
||||||
|
|
||||||
namespace extensions::cef {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// Returns the quota limit for local storage, taken from the schema in
|
|
||||||
// extensions/common/api/storage.json.
|
|
||||||
SettingsStorageQuotaEnforcer::Limits GetLocalQuotaLimits() {
|
|
||||||
SettingsStorageQuotaEnforcer::Limits limits = {
|
|
||||||
static_cast<size_t>(api::storage::local::QUOTA_BYTES),
|
|
||||||
std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max()};
|
|
||||||
return limits;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
SyncValueStoreCache::SyncValueStoreCache(
|
|
||||||
scoped_refptr<value_store::ValueStoreFactory> factory)
|
|
||||||
: storage_factory_(std::move(factory)), quota_(GetLocalQuotaLimits()) {
|
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncValueStoreCache::~SyncValueStoreCache() {
|
|
||||||
DCHECK(IsOnBackendSequence());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SyncValueStoreCache::RunWithValueStoreForExtension(
|
|
||||||
StorageCallback callback,
|
|
||||||
scoped_refptr<const Extension> extension) {
|
|
||||||
DCHECK(IsOnBackendSequence());
|
|
||||||
|
|
||||||
value_store::ValueStore* storage = GetStorage(extension.get());
|
|
||||||
|
|
||||||
// A neat way to implement unlimited storage; if the extension has the
|
|
||||||
// unlimited storage permission, force through all calls to Set().
|
|
||||||
if (extension->permissions_data()->HasAPIPermission(
|
|
||||||
mojom::APIPermissionID::kUnlimitedStorage)) {
|
|
||||||
WeakUnlimitedSettingsStorage unlimited_storage(storage);
|
|
||||||
std::move(callback).Run(&unlimited_storage);
|
|
||||||
} else {
|
|
||||||
std::move(callback).Run(storage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SyncValueStoreCache::DeleteStorageSoon(const std::string& extension_id) {
|
|
||||||
DCHECK(IsOnBackendSequence());
|
|
||||||
storage_map_.erase(extension_id);
|
|
||||||
|
|
||||||
value_store_util::DeleteValueStore(settings_namespace::SYNC,
|
|
||||||
value_store_util::ModelType::APP,
|
|
||||||
extension_id, storage_factory_);
|
|
||||||
|
|
||||||
value_store_util::DeleteValueStore(settings_namespace::SYNC,
|
|
||||||
value_store_util::ModelType::EXTENSION,
|
|
||||||
extension_id, storage_factory_);
|
|
||||||
}
|
|
||||||
|
|
||||||
value_store::ValueStore* SyncValueStoreCache::GetStorage(
|
|
||||||
const Extension* extension) {
|
|
||||||
auto iter = storage_map_.find(extension->id());
|
|
||||||
if (iter != storage_map_.end()) {
|
|
||||||
return iter->second.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
value_store_util::ModelType model_type =
|
|
||||||
extension->is_app() ? value_store_util::ModelType::APP
|
|
||||||
: value_store_util::ModelType::EXTENSION;
|
|
||||||
std::unique_ptr<value_store::ValueStore> store =
|
|
||||||
value_store_util::CreateSettingsStore(settings_namespace::LOCAL,
|
|
||||||
model_type, extension->id(),
|
|
||||||
storage_factory_);
|
|
||||||
std::unique_ptr<SettingsStorageQuotaEnforcer> storage(
|
|
||||||
new SettingsStorageQuotaEnforcer(quota_, std::move(store)));
|
|
||||||
DCHECK(storage.get());
|
|
||||||
|
|
||||||
value_store::ValueStore* storage_ptr = storage.get();
|
|
||||||
storage_map_[extension->id()] = std::move(storage);
|
|
||||||
return storage_ptr;
|
|
||||||
}
|
|
||||||
} // namespace extensions::cef
|
|
@ -1,58 +0,0 @@
|
|||||||
// 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_API_STORAGE_SYNC_VALUE_STORE_CACHE_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_STORAGE_SYNC_VALUE_STORE_CACHE_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "base/memory/ref_counted.h"
|
|
||||||
#include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
|
|
||||||
#include "extensions/browser/api/storage/value_store_cache.h"
|
|
||||||
|
|
||||||
namespace value_store {
|
|
||||||
class ValueStoreFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace extensions::cef {
|
|
||||||
|
|
||||||
// Based on LocalValueStoreCache
|
|
||||||
// ValueStoreCache for the SYNC namespace. It owns a backend for apps and
|
|
||||||
// another for extensions. Each backend takes care of persistence.
|
|
||||||
class SyncValueStoreCache : public ValueStoreCache {
|
|
||||||
public:
|
|
||||||
explicit SyncValueStoreCache(
|
|
||||||
scoped_refptr<value_store::ValueStoreFactory> factory);
|
|
||||||
|
|
||||||
SyncValueStoreCache(const SyncValueStoreCache&) = delete;
|
|
||||||
SyncValueStoreCache& operator=(const SyncValueStoreCache&) = delete;
|
|
||||||
|
|
||||||
~SyncValueStoreCache() override;
|
|
||||||
|
|
||||||
// ValueStoreCache implementation:
|
|
||||||
void RunWithValueStoreForExtension(
|
|
||||||
StorageCallback callback,
|
|
||||||
scoped_refptr<const Extension> extension) override;
|
|
||||||
void DeleteStorageSoon(const std::string& extension_id) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using StorageMap =
|
|
||||||
std::map<std::string, std::unique_ptr<value_store::ValueStore>>;
|
|
||||||
|
|
||||||
value_store::ValueStore* GetStorage(const Extension* extension);
|
|
||||||
|
|
||||||
// The Factory to use for creating new ValueStores.
|
|
||||||
const scoped_refptr<value_store::ValueStoreFactory> storage_factory_;
|
|
||||||
|
|
||||||
// Quota limits (see SettingsStorageQuotaEnforcer).
|
|
||||||
const SettingsStorageQuotaEnforcer::Limits quota_;
|
|
||||||
|
|
||||||
// The collection of ValueStores for local storage.
|
|
||||||
StorageMap storage_map_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace extensions::cef
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_STORAGE_SYNC_VALUE_STORE_CACHE_H_
|
|
@ -1,538 +0,0 @@
|
|||||||
// 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 "cef/libcef/browser/extensions/api/tabs/tabs_api.h"
|
|
||||||
|
|
||||||
#include "base/notreached.h"
|
|
||||||
#include "base/strings/string_number_conversions.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
|
||||||
#include "cef/libcef/browser/extensions/extension_web_contents_observer.h"
|
|
||||||
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
|
|
||||||
#include "chrome/browser/extensions/extension_tab_util.h"
|
|
||||||
#include "components/zoom/zoom_controller.h"
|
|
||||||
#include "content/public/browser/navigation_controller.h"
|
|
||||||
#include "content/public/browser/navigation_entry.h"
|
|
||||||
#include "content/public/browser/render_frame_host.h"
|
|
||||||
#include "content/public/browser/site_instance.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"
|
|
||||||
#include "third_party/blink/public/common/page/page_zoom.h"
|
|
||||||
|
|
||||||
using zoom::ZoomController;
|
|
||||||
|
|
||||||
namespace extensions::cef {
|
|
||||||
|
|
||||||
namespace keys = extensions::tabs_constants;
|
|
||||||
namespace tabs = api::tabs;
|
|
||||||
|
|
||||||
using api::extension_types::InjectDetails;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const char kNotImplementedError[] = "Not implemented";
|
|
||||||
|
|
||||||
void ZoomModeToZoomSettings(zoom::ZoomController::ZoomMode zoom_mode,
|
|
||||||
tabs::ZoomSettings* zoom_settings) {
|
|
||||||
DCHECK(zoom_settings);
|
|
||||||
switch (zoom_mode) {
|
|
||||||
case zoom::ZoomController::ZOOM_MODE_DEFAULT:
|
|
||||||
zoom_settings->mode = tabs::ZoomSettingsMode::kAutomatic;
|
|
||||||
zoom_settings->scope = tabs::ZoomSettingsScope::kPerOrigin;
|
|
||||||
break;
|
|
||||||
case zoom::ZoomController::ZOOM_MODE_ISOLATED:
|
|
||||||
zoom_settings->mode = tabs::ZoomSettingsMode::kAutomatic;
|
|
||||||
zoom_settings->scope = tabs::ZoomSettingsScope::kPerTab;
|
|
||||||
break;
|
|
||||||
case zoom::ZoomController::ZOOM_MODE_MANUAL:
|
|
||||||
zoom_settings->mode = tabs::ZoomSettingsMode::kManual;
|
|
||||||
zoom_settings->scope = tabs::ZoomSettingsScope::kPerTab;
|
|
||||||
break;
|
|
||||||
case zoom::ZoomController::ZOOM_MODE_DISABLED:
|
|
||||||
zoom_settings->mode = tabs::ZoomSettingsMode::kDisabled;
|
|
||||||
zoom_settings->scope = tabs::ZoomSettingsScope::kPerTab;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsGetFunction::Run() {
|
|
||||||
return RespondNow(Error(kNotImplementedError));
|
|
||||||
}
|
|
||||||
|
|
||||||
TabsCreateFunction::TabsCreateFunction() : cef_details_(this) {}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsCreateFunction::Run() {
|
|
||||||
std::optional<tabs::Create::Params> params =
|
|
||||||
tabs::Create::Params::Create(args());
|
|
||||||
EXTENSION_FUNCTION_VALIDATE(params);
|
|
||||||
|
|
||||||
CefExtensionFunctionDetails::OpenTabParams options;
|
|
||||||
options.window_id = params->create_properties.window_id;
|
|
||||||
options.opener_tab_id = params->create_properties.opener_tab_id;
|
|
||||||
options.active = params->create_properties.selected;
|
|
||||||
// The 'active' property has replaced the 'selected' property.
|
|
||||||
options.active = params->create_properties.active;
|
|
||||||
options.pinned = params->create_properties.pinned;
|
|
||||||
options.index = params->create_properties.index;
|
|
||||||
options.url = params->create_properties.url;
|
|
||||||
|
|
||||||
std::string error;
|
|
||||||
auto result = cef_details_.OpenTab(options, user_gesture(), &error);
|
|
||||||
if (!result) {
|
|
||||||
return RespondNow(Error(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return data about the newly created tab.
|
|
||||||
return RespondNow(has_callback()
|
|
||||||
? WithArguments(base::Value(result->ToValue()))
|
|
||||||
: NoArguments());
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseAPIFunction::BaseAPIFunction() : cef_details_(this) {}
|
|
||||||
|
|
||||||
content::WebContents* BaseAPIFunction::GetWebContents(int tab_id) {
|
|
||||||
// Find a browser that we can access, or set |error_| and return nullptr.
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
|
||||||
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error_);
|
|
||||||
if (!browser) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return browser->web_contents();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
|
||||||
std::optional<tabs::Update::Params> params =
|
|
||||||
tabs::Update::Params::Create(args());
|
|
||||||
EXTENSION_FUNCTION_VALIDATE(params);
|
|
||||||
|
|
||||||
tab_id_ = params->tab_id ? *params->tab_id : -1;
|
|
||||||
content::WebContents* web_contents = GetWebContents(tab_id_);
|
|
||||||
if (!web_contents) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
web_contents_ = web_contents;
|
|
||||||
|
|
||||||
// TODO(rafaelw): handle setting remaining tab properties:
|
|
||||||
// -title
|
|
||||||
// -favIconUrl
|
|
||||||
|
|
||||||
// Navigate the tab to a new location if the url is different.
|
|
||||||
if (params->update_properties.url.has_value()) {
|
|
||||||
std::string updated_url = *params->update_properties.url;
|
|
||||||
if (!UpdateURL(updated_url, tab_id_, &error_)) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool active = false;
|
|
||||||
// TODO(rafaelw): Setting |active| from js doesn't make much sense.
|
|
||||||
// Move tab selection management up to window.
|
|
||||||
if (params->update_properties.selected.has_value()) {
|
|
||||||
active = *params->update_properties.selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The 'active' property has replaced 'selected'.
|
|
||||||
if (params->update_properties.active.has_value()) {
|
|
||||||
active = *params->update_properties.active;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active) {
|
|
||||||
// TODO: Activate the tab at |tab_id_|.
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params->update_properties.highlighted.has_value() &&
|
|
||||||
*params->update_properties.highlighted) {
|
|
||||||
// TODO: Highlight the tab at |tab_id_|.
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params->update_properties.pinned.has_value() &&
|
|
||||||
*params->update_properties.pinned) {
|
|
||||||
// TODO: Pin the tab at |tab_id_|.
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params->update_properties.muted.has_value()) {
|
|
||||||
// TODO: Mute/unmute the tab at |tab_id_|.
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return RespondNow(Error(ErrorUtils::FormatErrorMessage(
|
|
||||||
tabs_constants::kCannotUpdateMuteCaptured,
|
|
||||||
base::NumberToString(tab_id_))));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params->update_properties.opener_tab_id.has_value()) {
|
|
||||||
int opener_id = *params->update_properties.opener_tab_id;
|
|
||||||
if (opener_id == tab_id_) {
|
|
||||||
return RespondNow(Error("Cannot set a tab's opener to itself."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Set the opener for the tab at |tab_id_|.
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params->update_properties.auto_discardable.has_value()) {
|
|
||||||
// TODO: Set auto-discardable state for the tab at |tab_id_|.
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
return RespondNow(GetResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TabsUpdateFunction::UpdateURL(const std::string& url_string,
|
|
||||||
int tab_id,
|
|
||||||
std::string* error) {
|
|
||||||
GURL url;
|
|
||||||
auto url_expected = ExtensionTabUtil::PrepareURLForNavigation(
|
|
||||||
url_string, extension(), browser_context());
|
|
||||||
if (url_expected.has_value()) {
|
|
||||||
url = *url_expected;
|
|
||||||
} else {
|
|
||||||
*error = std::move(url_expected.error());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::NavigationController::LoadURLParams load_params(url);
|
|
||||||
|
|
||||||
// Treat extension-initiated navigations as renderer-initiated so that the URL
|
|
||||||
// does not show in the omnibox until it commits. This avoids URL spoofs
|
|
||||||
// since URLs can be opened on behalf of untrusted content.
|
|
||||||
load_params.is_renderer_initiated = true;
|
|
||||||
// All renderer-initiated navigations need to have an initiator origin.
|
|
||||||
load_params.initiator_origin = extension()->origin();
|
|
||||||
// |source_site_instance| needs to be set so that a renderer process
|
|
||||||
// compatible with |initiator_origin| is picked by Site Isolation.
|
|
||||||
load_params.source_site_instance = content::SiteInstance::CreateForURL(
|
|
||||||
web_contents_->GetBrowserContext(),
|
|
||||||
load_params.initiator_origin->GetURL());
|
|
||||||
|
|
||||||
// Marking the navigation as initiated via an API means that the focus
|
|
||||||
// will stay in the omnibox - see https://crbug.com/1085779.
|
|
||||||
load_params.transition_type = ui::PAGE_TRANSITION_FROM_API;
|
|
||||||
|
|
||||||
web_contents_->GetController().LoadURLWithParams(load_params);
|
|
||||||
|
|
||||||
DCHECK_EQ(url,
|
|
||||||
web_contents_->GetController().GetPendingEntry()->GetVirtualURL());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() {
|
|
||||||
if (!has_callback()) {
|
|
||||||
return NoArguments();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ArgumentList(tabs::Get::Results::Create(cef_details_.CreateTabObject(
|
|
||||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_),
|
|
||||||
/*opener_browser_id=*/-1, /*active=*/true, tab_id_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() : cef_details_(this) {}
|
|
||||||
|
|
||||||
ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() = default;
|
|
||||||
|
|
||||||
ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
|
||||||
if (init_result_) {
|
|
||||||
return init_result_.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args().size() < 2) {
|
|
||||||
return set_init_result(VALIDATION_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& tab_id_value = args()[0];
|
|
||||||
// |tab_id| is optional so it's ok if it's not there.
|
|
||||||
int tab_id = -1;
|
|
||||||
if (tab_id_value.is_int()) {
|
|
||||||
// But if it is present, it needs to be non-negative.
|
|
||||||
tab_id = tab_id_value.GetInt();
|
|
||||||
if (tab_id < 0) {
|
|
||||||
return set_init_result(VALIDATION_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// |details| are not optional.
|
|
||||||
const base::Value& details_value = args()[1];
|
|
||||||
if (!details_value.is_dict()) {
|
|
||||||
return set_init_result(VALIDATION_FAILURE);
|
|
||||||
}
|
|
||||||
auto details = InjectDetails::FromValue(details_value.GetDict());
|
|
||||||
if (!details) {
|
|
||||||
return set_init_result(VALIDATION_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a browser that we can access, or fail with error.
|
|
||||||
std::string error;
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> 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(
|
|
||||||
mojom::HostID(mojom::HostID::HostType::kExtensions, extension()->id()));
|
|
||||||
return set_init_result(SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExecuteCodeInTabFunction::ShouldInsertCSS() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExecuteCodeInTabFunction::ShouldRemoveCSS() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage(std::string* error) {
|
|
||||||
CHECK_GE(execute_tab_id_, 0);
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> 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::NumberToString(frame_id),
|
|
||||||
base::NumberToString(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(effective_document_url,
|
|
||||||
execute_tab_id_, error)) {
|
|
||||||
if (is_about_url &&
|
|
||||||
extension()->permissions_data()->active_permissions().HasAPIPermission(
|
|
||||||
mojom::APIPermissionID::kTab)) {
|
|
||||||
*error = ErrorUtils::FormatErrorMessage(
|
|
||||||
manifest_errors::kCannotAccessAboutUrl,
|
|
||||||
rfh->GetLastCommittedURL().spec(),
|
|
||||||
rfh->GetLastCommittedOrigin().Serialize());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor(
|
|
||||||
std::string* error) {
|
|
||||||
CHECK_GE(execute_tab_id_, 0);
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> 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,
|
|
||||||
std::string* error) {
|
|
||||||
if (cef_details_.LoadFile(
|
|
||||||
file, base::BindOnce(&ExecuteCodeInTabFunction::LoadFileComplete,
|
|
||||||
this, file))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default handling.
|
|
||||||
return ExecuteCodeFunction::LoadFile(file, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExecuteCodeInTabFunction::LoadFileComplete(
|
|
||||||
const std::string& file,
|
|
||||||
std::unique_ptr<std::string> data) {
|
|
||||||
std::vector<std::unique_ptr<std::string>> data_list;
|
|
||||||
std::optional<std::string> error;
|
|
||||||
const bool success = !!data.get();
|
|
||||||
if (success) {
|
|
||||||
DCHECK(data);
|
|
||||||
data_list.push_back(std::move(data));
|
|
||||||
} else {
|
|
||||||
error = base::StringPrintf("Failed to load file '%s'.", file.c_str());
|
|
||||||
}
|
|
||||||
DidLoadAndLocalizeFile(file, std::move(data_list), std::move(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TabsInsertCSSFunction::ShouldInsertCSS() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TabsRemoveCSSFunction::ShouldRemoveCSS() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
|
|
||||||
std::optional<tabs::SetZoom::Params> params =
|
|
||||||
tabs::SetZoom::Params::Create(args());
|
|
||||||
EXTENSION_FUNCTION_VALIDATE(params);
|
|
||||||
|
|
||||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
|
||||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
|
||||||
if (!web_contents) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
GURL url(web_contents->GetVisibleURL());
|
|
||||||
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_)) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZoomController* zoom_controller =
|
|
||||||
ZoomController::FromWebContents(web_contents);
|
|
||||||
double zoom_level =
|
|
||||||
params->zoom_factor > 0
|
|
||||||
? blink::PageZoomFactorToZoomLevel(params->zoom_factor)
|
|
||||||
: zoom_controller->GetDefaultZoomLevel();
|
|
||||||
|
|
||||||
auto client = base::MakeRefCounted<ExtensionZoomRequestClient>(extension());
|
|
||||||
if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) {
|
|
||||||
// Tried to zoom a tab in disabled mode.
|
|
||||||
return RespondNow(Error(tabs_constants::kCannotZoomDisabledTabError));
|
|
||||||
}
|
|
||||||
|
|
||||||
return RespondNow(NoArguments());
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
|
|
||||||
std::optional<tabs::GetZoom::Params> params =
|
|
||||||
tabs::GetZoom::Params::Create(args());
|
|
||||||
EXTENSION_FUNCTION_VALIDATE(params);
|
|
||||||
|
|
||||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
|
||||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
|
||||||
if (!web_contents) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
double zoom_level =
|
|
||||||
zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel();
|
|
||||||
double zoom_factor = blink::PageZoomLevelToZoomFactor(zoom_level);
|
|
||||||
|
|
||||||
return RespondNow(ArgumentList(tabs::GetZoom::Results::Create(zoom_factor)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
|
|
||||||
using tabs::ZoomSettings;
|
|
||||||
|
|
||||||
std::optional<tabs::SetZoomSettings::Params> params =
|
|
||||||
tabs::SetZoomSettings::Params::Create(args());
|
|
||||||
EXTENSION_FUNCTION_VALIDATE(params);
|
|
||||||
|
|
||||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
|
||||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
|
||||||
if (!web_contents) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
GURL url(web_contents->GetVisibleURL());
|
|
||||||
std::string error;
|
|
||||||
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_)) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// "per-origin" scope is only available in "automatic" mode.
|
|
||||||
if (params->zoom_settings.scope == tabs::ZoomSettingsScope::kPerOrigin &&
|
|
||||||
params->zoom_settings.mode != tabs::ZoomSettingsMode::kAutomatic &&
|
|
||||||
params->zoom_settings.mode != tabs::ZoomSettingsMode::kNone) {
|
|
||||||
return RespondNow(Error(tabs_constants::kPerOriginOnlyInAutomaticError));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the correct internal zoom mode to set |web_contents| to from the
|
|
||||||
// user-specified |zoom_settings|.
|
|
||||||
ZoomController::ZoomMode zoom_mode = ZoomController::ZOOM_MODE_DEFAULT;
|
|
||||||
switch (params->zoom_settings.mode) {
|
|
||||||
case tabs::ZoomSettingsMode::kNone:
|
|
||||||
case tabs::ZoomSettingsMode::kAutomatic:
|
|
||||||
switch (params->zoom_settings.scope) {
|
|
||||||
case tabs::ZoomSettingsScope::kNone:
|
|
||||||
case tabs::ZoomSettingsScope::kPerOrigin:
|
|
||||||
zoom_mode = ZoomController::ZOOM_MODE_DEFAULT;
|
|
||||||
break;
|
|
||||||
case tabs::ZoomSettingsScope::kPerTab:
|
|
||||||
zoom_mode = ZoomController::ZOOM_MODE_ISOLATED;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case tabs::ZoomSettingsMode::kManual:
|
|
||||||
zoom_mode = ZoomController::ZOOM_MODE_MANUAL;
|
|
||||||
break;
|
|
||||||
case tabs::ZoomSettingsMode::kDisabled:
|
|
||||||
zoom_mode = ZoomController::ZOOM_MODE_DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZoomController::FromWebContents(web_contents)->SetZoomMode(zoom_mode);
|
|
||||||
|
|
||||||
return RespondNow(NoArguments());
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
|
|
||||||
std::optional<tabs::GetZoomSettings::Params> params =
|
|
||||||
tabs::GetZoomSettings::Params::Create(args());
|
|
||||||
EXTENSION_FUNCTION_VALIDATE(params);
|
|
||||||
|
|
||||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
|
||||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
|
||||||
if (!web_contents) {
|
|
||||||
return RespondNow(Error(std::move(error_)));
|
|
||||||
}
|
|
||||||
ZoomController* zoom_controller =
|
|
||||||
ZoomController::FromWebContents(web_contents);
|
|
||||||
|
|
||||||
ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
|
|
||||||
tabs::ZoomSettings zoom_settings;
|
|
||||||
ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
|
|
||||||
zoom_settings.default_zoom_factor =
|
|
||||||
blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel());
|
|
||||||
|
|
||||||
return RespondNow(
|
|
||||||
ArgumentList(tabs::GetZoomSettings::Results::Create(zoom_settings)));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace extensions::cef
|
|
@ -1,185 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
|
||||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
|
||||||
|
|
||||||
#include "base/memory/raw_ptr.h"
|
|
||||||
#include "cef/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
|
|
||||||
// chrome/browser/extensions/api/tabs/tabs_api.h.
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class WebContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace extensions::cef {
|
|
||||||
|
|
||||||
class TabsGetFunction : public ExtensionFunction {
|
|
||||||
~TabsGetFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.get", TABS_GET)
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsCreateFunction : public ExtensionFunction {
|
|
||||||
public:
|
|
||||||
TabsCreateFunction();
|
|
||||||
~TabsCreateFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.create", TABS_CREATE)
|
|
||||||
|
|
||||||
private:
|
|
||||||
const CefExtensionFunctionDetails cef_details_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BaseAPIFunction : public ExtensionFunction {
|
|
||||||
public:
|
|
||||||
BaseAPIFunction();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~BaseAPIFunction() override = default;
|
|
||||||
|
|
||||||
// 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_|.
|
|
||||||
content::WebContents* GetWebContents(int tab_id);
|
|
||||||
|
|
||||||
std::string error_;
|
|
||||||
const CefExtensionFunctionDetails cef_details_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsUpdateFunction : public BaseAPIFunction {
|
|
||||||
private:
|
|
||||||
~TabsUpdateFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
bool UpdateURL(const std::string& url, int tab_id, std::string* error);
|
|
||||||
ResponseValue GetResult();
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.update", TABS_UPDATE)
|
|
||||||
|
|
||||||
int tab_id_ = -1;
|
|
||||||
raw_ptr<content::WebContents> web_contents_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Implement API calls tabs.executeScript, tabs.insertCSS, and tabs.removeCSS.
|
|
||||||
class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
|
||||||
public:
|
|
||||||
ExecuteCodeInTabFunction();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~ExecuteCodeInTabFunction() override;
|
|
||||||
|
|
||||||
// Initializes |execute_tab_id_| and |details_|.
|
|
||||||
InitResult Init() override;
|
|
||||||
bool ShouldInsertCSS() const override;
|
|
||||||
bool ShouldRemoveCSS() const override;
|
|
||||||
bool CanExecuteScriptOnPage(std::string* error) override;
|
|
||||||
ScriptExecutor* GetScriptExecutor(std::string* error) override;
|
|
||||||
bool IsWebView() const override;
|
|
||||||
const GURL& GetWebViewSrc() const override;
|
|
||||||
bool LoadFile(const std::string& file, std::string* error) 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_ = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
|
|
||||||
private:
|
|
||||||
~TabsExecuteScriptFunction() override = default;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT)
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
|
|
||||||
private:
|
|
||||||
~TabsInsertCSSFunction() override = default;
|
|
||||||
|
|
||||||
bool ShouldInsertCSS() const override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS)
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsRemoveCSSFunction : public ExecuteCodeInTabFunction {
|
|
||||||
private:
|
|
||||||
~TabsRemoveCSSFunction() override = default;
|
|
||||||
|
|
||||||
bool ShouldRemoveCSS() const override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.removeCSS", TABS_INSERTCSS)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Based on ChromeAsyncExtensionFunction.
|
|
||||||
class ZoomAPIFunction : public ExtensionFunction {
|
|
||||||
public:
|
|
||||||
ZoomAPIFunction();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~ZoomAPIFunction() override = default;
|
|
||||||
|
|
||||||
// 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_|.
|
|
||||||
content::WebContents* GetWebContents(int tab_id);
|
|
||||||
|
|
||||||
std::string error_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const CefExtensionFunctionDetails cef_details_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsSetZoomFunction : public BaseAPIFunction {
|
|
||||||
private:
|
|
||||||
~TabsSetZoomFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.setZoom", TABS_SETZOOM)
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsGetZoomFunction : public BaseAPIFunction {
|
|
||||||
private:
|
|
||||||
~TabsGetZoomFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.getZoom", TABS_GETZOOM)
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsSetZoomSettingsFunction : public BaseAPIFunction {
|
|
||||||
private:
|
|
||||||
~TabsSetZoomSettingsFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.setZoomSettings", TABS_SETZOOMSETTINGS)
|
|
||||||
};
|
|
||||||
|
|
||||||
class TabsGetZoomSettingsFunction : public BaseAPIFunction {
|
|
||||||
private:
|
|
||||||
~TabsGetZoomSettingsFunction() override = default;
|
|
||||||
|
|
||||||
ResponseAction Run() override;
|
|
||||||
|
|
||||||
DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS)
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace extensions::cef
|
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user