mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a29e9a3611 | ||
|
481a82af37 | ||
|
03f933676a | ||
|
8bb770500e | ||
|
fc87911e98 | ||
|
a717e440aa | ||
|
8856df480e | ||
|
ca81ee15f8 | ||
|
315d248d53 | ||
|
dd613a387b | ||
|
68f4b0c134 | ||
|
bbf40c7646 | ||
|
04acc3ebc4 | ||
|
9a70877443 | ||
|
be119b4c9a | ||
|
cc1b6ac609 | ||
|
4578ec8d19 | ||
|
4dd4abc3c2 | ||
|
c3aa36323b | ||
|
a1ba0c9166 | ||
|
e618f44667 | ||
|
9e296bde3c | ||
|
015e3621a3 | ||
|
cae194f493 | ||
|
4fbd247231 | ||
|
e94a261bf5 | ||
|
9022d40e6a | ||
|
38d8acfa18 | ||
|
7ca9e9c54b | ||
|
64c561f0bd | ||
|
f2c0c3f8fb | ||
|
5f9bd3ecbd | ||
|
8796d3cd95 | ||
|
cc56720bd2 | ||
|
88faf1023a | ||
|
42f517ec69 | ||
|
4791109a28 | ||
|
19391d8ab0 |
44
BUILD.gn
44
BUILD.gn
@@ -409,6 +409,8 @@ static_library("libcef_static") {
|
||||
gypi_paths.autogen_cpp_includes + [
|
||||
"libcef/browser/alloy/alloy_browser_context.cc",
|
||||
"libcef/browser/alloy/alloy_browser_context.h",
|
||||
"libcef/browser/alloy/alloy_browser_host_impl.cc",
|
||||
"libcef/browser/alloy/alloy_browser_host_impl.h",
|
||||
"libcef/browser/alloy/alloy_browser_main.cc",
|
||||
"libcef/browser/alloy/alloy_browser_main.h",
|
||||
"libcef/browser/alloy/browser_platform_delegate_alloy.cc",
|
||||
@@ -423,12 +425,15 @@ static_library("libcef_static") {
|
||||
"libcef/browser/alloy/alloy_content_browser_client.h",
|
||||
"libcef/browser/audio_capturer.cc",
|
||||
"libcef/browser/audio_capturer.h",
|
||||
"libcef/browser/browser_contents_delegate.cc",
|
||||
"libcef/browser/browser_contents_delegate.h",
|
||||
"libcef/browser/browser_context.cc",
|
||||
"libcef/browser/browser_context.h",
|
||||
"libcef/browser/browser_context_keyed_service_factories.cc",
|
||||
"libcef/browser/browser_context_keyed_service_factories.h",
|
||||
"libcef/browser/browser_host_impl.cc",
|
||||
"libcef/browser/browser_host_impl.h",
|
||||
"libcef/browser/browser_host_base.cc",
|
||||
"libcef/browser/browser_host_base.h",
|
||||
"libcef/browser/browser_host_create.cc",
|
||||
"libcef/browser/browser_info.cc",
|
||||
"libcef/browser/browser_info.h",
|
||||
"libcef/browser/browser_info_manager.cc",
|
||||
@@ -442,10 +447,15 @@ static_library("libcef_static") {
|
||||
"libcef/browser/browser_platform_delegate_create.cc",
|
||||
"libcef/browser/browser_util.cc",
|
||||
"libcef/browser/browser_util.h",
|
||||
"libcef/browser/chrome/browser_delegate.h",
|
||||
"libcef/browser/chrome/browser_platform_delegate_chrome.cc",
|
||||
"libcef/browser/chrome/browser_platform_delegate_chrome.h",
|
||||
"libcef/browser/chrome/chrome_browser_context.cc",
|
||||
"libcef/browser/chrome/chrome_browser_context.h",
|
||||
"libcef/browser/chrome/chrome_browser_delegate.cc",
|
||||
"libcef/browser/chrome/chrome_browser_delegate.h",
|
||||
"libcef/browser/chrome/chrome_browser_host_impl.cc",
|
||||
"libcef/browser/chrome/chrome_browser_host_impl.h",
|
||||
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.cc",
|
||||
"libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h",
|
||||
"libcef/browser/chrome/chrome_content_browser_client_cef.cc",
|
||||
@@ -546,6 +556,8 @@ static_library("libcef_static") {
|
||||
"libcef/browser/menu_runner.h",
|
||||
"libcef/browser/native/browser_platform_delegate_native.cc",
|
||||
"libcef/browser/native/browser_platform_delegate_native.h",
|
||||
"libcef/browser/native/cursor_util.h",
|
||||
"libcef/browser/native/cursor_util.cc",
|
||||
"libcef/browser/navigate_params.cc",
|
||||
"libcef/browser/navigate_params.h",
|
||||
"libcef/browser/navigation_entry_impl.cc",
|
||||
@@ -559,6 +571,8 @@ static_library("libcef_static") {
|
||||
"libcef/browser/net/internal_scheme_handler.h",
|
||||
"libcef/browser/net/scheme_handler.cc",
|
||||
"libcef/browser/net/scheme_handler.h",
|
||||
"libcef/browser/net/throttle_handler.cc",
|
||||
"libcef/browser/net/throttle_handler.h",
|
||||
"libcef/browser/net_service/browser_urlrequest_impl.cc",
|
||||
"libcef/browser/net_service/browser_urlrequest_impl.h",
|
||||
"libcef/browser/net_service/cookie_helper.cc",
|
||||
@@ -751,8 +765,18 @@ static_library("libcef_static") {
|
||||
"libcef/features/runtime_checks.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",
|
||||
"libcef/renderer/browser_impl.cc",
|
||||
"libcef/renderer/browser_impl.h",
|
||||
"libcef/renderer/browser_manager.cc",
|
||||
"libcef/renderer/browser_manager.h",
|
||||
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
|
||||
"libcef/renderer/chrome/chrome_content_renderer_client_cef.h",
|
||||
"libcef/renderer/dom_document_impl.cc",
|
||||
"libcef/renderer/dom_document_impl.h",
|
||||
"libcef/renderer/dom_node_impl.cc",
|
||||
@@ -774,8 +798,6 @@ static_library("libcef_static") {
|
||||
"libcef/renderer/render_urlrequest_impl.cc",
|
||||
"libcef/renderer/render_urlrequest_impl.h",
|
||||
"libcef/renderer/thread_util.h",
|
||||
"libcef/renderer/url_loader_throttle_provider_impl.cc",
|
||||
"libcef/renderer/url_loader_throttle_provider_impl.h",
|
||||
"libcef/renderer/v8_impl.cc",
|
||||
"libcef/renderer/v8_impl.h",
|
||||
|
||||
@@ -839,6 +861,7 @@ static_library("libcef_static") {
|
||||
"//components/google/core/common",
|
||||
"//components/keyed_service/content:content",
|
||||
"//components/keyed_service/core:core",
|
||||
"//components/media_router/common/mojom:media_router",
|
||||
"//components/navigation_interception",
|
||||
"//components/network_session_configurator/common",
|
||||
"//components/pdf/browser",
|
||||
@@ -886,7 +909,6 @@ static_library("libcef_static") {
|
||||
"//printing/buildflags",
|
||||
"//services/network:network_service",
|
||||
"//services/network/public/cpp",
|
||||
"//services/service_manager/embedder",
|
||||
"//services/service_manager/public/cpp",
|
||||
"//skia",
|
||||
"//storage/browser",
|
||||
@@ -918,6 +940,7 @@ static_library("libcef_static") {
|
||||
"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.h",
|
||||
"libcef/browser/native/cursor_util_win.cc",
|
||||
"libcef/browser/native/file_dialog_runner_win.cc",
|
||||
"libcef/browser/native/file_dialog_runner_win.h",
|
||||
"libcef/browser/native/javascript_dialog_runner_win.cc",
|
||||
@@ -931,7 +954,6 @@ static_library("libcef_static") {
|
||||
"libcef/browser/native/native_menu_win.h",
|
||||
"libcef/browser/osr/browser_platform_delegate_osr_win.cc",
|
||||
"libcef/browser/osr/browser_platform_delegate_osr_win.h",
|
||||
"libcef/browser/osr/render_widget_host_view_osr_win.cc",
|
||||
|
||||
# Part of //chrome/utility.
|
||||
"//chrome/utility/printing_handler.cc",
|
||||
@@ -962,11 +984,11 @@ static_library("libcef_static") {
|
||||
sources += includes_linux + [
|
||||
"libcef/browser/native/browser_platform_delegate_native_linux.cc",
|
||||
"libcef/browser/native/browser_platform_delegate_native_linux.h",
|
||||
"libcef/browser/native/cursor_util_linux.cc",
|
||||
"libcef/browser/native/menu_runner_linux.cc",
|
||||
"libcef/browser/native/menu_runner_linux.h",
|
||||
"libcef/browser/osr/browser_platform_delegate_osr_linux.cc",
|
||||
"libcef/browser/osr/browser_platform_delegate_osr_linux.h",
|
||||
"libcef/browser/osr/render_widget_host_view_osr_linux.cc",
|
||||
"libcef/browser/printing/print_dialog_linux.cc",
|
||||
"libcef/browser/printing/print_dialog_linux.h",
|
||||
]
|
||||
@@ -1166,7 +1188,6 @@ static_library("libcef_static") {
|
||||
sources += [
|
||||
# Support for UI input events.
|
||||
# Part of //ui/aura:test_support which is testingonly.
|
||||
"//ui/aura/test/x11_event_sender.cc",
|
||||
"//ui/aura/test/x11_event_sender.h",
|
||||
# Part of //ui/views:test_support which is testingonly.
|
||||
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
|
||||
@@ -1246,7 +1267,10 @@ if (is_mac) {
|
||||
sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ]
|
||||
# CEF sources use include paths relative to the CEF root directory.
|
||||
include_dirs = [ "." ]
|
||||
deps = [ "//sandbox/mac:seatbelt" ]
|
||||
deps = [
|
||||
"//build/config:executable_deps",
|
||||
"//sandbox/mac:seatbelt"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1611,7 +1635,7 @@ if (is_mac) {
|
||||
]
|
||||
public_deps += [ "//v8" ]
|
||||
if (use_v8_context_snapshot) {
|
||||
sources += [ "$root_out_dir/v8_context_snapshot.bin" ]
|
||||
sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
|
||||
public_deps += [ "//tools/v8_context_snapshot" ]
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,6 @@
|
||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||
|
||||
{
|
||||
'chromium_checkout': 'refs/tags/86.0.4240.198',
|
||||
'depot_tools_checkout': '5dba9c97fb'
|
||||
'chromium_checkout': 'refs/tags/87.0.4280.141',
|
||||
'depot_tools_checkout': '39d870e1f0'
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# distribution include:
|
||||
#
|
||||
# Linux: Ninja, Unix Makefiles
|
||||
# MacOS: Ninja, Xcode 8+
|
||||
# MacOS: Ninja, Xcode 8+ (x64) or Xcode 12.2+ (ARM64)
|
||||
# Windows: Ninja, Visual Studio 2015+
|
||||
#
|
||||
# Ninja is a cross-platform open-source tool for running fast builds using
|
||||
@@ -53,8 +53,8 @@
|
||||
# installed. Only 64-bit builds are supported.
|
||||
#
|
||||
# - Windows requirements:
|
||||
# Visual Studio 2015 or newer building on Windows 7 or newer. Visual Studio
|
||||
# 2019 and Windows 10 64-bit are recommended.
|
||||
# Visual Studio 2015 Update 2 or newer building on Windows 7 or newer. Visual
|
||||
# Studio 2019 and Windows 10 64-bit are recommended.
|
||||
#
|
||||
# BUILD EXAMPLES
|
||||
#
|
||||
@@ -84,6 +84,15 @@
|
||||
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
|
||||
# > ninja cefclient cefsimple
|
||||
#
|
||||
# To perform a MacOS build using an ARM64 CEF binary distribution:
|
||||
# Using the Xcode IDE:
|
||||
# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" ..
|
||||
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
||||
#
|
||||
# Using Ninja:
|
||||
# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug ..
|
||||
# > ninja cefclient cefsimple
|
||||
#
|
||||
# To perform a Windows build using a 32-bit CEF binary distribution:
|
||||
# Using the Visual Studio 2019 IDE:
|
||||
# > cmake -G "Visual Studio 16" -A Win32 ..
|
||||
|
@@ -328,6 +328,8 @@ if(OS_MAC)
|
||||
# Target architecture.
|
||||
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
elseif(PROJECT_ARCH STREQUAL "arm64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||
else()
|
||||
set(CMAKE_OSX_ARCHITECTURES "i386")
|
||||
endif()
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=6cb00a0fa3631a46903abb3a783f315895511db2$
|
||||
// $hash=965eb2e55afec0a4618a7acd9478b9c1215be29d$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
@@ -562,19 +562,6 @@ typedef struct _cef_browser_host_t {
|
||||
struct _cef_navigation_entry_visitor_t* visitor,
|
||||
int current_only);
|
||||
|
||||
///
|
||||
// Set whether mouse cursor change is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* set_mouse_cursor_change_disabled)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int disabled);
|
||||
|
||||
///
|
||||
// Returns true (1) if mouse cursor change is disabled.
|
||||
///
|
||||
int(CEF_CALLBACK* is_mouse_cursor_change_disabled)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// If a misspelled word is currently selected in an editable node calling this
|
||||
// function will replace it with the specified |word|.
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=306236316b35037523ca566068d133755bce48fd$
|
||||
// $hash=d56cbf83d6faefa9f716c7308bf7007dad98697d$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
@@ -41,6 +41,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_client_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_print_handler_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
@@ -60,6 +61,25 @@ typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread to retrieve the list of schemes
|
||||
// that should support cookies. If |include_defaults| is true (1) the default
|
||||
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
|
||||
// an NULL |schemes| value and setting |include_defaults| to false (0) will
|
||||
// disable all loading and saving of cookies.
|
||||
//
|
||||
// This state will apply to the cef_cookie_manager_t associated with the
|
||||
// global cef_request_context_t. It will also be used as the initial state for
|
||||
// any new cef_request_context_ts created by the client. After creating a new
|
||||
// cef_request_context_t the cef_cookie_manager_t::SetSupportedSchemes
|
||||
// function may be called on the associated cef_cookie_manager_t to futher
|
||||
// override these values.
|
||||
///
|
||||
void(CEF_CALLBACK* get_cookieable_schemes)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
cef_string_list_t schemes,
|
||||
int* include_defaults);
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the CEF context
|
||||
// has been initialized.
|
||||
@@ -101,6 +121,16 @@ typedef struct _cef_browser_process_handler_t {
|
||||
void(CEF_CALLBACK* on_schedule_message_pump_work)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
int64 delay_ms);
|
||||
|
||||
///
|
||||
// Return the default client for use with a newly created browser window. If
|
||||
// null is returned the browser will be unmanaged (no callbacks will be
|
||||
// executed for that browser) and application shutdown will be blocked until
|
||||
// the browser window is closed manually. This function is currently only used
|
||||
// with the chrome runtime.
|
||||
///
|
||||
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
} cef_browser_process_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=951c936c8070dbf9bd246cc766b81cdfe06a3d81$
|
||||
// $hash=eada7e92085d96497f4e69f3e8a7e8aa6746b175$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||
@@ -141,6 +141,19 @@ typedef struct _cef_display_handler_t {
|
||||
struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
double progress);
|
||||
|
||||
///
|
||||
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||
// |custom_cursor_info| will be populated with the custom cursor information.
|
||||
// Return true (1) if the cursor change was handled or false (0) for default
|
||||
// handling.
|
||||
///
|
||||
int(CEF_CALLBACK* on_cursor_change)(
|
||||
struct _cef_display_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_cursor_handle_t cursor,
|
||||
cef_cursor_type_t type,
|
||||
const struct _cef_cursor_info_t* custom_cursor_info);
|
||||
} cef_display_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=14cf03e02d8ca3416e65f756470afd8185c7bc78$
|
||||
// $hash=19337a70a13352e70452be7fcc25ef2de4b1ae4c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_
|
||||
@@ -153,13 +153,11 @@ CEF_EXPORT struct _cef_value_t* cef_parse_json_buffer(
|
||||
///
|
||||
// Parses the specified |json_string| and returns a dictionary or list
|
||||
// representation. If JSON parsing fails this function returns NULL and
|
||||
// populates |error_code_out| and |error_msg_out| with an error code and a
|
||||
// formatted error message respectively.
|
||||
// populates |error_msg_out| with a formatted error message.
|
||||
///
|
||||
CEF_EXPORT struct _cef_value_t* cef_parse_jsonand_return_error(
|
||||
const cef_string_t* json_string,
|
||||
cef_json_parser_options_t options,
|
||||
cef_json_parser_error_t* error_code_out,
|
||||
cef_string_t* error_msg_out);
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e642fc1fe3b97a90c0eae7f0fc0a5cfd385e3e17$
|
||||
// $hash=f9806cd79f33b6a762fff25edd4189ae42bc8fd2$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_
|
||||
@@ -159,17 +159,6 @@ typedef struct _cef_render_handler_t {
|
||||
cef_rect_t const* dirtyRects,
|
||||
void* shared_handle);
|
||||
|
||||
///
|
||||
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||
// |custom_cursor_info| will be populated with the custom cursor information.
|
||||
///
|
||||
void(CEF_CALLBACK* on_cursor_change)(
|
||||
struct _cef_render_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_cursor_handle_t cursor,
|
||||
cef_cursor_type_t type,
|
||||
const struct _cef_cursor_info_t* custom_cursor_info);
|
||||
|
||||
///
|
||||
// Called when the user starts dragging content in the web view. Contextual
|
||||
// information about the dragged content is supplied by |drag_data|. (|x|,
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=370cdeaa3252a9ed0e1a627d858dcab23af24ee1$
|
||||
// $hash=d443c0990241554b548bc946f46f35582445e818$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_
|
||||
@@ -98,8 +98,8 @@ typedef struct _cef_thread_t {
|
||||
// identify the thread. |priority| is the thread execution priority.
|
||||
// |message_loop_type| indicates the set of asynchronous events that the thread
|
||||
// can process. If |stoppable| is true (1) the thread will stopped and joined on
|
||||
// destruction or when stop() is called; otherwise, the the thread cannot be
|
||||
// stopped and will be leaked on shutdown. On Windows the |com_init_mode| value
|
||||
// destruction or when stop() is called; otherwise, the thread cannot be stopped
|
||||
// and will be leaked on shutdown. On Windows the |com_init_mode| value
|
||||
// specifies how COM will be initialized for the thread. If |com_init_mode| is
|
||||
// set to COM_INIT_MODE_STA then |message_loop_type| must be set to ML_TYPE_UI.
|
||||
///
|
||||
|
@@ -42,13 +42,13 @@
|
||||
// way that may cause binary incompatibility with other builds. The universal
|
||||
// hash value will change if any platform is affected whereas the platform hash
|
||||
// values will change only if that particular platform is affected.
|
||||
#define CEF_API_HASH_UNIVERSAL "09d3d4f08869644fe3baa7a751de537f3446525b"
|
||||
#define CEF_API_HASH_UNIVERSAL "7f349b7262bfe13bda037370004f56a6081e543b"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "3022db6736af26cc38158d38e22f74a51312a5c9"
|
||||
#define CEF_API_HASH_PLATFORM "8a5523fec15255e2fb1de64deaa15dc3554b91e5"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "13e2e2451c2320f0d16b35ba53b3295409888dd8"
|
||||
#define CEF_API_HASH_PLATFORM "f572c8f7d3aee3cd3b85bd398b0ba43eb7fe79a0"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "d781b815150795b0bce95d72ce967b508c9a04d5"
|
||||
#define CEF_API_HASH_PLATFORM "abf4cc6ff102e5cd019aaf51f13eb30f9bfeae45"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -592,18 +592,6 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
||||
CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||
bool current_only) = 0;
|
||||
|
||||
///
|
||||
// Set whether mouse cursor change is disabled.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetMouseCursorChangeDisabled(bool disabled) = 0;
|
||||
|
||||
///
|
||||
// Returns true if mouse cursor change is disabled.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsMouseCursorChangeDisabled() = 0;
|
||||
|
||||
///
|
||||
// If a misspelled word is currently selected in an editable node calling
|
||||
// this method will replace it with the specified |word|.
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_print_handler.h"
|
||||
#include "include/cef_values.h"
|
||||
@@ -50,6 +51,23 @@
|
||||
/*--cef(source=client,no_debugct_check)--*/
|
||||
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
// Called on the browser process UI thread to retrieve the list of schemes
|
||||
// that should support cookies. If |include_defaults| is true the default
|
||||
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
|
||||
// an empty |schemes| value and setting |include_defaults| to false will
|
||||
// disable all loading and saving of cookies.
|
||||
//
|
||||
// This state will apply to the CefCookieManager associated with the global
|
||||
// CefRequestContext. It will also be used as the initial state for any new
|
||||
// CefRequestContexts created by the client. After creating a new
|
||||
// CefRequestContext the CefCookieManager::SetSupportedSchemes method may be
|
||||
// called on the associated CefCookieManager to futher override these values.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void GetCookieableSchemes(std::vector<CefString>& schemes,
|
||||
bool& include_defaults) {}
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the CEF context
|
||||
// has been initialized.
|
||||
@@ -90,6 +108,16 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnScheduleMessagePumpWork(int64 delay_ms) {}
|
||||
|
||||
///
|
||||
// Return the default client for use with a newly created browser window. If
|
||||
// null is returned the browser will be unmanaged (no callbacks will be
|
||||
// executed for that browser) and application shutdown will be blocked until
|
||||
// the browser window is closed manually. This method is currently only used
|
||||
// with the chrome runtime.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefClient> GetDefaultClient() { return nullptr; }
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
|
||||
|
@@ -135,6 +135,19 @@ class CefDisplayHandler : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
virtual void OnLoadingProgressChange(CefRefPtr<CefBrowser> browser,
|
||||
double progress) {}
|
||||
|
||||
///
|
||||
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||
// |custom_cursor_info| will be populated with the custom cursor information.
|
||||
// Return true if the cursor change was handled or false for default handling.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnCursorChange(CefRefPtr<CefBrowser> browser,
|
||||
CefCursorHandle cursor,
|
||||
cef_cursor_type_t type,
|
||||
const CefCursorInfo& custom_cursor_info) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_
|
||||
|
@@ -146,14 +146,12 @@ CefRefPtr<CefValue> CefParseJSON(const void* json,
|
||||
///
|
||||
// Parses the specified |json_string| and returns a dictionary or list
|
||||
// representation. If JSON parsing fails this method returns NULL and populates
|
||||
// |error_code_out| and |error_msg_out| with an error code and a formatted error
|
||||
// message respectively.
|
||||
// |error_msg_out| with a formatted error message.
|
||||
///
|
||||
/*--cef()--*/
|
||||
CefRefPtr<CefValue> CefParseJSONAndReturnError(
|
||||
const CefString& json_string,
|
||||
cef_json_parser_options_t options,
|
||||
cef_json_parser_error_t& error_code_out,
|
||||
CefString& error_msg_out);
|
||||
|
||||
///
|
||||
|
@@ -52,7 +52,6 @@
|
||||
/*--cef(source=client)--*/
|
||||
class CefRenderHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
typedef cef_cursor_type_t CursorType;
|
||||
typedef cef_drag_operations_mask_t DragOperation;
|
||||
typedef cef_drag_operations_mask_t DragOperationsMask;
|
||||
typedef cef_paint_element_type_t PaintElementType;
|
||||
@@ -162,16 +161,6 @@ class CefRenderHandler : public virtual CefBaseRefCounted {
|
||||
const RectList& dirtyRects,
|
||||
void* shared_handle) {}
|
||||
|
||||
///
|
||||
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||
// |custom_cursor_info| will be populated with the custom cursor information.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
|
||||
CefCursorHandle cursor,
|
||||
CursorType type,
|
||||
const CefCursorInfo& custom_cursor_info) {}
|
||||
|
||||
///
|
||||
// Called when the user starts dragging content in the web view. Contextual
|
||||
// information about the dragged content is supplied by |drag_data|.
|
||||
|
@@ -61,7 +61,7 @@ class CefThread : public CefBaseRefCounted {
|
||||
// to identify the thread. |priority| is the thread execution priority.
|
||||
// |message_loop_type| indicates the set of asynchronous events that the
|
||||
// thread can process. If |stoppable| is true the thread will stopped and
|
||||
// joined on destruction or when Stop() is called; otherwise, the the thread
|
||||
// joined on destruction or when Stop() is called; otherwise, the thread
|
||||
// cannot be stopped and will be leaked on shutdown. On Windows the
|
||||
// |com_init_mode| value specifies how COM will be initialized for the thread.
|
||||
// If |com_init_mode| is set to COM_INIT_MODE_STA then |message_loop_type|
|
||||
|
@@ -2367,22 +2367,6 @@ typedef enum {
|
||||
JSON_PARSER_ALLOW_TRAILING_COMMAS = 1 << 0,
|
||||
} cef_json_parser_options_t;
|
||||
|
||||
///
|
||||
// Error codes that can be returned from CefParseJSONAndReturnError.
|
||||
///
|
||||
typedef enum {
|
||||
JSON_NO_ERROR = 0,
|
||||
JSON_INVALID_ESCAPE,
|
||||
JSON_SYNTAX_ERROR,
|
||||
JSON_UNEXPECTED_TOKEN,
|
||||
JSON_TRAILING_COMMA,
|
||||
JSON_TOO_MUCH_NESTING,
|
||||
JSON_UNEXPECTED_DATA_AFTER_ROOT,
|
||||
JSON_UNSUPPORTED_ENCODING,
|
||||
JSON_UNQUOTED_DICTIONARY_KEY,
|
||||
JSON_PARSE_ERROR_COUNT
|
||||
} cef_json_parser_error_t;
|
||||
|
||||
///
|
||||
// Options that can be passed to CefWriteJSON.
|
||||
///
|
||||
|
@@ -285,10 +285,6 @@ bool AlloyBrowserContext::IsPrintPreviewSupported() const {
|
||||
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
|
||||
}
|
||||
|
||||
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
|
||||
visitedlink_master_->AddURLs(urls);
|
||||
}
|
||||
|
||||
content::ResourceContext* AlloyBrowserContext::GetResourceContext() {
|
||||
if (!resource_context_) {
|
||||
resource_context_ = std::make_unique<content::ResourceContext>();
|
||||
@@ -454,3 +450,7 @@ DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() {
|
||||
}
|
||||
return download_prefs_.get();
|
||||
}
|
||||
|
||||
void AlloyBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
|
||||
visitedlink_master_->AddURLs(urls);
|
||||
}
|
||||
|
@@ -53,7 +53,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
||||
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
|
||||
bool UnloadExtension(const CefString& extension_id) override;
|
||||
bool IsPrintPreviewSupported() const override;
|
||||
void AddVisitedURLs(const std::vector<GURL>& urls) override;
|
||||
|
||||
// content::BrowserContext overrides.
|
||||
content::ResourceContext* GetResourceContext() override;
|
||||
@@ -104,9 +103,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
||||
bool ShouldPersistSessionCookies() const override {
|
||||
return !!settings_.persist_session_cookies;
|
||||
}
|
||||
base::Optional<std::vector<std::string>> GetCookieableSchemes() override {
|
||||
return cookieable_schemes();
|
||||
}
|
||||
|
||||
// visitedlink::VisitedLinkDelegate methods.
|
||||
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
|
||||
@@ -116,6 +112,10 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
||||
return extension_system_;
|
||||
}
|
||||
|
||||
// Called from AlloyBrowserHostImpl::DidFinishNavigation to update the table
|
||||
// of visited links.
|
||||
void AddVisitedURLs(const std::vector<GURL>& urls);
|
||||
|
||||
// Called from DownloadPrefs::FromBrowserContext.
|
||||
DownloadPrefs* GetDownloadPrefs();
|
||||
|
||||
|
1754
libcef/browser/alloy/alloy_browser_host_impl.cc
Normal file
1754
libcef/browser/alloy/alloy_browser_host_impl.cc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,8 @@
|
||||
// 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_HOST_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_BROWSER_HOST_IMPL_H_
|
||||
#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_HOST_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_HOST_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/file_dialog_manager.h"
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
@@ -22,62 +22,36 @@
|
||||
#include "libcef/browser/menu_manager.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "extensions/common/view_type.h"
|
||||
|
||||
namespace content {
|
||||
struct DragEventSourceInfo;
|
||||
class RenderWidgetHostImpl;
|
||||
} // namespace content
|
||||
|
||||
namespace extensions {
|
||||
class Extension;
|
||||
class ExtensionHost;
|
||||
} // namespace extensions
|
||||
|
||||
namespace gfx {
|
||||
class ImageSkia;
|
||||
}
|
||||
|
||||
#if defined(USE_AURA)
|
||||
namespace views {
|
||||
class Widget;
|
||||
}
|
||||
#endif // defined(USE_AURA)
|
||||
|
||||
class CefAudioCapturer;
|
||||
class CefBrowserInfo;
|
||||
class CefBrowserPlatformDelegate;
|
||||
class CefDevToolsManager;
|
||||
class SiteInstance;
|
||||
|
||||
// Implementation of CefBrowser.
|
||||
// CefBrowser implementation for the alloy runtime. Method calls are delegated
|
||||
// to the CefPlatformDelegate or the WebContents as appropriate. All methods are
|
||||
// thread-safe unless otherwise indicated.
|
||||
//
|
||||
// WebContentsDelegate: Interface for handling WebContents delegations. There is
|
||||
// a one-to-one relationship between CefBrowserHostImpl and WebContents
|
||||
// a one-to-one relationship between AlloyBrowserHostImpl and WebContents
|
||||
// instances.
|
||||
//
|
||||
// WebContentsObserver: Interface for observing WebContents notifications and
|
||||
// IPC messages. There is a one-to-one relationship between WebContents and
|
||||
// RenderViewHost instances. IPC messages received by the RenderViewHost will be
|
||||
// forwarded to this WebContentsObserver implementation via WebContents. IPC
|
||||
// messages sent using CefBrowserHostImpl::Send() will be forwarded to the
|
||||
// messages sent using AlloyBrowserHostImpl::Send() will be forwarded to the
|
||||
// RenderViewHost (after posting to the UI thread if necessary). Use
|
||||
// WebContentsObserver::routing_id() when sending IPC messages.
|
||||
//
|
||||
// NotificationObserver: Interface for observing post-processed notifications.
|
||||
class CefBrowserHostImpl : public CefBrowserHost,
|
||||
public CefBrowser,
|
||||
public content::WebContentsDelegate,
|
||||
public content::WebContentsObserver,
|
||||
public content::NotificationObserver {
|
||||
class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
public content::WebContentsDelegate,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
// Used for handling the response to command messages.
|
||||
class CommandResponseHandler : public virtual CefBaseRefCounted {
|
||||
@@ -85,87 +59,36 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
virtual void OnResponse(const std::string& response) = 0;
|
||||
};
|
||||
|
||||
// Interface to implement for observers that wish to be informed of changes
|
||||
// to the CefBrowserHostImpl. All methods will be called on the UI thread.
|
||||
class Observer {
|
||||
public:
|
||||
// Called before |browser| is destroyed. Any references to |browser| should
|
||||
// be cleared when this method is called.
|
||||
virtual void OnBrowserDestroyed(CefBrowserHostImpl* browser) = 0;
|
||||
~AlloyBrowserHostImpl() override;
|
||||
|
||||
protected:
|
||||
virtual ~Observer() {}
|
||||
};
|
||||
|
||||
~CefBrowserHostImpl() override;
|
||||
|
||||
struct CreateParams {
|
||||
// Platform-specific window creation info. Will be nullptr when creating a
|
||||
// views-hosted browser.
|
||||
std::unique_ptr<CefWindowInfo> window_info;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
// The BrowserView that will own a views-hosted browser. Will be nullptr for
|
||||
// popup browsers (the BrowserView will be created later in that case).
|
||||
CefRefPtr<CefBrowserView> browser_view;
|
||||
#endif
|
||||
|
||||
// Client implementation. May be nullptr.
|
||||
CefRefPtr<CefClient> client;
|
||||
|
||||
// Initial URL to load. May be empty. If this is a valid extension URL then
|
||||
// the browser will be created as an app view extension host.
|
||||
GURL url;
|
||||
|
||||
// Browser settings.
|
||||
CefBrowserSettings settings;
|
||||
|
||||
// Other browser that opened this DevTools browser. Will be nullptr for non-
|
||||
// DevTools browsers.
|
||||
CefRefPtr<CefBrowserHostImpl> devtools_opener;
|
||||
|
||||
// Request context to use when creating the browser. If nullptr the global
|
||||
// request context will be used.
|
||||
CefRefPtr<CefRequestContext> request_context;
|
||||
|
||||
CefRefPtr<CefDictionaryValue> extra_info;
|
||||
|
||||
// Used when explicitly creating the browser as an extension host via
|
||||
// ProcessManager::CreateBackgroundHost.
|
||||
const extensions::Extension* extension = nullptr;
|
||||
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
|
||||
};
|
||||
|
||||
// Create a new CefBrowserHostImpl instance.
|
||||
static CefRefPtr<CefBrowserHostImpl> Create(CreateParams& create_params);
|
||||
// Create a new AlloyBrowserHostImpl instance with owned WebContents.
|
||||
static CefRefPtr<AlloyBrowserHostImpl> Create(
|
||||
CefBrowserCreateParams& create_params);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForHost(
|
||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForHost(
|
||||
const content::RenderViewHost* host);
|
||||
// Returns the browser associated with the specified RenderFrameHost.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForHost(
|
||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForHost(
|
||||
const content::RenderFrameHost* host);
|
||||
// Returns the browser associated with the specified WebContents.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForContents(
|
||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForContents(
|
||||
const content::WebContents* contents);
|
||||
// Returns the browser associated with the specified FrameTreeNode ID.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrameTreeNode(
|
||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForFrameTreeNode(
|
||||
int frame_tree_node_id);
|
||||
// Returns the browser associated with the specified frame routing IDs.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrameRoute(
|
||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id);
|
||||
|
||||
// CefBrowserHost methods.
|
||||
CefRefPtr<CefBrowser> GetBrowser() override;
|
||||
void CloseBrowser(bool force_close) override;
|
||||
bool TryCloseBrowser() override;
|
||||
void SetFocus(bool focus) override;
|
||||
CefWindowHandle GetWindowHandle() override;
|
||||
CefWindowHandle GetOpenerWindowHandle() override;
|
||||
bool HasView() override;
|
||||
CefRefPtr<CefClient> GetClient() override;
|
||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||
double GetZoomLevel() override;
|
||||
void SetZoomLevel(double zoomLevel) override;
|
||||
void RunFileDialog(FileDialogMode mode,
|
||||
@@ -174,12 +97,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) override;
|
||||
void StartDownload(const CefString& url) override;
|
||||
void DownloadImage(const CefString& image_url,
|
||||
bool is_favicon,
|
||||
uint32 max_image_size,
|
||||
bool bypass_cache,
|
||||
CefRefPtr<CefDownloadImageCallback> callback) override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
@@ -202,27 +119,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
CefRefPtr<CefDictionaryValue> params) override;
|
||||
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
|
||||
CefRefPtr<CefDevToolsMessageObserver> observer) override;
|
||||
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||
bool current_only) override;
|
||||
void SetMouseCursorChangeDisabled(bool disabled) override;
|
||||
bool IsMouseCursorChangeDisabled() override;
|
||||
bool IsWindowRenderingDisabled() override;
|
||||
void ReplaceMisspelling(const CefString& word) override;
|
||||
void AddWordToDictionary(const CefString& word) override;
|
||||
void WasResized() override;
|
||||
void WasHidden(bool hidden) override;
|
||||
void NotifyScreenInfoChanged() override;
|
||||
void Invalidate(PaintElementType type) override;
|
||||
void SendExternalBeginFrame() override;
|
||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||
void SendMouseClickEvent(const CefMouseEvent& event,
|
||||
MouseButtonType type,
|
||||
bool mouseUp,
|
||||
int clickCount) override;
|
||||
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
||||
void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) override;
|
||||
void SendTouchEvent(const CefTouchEvent& event) override;
|
||||
void SendFocusEvent(bool setFocus) override;
|
||||
void SendCaptureLostEvent() override;
|
||||
@@ -249,7 +151,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
|
||||
void SetAudioMuted(bool mute) override;
|
||||
bool IsAudioMuted() override;
|
||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||
void SetAccessibilityState(cef_state_t accessibility_state) override;
|
||||
void SetAutoResizeEnabled(bool enabled,
|
||||
const CefSize& min_size,
|
||||
@@ -257,28 +158,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
CefRefPtr<CefExtension> GetExtension() override;
|
||||
bool IsBackgroundHost() override;
|
||||
|
||||
// CefBrowser methods.
|
||||
CefRefPtr<CefBrowserHost> GetHost() override;
|
||||
bool CanGoBack() override;
|
||||
void GoBack() override;
|
||||
bool CanGoForward() override;
|
||||
void GoForward() override;
|
||||
bool IsLoading() override;
|
||||
void Reload() override;
|
||||
void ReloadIgnoreCache() override;
|
||||
void StopLoad() override;
|
||||
int GetIdentifier() override;
|
||||
bool IsSame(CefRefPtr<CefBrowser> that) override;
|
||||
bool IsPopup() override;
|
||||
bool HasDocument() override;
|
||||
CefRefPtr<CefFrame> GetMainFrame() override;
|
||||
CefRefPtr<CefFrame> GetFocusedFrame() override;
|
||||
CefRefPtr<CefFrame> GetFrame(int64 identifier) override;
|
||||
CefRefPtr<CefFrame> GetFrame(const CefString& name) override;
|
||||
size_t GetFrameCount() override;
|
||||
void GetFrameIdentifiers(std::vector<int64>& identifiers) override;
|
||||
void GetFrameNames(std::vector<CefString>& names) override;
|
||||
|
||||
// Returns true if windowless rendering is enabled.
|
||||
bool IsWindowless() const;
|
||||
|
||||
@@ -293,7 +172,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
|
||||
// Destroy the browser members. This method should only be called after the
|
||||
// native browser window is not longer processing messages.
|
||||
void DestroyBrowser();
|
||||
void DestroyBrowser() override;
|
||||
|
||||
// Cancel display of the context menu, if any.
|
||||
void CancelContextMenu();
|
||||
@@ -308,53 +187,29 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
CefRefPtr<CefBrowserView> GetBrowserView() const;
|
||||
#endif
|
||||
|
||||
// Returns the frame associated with the specified RenderFrameHost.
|
||||
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
|
||||
|
||||
// Returns the frame associated with the specified FrameTreeNode ID.
|
||||
CefRefPtr<CefFrame> GetFrameForFrameTreeNode(int frame_tree_node_id);
|
||||
|
||||
// Load the specified URL in the main frame.
|
||||
void LoadMainFrameURL(const std::string& url,
|
||||
const content::Referrer& referrer,
|
||||
ui::PageTransition transition,
|
||||
const std::string& extra_headers);
|
||||
|
||||
// Called from CefFrameHostImpl.
|
||||
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||
const GURL& validated_url,
|
||||
int http_status_code);
|
||||
|
||||
// Open the specified text in the default text editor.
|
||||
void ViewText(const std::string& text);
|
||||
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params) override;
|
||||
|
||||
// Convert from view coordinates to screen coordinates. Potential display
|
||||
// scaling will be applied to the result.
|
||||
gfx::Point GetScreenPoint(const gfx::Point& view) const;
|
||||
|
||||
void StartDragging(const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
blink::DragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
const blink::mojom::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
void UpdateDragCursor(blink::WebDragOperation operation);
|
||||
void UpdateDragCursor(blink::DragOperation operation);
|
||||
|
||||
// Thread safe accessors.
|
||||
const CefBrowserSettings& settings() const { return settings_; }
|
||||
SkColor GetBackgroundColor() const;
|
||||
CefRefPtr<CefClient> client() const { return client_; }
|
||||
scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; }
|
||||
int browser_id() const;
|
||||
CefRefPtr<CefRequestContextImpl> request_context() const {
|
||||
return request_context_;
|
||||
}
|
||||
|
||||
// Accessors that must be called on the UI thread.
|
||||
content::BrowserContext* GetBrowserContext() const;
|
||||
extensions::ExtensionHost* GetExtensionHost() const;
|
||||
|
||||
void OnSetFocus(cef_focus_source_t source);
|
||||
void OnSetFocus(cef_focus_source_t source) override;
|
||||
|
||||
// Run the file chooser dialog specified by |params|. Only a single dialog may
|
||||
// be pending at any given time. |callback| will be executed asynchronously
|
||||
@@ -387,7 +242,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
bool* was_blocked) override;
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool to_different_document) override;
|
||||
void LoadProgressChanged(double progress) override;
|
||||
void CloseContents(content::WebContents* source) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
@@ -411,7 +265,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const blink::WebGestureEvent& event) override;
|
||||
bool CanDragEnter(content::WebContents* source,
|
||||
const content::DropData& data,
|
||||
blink::WebDragOperationsMask operations_allowed) override;
|
||||
blink::DragOperationsMask operations_allowed) override;
|
||||
void GetCustomWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& target_url,
|
||||
@@ -467,87 +321,39 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
|
||||
// content::WebContentsObserver methods.
|
||||
using content::WebContentsObserver::BeforeUnloadFired;
|
||||
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
||||
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
||||
content::RenderFrameHost* new_host) override;
|
||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
|
||||
void RenderViewReady() override;
|
||||
void RenderProcessGone(base::TerminationStatus status) override;
|
||||
void DidFinishNavigation(
|
||||
content::NavigationHandle* navigation_handle) override;
|
||||
void DidStopLoading() override;
|
||||
void DocumentAvailableInMainFrame() override;
|
||||
void DidFailLoad(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url,
|
||||
int error_code) override;
|
||||
void TitleWasSet(content::NavigationEntry* entry) override;
|
||||
void PluginCrashed(const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) override;
|
||||
void DidUpdateFaviconURL(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
|
||||
void OnAudioStateChanged(bool audible) override;
|
||||
bool OnMessageReceived(const IPC::Message& message,
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
|
||||
void AccessibilityEventReceived(
|
||||
const content::AXEventNotificationDetails& content_event_bundle) override;
|
||||
void AccessibilityLocationChangesReceived(
|
||||
const std::vector<content::AXLocationChangeNotificationDetails>& locData)
|
||||
override;
|
||||
void OnWebContentsFocused(
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
void WebContentsDestroyed() override;
|
||||
|
||||
// Manage observer objects. The observer must either outlive this object or
|
||||
// remove itself before destruction. These methods can only be called on the
|
||||
// UI thread.
|
||||
void AddObserver(Observer* observer);
|
||||
void RemoveObserver(Observer* observer);
|
||||
bool HasObserver(Observer* observer) const;
|
||||
|
||||
class NavigationLock final {
|
||||
private:
|
||||
friend class CefBrowserHostImpl;
|
||||
friend std::unique_ptr<NavigationLock>::deleter_type;
|
||||
|
||||
explicit NavigationLock(CefRefPtr<CefBrowserHostImpl> browser);
|
||||
~NavigationLock();
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser_;
|
||||
};
|
||||
|
||||
// Block navigation-related events on NavigationLock life span.
|
||||
std::unique_ptr<NavigationLock> CreateNavigationLock();
|
||||
|
||||
private:
|
||||
friend class CefBrowserPlatformDelegateAlloy;
|
||||
|
||||
static CefRefPtr<CefBrowserHostImpl> CreateInternal(
|
||||
static CefRefPtr<AlloyBrowserHostImpl> CreateInternal(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* web_contents,
|
||||
bool own_web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefBrowserHostImpl> opener,
|
||||
CefRefPtr<AlloyBrowserHostImpl> opener,
|
||||
bool is_devtools_popup,
|
||||
CefRefPtr<CefRequestContextImpl> request_context,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
CefRefPtr<CefExtension> extension);
|
||||
|
||||
// content::NotificationObserver methods.
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
CefBrowserHostImpl(
|
||||
AlloyBrowserHostImpl(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefBrowserHostImpl> opener,
|
||||
CefRefPtr<AlloyBrowserHostImpl> opener,
|
||||
CefRefPtr<CefRequestContextImpl> request_context,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
CefRefPtr<CefExtension> extension);
|
||||
@@ -555,21 +361,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Give the platform delegate an opportunity to create the host window.
|
||||
bool CreateHostWindow();
|
||||
|
||||
// Returns true if navigation actions are currently locked.
|
||||
bool navigation_locked() const;
|
||||
// Action to be executed once the navigation lock is released.
|
||||
void set_pending_navigation_action(base::OnceClosure action);
|
||||
|
||||
void OnAddressChange(const GURL& url);
|
||||
void OnLoadStart(CefRefPtr<CefFrame> frame,
|
||||
ui::PageTransition transition_type);
|
||||
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
|
||||
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code);
|
||||
void OnFullscreenModeChange(bool fullscreen);
|
||||
void OnTitleChange(const base::string16& title);
|
||||
|
||||
// Create the CefFileDialogManager if it doesn't already exist.
|
||||
void EnsureFileDialogManager();
|
||||
|
||||
@@ -580,57 +371,23 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void InitializeDevToolsRegistrationOnUIThread(
|
||||
CefRefPtr<CefRegistration> registration);
|
||||
|
||||
CefBrowserSettings settings_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
scoped_refptr<CefBrowserInfo> browser_info_;
|
||||
void SetFocusInternal(bool focus);
|
||||
|
||||
CefWindowHandle opener_;
|
||||
CefRefPtr<CefRequestContextImpl> request_context_;
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
|
||||
const bool is_windowless_;
|
||||
const bool is_views_hosted_;
|
||||
CefWindowHandle host_window_handle_ = kNullWindowHandle;
|
||||
CefRefPtr<CefExtension> extension_;
|
||||
bool is_background_host_ = false;
|
||||
|
||||
// Volatile state information. All access must be protected by the state lock.
|
||||
base::Lock state_lock_;
|
||||
bool is_loading_ = false;
|
||||
bool can_go_back_ = false;
|
||||
bool can_go_forward_ = false;
|
||||
bool has_document_ = false;
|
||||
bool is_fullscreen_ = false;
|
||||
|
||||
// The currently focused frame, or nullptr if the main frame is focused.
|
||||
CefRefPtr<CefFrameHostImpl> focused_frame_;
|
||||
|
||||
// Represents the current browser destruction state. Only accessed on the UI
|
||||
// thread.
|
||||
DestructionState destruction_state_ = DESTRUCTION_STATE_NONE;
|
||||
|
||||
// Navigation will not occur while |navigation_lock_count_| > 0.
|
||||
// |pending_navigation_action_| will be executed when the lock is released.
|
||||
// Only accessed on the UI thread.
|
||||
int navigation_lock_count_ = 0;
|
||||
base::OnceClosure pending_navigation_action_;
|
||||
|
||||
// True if the OS window hosting the browser has been destroyed. Only accessed
|
||||
// on the UI thread.
|
||||
bool window_destroyed_ = false;
|
||||
|
||||
// True if currently in the OnSetFocus callback. Only accessed on the UI
|
||||
// thread.
|
||||
bool is_in_onsetfocus_ = false;
|
||||
|
||||
// True if the focus is currently on an editable field on the page. Only
|
||||
// accessed on the UI thread.
|
||||
bool focus_on_editable_field_ = false;
|
||||
|
||||
// True if mouse cursor change is disabled.
|
||||
bool mouse_cursor_change_disabled_ = false;
|
||||
|
||||
// Used for managing notification subscriptions.
|
||||
std::unique_ptr<content::NotificationRegistrar> registrar_;
|
||||
|
||||
// Used for creating and managing file dialogs.
|
||||
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;
|
||||
|
||||
@@ -643,9 +400,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Used for creating and managing DevTools instances.
|
||||
std::unique_ptr<CefDevToolsManager> devtools_manager_;
|
||||
|
||||
// Observers that want to be notified of changes to this object.
|
||||
base::ObserverList<Observer>::Unchecked observers_;
|
||||
|
||||
// Used for capturing audio for CefAudioHandler.
|
||||
std::unique_ptr<CefAudioCapturer> audio_capturer_;
|
||||
|
||||
@@ -653,9 +407,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// starts running when a tab stops being audible, and is canceled if it starts
|
||||
// being audible again before it fires.
|
||||
base::OneShotTimer recently_audible_timer_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_HOST_IMPL_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_HOST_IMPL_H_
|
@@ -27,15 +27,16 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/media/router/chrome_media_router_factory.h"
|
||||
#include "chrome/browser/net/system_network_context_manager.h"
|
||||
#include "chrome/browser/plugins/plugin_finder.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/extension_system.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "net/base/net_module.h"
|
||||
#include "services/service_manager/embedder/result_codes.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
#if defined(USE_AURA) && defined(USE_X11)
|
||||
@@ -88,7 +89,7 @@ int AlloyBrowserMainParts::PreEarlyInitialization() {
|
||||
ui::InitializeInputMethodForTesting();
|
||||
#endif
|
||||
|
||||
return service_manager::RESULT_CODE_NORMAL_EXIT;
|
||||
return content::RESULT_CODE_NORMAL_EXIT;
|
||||
}
|
||||
|
||||
void AlloyBrowserMainParts::ToolkitInitialized() {
|
||||
@@ -130,6 +131,8 @@ void AlloyBrowserMainParts::PreMainMessageLoopStart() {
|
||||
// setup.exe. In Chrome, these strings are in the locale files.
|
||||
ChromeBrowserMainPartsWin::SetupInstallerUtilStrings();
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
media_router::ChromeMediaRouterFactory::DoPlatformInit();
|
||||
}
|
||||
|
||||
void AlloyBrowserMainParts::PostMainMessageLoopStart() {
|
||||
|
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "include/cef_version.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_context.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_main.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_message_filter.h"
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||
#include "libcef/browser/net/chrome_scheme_handler.h"
|
||||
#include "libcef/browser/net/throttle_handler.h"
|
||||
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
||||
#include "libcef/browser/net_service/login_delegate.h"
|
||||
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
||||
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
||||
@@ -71,12 +73,10 @@
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "chrome/services/printing/printing_service.h"
|
||||
#include "components/content_settings/core/browser/cookie_settings.h"
|
||||
#include "components/navigation_interception/intercept_navigation_throttle.h"
|
||||
#include "components/navigation_interception/navigation_params.h"
|
||||
#include "components/spellcheck/common/spellcheck.mojom.h"
|
||||
#include "components/version_info/version_info.h"
|
||||
#include "content/browser/frame_host/render_frame_host_impl.h"
|
||||
#include "content/browser/plugin_service_impl.h"
|
||||
#include "content/browser/renderer_host/render_frame_host_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_ppapi_host.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -97,7 +97,6 @@
|
||||
#include "content/public/common/storage_quota_params.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "extensions/browser/extension_message_filter.h"
|
||||
#include "extensions/browser/extension_protocols.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
@@ -117,9 +116,9 @@
|
||||
#include "sandbox/policy/switches.h"
|
||||
#include "services/network/public/cpp/network_switches.h"
|
||||
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
|
||||
#include "services/service_manager/embedder/switches.h"
|
||||
#include "services/service_manager/public/mojom/connector.mojom.h"
|
||||
#include "storage/browser/quota/quota_settings.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h"
|
||||
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
|
||||
#include "third_party/blink/public/web/web_window_features.h"
|
||||
@@ -349,9 +348,9 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||
|
||||
bool handled = false;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForFrameRoute(render_process_id,
|
||||
params.render_frame_id);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForFrameRoute(render_process_id,
|
||||
params.render_frame_id);
|
||||
if (browser.get()) {
|
||||
CefRefPtr<CefClient> client = browser->GetClient();
|
||||
if (client.get()) {
|
||||
@@ -440,73 +439,6 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
|
||||
}
|
||||
#endif // defined(OS_POSIX) && !defined(OS_MAC)
|
||||
|
||||
// TODO(cef): We can't currently trust NavigationParams::is_main_frame() because
|
||||
// it's always set to true in
|
||||
// InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation. Remove the
|
||||
// |is_main_frame| argument once this problem is fixed.
|
||||
bool NavigationOnUIThread(
|
||||
bool is_main_frame,
|
||||
int64_t frame_id,
|
||||
int64_t parent_frame_id,
|
||||
int frame_tree_node_id,
|
||||
content::WebContents* source,
|
||||
const navigation_interception::NavigationParams& params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
content::OpenURLParams open_params(
|
||||
params.url(), params.referrer(), WindowOpenDisposition::CURRENT_TAB,
|
||||
params.transition_type(), params.is_renderer_initiated());
|
||||
open_params.user_gesture = params.has_user_gesture();
|
||||
open_params.initiator_origin = params.initiator_origin();
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser;
|
||||
if (!CefBrowserInfoManager::GetInstance()->MaybeAllowNavigation(
|
||||
source->GetMainFrame(), open_params, browser)) {
|
||||
// Cancel the navigation.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ignore_navigation = false;
|
||||
|
||||
if (browser.get()) {
|
||||
CefRefPtr<CefClient> client = browser->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefFrame> frame;
|
||||
if (is_main_frame) {
|
||||
frame = browser->GetMainFrame();
|
||||
} else if (frame_id >= 0) {
|
||||
frame = browser->GetFrame(frame_id);
|
||||
}
|
||||
if (!frame && frame_tree_node_id >= 0) {
|
||||
frame = browser->GetFrameForFrameTreeNode(frame_tree_node_id);
|
||||
}
|
||||
if (!frame) {
|
||||
// Create a temporary frame object for navigation of sub-frames that
|
||||
// don't yet exist.
|
||||
frame = browser->browser_info()->CreateTempSubFrame(parent_frame_id);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
|
||||
request->Set(params, is_main_frame);
|
||||
request->SetReadOnly(true);
|
||||
|
||||
// Initiating a new navigation in OnBeforeBrowse will delete the
|
||||
// InterceptNavigationThrottle that currently owns this callback,
|
||||
// resulting in a crash. Use the lock to prevent that.
|
||||
std::unique_ptr<CefBrowserHostImpl::NavigationLock> navigation_lock =
|
||||
browser->CreateNavigationLock();
|
||||
ignore_navigation = handler->OnBeforeBrowse(
|
||||
browser.get(), frame, request.get(), params.has_user_gesture(),
|
||||
params.is_redirect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ignore_navigation;
|
||||
}
|
||||
|
||||
// From chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc.
|
||||
void BindPluginInfoHost(
|
||||
int render_process_id,
|
||||
@@ -825,7 +757,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
if (process_type == service_manager::switches::kZygoteProcess) {
|
||||
if (process_type == switches::kZygoteProcess) {
|
||||
// Propagate the following switches to the zygote command line (along with
|
||||
// any associated values) if present in the browser command line.
|
||||
static const char* const kSwitchNames[] = {
|
||||
@@ -940,8 +872,8 @@ void AlloyContentBrowserClient::AllowCertificateError(
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (!browser.get())
|
||||
return;
|
||||
CefRefPtr<CefClient> client = browser->GetClient();
|
||||
@@ -976,8 +908,8 @@ base::OnceClosure AlloyContentBrowserClient::SelectClientCertificate(
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
CefRefPtr<CefRequestHandler> handler;
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (browser.get()) {
|
||||
CefRefPtr<CefClient> client = browser->GetClient();
|
||||
if (client.get())
|
||||
@@ -1033,7 +965,7 @@ bool AlloyContentBrowserClient::CanCreateWindow(
|
||||
|
||||
void AlloyContentBrowserClient::OverrideWebkitPrefs(
|
||||
content::RenderViewHost* rvh,
|
||||
content::WebPreferences* prefs) {
|
||||
blink::web_pref::WebPreferences* prefs) {
|
||||
// Using RVH instead of RFH here because rvh->GetMainFrame() may be nullptr
|
||||
// when this method is called.
|
||||
renderer_prefs::PopulateWebPreferences(rvh, *prefs);
|
||||
@@ -1046,7 +978,7 @@ void AlloyContentBrowserClient::OverrideWebkitPrefs(
|
||||
|
||||
bool AlloyContentBrowserClient::OverrideWebPreferencesAfterNavigation(
|
||||
content::WebContents* web_contents,
|
||||
content::WebPreferences* prefs) {
|
||||
blink::web_pref::WebPreferences* prefs) {
|
||||
return renderer_prefs::PopulateWebPreferencesAfterNavigation(web_contents,
|
||||
*prefs);
|
||||
}
|
||||
@@ -1075,33 +1007,8 @@ AlloyContentBrowserClient::GetDevToolsManagerDelegate() {
|
||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||
AlloyContentBrowserClient::CreateThrottlesForNavigation(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
||||
|
||||
const bool is_main_frame = navigation_handle->IsInMainFrame();
|
||||
|
||||
// Identify the RenderFrameHost that originated the navigation.
|
||||
const int64_t parent_frame_id =
|
||||
!is_main_frame
|
||||
? CefFrameHostImpl::MakeFrameId(navigation_handle->GetParentFrame())
|
||||
: CefFrameHostImpl::kInvalidFrameId;
|
||||
|
||||
const int64_t frame_id = !is_main_frame && navigation_handle->HasCommitted()
|
||||
? CefFrameHostImpl::MakeFrameId(
|
||||
navigation_handle->GetRenderFrameHost())
|
||||
: CefFrameHostImpl::kInvalidFrameId;
|
||||
|
||||
// Must use SynchronyMode::kSync to ensure that OnBeforeBrowse is always
|
||||
// called before OnBeforeResourceLoad.
|
||||
std::unique_ptr<content::NavigationThrottle> throttle =
|
||||
std::make_unique<navigation_interception::InterceptNavigationThrottle>(
|
||||
navigation_handle,
|
||||
base::Bind(&NavigationOnUIThread, is_main_frame, frame_id,
|
||||
parent_frame_id, navigation_handle->GetFrameTreeNodeId()),
|
||||
navigation_interception::SynchronyMode::kSync);
|
||||
throttles.push_back(std::move(throttle));
|
||||
|
||||
throttle::NavigationThrottleList throttles;
|
||||
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
|
||||
return throttles;
|
||||
}
|
||||
|
||||
@@ -1137,7 +1044,7 @@ void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||
content::PosixFileDescriptorInfo* mappings) {
|
||||
int crash_signal_fd = GetCrashSignalFD(command_line);
|
||||
if (crash_signal_fd >= 0) {
|
||||
mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd);
|
||||
mappings->Share(kCrashDumpSignal, crash_signal_fd);
|
||||
}
|
||||
}
|
||||
#endif // defined(OS_LINUX)
|
||||
@@ -1192,6 +1099,7 @@ AlloyContentBrowserClient::CreateLoginDelegate(
|
||||
void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
|
||||
int frame_tree_node_id,
|
||||
base::UkmSourceId ukm_source_id,
|
||||
NonNetworkURLLoaderFactoryDeprecatedMap* uniquely_owned_factories,
|
||||
NonNetworkURLLoaderFactoryMap* factories) {
|
||||
if (!extensions::ExtensionsEnabled())
|
||||
return;
|
||||
@@ -1208,6 +1116,7 @@ void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
|
||||
void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
NonNetworkURLLoaderFactoryDeprecatedMap* uniquely_owned_factories,
|
||||
NonNetworkURLLoaderFactoryMap* factories) {
|
||||
if (!extensions::ExtensionsEnabled())
|
||||
return;
|
||||
@@ -1249,10 +1158,10 @@ void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||
allowed_webui_hosts.emplace_back(chrome::kChromeUIThemeHost);
|
||||
}
|
||||
if (!allowed_webui_hosts.empty()) {
|
||||
factories->emplace(
|
||||
content::kChromeUIScheme,
|
||||
content::CreateWebUIURLLoader(frame_host, content::kChromeUIScheme,
|
||||
std::move(allowed_webui_hosts)));
|
||||
factories->emplace(content::kChromeUIScheme,
|
||||
content::CreateWebUIURLLoaderFactory(
|
||||
frame_host, content::kChromeUIScheme,
|
||||
std::move(allowed_webui_hosts)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1263,6 +1172,7 @@ bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
base::UkmSourceId ukm_source_id,
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
@@ -1307,10 +1217,16 @@ void AlloyContentBrowserClient::ConfigureNetworkContextParams(
|
||||
return;
|
||||
}
|
||||
|
||||
Profile* profile = Profile::FromBrowserContext(context);
|
||||
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
||||
|
||||
Profile* profile = cef_context->AsProfile();
|
||||
profile->ConfigureNetworkContextParams(in_memory, relative_partition_path,
|
||||
network_context_params,
|
||||
cert_verifier_creation_params);
|
||||
|
||||
network_context_params->cookieable_schemes =
|
||||
cef_context->GetCookieableSchemes();
|
||||
|
||||
// TODO(cef): Remove this and add required NetworkIsolationKeys,
|
||||
// this is currently not the case and this was not required pre M84.
|
||||
network_context_params->require_network_isolation_key = false;
|
||||
@@ -1337,7 +1253,7 @@ AlloyContentBrowserClient::GetNetworkContextsParentDirectory() {
|
||||
|
||||
bool AlloyContentBrowserClient::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
base::OnceCallback<content::WebContents*()> web_contents_getter,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
int child_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
@@ -1357,32 +1273,16 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
|
||||
out_factory->InitWithNewPipeAndPassReceiver();
|
||||
|
||||
// CefBrowserPlatformDelegate::HandleExternalProtocol may be called if
|
||||
// nothing handles the request.
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||
web_contents_getter, frame_tree_node_id, resource_request);
|
||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||
web_contents_getter, std::move(receiver), std::move(request_handler));
|
||||
} else {
|
||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||
web_contents_getter, frame_tree_node_id, resource_request);
|
||||
CEF_POST_TASK(
|
||||
CEF_IOT,
|
||||
base::BindOnce(
|
||||
[](mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver,
|
||||
std::unique_ptr<net_service::InterceptedRequestHandler>
|
||||
request_handler,
|
||||
content::WebContents::Getter web_contents_getter) {
|
||||
// Manages its own lifetime.
|
||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||
web_contents_getter, frame_tree_node_id, resource_request,
|
||||
base::Bind(CefBrowserPlatformDelegate::HandleExternalProtocol,
|
||||
resource_request.url));
|
||||
|
||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||
web_contents_getter, std::move(receiver),
|
||||
std::move(request_handler));
|
||||
},
|
||||
std::move(receiver), std::move(request_handler),
|
||||
std::move(web_contents_getter)));
|
||||
}
|
||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||
web_contents_getter, std::move(receiver), std::move(request_handler));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -102,10 +102,10 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) override;
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
|
||||
content::WebPreferences* prefs) override;
|
||||
blink::web_pref::WebPreferences* prefs) override;
|
||||
bool OverrideWebPreferencesAfterNavigation(
|
||||
content::WebContents* web_contents,
|
||||
content::WebPreferences* prefs) override;
|
||||
blink::web_pref::WebPreferences* prefs) override;
|
||||
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
|
||||
std::string GetDefaultDownloadName() override;
|
||||
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
||||
@@ -151,10 +151,12 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
void RegisterNonNetworkNavigationURLLoaderFactories(
|
||||
int frame_tree_node_id,
|
||||
base::UkmSourceId ukm_source_id,
|
||||
NonNetworkURLLoaderFactoryDeprecatedMap* uniquely_owned_factories,
|
||||
NonNetworkURLLoaderFactoryMap* factories) override;
|
||||
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
NonNetworkURLLoaderFactoryDeprecatedMap* uniquely_owned_factories,
|
||||
NonNetworkURLLoaderFactoryMap* factories) override;
|
||||
bool WillCreateURLLoaderFactory(
|
||||
content::BrowserContext* browser_context,
|
||||
@@ -163,6 +165,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
base::UkmSourceId ukm_source_id,
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
@@ -181,7 +184,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
||||
bool HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
base::OnceCallback<content::WebContents*()> web_contents_getter,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
int child_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "libcef/browser/alloy/browser_platform_delegate_alloy.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
#include "libcef/browser/extensions/extension_background_host.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
@@ -24,12 +25,24 @@
|
||||
#include "extensions/browser/process_manager.h"
|
||||
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
|
||||
|
||||
namespace {
|
||||
|
||||
printing::CefPrintViewManager* GetPrintViewManager(
|
||||
content::WebContents* web_contents) {
|
||||
return printing::CefPrintViewManager::FromWebContents(web_contents);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
|
||||
: weak_ptr_factory_(this) {}
|
||||
|
||||
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
|
||||
CefBrowserHostImpl::CreateParams& create_params,
|
||||
CefBrowserCreateParams& create_params,
|
||||
bool& own_web_contents) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
DCHECK(primary_);
|
||||
|
||||
// Get or create the request context and browser context.
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||
@@ -105,8 +118,11 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
CefRefPtr<CefBrowserHostImpl> owner =
|
||||
CefBrowserHostImpl::GetBrowserForContents(new_contents.get());
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
DCHECK(primary_);
|
||||
|
||||
CefRefPtr<AlloyBrowserHostImpl> owner =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(new_contents.get());
|
||||
if (owner) {
|
||||
// Taking ownership of |new_contents|.
|
||||
static_cast<CefBrowserPlatformDelegateAlloy*>(
|
||||
@@ -143,10 +159,15 @@ void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
||||
CefBrowserHostImpl* browser) {
|
||||
CefBrowserHostBase* browser) {
|
||||
CefBrowserPlatformDelegate::BrowserCreated(browser);
|
||||
|
||||
web_contents_->SetDelegate(browser);
|
||||
// Only register WebContents delegate/observers if we're the primary delegate.
|
||||
if (!primary_)
|
||||
return;
|
||||
|
||||
DCHECK(!web_contents_->GetDelegate());
|
||||
web_contents_->SetDelegate(static_cast<AlloyBrowserHostImpl*>(browser));
|
||||
|
||||
PrefsTabHelper::CreateForWebContents(web_contents_);
|
||||
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
|
||||
@@ -169,24 +190,29 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
|
||||
const extensions::Extension* extension,
|
||||
const GURL& url,
|
||||
extensions::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 = static_cast<AlloyBrowserHostImpl*>(browser_);
|
||||
|
||||
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
|
||||
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
|
||||
// Create an extension host that we own.
|
||||
extension_host_ = new extensions::CefExtensionViewHost(
|
||||
browser_, extension, web_contents_, url, host_type);
|
||||
alloy_browser, extension, web_contents_, url, host_type);
|
||||
// Trigger load of the extension URL.
|
||||
extension_host_->CreateRenderViewSoon();
|
||||
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
|
||||
is_background_host_ = true;
|
||||
browser_->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(
|
||||
browser_,
|
||||
alloy_browser,
|
||||
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
extension, web_contents_, url, host_type);
|
||||
@@ -202,9 +228,11 @@ extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
DestroyExtensionHost();
|
||||
owned_web_contents_.reset();
|
||||
CefBrowserHostBase* browser) {
|
||||
if (primary_) {
|
||||
DestroyExtensionHost();
|
||||
owned_web_contents_.reset();
|
||||
}
|
||||
|
||||
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
|
||||
}
|
||||
@@ -303,6 +331,8 @@ void CefBrowserPlatformDelegateAlloy::SetAccessibilityState(
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
auto actionable_contents = GetActionableWebContents();
|
||||
if (!actionable_contents)
|
||||
return false;
|
||||
@@ -318,6 +348,8 @@ bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::Print() {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
auto actionable_contents = GetActionableWebContents();
|
||||
if (!actionable_contents)
|
||||
return;
|
||||
@@ -325,11 +357,9 @@ void CefBrowserPlatformDelegateAlloy::Print() {
|
||||
auto rfh = actionable_contents->GetMainFrame();
|
||||
|
||||
if (IsPrintPreviewSupported()) {
|
||||
printing::CefPrintViewManager::FromWebContents(actionable_contents)
|
||||
->PrintPreviewNow(rfh, false);
|
||||
GetPrintViewManager(actionable_contents)->PrintPreviewNow(rfh, false);
|
||||
} else {
|
||||
printing::PrintViewManager::FromWebContents(actionable_contents)
|
||||
->PrintNow(rfh);
|
||||
GetPrintViewManager(actionable_contents)->PrintNow(rfh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,6 +367,8 @@ void CefBrowserPlatformDelegateAlloy::PrintToPDF(
|
||||
const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
content::WebContents* actionable_contents = GetActionableWebContents();
|
||||
if (!actionable_contents)
|
||||
return;
|
||||
@@ -345,7 +377,7 @@ void CefBrowserPlatformDelegateAlloy::PrintToPDF(
|
||||
pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished,
|
||||
callback.get(), path);
|
||||
}
|
||||
printing::CefPrintViewManager::FromWebContents(actionable_contents)
|
||||
GetPrintViewManager(actionable_contents)
|
||||
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
|
||||
settings, pdf_callback);
|
||||
}
|
||||
@@ -369,7 +401,7 @@ void CefBrowserPlatformDelegateAlloy::Find(int identifier,
|
||||
auto options = blink::mojom::FindOptions::New();
|
||||
options->forward = forward;
|
||||
options->match_case = matchCase;
|
||||
options->find_next_if_selection_matches = findNext;
|
||||
options->find_match = findNext;
|
||||
web_contents_->Find(identifier, searchText, std::move(options));
|
||||
}
|
||||
|
||||
@@ -405,6 +437,8 @@ CefBrowserPlatformDelegateAlloy::GetActionableWebContents() const {
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
|
||||
content::WebContents* owned_contents) {
|
||||
DCHECK(primary_);
|
||||
|
||||
// Should not currently own a WebContents.
|
||||
CHECK(!owned_web_contents_);
|
||||
owned_web_contents_.reset(owned_contents);
|
||||
|
@@ -10,13 +10,14 @@
|
||||
#include "libcef/browser/web_contents_dialog_helper.h"
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
// Implementation of Alloy-based browser functionality.
|
||||
class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
public:
|
||||
content::WebContents* CreateWebContents(
|
||||
CefBrowserHostImpl::CreateParams& create_params,
|
||||
bool& own_web_contents) override;
|
||||
content::WebContents* CreateWebContents(CefBrowserCreateParams& create_params,
|
||||
bool& own_web_contents) override;
|
||||
void WebContentsCreated(content::WebContents* web_contents,
|
||||
bool owned) override;
|
||||
void AddNewContents(content::WebContents* source,
|
||||
@@ -29,12 +30,12 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
|
||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||
void RenderViewReady() override;
|
||||
void BrowserCreated(CefBrowserHostImpl* browser) override;
|
||||
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||
void CreateExtensionHost(const extensions::Extension* extension,
|
||||
const GURL& url,
|
||||
extensions::ViewType host_type) override;
|
||||
extensions::ExtensionHost* GetExtensionHost() const override;
|
||||
void BrowserDestroyed(CefBrowserHostImpl* browser) override;
|
||||
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||
void SendCaptureLostEvent() override;
|
||||
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
|
||||
void NotifyMoveOrResizeStarted() override;
|
||||
@@ -69,6 +70,9 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
// Otherwise, the browser's WebContents will be returned.
|
||||
content::WebContents* GetActionableWebContents() const;
|
||||
|
||||
// Called from BrowserPlatformDelegateNative::set_windowless_handler().
|
||||
void set_as_secondary() { primary_ = false; }
|
||||
|
||||
private:
|
||||
void SetOwnedWebContents(content::WebContents* owned_contents);
|
||||
|
||||
@@ -98,6 +102,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
gfx::Size auto_resize_min_;
|
||||
gfx::Size auto_resize_max_;
|
||||
|
||||
// True if this is the primary platform delegate, in which case it will
|
||||
// register WebContents delegate/observers.
|
||||
bool primary_ = true;
|
||||
|
||||
base::WeakPtrFactory<CefBrowserPlatformDelegateAlloy> weak_ptr_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegateAlloy);
|
||||
|
@@ -325,6 +325,12 @@ ChromeBrowserProcessAlloy::floc_blocklist_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
federated_learning::FlocSortingLshClustersService*
|
||||
ChromeBrowserProcessAlloy::floc_sorting_lsh_clusters_service() {
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
optimization_guide::OptimizationGuideService*
|
||||
ChromeBrowserProcessAlloy::optimization_guide_service() {
|
||||
NOTREACHED();
|
||||
|
@@ -83,6 +83,8 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
|
||||
subresource_filter::RulesetService* subresource_filter_ruleset_service()
|
||||
override;
|
||||
federated_learning::FlocBlocklistService* floc_blocklist_service() override;
|
||||
federated_learning::FlocSortingLshClustersService*
|
||||
floc_sorting_lsh_clusters_service() override;
|
||||
optimization_guide::OptimizationGuideService* optimization_guide_service()
|
||||
override;
|
||||
StartupData* startup_data() override;
|
||||
|
@@ -23,9 +23,10 @@ class CefVariationsClient : public variations::VariationsClient {
|
||||
return browser_context_->IsOffTheRecord();
|
||||
}
|
||||
|
||||
std::string GetVariationsHeader() const override {
|
||||
variations::mojom::VariationsHeadersPtr GetVariationsHeaders()
|
||||
const override {
|
||||
return variations::VariationsIdsProvider::GetInstance()
|
||||
->GetClientDataHeader(false /* is_signed_in */);
|
||||
->GetClientDataHeaders(false /* is_signed_in */);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -171,3 +172,7 @@ base::Time ChromeProfileAlloy::GetCreationTime() const {
|
||||
void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void ChromeProfileAlloy::RecordMainFrameNavigation() {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ class ChromeProfileAlloy : public Profile {
|
||||
ExitType GetLastSessionExitType() const override;
|
||||
base::Time GetCreationTime() const override;
|
||||
void SetCreationTimeForTesting(base::Time creation_time) override;
|
||||
void RecordMainFrameNavigation() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<variations::VariationsClient> variations_client_;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/audio_capturer.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
|
||||
#include "components/mirroring/service/captured_audio_input.h"
|
||||
#include "content/public/browser/audio_loopback_stream_creator.h"
|
||||
@@ -51,7 +51,7 @@ void StreamCreatorHelper(
|
||||
} // namespace
|
||||
|
||||
CefAudioCapturer::CefAudioCapturer(const CefAudioParameters& params,
|
||||
CefRefPtr<CefBrowserHostImpl> browser,
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser,
|
||||
CefRefPtr<CefAudioHandler> audio_handler)
|
||||
: params_(params),
|
||||
browser_(browser),
|
||||
|
@@ -21,12 +21,12 @@ class AudioInputDevice;
|
||||
} // namespace media
|
||||
|
||||
class CefAudioHandler;
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
|
||||
public:
|
||||
CefAudioCapturer(const CefAudioParameters& params,
|
||||
CefRefPtr<CefBrowserHostImpl> browser,
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser,
|
||||
CefRefPtr<CefAudioHandler> audio_handler);
|
||||
~CefAudioCapturer() override;
|
||||
|
||||
@@ -42,7 +42,7 @@ class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
|
||||
void StopStream();
|
||||
|
||||
CefAudioParameters params_;
|
||||
CefRefPtr<CefBrowserHostImpl> browser_;
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser_;
|
||||
CefRefPtr<CefAudioHandler> audio_handler_;
|
||||
std::unique_ptr<content::AudioLoopbackStreamCreator> audio_stream_creator_;
|
||||
scoped_refptr<media::AudioInputDevice> audio_input_device_;
|
||||
|
616
libcef/browser/browser_contents_delegate.cc
Normal file
616
libcef/browser/browser_contents_delegate.cc
Normal file
@@ -0,0 +1,616 @@
|
||||
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/browser_contents_delegate.h"
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/browser_util.h"
|
||||
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "content/public/browser/notification_types.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
|
||||
using content::KeyboardEventProcessingResult;
|
||||
|
||||
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
||||
scoped_refptr<CefBrowserInfo> browser_info)
|
||||
: browser_info_(browser_info) {
|
||||
DCHECK(browser_info_->browser());
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::ObserveWebContents(
|
||||
content::WebContents* new_contents) {
|
||||
WebContentsObserver::Observe(new_contents);
|
||||
|
||||
if (new_contents) {
|
||||
registrar_.reset(new content::NotificationRegistrar);
|
||||
|
||||
// When navigating through the history, the restored NavigationEntry's title
|
||||
// will be used. If the entry ends up having the same title after we return
|
||||
// to it, as will usually be the case, the
|
||||
// NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since
|
||||
// the NavigationEntry's title hasn't changed.
|
||||
registrar_->Add(this, content::NOTIFICATION_LOAD_STOP,
|
||||
content::Source<content::NavigationController>(
|
||||
&new_contents->GetController()));
|
||||
|
||||
// Make sure RenderViewCreated is called at least one time.
|
||||
RenderViewCreated(new_contents->GetRenderViewHost());
|
||||
|
||||
// Create the frame representation before OnAfterCreated is called for a new
|
||||
// browser. Additionally, RenderFrameCreated is otherwise not called at all
|
||||
// for new popup browsers.
|
||||
RenderFrameCreated(new_contents->GetMainFrame());
|
||||
} else {
|
||||
registrar_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::AddObserver(Observer* observer) {
|
||||
observers_.AddObserver(observer);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RemoveObserver(Observer* observer) {
|
||||
observers_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
// |source| may be NULL for navigations in the current tab, or if the
|
||||
// navigation originates from a guest view via MaybeAllowNavigation.
|
||||
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
bool cancel = false;
|
||||
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetRequestHandler()) {
|
||||
cancel = handler->OnOpenURLFromTab(
|
||||
browser(), browser()->GetFrame(params.frame_tree_node_id),
|
||||
params.url.spec(),
|
||||
static_cast<cef_window_open_disposition_t>(params.disposition),
|
||||
params.user_gesture);
|
||||
}
|
||||
}
|
||||
|
||||
// Returning nullptr will cancel the navigation.
|
||||
return cancel ? nullptr : web_contents();
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::LoadingStateChanged(
|
||||
content::WebContents* source,
|
||||
bool to_different_document) {
|
||||
const int current_index =
|
||||
source->GetController().GetLastCommittedEntryIndex();
|
||||
const int max_index = source->GetController().GetEntryCount() - 1;
|
||||
|
||||
const bool is_loading = source->IsLoading();
|
||||
const bool can_go_back = (current_index > 0);
|
||||
const bool can_go_forward = (current_index < max_index);
|
||||
|
||||
// This method may be called multiple times in a row with |is_loading|
|
||||
// true as a result of https://crrev.com/5e750ad0. Ignore the 2nd+ times.
|
||||
if (is_loading_ == is_loading && can_go_back_ == can_go_back &&
|
||||
can_go_forward_ == can_go_forward) {
|
||||
return;
|
||||
}
|
||||
|
||||
is_loading_ = is_loading;
|
||||
can_go_back_ = can_go_back;
|
||||
can_go_forward_ = can_go_forward;
|
||||
OnStateChanged(State::kNavigation);
|
||||
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetLoadHandler()) {
|
||||
handler->OnLoadingStateChange(browser(), is_loading, can_go_back,
|
||||
can_go_forward);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::UpdateTargetURL(content::WebContents* source,
|
||||
const GURL& url) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
handler->OnStatusMessage(browser(), url.spec());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserContentsDelegate::DidAddMessageToConsole(
|
||||
content::WebContents* source,
|
||||
blink::mojom::ConsoleMessageLevel log_level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
// Use LOGSEVERITY_DEBUG for unrecognized |level| values.
|
||||
cef_log_severity_t cef_level = LOGSEVERITY_DEBUG;
|
||||
switch (log_level) {
|
||||
case blink::mojom::ConsoleMessageLevel::kVerbose:
|
||||
cef_level = LOGSEVERITY_DEBUG;
|
||||
break;
|
||||
case blink::mojom::ConsoleMessageLevel::kInfo:
|
||||
cef_level = LOGSEVERITY_INFO;
|
||||
break;
|
||||
case blink::mojom::ConsoleMessageLevel::kWarning:
|
||||
cef_level = LOGSEVERITY_WARNING;
|
||||
break;
|
||||
case blink::mojom::ConsoleMessageLevel::kError:
|
||||
cef_level = LOGSEVERITY_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
return handler->OnConsoleMessage(browser(), cef_level, message, source_id,
|
||||
line_no);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DidNavigateMainFramePostCommit(
|
||||
content::WebContents* web_contents) {
|
||||
has_document_ = false;
|
||||
OnStateChanged(State::kDocument);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::EnterFullscreenModeForTab(
|
||||
content::RenderFrameHost* requesting_frame,
|
||||
const blink::mojom::FullscreenOptions& options) {
|
||||
OnFullscreenModeChange(/*fullscreen=*/true);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::ExitFullscreenModeForTab(
|
||||
content::WebContents* web_contents) {
|
||||
OnFullscreenModeChange(/*fullscreen=*/false);
|
||||
}
|
||||
|
||||
KeyboardEventProcessingResult
|
||||
CefBrowserContentsDelegate::PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (auto delegate = platform_delegate()) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetKeyboardHandler()) {
|
||||
CefKeyEvent cef_event;
|
||||
if (browser_util::GetCefKeyEvent(event, cef_event)) {
|
||||
cef_event.focus_on_editable_field = focus_on_editable_field_;
|
||||
|
||||
auto event_handle = delegate->GetEventHandle(event);
|
||||
bool is_keyboard_shortcut = false;
|
||||
bool result = handler->OnPreKeyEvent(
|
||||
browser(), cef_event, event_handle, &is_keyboard_shortcut);
|
||||
if (result) {
|
||||
return KeyboardEventProcessingResult::HANDLED;
|
||||
} else if (is_keyboard_shortcut) {
|
||||
return KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return KeyboardEventProcessingResult::NOT_HANDLED;
|
||||
}
|
||||
|
||||
bool CefBrowserContentsDelegate::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
// Check to see if event should be ignored.
|
||||
if (event.skip_in_browser)
|
||||
return false;
|
||||
|
||||
if (auto delegate = platform_delegate()) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetKeyboardHandler()) {
|
||||
CefKeyEvent cef_event;
|
||||
if (browser_util::GetCefKeyEvent(event, cef_event)) {
|
||||
cef_event.focus_on_editable_field = focus_on_editable_field_;
|
||||
|
||||
auto event_handle = delegate->GetEventHandle(event);
|
||||
if (handler->OnKeyEvent(browser(), cef_event, event_handle)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderFrameCreated(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderFrameHostChanged(
|
||||
content::RenderFrameHost* old_host,
|
||||
content::RenderFrameHost* new_host) {
|
||||
// Just in case RenderFrameCreated wasn't called for some reason.
|
||||
RenderFrameCreated(new_host);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderFrameDeleted(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
const auto frame_id = CefFrameHostImpl::MakeFrameId(render_frame_host);
|
||||
browser_info_->RemoveFrame(render_frame_host);
|
||||
|
||||
if (focused_frame_ && focused_frame_->GetIdentifier() == frame_id) {
|
||||
focused_frame_ = nullptr;
|
||||
OnStateChanged(State::kFocusedFrame);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
// May be already registered if the renderer crashed previously.
|
||||
if (!registrar_->IsRegistered(
|
||||
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||
content::Source<content::RenderViewHost>(render_view_host))) {
|
||||
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||
content::Source<content::RenderViewHost>(render_view_host));
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderViewDeleted(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
if (registrar_->IsRegistered(
|
||||
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||
content::Source<content::RenderViewHost>(render_view_host))) {
|
||||
registrar_->Remove(
|
||||
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||
content::Source<content::RenderViewHost>(render_view_host));
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderViewReady() {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetRequestHandler()) {
|
||||
handler->OnRenderViewReady(browser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::RenderProcessGone(
|
||||
base::TerminationStatus status) {
|
||||
cef_termination_status_t ts = TS_ABNORMAL_TERMINATION;
|
||||
if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED)
|
||||
ts = TS_PROCESS_WAS_KILLED;
|
||||
else if (status == base::TERMINATION_STATUS_PROCESS_CRASHED)
|
||||
ts = TS_PROCESS_CRASHED;
|
||||
else if (status == base::TERMINATION_STATUS_OOM)
|
||||
ts = TS_PROCESS_OOM;
|
||||
else if (status != base::TERMINATION_STATUS_ABNORMAL_TERMINATION)
|
||||
return;
|
||||
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetRequestHandler()) {
|
||||
auto navigation_lock = browser_info_->CreateNavigationLock();
|
||||
handler->OnRenderProcessTerminated(browser(), ts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnFrameFocused(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
CefRefPtr<CefFrameHostImpl> frame = static_cast<CefFrameHostImpl*>(
|
||||
browser_info_->GetFrameForHost(render_frame_host).get());
|
||||
if (!frame || frame->IsFocused())
|
||||
return;
|
||||
|
||||
CefRefPtr<CefFrameHostImpl> previous_frame = focused_frame_;
|
||||
if (frame->IsMain())
|
||||
focused_frame_ = nullptr;
|
||||
else
|
||||
focused_frame_ = frame;
|
||||
|
||||
if (!previous_frame) {
|
||||
// The main frame is focused by default.
|
||||
previous_frame = browser_info_->GetMainFrame();
|
||||
}
|
||||
|
||||
if (previous_frame->GetIdentifier() != frame->GetIdentifier()) {
|
||||
previous_frame->SetFocused(false);
|
||||
frame->SetFocused(true);
|
||||
}
|
||||
|
||||
OnStateChanged(State::kFocusedFrame);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DocumentAvailableInMainFrame() {
|
||||
has_document_ = true;
|
||||
OnStateChanged(State::kDocument);
|
||||
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetRequestHandler()) {
|
||||
handler->OnDocumentAvailableInMainFrame(browser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::LoadProgressChanged(double progress) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
handler->OnLoadingProgressChange(browser(), progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DidStopLoading() {
|
||||
// Notify all renderers that loading has stopped. We used to use
|
||||
// RenderFrameObserver::DidStopLoading in the renderer process but that was
|
||||
// removed in https://crrev.com/3e37dd0ead. However, that callback wasn't
|
||||
// necessarily accurate because it wasn't called in all of the cases where
|
||||
// RenderFrameImpl sends the FrameHostMsg_DidStopLoading message. This adds
|
||||
// an additional round trip but should provide the same or improved
|
||||
// functionality.
|
||||
for (const auto& frame : browser_info_->GetAllFrames()) {
|
||||
frame->MaybeSendDidStopLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DidFinishNavigation(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
const net::Error error_code = navigation_handle->GetNetErrorCode();
|
||||
|
||||
// Skip calls where the navigation has not yet committed and there is no
|
||||
// error code. For example, when creating a browser without loading a URL.
|
||||
if (!navigation_handle->HasCommitted() && error_code == net::OK)
|
||||
return;
|
||||
|
||||
const bool is_main_frame = navigation_handle->IsInMainFrame();
|
||||
const GURL& url =
|
||||
(error_code == net::OK ? navigation_handle->GetURL() : GURL());
|
||||
|
||||
auto browser_info = browser_info_;
|
||||
|
||||
// May return NULL when starting a new navigation if the previous navigation
|
||||
// caused the renderer process to crash during load.
|
||||
CefRefPtr<CefFrameHostImpl> frame = browser_info->GetFrameForFrameTreeNode(
|
||||
navigation_handle->GetFrameTreeNodeId());
|
||||
if (!frame) {
|
||||
if (is_main_frame) {
|
||||
frame = browser_info->GetMainFrame();
|
||||
} else {
|
||||
frame =
|
||||
browser_info->CreateTempSubFrame(CefFrameHostImpl::kInvalidFrameId);
|
||||
}
|
||||
}
|
||||
frame->RefreshAttributes();
|
||||
|
||||
if (error_code == net::OK) {
|
||||
// The navigation has been committed and there is no error.
|
||||
DCHECK(navigation_handle->HasCommitted());
|
||||
|
||||
// Don't call OnLoadStart for same page navigations (fragments,
|
||||
// history state).
|
||||
if (!navigation_handle->IsSameDocument()) {
|
||||
OnLoadStart(frame.get(), navigation_handle->GetPageTransition());
|
||||
}
|
||||
|
||||
if (is_main_frame) {
|
||||
OnAddressChange(url);
|
||||
}
|
||||
} else {
|
||||
// The navigation failed with an error. This may happen before commit
|
||||
// (e.g. network error) or after commit (e.g. response filter error).
|
||||
// If the error happened before commit then this call will originate from
|
||||
// RenderFrameHostImpl::OnDidFailProvisionalLoadWithError.
|
||||
// OnLoadStart/OnLoadEnd will not be called.
|
||||
OnLoadError(frame.get(), navigation_handle->GetURL(), error_code);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DidFailLoad(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url,
|
||||
int error_code) {
|
||||
// The navigation failed after commit. OnLoadStart was called so we also
|
||||
// call OnLoadEnd.
|
||||
auto frame = browser_info_->GetFrameForHost(render_frame_host);
|
||||
frame->RefreshAttributes();
|
||||
OnLoadError(frame, validated_url, error_code);
|
||||
OnLoadEnd(frame, validated_url, error_code);
|
||||
}
|
||||
|
||||
bool CefBrowserContentsDelegate::OnMessageReceived(
|
||||
const IPC::Message& message,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
// Messages may arrive after a frame is detached. Ignore those messages.
|
||||
auto frame = browser_info_->GetFrameForHost(render_frame_host);
|
||||
if (frame) {
|
||||
return static_cast<CefFrameHostImpl*>(frame.get())
|
||||
->OnMessageReceived(message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::TitleWasSet(content::NavigationEntry* entry) {
|
||||
// |entry| may be NULL if a popup is created via window.open and never
|
||||
// navigated.
|
||||
if (entry)
|
||||
OnTitleChange(entry->GetTitle());
|
||||
else if (web_contents())
|
||||
OnTitleChange(web_contents()->GetTitle());
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::PluginCrashed(
|
||||
const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetRequestHandler()) {
|
||||
handler->OnPluginCrashed(browser(), plugin_path.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DidUpdateFaviconURL(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const std::vector<blink::mojom::FaviconURLPtr>& candidates) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
std::vector<CefString> icon_urls;
|
||||
for (const auto& icon : candidates) {
|
||||
if (icon->icon_type == blink::mojom::FaviconIconType::kFavicon) {
|
||||
icon_urls.push_back(icon->icon_url.spec());
|
||||
}
|
||||
}
|
||||
if (!icon_urls.empty()) {
|
||||
handler->OnFaviconURLChange(browser(), icon_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnWebContentsFocused(
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetFocusHandler()) {
|
||||
handler->OnGotFocus(browser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::WebContentsDestroyed() {
|
||||
auto wc = web_contents();
|
||||
ObserveWebContents(nullptr);
|
||||
for (auto& observer : observers_) {
|
||||
observer.OnWebContentsDestroyed(wc);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::Observe(
|
||||
int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
|
||||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
|
||||
|
||||
if (type == content::NOTIFICATION_LOAD_STOP) {
|
||||
content::NavigationController* controller =
|
||||
content::Source<content::NavigationController>(source).ptr();
|
||||
OnTitleChange(controller->GetWebContents()->GetTitle());
|
||||
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
|
||||
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetLoadHandler()) {
|
||||
handler->OnLoadEnd(browser(), frame, http_status_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserContentsDelegate::OnSetFocus(cef_focus_source_t source) {
|
||||
// SetFocus() might be called while inside the OnSetFocus() callback. If
|
||||
// so, don't re-enter the callback.
|
||||
if (is_in_onsetfocus_)
|
||||
return true;
|
||||
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetFocusHandler()) {
|
||||
is_in_onsetfocus_ = true;
|
||||
bool handled = handler->OnSetFocus(browser(), source);
|
||||
is_in_onsetfocus_ = false;
|
||||
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefClient> CefBrowserContentsDelegate::client() const {
|
||||
if (auto b = browser()) {
|
||||
return b->GetHost()->GetClient();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefBrowserContentsDelegate::browser() const {
|
||||
return browser_info_->browser();
|
||||
}
|
||||
|
||||
CefBrowserPlatformDelegate* CefBrowserContentsDelegate::platform_delegate()
|
||||
const {
|
||||
auto browser = browser_info_->browser();
|
||||
if (browser)
|
||||
return browser->platform_delegate();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnAddressChange(const GURL& url) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
// On the handler of an address change.
|
||||
handler->OnAddressChange(browser(), browser_info_->GetMainFrame(),
|
||||
url.spec());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnLoadStart(
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ui::PageTransition transition_type) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetLoadHandler()) {
|
||||
// On the handler that loading has started.
|
||||
handler->OnLoadStart(browser(), frame,
|
||||
static_cast<cef_transition_type_t>(transition_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnLoadError(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int error_code) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetLoadHandler()) {
|
||||
auto navigation_lock = browser_info_->CreateNavigationLock();
|
||||
// On the handler that loading has failed.
|
||||
handler->OnLoadError(browser(), frame,
|
||||
static_cast<cef_errorcode_t>(error_code),
|
||||
net::ErrorToShortString(error_code), url.spec());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnTitleChange(const base::string16& title) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
handler->OnTitleChange(browser(), title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnFullscreenModeChange(bool fullscreen) {
|
||||
if (fullscreen == is_fullscreen_)
|
||||
return;
|
||||
|
||||
is_fullscreen_ = fullscreen;
|
||||
OnStateChanged(State::kFullscreen);
|
||||
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetDisplayHandler()) {
|
||||
handler->OnFullscreenModeChange(browser(), fullscreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnStateChanged(State state_changed) {
|
||||
for (auto& observer : observers_) {
|
||||
observer.OnStateChanged(state_changed);
|
||||
}
|
||||
}
|
198
libcef/browser/browser_contents_delegate.h
Normal file
198
libcef/browser/browser_contents_delegate.h
Normal file
@@ -0,0 +1,198 @@
|
||||
// Copyright 2020 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_CONTENTS_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_BROWSER_CONTENTS_DELEGATE_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
|
||||
class CefBrowser;
|
||||
class CefBrowserInfo;
|
||||
class CefBrowserPlatformDelegate;
|
||||
class CefClient;
|
||||
|
||||
// Flags that represent which states have changed.
|
||||
enum class CefBrowserContentsState : uint8_t {
|
||||
kNone = 0,
|
||||
kNavigation = (1 << 0),
|
||||
kDocument = (1 << 1),
|
||||
kFullscreen = (1 << 2),
|
||||
kFocusedFrame = (1 << 3),
|
||||
};
|
||||
|
||||
constexpr inline CefBrowserContentsState operator&(
|
||||
CefBrowserContentsState lhs,
|
||||
CefBrowserContentsState rhs) {
|
||||
return static_cast<CefBrowserContentsState>(static_cast<int>(lhs) &
|
||||
static_cast<int>(rhs));
|
||||
}
|
||||
|
||||
constexpr inline CefBrowserContentsState operator|(
|
||||
CefBrowserContentsState lhs,
|
||||
CefBrowserContentsState rhs) {
|
||||
return static_cast<CefBrowserContentsState>(static_cast<int>(lhs) |
|
||||
static_cast<int>(rhs));
|
||||
}
|
||||
|
||||
// Tracks state and executes client callbacks based on WebContents callbacks.
|
||||
// Includes functionality that is shared by the alloy and chrome runtimes.
|
||||
// Only accessed on the UI thread.
|
||||
class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||
public content::WebContentsObserver,
|
||||
public content::NotificationObserver {
|
||||
public:
|
||||
using State = CefBrowserContentsState;
|
||||
|
||||
// Interface to implement for observers that wish to be informed of changes
|
||||
// to the delegate. All methods will be called on the UI thread.
|
||||
class Observer : public base::CheckedObserver {
|
||||
public:
|
||||
// Called after state has changed and before the associated CefClient
|
||||
// callback is executed.
|
||||
virtual void OnStateChanged(State state_changed) = 0;
|
||||
|
||||
// Called when the associated WebContents is destroyed.
|
||||
virtual void OnWebContentsDestroyed(content::WebContents* web_contents) = 0;
|
||||
|
||||
protected:
|
||||
~Observer() override {}
|
||||
};
|
||||
|
||||
explicit CefBrowserContentsDelegate(
|
||||
scoped_refptr<CefBrowserInfo> browser_info);
|
||||
|
||||
void ObserveWebContents(content::WebContents* new_contents);
|
||||
|
||||
// Manage observer objects. The observer must either outlive this object or
|
||||
// be removed before destruction.
|
||||
void AddObserver(Observer* observer);
|
||||
void RemoveObserver(Observer* observer);
|
||||
|
||||
// WebContentsDelegate methods:
|
||||
content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool to_different_document) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
blink::mojom::ConsoleMessageLevel log_level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) override;
|
||||
void DidNavigateMainFramePostCommit(
|
||||
content::WebContents* web_contents) override;
|
||||
void EnterFullscreenModeForTab(
|
||||
content::RenderFrameHost* requesting_frame,
|
||||
const blink::mojom::FullscreenOptions& options) override;
|
||||
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
|
||||
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
bool HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
|
||||
// WebContentsObserver methods:
|
||||
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
||||
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
||||
content::RenderFrameHost* new_host) override;
|
||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
|
||||
void RenderViewReady() override;
|
||||
void RenderProcessGone(base::TerminationStatus status) override;
|
||||
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
|
||||
void DocumentAvailableInMainFrame() override;
|
||||
void LoadProgressChanged(double progress) override;
|
||||
void DidStopLoading() override;
|
||||
void DidFinishNavigation(
|
||||
content::NavigationHandle* navigation_handle) override;
|
||||
void DidFailLoad(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url,
|
||||
int error_code) override;
|
||||
bool OnMessageReceived(const IPC::Message& message,
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
void TitleWasSet(content::NavigationEntry* entry) override;
|
||||
void PluginCrashed(const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) override;
|
||||
void DidUpdateFaviconURL(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
|
||||
void OnWebContentsFocused(
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
void WebContentsDestroyed() override;
|
||||
|
||||
// NotificationObserver methods.
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
// Accessors for state information. Changes will be signaled to
|
||||
// Observer::OnStateChanged.
|
||||
bool is_loading() const { return is_loading_; }
|
||||
bool can_go_back() const { return can_go_back_; }
|
||||
bool can_go_forward() const { return can_go_forward_; }
|
||||
bool has_document() const { return has_document_; }
|
||||
bool is_fullscreen() const { return is_fullscreen_; }
|
||||
CefRefPtr<CefFrameHostImpl> focused_frame() const { return focused_frame_; }
|
||||
|
||||
// Helpers for executing client callbacks.
|
||||
// TODO(cef): Make this private if/when possible.
|
||||
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code);
|
||||
bool OnSetFocus(cef_focus_source_t source);
|
||||
|
||||
private:
|
||||
CefRefPtr<CefClient> client() const;
|
||||
CefRefPtr<CefBrowser> browser() const;
|
||||
CefBrowserPlatformDelegate* platform_delegate() const;
|
||||
|
||||
// Helpers for executing client callbacks.
|
||||
void OnAddressChange(const GURL& url);
|
||||
void OnLoadStart(CefRefPtr<CefFrame> frame,
|
||||
ui::PageTransition transition_type);
|
||||
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
|
||||
void OnTitleChange(const base::string16& title);
|
||||
void OnFullscreenModeChange(bool fullscreen);
|
||||
|
||||
void OnStateChanged(State state_changed);
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info_;
|
||||
|
||||
bool is_loading_ = false;
|
||||
bool can_go_back_ = false;
|
||||
bool can_go_forward_ = false;
|
||||
bool has_document_ = false;
|
||||
bool is_fullscreen_ = false;
|
||||
|
||||
// The currently focused frame, or nullptr if the main frame is focused.
|
||||
CefRefPtr<CefFrameHostImpl> focused_frame_;
|
||||
|
||||
// True if currently in the OnSetFocus callback.
|
||||
bool is_in_onsetfocus_ = false;
|
||||
|
||||
// Observers that want to be notified of changes to this object.
|
||||
base::ObserverList<Observer> observers_;
|
||||
|
||||
// Used for managing notification subscriptions.
|
||||
std::unique_ptr<content::NotificationRegistrar> registrar_;
|
||||
|
||||
// True if the focus is currently on an editable field on the page.
|
||||
bool focus_on_editable_field_ = false;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserContentsDelegate);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_CONTENTS_DELEGATE_H_
|
@@ -456,8 +456,6 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {}
|
||||
|
||||
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
|
||||
CEF_REQUIRE_UIT();
|
||||
auto browser_context = AsBrowserContext();
|
||||
@@ -472,3 +470,12 @@ CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
|
||||
}
|
||||
return media_router_manager_.get();
|
||||
}
|
||||
|
||||
CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()
|
||||
const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (cookieable_schemes_)
|
||||
return cookieable_schemes_;
|
||||
|
||||
return CefCookieManagerImpl::GetGlobalCookieableSchemes();
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
// Content API representation of a browser. Created by BHI or the system (for
|
||||
// popups) and owned by BHI. Keeps a pointer to the content::BrowserContext.
|
||||
//
|
||||
// BHI = CefBrowserHostImpl
|
||||
// BHI = AlloyBrowserHostImpl
|
||||
// Implements the CefBrowser and CefBrowserHost interfaces which are exposed
|
||||
// to clients. References an RCI instance. Owns a WC. Lifespan is controlled
|
||||
// by client references and CefBrowserInfoManager (until the browser has
|
||||
@@ -62,9 +62,9 @@
|
||||
//
|
||||
//
|
||||
// How shutdown works:
|
||||
// 1. CefBrowserHostImpl::DestroyBrowser is called on the UI thread after the
|
||||
// 1. AlloyBrowserHostImpl::DestroyBrowser is called on the UI thread after the
|
||||
// browser is closed and deletes the WebContents.
|
||||
// 1. CefBrowserHostImpl is destroyed on any thread when the last reference
|
||||
// 1. AlloyBrowserHostImpl is destroyed on any thread when the last reference
|
||||
// is released.
|
||||
// 2. CefRequestContextImpl is destroyed (possibly asynchronously) on the UI
|
||||
// thread when the last reference is released.
|
||||
@@ -85,7 +85,7 @@ class Profile;
|
||||
|
||||
// Main entry point for configuring behavior on a per-RequestContext basis. The
|
||||
// content::BrowserContext represented by this class is passed to
|
||||
// WebContents::Create in CefBrowserHostImpl::CreateInternal. Only accessed on
|
||||
// WebContents::Create in AlloyBrowserHostImpl::CreateInternal. Only accessed on
|
||||
// the UI thread unless otherwise indicated.
|
||||
class CefBrowserContext {
|
||||
public:
|
||||
@@ -188,19 +188,20 @@ class CefBrowserContext {
|
||||
// Returns true if this context supports print preview.
|
||||
virtual bool IsPrintPreviewSupported() const;
|
||||
|
||||
// Called from CefBrowserHostImpl::DidNavigateAnyFrame to update the table of
|
||||
// visited links.
|
||||
virtual void AddVisitedURLs(const std::vector<GURL>& urls);
|
||||
|
||||
network::mojom::NetworkContext* GetNetworkContext();
|
||||
|
||||
CefMediaRouterManager* GetMediaRouterManager();
|
||||
|
||||
using CookieableSchemes = base::Optional<std::vector<std::string>>;
|
||||
|
||||
// Returns the schemes associated with this context specifically, or the
|
||||
// global configuration if unset.
|
||||
CookieableSchemes GetCookieableSchemes() const;
|
||||
|
||||
// Set the schemes associated with this context specifically.
|
||||
void set_cookieable_schemes(const CookieableSchemes& schemes) {
|
||||
cookieable_schemes_ = schemes;
|
||||
}
|
||||
CookieableSchemes cookieable_schemes() const { return cookieable_schemes_; }
|
||||
|
||||
// These accessors are safe to call from any thread because the values don't
|
||||
// change during this object's lifespan.
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
|
||||
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
||||
#include "chrome/browser/media/router/chrome_media_router_factory.h"
|
||||
#include "chrome/browser/plugins/plugin_prefs_factory.h"
|
||||
#include "chrome/browser/profiles/renderer_updater_factory.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_factory.h"
|
||||
@@ -19,6 +20,7 @@ namespace cef {
|
||||
|
||||
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
|
||||
CookieSettingsFactory::GetInstance();
|
||||
media_router::ChromeMediaRouterFactory::GetInstance();
|
||||
PluginPrefsFactory::GetInstance();
|
||||
PrefsTabHelper::GetServiceInstance();
|
||||
RendererUpdaterFactory::GetInstance();
|
||||
|
789
libcef/browser/browser_host_base.cc
Normal file
789
libcef/browser/browser_host_base.cc
Normal file
@@ -0,0 +1,789 @@
|
||||
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/image_impl.h"
|
||||
#include "libcef/browser/navigation_entry_impl.h"
|
||||
#include "libcef/browser/net/scheme_handler.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_factory.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_service.h"
|
||||
#include "components/favicon/core/favicon_url.h"
|
||||
#include "components/spellcheck/common/spellcheck_features.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/download_request_utils.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#include "components/spellcheck/browser/spellcheck_platform.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// Associates a CefBrowserHostBase instance with a WebContents. This object will
|
||||
// be deleted automatically when the WebContents is destroyed.
|
||||
class WebContentsUserDataAdapter : public base::SupportsUserData::Data {
|
||||
public:
|
||||
static void Register(CefRefPtr<CefBrowserHostBase> browser) {
|
||||
new WebContentsUserDataAdapter(browser);
|
||||
}
|
||||
|
||||
static CefRefPtr<CefBrowserHostBase> Get(
|
||||
const content::WebContents* web_contents) {
|
||||
WebContentsUserDataAdapter* adapter =
|
||||
static_cast<WebContentsUserDataAdapter*>(
|
||||
web_contents->GetUserData(UserDataKey()));
|
||||
if (adapter)
|
||||
return adapter->browser_;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
WebContentsUserDataAdapter(CefRefPtr<CefBrowserHostBase> browser)
|
||||
: browser_(browser) {
|
||||
auto web_contents = browser->GetWebContents();
|
||||
DCHECK(web_contents);
|
||||
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
|
||||
}
|
||||
|
||||
static void* UserDataKey() {
|
||||
// We just need a unique constant. Use the address of a static that
|
||||
// COMDAT folding won't touch in an optimizing linker.
|
||||
static int data_key = 0;
|
||||
return reinterpret_cast<void*>(&data_key);
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostBase> browser_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForHost(
|
||||
const content::RenderViewHost* host) {
|
||||
DCHECK(host);
|
||||
CEF_REQUIRE_UIT();
|
||||
content::WebContents* web_contents = content::WebContents::FromRenderViewHost(
|
||||
const_cast<content::RenderViewHost*>(host));
|
||||
if (web_contents)
|
||||
return GetBrowserForContents(web_contents);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForHost(
|
||||
const content::RenderFrameHost* host) {
|
||||
DCHECK(host);
|
||||
CEF_REQUIRE_UIT();
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(
|
||||
const_cast<content::RenderFrameHost*>(host));
|
||||
if (web_contents)
|
||||
return GetBrowserForContents(web_contents);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForContents(
|
||||
const content::WebContents* contents) {
|
||||
DCHECK(contents);
|
||||
CEF_REQUIRE_UIT();
|
||||
return WebContentsUserDataAdapter::Get(contents);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForFrameTreeNode(
|
||||
int frame_tree_node_id) {
|
||||
// Use the thread-safe approach.
|
||||
auto info =
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoForFrameTreeNode(
|
||||
frame_tree_node_id);
|
||||
if (info) {
|
||||
auto browser = info->browser();
|
||||
if (!browser) {
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id()
|
||||
<< " but no browser object matching frame tree node id "
|
||||
<< frame_tree_node_id;
|
||||
}
|
||||
return browser;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id) {
|
||||
if (render_process_id == -1 || render_routing_id == MSG_ROUTING_NONE)
|
||||
return nullptr;
|
||||
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
// Use the non-thread-safe but potentially faster approach.
|
||||
content::RenderFrameHost* render_frame_host =
|
||||
content::RenderFrameHost::FromID(render_process_id, render_routing_id);
|
||||
if (!render_frame_host)
|
||||
return nullptr;
|
||||
return GetBrowserForHost(render_frame_host);
|
||||
} else {
|
||||
// Use the thread-safe approach.
|
||||
bool is_guest_view = false;
|
||||
auto info =
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoForFrameRoute(
|
||||
render_process_id, render_routing_id, &is_guest_view);
|
||||
if (info && !is_guest_view) {
|
||||
auto browser = info->browser();
|
||||
if (!browser) {
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id()
|
||||
<< " but no browser object matching frame process id "
|
||||
<< render_process_id << " and routing id "
|
||||
<< render_routing_id;
|
||||
}
|
||||
return browser;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
CefBrowserHostBase::CefBrowserHostBase(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefRequestContextImpl> request_context)
|
||||
: settings_(settings),
|
||||
client_(client),
|
||||
platform_delegate_(std::move(platform_delegate)),
|
||||
browser_info_(browser_info),
|
||||
request_context_(request_context) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!browser_info_->browser().get());
|
||||
browser_info_->SetBrowser(this);
|
||||
|
||||
contents_delegate_ =
|
||||
std::make_unique<CefBrowserContentsDelegate>(browser_info_);
|
||||
contents_delegate_->AddObserver(this);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::InitializeBrowser() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// Associate the WebContents with this browser object.
|
||||
DCHECK(GetWebContents());
|
||||
WebContentsUserDataAdapter::Register(this);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::DestroyBrowser() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
platform_delegate_.reset(nullptr);
|
||||
|
||||
contents_delegate_->RemoveObserver(this);
|
||||
contents_delegate_->ObserveWebContents(nullptr);
|
||||
|
||||
CefBrowserInfoManager::GetInstance()->RemoveBrowserInfo(browser_info_);
|
||||
browser_info_->SetBrowser(nullptr);
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefBrowserHostBase::GetBrowser() {
|
||||
return this;
|
||||
}
|
||||
|
||||
CefRefPtr<CefClient> CefBrowserHostBase::GetClient() {
|
||||
return client_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContext> CefBrowserHostBase::GetRequestContext() {
|
||||
return request_context_;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::StartDownload(const CefString& url) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT, base::BindOnce(&CefBrowserHostBase::StartDownload, this, url));
|
||||
return;
|
||||
}
|
||||
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (gurl.is_empty() || !gurl.is_valid())
|
||||
return;
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
auto browser_context = web_contents->GetBrowserContext();
|
||||
if (!browser_context)
|
||||
return;
|
||||
|
||||
content::DownloadManager* manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context);
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
std::unique_ptr<download::DownloadUrlParameters> params(
|
||||
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
|
||||
web_contents, gurl, MISSING_TRAFFIC_ANNOTATION));
|
||||
manager->DownloadUrl(std::move(params));
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::DownloadImage(
|
||||
const CefString& image_url,
|
||||
bool is_favicon,
|
||||
uint32 max_image_size,
|
||||
bool bypass_cache,
|
||||
CefRefPtr<CefDownloadImageCallback> callback) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::DownloadImage, this, image_url,
|
||||
is_favicon, max_image_size, bypass_cache, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!callback)
|
||||
return;
|
||||
|
||||
GURL gurl = GURL(image_url.ToString());
|
||||
if (gurl.is_empty() || !gurl.is_valid())
|
||||
return;
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
web_contents->DownloadImage(
|
||||
gurl, is_favicon, max_image_size,
|
||||
max_image_size * gfx::ImageSkia::GetMaxSupportedScale(), bypass_cache,
|
||||
base::BindOnce(
|
||||
[](uint32 max_image_size,
|
||||
CefRefPtr<CefDownloadImageCallback> callback, int id,
|
||||
int http_status_code, const GURL& image_url,
|
||||
const std::vector<SkBitmap>& bitmaps,
|
||||
const std::vector<gfx::Size>& sizes) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
CefRefPtr<CefImageImpl> image_impl;
|
||||
|
||||
if (!bitmaps.empty()) {
|
||||
image_impl = new CefImageImpl();
|
||||
image_impl->AddBitmaps(max_image_size, bitmaps);
|
||||
}
|
||||
|
||||
callback->OnDownloadImageFinished(
|
||||
image_url.spec(), http_status_code, image_impl.get());
|
||||
},
|
||||
max_image_size, callback));
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::GetNavigationEntries(
|
||||
CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||
bool current_only) {
|
||||
DCHECK(visitor.get());
|
||||
if (!visitor.get())
|
||||
return;
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT, base::BindOnce(&CefBrowserHostBase::GetNavigationEntries, this,
|
||||
visitor, current_only));
|
||||
return;
|
||||
}
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
content::NavigationController& controller = web_contents->GetController();
|
||||
const int total = controller.GetEntryCount();
|
||||
const int current = controller.GetCurrentEntryIndex();
|
||||
|
||||
if (current_only) {
|
||||
// Visit only the current entry.
|
||||
CefRefPtr<CefNavigationEntryImpl> entry =
|
||||
new CefNavigationEntryImpl(controller.GetEntryAtIndex(current));
|
||||
visitor->Visit(entry.get(), true, current, total);
|
||||
entry->Detach(nullptr);
|
||||
} else {
|
||||
// Visit all entries.
|
||||
bool cont = true;
|
||||
for (int i = 0; i < total && cont; ++i) {
|
||||
CefRefPtr<CefNavigationEntryImpl> entry =
|
||||
new CefNavigationEntryImpl(controller.GetEntryAtIndex(i));
|
||||
cont = visitor->Visit(entry.get(), (i == current), i, total);
|
||||
entry->Detach(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefNavigationEntry> CefBrowserHostBase::GetVisibleNavigationEntry() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::NavigationEntry* entry = nullptr;
|
||||
auto web_contents = GetWebContents();
|
||||
if (web_contents)
|
||||
entry = web_contents->GetController().GetVisibleEntry();
|
||||
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
|
||||
return new CefNavigationEntryImpl(entry);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ReplaceMisspelling(const CefString& word) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::ReplaceMisspelling, this, word));
|
||||
return;
|
||||
}
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (web_contents)
|
||||
web_contents->ReplaceMisspelling(word);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::AddWordToDictionary(const CefString& word) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::AddWordToDictionary, this, word));
|
||||
return;
|
||||
}
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
SpellcheckService* spellcheck = nullptr;
|
||||
content::BrowserContext* browser_context = web_contents->GetBrowserContext();
|
||||
if (browser_context) {
|
||||
spellcheck = SpellcheckServiceFactory::GetForContext(browser_context);
|
||||
if (spellcheck)
|
||||
spellcheck->GetCustomDictionary()->AddWord(word);
|
||||
}
|
||||
#if defined(OS_MAC)
|
||||
if (spellcheck && spellcheck::UseBrowserSpellChecker()) {
|
||||
spellcheck_platform::AddWord(spellcheck->platform_spell_checker(), word);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::SendKeyEvent(const CefKeyEvent& event) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SendKeyEvent,
|
||||
this, event));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->SendKeyEvent(event);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::SendMouseClickEvent(const CefMouseEvent& event,
|
||||
MouseButtonType type,
|
||||
bool mouseUp,
|
||||
int clickCount) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::SendMouseClickEvent, this,
|
||||
event, type, mouseUp, clickCount));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_) {
|
||||
platform_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::SendMouseMoveEvent(const CefMouseEvent& event,
|
||||
bool mouseLeave) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::SendMouseMoveEvent, this,
|
||||
event, mouseLeave));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_) {
|
||||
platform_delegate_->SendMouseMoveEvent(event, mouseLeave);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) {
|
||||
if (deltaX == 0 && deltaY == 0) {
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::SendMouseWheelEvent, this,
|
||||
event, deltaX, deltaY));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_) {
|
||||
platform_delegate_->SendMouseWheelEvent(event, deltaX, deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHost> CefBrowserHostBase::GetHost() {
|
||||
return this;
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::CanGoBack() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
return can_go_back_;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::GoBack() {
|
||||
auto callback = base::BindOnce(&CefBrowserHostBase::GoBack, this);
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto wc = GetWebContents();
|
||||
if (wc && wc->GetController().CanGoBack()) {
|
||||
wc->GetController().GoBack();
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::CanGoForward() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
return can_go_forward_;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::GoForward() {
|
||||
auto callback = base::BindOnce(&CefBrowserHostBase::GoForward, this);
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto wc = GetWebContents();
|
||||
if (wc && wc->GetController().CanGoForward()) {
|
||||
wc->GetController().GoForward();
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::IsLoading() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
return is_loading_;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::Reload() {
|
||||
auto callback = base::BindOnce(&CefBrowserHostBase::Reload, this);
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto wc = GetWebContents();
|
||||
if (wc) {
|
||||
wc->GetController().Reload(content::ReloadType::NORMAL, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ReloadIgnoreCache() {
|
||||
auto callback = base::BindOnce(&CefBrowserHostBase::ReloadIgnoreCache, this);
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto wc = GetWebContents();
|
||||
if (wc) {
|
||||
wc->GetController().Reload(content::ReloadType::BYPASSING_CACHE, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::StopLoad() {
|
||||
auto callback = base::BindOnce(&CefBrowserHostBase::StopLoad, this);
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto wc = GetWebContents();
|
||||
if (wc) {
|
||||
wc->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
int CefBrowserHostBase::GetIdentifier() {
|
||||
return browser_id();
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::IsSame(CefRefPtr<CefBrowser> that) {
|
||||
auto impl = static_cast<CefBrowserHostBase*>(that.get());
|
||||
return (impl == this);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::HasDocument() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
return has_document_;
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::IsPopup() {
|
||||
return browser_info_->is_popup();
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetMainFrame() {
|
||||
return GetFrame(CefFrameHostImpl::kMainFrameId);
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFocusedFrame() {
|
||||
return GetFrame(CefFrameHostImpl::kFocusedFrameId);
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrame(int64 identifier) {
|
||||
if (identifier == CefFrameHostImpl::kInvalidFrameId) {
|
||||
return nullptr;
|
||||
} else if (identifier == CefFrameHostImpl::kMainFrameId) {
|
||||
return browser_info_->GetMainFrame();
|
||||
} else if (identifier == CefFrameHostImpl::kFocusedFrameId) {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
if (!focused_frame_) {
|
||||
// The main frame is focused by default.
|
||||
return browser_info_->GetMainFrame();
|
||||
}
|
||||
return focused_frame_;
|
||||
}
|
||||
|
||||
return browser_info_->GetFrameForId(identifier);
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrame(const CefString& name) {
|
||||
for (const auto& frame : browser_info_->GetAllFrames()) {
|
||||
if (frame->GetName() == name)
|
||||
return frame;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t CefBrowserHostBase::GetFrameCount() {
|
||||
return browser_info_->GetAllFrames().size();
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::GetFrameIdentifiers(std::vector<int64>& identifiers) {
|
||||
if (identifiers.size() > 0)
|
||||
identifiers.clear();
|
||||
|
||||
const auto frames = browser_info_->GetAllFrames();
|
||||
if (frames.empty())
|
||||
return;
|
||||
|
||||
identifiers.reserve(frames.size());
|
||||
for (const auto& frame : frames) {
|
||||
identifiers.push_back(frame->GetIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::GetFrameNames(std::vector<CefString>& names) {
|
||||
if (names.size() > 0)
|
||||
names.clear();
|
||||
|
||||
const auto frames = browser_info_->GetAllFrames();
|
||||
if (frames.empty())
|
||||
return;
|
||||
|
||||
names.reserve(frames.size());
|
||||
for (const auto& frame : frames) {
|
||||
names.push_back(frame->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnStateChanged(CefBrowserContentsState state_changed) {
|
||||
// Make sure that CefBrowser state is consistent before the associated
|
||||
// CefClient callback is executed.
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
if ((state_changed & CefBrowserContentsState::kNavigation) ==
|
||||
CefBrowserContentsState::kNavigation) {
|
||||
is_loading_ = contents_delegate_->is_loading();
|
||||
can_go_back_ = contents_delegate_->can_go_back();
|
||||
can_go_forward_ = contents_delegate_->can_go_forward();
|
||||
}
|
||||
if ((state_changed & CefBrowserContentsState::kDocument) ==
|
||||
CefBrowserContentsState::kDocument) {
|
||||
has_document_ = contents_delegate_->has_document();
|
||||
}
|
||||
if ((state_changed & CefBrowserContentsState::kFullscreen) ==
|
||||
CefBrowserContentsState::kFullscreen) {
|
||||
is_fullscreen_ = contents_delegate_->is_fullscreen();
|
||||
}
|
||||
if ((state_changed & CefBrowserContentsState::kFocusedFrame) ==
|
||||
CefBrowserContentsState::kFocusedFrame) {
|
||||
focused_frame_ = contents_delegate_->focused_frame();
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnWebContentsDestroyed(
|
||||
content::WebContents* web_contents) {}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
|
||||
const content::RenderFrameHost* host) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!host)
|
||||
return nullptr;
|
||||
|
||||
return browser_info_->GetFrameForHost(host);
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForFrameTreeNode(
|
||||
int frame_tree_node_id) {
|
||||
return browser_info_->GetFrameForFrameTreeNode(frame_tree_node_id, nullptr);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::AddObserver(Observer* observer) {
|
||||
CEF_REQUIRE_UIT();
|
||||
observers_.AddObserver(observer);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::RemoveObserver(Observer* observer) {
|
||||
CEF_REQUIRE_UIT();
|
||||
observers_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::HasObserver(Observer* observer) const {
|
||||
CEF_REQUIRE_UIT();
|
||||
return observers_.HasObserver(observer);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::LoadMainFrameURL(
|
||||
const content::OpenURLParams& params) {
|
||||
if (!params.url.is_valid()) {
|
||||
LOG(ERROR) << "Invalid URL: " << params.url.spec();
|
||||
return;
|
||||
}
|
||||
|
||||
auto callback =
|
||||
base::BindOnce(&CefBrowserHostBase::LoadMainFrameURL, this, params);
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Navigate(params)) {
|
||||
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::Navigate(const content::OpenURLParams& params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
auto web_contents = GetWebContents();
|
||||
if (web_contents) {
|
||||
web_contents->GetController().LoadURL(
|
||||
params.url, params.referrer, params.transition, params.extra_headers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||
const GURL& validated_url,
|
||||
int http_status_code) {
|
||||
frame->RefreshAttributes();
|
||||
|
||||
// Give internal scheme handlers an opportunity to update content.
|
||||
scheme::DidFinishLoad(frame, validated_url);
|
||||
|
||||
contents_delegate_->OnLoadEnd(frame, validated_url, http_status_code);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ViewText(const std::string& text) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefBrowserHostBase::ViewText, this, text));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->ViewText(text);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::MaybeAllowNavigation(
|
||||
content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnAfterCreated() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (client_) {
|
||||
if (auto handler = client_->GetLifeSpanHandler()) {
|
||||
handler->OnAfterCreated(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnBeforeClose() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (client_) {
|
||||
if (auto handler = client_->GetLifeSpanHandler()) {
|
||||
handler->OnBeforeClose(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnBrowserDestroyed() {
|
||||
CEF_REQUIRE_UIT();
|
||||
for (auto& observer : observers_)
|
||||
observer.OnBrowserDestroyed(this);
|
||||
}
|
||||
|
||||
int CefBrowserHostBase::browser_id() const {
|
||||
return browser_info_->browser_id();
|
||||
}
|
||||
|
||||
content::WebContents* CefBrowserHostBase::GetWebContents() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
return contents_delegate_->web_contents();
|
||||
}
|
||||
|
||||
content::BrowserContext* CefBrowserHostBase::GetBrowserContext() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
auto web_contents = GetWebContents();
|
||||
if (web_contents)
|
||||
return web_contents->GetBrowserContext();
|
||||
return nullptr;
|
||||
}
|
268
libcef/browser/browser_host_base.h
Normal file
268
libcef/browser/browser_host_base.h
Normal file
@@ -0,0 +1,268 @@
|
||||
// Copyright 2020 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_HOST_BASE_H_
|
||||
#define CEF_LIBCEF_BROWSER_BROWSER_HOST_BASE_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "libcef/browser/browser_contents_delegate.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "extensions/common/view_type.h"
|
||||
|
||||
namespace extensions {
|
||||
class Extension;
|
||||
}
|
||||
|
||||
// Parameters that are passed to the runtime-specific Create methods.
|
||||
struct CefBrowserCreateParams {
|
||||
CefBrowserCreateParams() {}
|
||||
|
||||
// Copy constructor used with the chrome runtime only.
|
||||
CefBrowserCreateParams(const CefBrowserCreateParams& that) {
|
||||
operator=(that);
|
||||
}
|
||||
CefBrowserCreateParams& operator=(const CefBrowserCreateParams& that) {
|
||||
// Not all parameters can be copied.
|
||||
client = that.client;
|
||||
url = that.url;
|
||||
settings = that.settings;
|
||||
request_context = that.request_context;
|
||||
extra_info = that.extra_info;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Platform-specific window creation info. Will be nullptr when creating a
|
||||
// views-hosted browser. Currently used with the alloy runtime only.
|
||||
std::unique_ptr<CefWindowInfo> window_info;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
// The BrowserView that will own a views-hosted browser. Will be nullptr for
|
||||
// popup browsers (the BrowserView will be created later in that case).
|
||||
// Currently used with the alloy runtime only.
|
||||
CefRefPtr<CefBrowserView> browser_view;
|
||||
#endif
|
||||
|
||||
// Client implementation. May be nullptr.
|
||||
CefRefPtr<CefClient> client;
|
||||
|
||||
// Initial URL to load. May be empty. If this is a valid extension URL then
|
||||
// the browser will be created as an app view extension host.
|
||||
GURL url;
|
||||
|
||||
// Browser settings.
|
||||
CefBrowserSettings settings;
|
||||
|
||||
// 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;
|
||||
|
||||
// Request context to use when creating the browser. If nullptr the global
|
||||
// request context will be used.
|
||||
CefRefPtr<CefRequestContext> request_context;
|
||||
|
||||
// Extra information that will be passed to
|
||||
// CefRenderProcessHandler::OnBrowserCreated.
|
||||
CefRefPtr<CefDictionaryValue> extra_info;
|
||||
|
||||
// Used when explicitly creating the browser as an extension host via
|
||||
// ProcessManager::CreateBackgroundHost. Currently used with the alloy
|
||||
// runtime only.
|
||||
const extensions::Extension* extension = nullptr;
|
||||
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
|
||||
};
|
||||
|
||||
// Base class for CefBrowserHost implementations. Includes functionality that is
|
||||
// shared by the alloy and chrome runtimes. All methods are thread-safe unless
|
||||
// otherwise indicated.
|
||||
class CefBrowserHostBase : public CefBrowserHost,
|
||||
public CefBrowser,
|
||||
public CefBrowserContentsDelegate::Observer {
|
||||
public:
|
||||
// Interface to implement for observers that wish to be informed of changes
|
||||
// to the CefBrowserHostBase. All methods will be called on the UI thread.
|
||||
class Observer : public base::CheckedObserver {
|
||||
public:
|
||||
// Called before |browser| is destroyed. Any references to |browser| should
|
||||
// be cleared when this method is called.
|
||||
virtual void OnBrowserDestroyed(CefBrowserHostBase* browser) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Observer() {}
|
||||
};
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<CefBrowserHostBase> GetBrowserForHost(
|
||||
const content::RenderViewHost* host);
|
||||
// Returns the browser associated with the specified RenderFrameHost.
|
||||
static CefRefPtr<CefBrowserHostBase> GetBrowserForHost(
|
||||
const content::RenderFrameHost* host);
|
||||
// Returns the browser associated with the specified WebContents.
|
||||
static CefRefPtr<CefBrowserHostBase> GetBrowserForContents(
|
||||
const content::WebContents* contents);
|
||||
// Returns the browser associated with the specified FrameTreeNode ID.
|
||||
static CefRefPtr<CefBrowserHostBase> GetBrowserForFrameTreeNode(
|
||||
int frame_tree_node_id);
|
||||
// Returns the browser associated with the specified frame routing IDs.
|
||||
static CefRefPtr<CefBrowserHostBase> GetBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id);
|
||||
|
||||
CefBrowserHostBase(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefRequestContextImpl> request_context);
|
||||
|
||||
// Called on the UI thread after the associated WebContents is created.
|
||||
virtual void InitializeBrowser();
|
||||
|
||||
// Called on the UI thread after the associated WebContents is destroyed.
|
||||
// Also called from CefBrowserInfoManager::DestroyAllBrowsers if the browser
|
||||
// was not properly shut down.
|
||||
virtual void DestroyBrowser();
|
||||
|
||||
// CefBrowserHost methods:
|
||||
CefRefPtr<CefBrowser> GetBrowser() override;
|
||||
CefRefPtr<CefClient> GetClient() override;
|
||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||
void StartDownload(const CefString& url) override;
|
||||
void DownloadImage(const CefString& image_url,
|
||||
bool is_favicon,
|
||||
uint32 max_image_size,
|
||||
bool bypass_cache,
|
||||
CefRefPtr<CefDownloadImageCallback> callback) override;
|
||||
void ReplaceMisspelling(const CefString& word) override;
|
||||
void AddWordToDictionary(const CefString& word) override;
|
||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||
void SendMouseClickEvent(const CefMouseEvent& event,
|
||||
MouseButtonType type,
|
||||
bool mouseUp,
|
||||
int clickCount) override;
|
||||
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
||||
void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) override;
|
||||
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||
bool current_only) override;
|
||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||
|
||||
// CefBrowser methods:
|
||||
CefRefPtr<CefBrowserHost> GetHost() override;
|
||||
bool CanGoBack() override;
|
||||
void GoBack() override;
|
||||
bool CanGoForward() override;
|
||||
void GoForward() override;
|
||||
bool IsLoading() override;
|
||||
void Reload() override;
|
||||
void ReloadIgnoreCache() override;
|
||||
void StopLoad() override;
|
||||
int GetIdentifier() override;
|
||||
bool IsSame(CefRefPtr<CefBrowser> that) override;
|
||||
bool HasDocument() override;
|
||||
bool IsPopup() override;
|
||||
CefRefPtr<CefFrame> GetMainFrame() override;
|
||||
CefRefPtr<CefFrame> GetFocusedFrame() override;
|
||||
CefRefPtr<CefFrame> GetFrame(int64 identifier) override;
|
||||
CefRefPtr<CefFrame> GetFrame(const CefString& name) override;
|
||||
size_t GetFrameCount() override;
|
||||
void GetFrameIdentifiers(std::vector<int64>& identifiers) override;
|
||||
void GetFrameNames(std::vector<CefString>& names) override;
|
||||
|
||||
// CefBrowserContentsDelegate::Observer methods:
|
||||
void OnStateChanged(CefBrowserContentsState state_changed) override;
|
||||
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
|
||||
|
||||
// Returns the frame associated with the specified RenderFrameHost.
|
||||
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
|
||||
|
||||
// Returns the frame associated with the specified FrameTreeNode ID.
|
||||
CefRefPtr<CefFrame> GetFrameForFrameTreeNode(int frame_tree_node_id);
|
||||
|
||||
// Manage observer objects. The observer must either outlive this object or
|
||||
// be removed before destruction. Must be called on the UI thread.
|
||||
void AddObserver(Observer* observer);
|
||||
void RemoveObserver(Observer* observer);
|
||||
bool HasObserver(Observer* observer) const;
|
||||
|
||||
// Methods called from CefFrameHostImpl.
|
||||
void LoadMainFrameURL(const content::OpenURLParams& params);
|
||||
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||
const GURL& validated_url,
|
||||
int http_status_code);
|
||||
virtual void OnSetFocus(cef_focus_source_t source) = 0;
|
||||
void ViewText(const std::string& text);
|
||||
|
||||
// Called from CefBrowserInfoManager::MaybeAllowNavigation.
|
||||
virtual bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||
bool is_guest_view,
|
||||
const content::OpenURLParams& params);
|
||||
|
||||
// Helpers for executing client callbacks. Must be called on the UI thread.
|
||||
void OnAfterCreated();
|
||||
void OnBeforeClose();
|
||||
void OnBrowserDestroyed();
|
||||
|
||||
// Thread-safe accessors.
|
||||
const CefBrowserSettings& settings() const { return settings_; }
|
||||
CefRefPtr<CefClient> client() const { return client_; }
|
||||
scoped_refptr<CefBrowserInfo> browser_info() const { return browser_info_; }
|
||||
int browser_id() const;
|
||||
CefRefPtr<CefRequestContextImpl> request_context() const {
|
||||
return request_context_;
|
||||
}
|
||||
|
||||
// Accessors that must be called on the UI thread.
|
||||
content::WebContents* GetWebContents() const;
|
||||
content::BrowserContext* GetBrowserContext() const;
|
||||
CefBrowserPlatformDelegate* platform_delegate() const {
|
||||
return platform_delegate_.get();
|
||||
}
|
||||
CefBrowserContentsDelegate* contents_delegate() const {
|
||||
return contents_delegate_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
// Called from LoadMainFrameURL to perform the actual navigation.
|
||||
virtual bool Navigate(const content::OpenURLParams& params);
|
||||
|
||||
// Thread-safe members.
|
||||
CefBrowserSettings settings_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
|
||||
scoped_refptr<CefBrowserInfo> browser_info_;
|
||||
CefRefPtr<CefRequestContextImpl> request_context_;
|
||||
|
||||
// Only accessed on the UI thread.
|
||||
std::unique_ptr<CefBrowserContentsDelegate> contents_delegate_;
|
||||
|
||||
// Observers that want to be notified of changes to this object.
|
||||
// Only accessed on the UI thread.
|
||||
base::ObserverList<Observer> observers_;
|
||||
|
||||
// Volatile state accessed from multiple threads. All access must be protected
|
||||
// by |state_lock_|.
|
||||
base::Lock state_lock_;
|
||||
bool is_loading_ = false;
|
||||
bool can_go_back_ = false;
|
||||
bool can_go_forward_ = false;
|
||||
bool has_document_ = false;
|
||||
bool is_fullscreen_ = false;
|
||||
CefRefPtr<CefFrameHostImpl> focused_frame_;
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(CefBrowserHostBase);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostBase);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_HOST_BASE_H_
|
144
libcef/browser/browser_host_create.cc
Normal file
144
libcef/browser/browser_host_create.cc
Normal file
@@ -0,0 +1,144 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions 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.
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/features/runtime.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class CreateBrowserHelper {
|
||||
public:
|
||||
CreateBrowserHelper(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefString& url,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue> extra_info,
|
||||
CefRefPtr<CefRequestContext> request_context)
|
||||
: window_info_(windowInfo),
|
||||
client_(client),
|
||||
url_(url),
|
||||
settings_(settings),
|
||||
extra_info_(extra_info),
|
||||
request_context_(request_context) {}
|
||||
|
||||
CefWindowInfo window_info_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
CefString url_;
|
||||
CefBrowserSettings settings_;
|
||||
CefRefPtr<CefDictionaryValue> extra_info_;
|
||||
CefRefPtr<CefRequestContext> request_context_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
bool CefBrowserHost::CreateBrowser(
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefString& url,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue> extra_info,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify that the settings structure is a valid size.
|
||||
if (settings.size != sizeof(cef_browser_settings_t)) {
|
||||
NOTREACHED() << "invalid CefBrowserSettings structure size";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify windowless rendering requirements.
|
||||
if (windowInfo.windowless_rendering_enabled &&
|
||||
!client->GetRenderHandler().get()) {
|
||||
NOTREACHED() << "CefRenderHandler implementation is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (windowInfo.windowless_rendering_enabled &&
|
||||
!CefContext::Get()->settings().windowless_rendering_enabled) {
|
||||
LOG(ERROR) << "Creating a windowless browser without setting "
|
||||
"CefSettings.windowless_rendering_enabled may result in "
|
||||
"reduced performance or runtime errors.";
|
||||
}
|
||||
|
||||
// Create the browser on the UI thread.
|
||||
CreateBrowserHelper* helper = new CreateBrowserHelper(
|
||||
windowInfo, client, url, settings, extra_info, request_context);
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(
|
||||
[](CreateBrowserHelper* helper) {
|
||||
CefBrowserHost::CreateBrowserSync(
|
||||
helper->window_info_, helper->client_,
|
||||
helper->url_, helper->settings_,
|
||||
helper->extra_info_,
|
||||
helper->request_context_);
|
||||
delete helper;
|
||||
},
|
||||
helper));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefString& url,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue> extra_info,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Verify that the settings structure is a valid size.
|
||||
if (settings.size != sizeof(cef_browser_settings_t)) {
|
||||
NOTREACHED() << "invalid CefBrowserSettings structure size";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Verify windowless rendering requirements.
|
||||
if (windowInfo.windowless_rendering_enabled &&
|
||||
!client->GetRenderHandler().get()) {
|
||||
NOTREACHED() << "CefRenderHandler implementation is required";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.window_info.reset(new CefWindowInfo(windowInfo));
|
||||
create_params.client = client;
|
||||
create_params.url = GURL(url.ToString());
|
||||
if (!url.empty() && !create_params.url.is_valid() &&
|
||||
!create_params.url.has_scheme()) {
|
||||
std::string new_url = std::string("http://") + url.ToString();
|
||||
create_params.url = GURL(new_url);
|
||||
}
|
||||
create_params.settings = settings;
|
||||
create_params.extra_info = extra_info;
|
||||
create_params.request_context = request_context;
|
||||
|
||||
if (cef::IsChromeRuntimeEnabled()) {
|
||||
auto browser = ChromeBrowserHostImpl::Create(create_params);
|
||||
return browser.get();
|
||||
}
|
||||
|
||||
auto browser = AlloyBrowserHostImpl::Create(create_params);
|
||||
return browser.get();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -4,13 +4,13 @@
|
||||
|
||||
#include "libcef/browser/browser_info.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "content/browser/frame_host/frame_tree_node.h"
|
||||
#include "content/browser/frame_host/render_frame_host_impl.h"
|
||||
#include "content/browser/renderer_host/frame_tree_node.h"
|
||||
#include "content/browser/renderer_host/render_frame_host_impl.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "ipc/ipc_message.h"
|
||||
|
||||
@@ -34,12 +34,12 @@ CefBrowserInfo::CefBrowserInfo(int browser_id,
|
||||
|
||||
CefBrowserInfo::~CefBrowserInfo() {}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> CefBrowserInfo::browser() const {
|
||||
CefRefPtr<CefBrowserHostBase> CefBrowserInfo::browser() const {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
return browser_;
|
||||
}
|
||||
|
||||
void CefBrowserInfo::SetBrowser(CefRefPtr<CefBrowserHostImpl> browser) {
|
||||
void CefBrowserInfo::SetBrowser(CefRefPtr<CefBrowserHostBase> browser) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
browser_ = browser;
|
||||
|
||||
@@ -297,6 +297,37 @@ CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {
|
||||
return frames;
|
||||
}
|
||||
|
||||
CefBrowserInfo::NavigationLock::NavigationLock() : weak_ptr_factory_(this) {}
|
||||
|
||||
CefBrowserInfo::NavigationLock::~NavigationLock() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (pending_action_) {
|
||||
CEF_POST_TASK(CEF_UIT, std::move(pending_action_));
|
||||
}
|
||||
}
|
||||
|
||||
scoped_refptr<CefBrowserInfo::NavigationLock>
|
||||
CefBrowserInfo::CreateNavigationLock() {
|
||||
CEF_REQUIRE_UIT();
|
||||
scoped_refptr<NavigationLock> lock;
|
||||
if (!navigation_lock_) {
|
||||
lock = new NavigationLock();
|
||||
navigation_lock_ = lock->weak_ptr_factory_.GetWeakPtr();
|
||||
} else {
|
||||
lock = navigation_lock_.get();
|
||||
}
|
||||
return lock;
|
||||
}
|
||||
|
||||
bool CefBrowserInfo::IsNavigationLocked(base::OnceClosure pending_action) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (navigation_lock_) {
|
||||
navigation_lock_->pending_action_ = std::move(pending_action);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserInfo::MaybeUpdateFrameTreeNodeIdMap(FrameInfo* info) {
|
||||
lock_.AssertAcquired();
|
||||
|
||||
|
@@ -12,8 +12,10 @@
|
||||
#include "include/internal/cef_ptr.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/containers/unique_ptr_adapters.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/values.h"
|
||||
|
||||
@@ -21,12 +23,12 @@ namespace content {
|
||||
class RenderFrameHost;
|
||||
}
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class CefBrowserHostBase;
|
||||
class CefFrameHostImpl;
|
||||
|
||||
// CefBrowserInfo is used to associate a browser ID and render view/process
|
||||
// IDs with a particular CefBrowserHostImpl. Render view/process IDs may change
|
||||
// during the lifetime of a single CefBrowserHostImpl.
|
||||
// IDs with a particular CefBrowserHostBase. Render view/process IDs may change
|
||||
// during the lifetime of a single CefBrowserHostBase.
|
||||
//
|
||||
// CefBrowserInfo objects are managed by CefBrowserInfoManager and should not be
|
||||
// created directly.
|
||||
@@ -44,23 +46,24 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
|
||||
// May return NULL if the browser has not yet been created or if the browser
|
||||
// has been destroyed.
|
||||
CefRefPtr<CefBrowserHostImpl> browser() const;
|
||||
CefRefPtr<CefBrowserHostBase> browser() const;
|
||||
|
||||
// Set or clear the browser. Called from the CefBrowserHostImpl constructor
|
||||
// Set or clear the browser. Called from CefBrowserHostBase InitializeBrowser
|
||||
// (to set) and DestroyBrowser (to clear).
|
||||
void SetBrowser(CefRefPtr<CefBrowserHostImpl> browser);
|
||||
void SetBrowser(CefRefPtr<CefBrowserHostBase> browser);
|
||||
|
||||
// Ensure that a frame record exists for |host|. Called for the main frame
|
||||
// when the RenderView is created, or for a sub-frame when the associated
|
||||
// RenderFrame is created in the renderer process.
|
||||
// Called from CefBrowserHostImpl::RenderFrameCreated (is_guest_view = false)
|
||||
// or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view = true).
|
||||
// Called from CefBrowserContentsDelegate::RenderFrameCreated (is_guest_view =
|
||||
// false) or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view =
|
||||
// true).
|
||||
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
|
||||
|
||||
// Remove the frame record for |host|. Called for the main frame when the
|
||||
// RenderView is destroyed, or for a sub-frame when the associated RenderFrame
|
||||
// is destroyed in the renderer process.
|
||||
// Called from CefBrowserHostImpl::FrameDeleted or
|
||||
// Called from CefBrowserContentsDelegate::RenderFrameDeleted or
|
||||
// CefMimeHandlerViewGuestDelegate::OnGuestDetached.
|
||||
void RemoveFrame(content::RenderFrameHost* host);
|
||||
|
||||
@@ -121,6 +124,28 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
typedef std::set<CefRefPtr<CefFrameHostImpl>> FrameHostList;
|
||||
FrameHostList GetAllFrames() const;
|
||||
|
||||
class NavigationLock final : public base::RefCounted<NavigationLock> {
|
||||
private:
|
||||
friend class CefBrowserInfo;
|
||||
friend class base::RefCounted<NavigationLock>;
|
||||
|
||||
NavigationLock();
|
||||
~NavigationLock();
|
||||
|
||||
base::OnceClosure pending_action_;
|
||||
base::WeakPtrFactory<NavigationLock> weak_ptr_factory_;
|
||||
};
|
||||
|
||||
// Block navigation actions on NavigationLock life span. Must be called on the
|
||||
// UI thread.
|
||||
scoped_refptr<NavigationLock> CreateNavigationLock();
|
||||
|
||||
// Returns true if navigation actions are currently blocked. If this method
|
||||
// returns true the most recent |pending_action| will be executed on the UI
|
||||
// thread once the navigation lock is released. Must be called on the UI
|
||||
// thread.
|
||||
bool IsNavigationLocked(base::OnceClosure pending_action);
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<CefBrowserInfo>;
|
||||
|
||||
@@ -151,11 +176,15 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
bool is_windowless_;
|
||||
CefRefPtr<CefDictionaryValue> extra_info_;
|
||||
|
||||
// Navigation will be blocked while |navigation_lock_| exists.
|
||||
// Only accessed on the UI thread.
|
||||
base::WeakPtr<NavigationLock> navigation_lock_;
|
||||
|
||||
mutable base::Lock lock_;
|
||||
|
||||
// The below members must be protected by |lock_|.
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser_;
|
||||
CefRefPtr<CefBrowserHostBase> browser_;
|
||||
|
||||
// Owner of FrameInfo structs.
|
||||
typedef std::set<std::unique_ptr<FrameInfo>, base::UniquePtrComparator>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
@@ -23,7 +24,6 @@
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "extensions/common/constants.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -122,7 +122,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
/*is_renderer_initiated=*/true);
|
||||
params.user_gesture = user_gesture;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser;
|
||||
CefRefPtr<CefBrowserHostBase> browser;
|
||||
if (!MaybeAllowNavigation(opener, params, browser) || !browser) {
|
||||
// Cancel the popup.
|
||||
return false;
|
||||
@@ -180,9 +180,9 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
}
|
||||
|
||||
if (allow) {
|
||||
CefBrowserHostImpl::CreateParams create_params;
|
||||
CefBrowserCreateParams create_params;
|
||||
|
||||
if (!browser->IsViewsHosted())
|
||||
if (!browser->HasView())
|
||||
create_params.window_info = std::move(window_info);
|
||||
|
||||
create_params.settings = pending_popup->settings;
|
||||
@@ -213,6 +213,7 @@ void CefBrowserInfoManager::GetCustomWebContentsView(
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view) {
|
||||
CEF_REQUIRE_UIT();
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
|
||||
PopPendingPopup(CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW,
|
||||
@@ -241,10 +242,15 @@ void CefBrowserInfoManager::WebContentsCreated(
|
||||
CefRefPtr<CefDictionaryValue>& extra_info) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
// GET_CUSTOM_WEB_CONTENTS_VIEW is only used with the alloy runtime.
|
||||
const auto previous_step =
|
||||
cef::IsAlloyRuntimeEnabled()
|
||||
? CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW
|
||||
: CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW;
|
||||
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
|
||||
PopPendingPopup(
|
||||
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
|
||||
opener_render_process_id, opener_render_routing_id, target_url);
|
||||
PopPendingPopup(previous_step, opener_render_process_id,
|
||||
opener_render_routing_id, target_url);
|
||||
DCHECK(pending_popup.get());
|
||||
DCHECK(pending_popup->platform_delegate.get());
|
||||
|
||||
@@ -332,7 +338,7 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
|
||||
if (!list.empty()) {
|
||||
BrowserInfoList::iterator it = list.begin();
|
||||
for (; it != list.end(); ++it) {
|
||||
CefRefPtr<CefBrowserHostImpl> browser = (*it)->browser();
|
||||
CefRefPtr<CefBrowserHostBase> browser = (*it)->browser();
|
||||
DCHECK(browser.get());
|
||||
if (browser.get()) {
|
||||
// DestroyBrowser will call RemoveBrowserInfo.
|
||||
@@ -361,28 +367,18 @@ CefBrowserInfoManager::GetBrowserInfoForFrameRoute(int render_process_id,
|
||||
bool CefBrowserInfoManager::MaybeAllowNavigation(
|
||||
content::RenderFrameHost* opener,
|
||||
const content::OpenURLParams& params,
|
||||
CefRefPtr<CefBrowserHostImpl>& browser_out) const {
|
||||
CefRefPtr<CefBrowserHostBase>& browser_out) const {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
bool is_guest_view = false;
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
|
||||
auto browser = extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
|
||||
if (!browser) {
|
||||
// Print preview uses a modal dialog where we don't own the WebContents.
|
||||
// Allow that navigation to proceed.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_guest_view && !params.url.SchemeIs(extensions::kExtensionScheme) &&
|
||||
!params.url.SchemeIs(content::kChromeUIScheme)) {
|
||||
// The PDF viewer will load the PDF extension in the guest view, and print
|
||||
// preview will load chrome://print in the guest view. All other navigations
|
||||
// are passed to the owner browser.
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::Bind(base::IgnoreResult(&CefBrowserHostImpl::OpenURLFromTab),
|
||||
browser.get(), nullptr, params));
|
||||
|
||||
if (!browser->MaybeAllowNavigation(opener, is_guest_view, params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@ namespace IPC {
|
||||
class Message;
|
||||
}
|
||||
|
||||
class CefBrowserHostBase;
|
||||
class CefBrowserPlatformDelegate;
|
||||
|
||||
// Singleton object for managing BrowserInfo instances.
|
||||
@@ -48,14 +49,14 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// Returns this singleton instance of this class.
|
||||
static CefBrowserInfoManager* GetInstance();
|
||||
|
||||
// Called from CefBrowserHostImpl::Create when a new browser is being created
|
||||
// Called immediately before a new CefBrowserHost implementation is created
|
||||
// directly. In this case |is_popup| will be true only for DevTools browsers.
|
||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
|
||||
bool is_popup,
|
||||
bool is_windowless,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
// Called from CefBrowserHostImpl::WebContentsCreated when a new browser is
|
||||
// Called from WebContentsDelegate::WebContentsCreated when a new browser is
|
||||
// being created for a traditional popup (e.g. window.open() or targeted
|
||||
// link). If any OnGetNewBrowserInfo requests are pending for the popup the
|
||||
// response will be sent when this method is called.
|
||||
@@ -64,7 +65,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
bool is_windowless,
|
||||
CefRefPtr<CefDictionaryValue> extra_info);
|
||||
|
||||
// Called from AlloyContentBrowserClient::CanCreateWindow. See comments on
|
||||
// Called from ContentBrowserClient::CanCreateWindow. See comments on
|
||||
// PendingPopup for more information.
|
||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||
const GURL& target_url,
|
||||
@@ -76,8 +77,8 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access);
|
||||
|
||||
// Called from CefBrowserHostImpl::GetCustomWebContentsView. See comments on
|
||||
// PendingPopup for more information.
|
||||
// Called from WebContentsDelegate::GetCustomWebContentsView (alloy runtime
|
||||
// only). See comments on PendingPopup for more information.
|
||||
void GetCustomWebContentsView(
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
@@ -85,7 +86,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view);
|
||||
|
||||
// Called from CefBrowserHostImpl::WebContentsCreated. See comments on
|
||||
// Called from WebContentsDelegate::WebContentsCreated. See comments on
|
||||
// PendingPopup for more information.
|
||||
void WebContentsCreated(
|
||||
const GURL& target_url,
|
||||
@@ -107,7 +108,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
int render_routing_id,
|
||||
IPC::Message* reply_msg);
|
||||
|
||||
// Called from CefBrowserHostImpl::DestroyBrowser() when a browser is
|
||||
// Called from CefBrowserHostBase::DestroyBrowser() when a browser is
|
||||
// destroyed.
|
||||
void RemoveBrowserInfo(scoped_refptr<CefBrowserInfo> browser_info);
|
||||
|
||||
@@ -116,7 +117,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Returns the CefBrowserInfo matching the specified IDs or nullptr if no
|
||||
// match is found. It is allowed to add new callers of this method but
|
||||
// consider using CefBrowserHostImpl::GetBrowserForFrameRoute() or
|
||||
// consider using CefBrowserHostBase::GetBrowserForFrameRoute() or
|
||||
// extensions::GetOwnerBrowserForFrameRoute() instead. If |is_guest_view| is
|
||||
// non-nullptr it will be set to true if the IDs match a guest view associated
|
||||
// with the returned browser info instead of the browser itself.
|
||||
@@ -127,7 +128,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Returns the CefBrowserInfo matching the specified ID or nullptr if no match
|
||||
// is found. It is allowed to add new callers of this method but consider
|
||||
// using CefBrowserHostImpl::GetBrowserForFrameTreeNode() instead. If
|
||||
// using CefBrowserHostBase::GetBrowserForFrameTreeNode() instead. If
|
||||
// |is_guest_view| is non-nullptr it will be set to true if the IDs match a
|
||||
// guest view associated with the returned browser info instead of the browser
|
||||
// itself.
|
||||
@@ -144,23 +145,24 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// |browser| will be set to the target browser if any.
|
||||
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||
const content::OpenURLParams& params,
|
||||
CefRefPtr<CefBrowserHostImpl>& browser) const;
|
||||
CefRefPtr<CefBrowserHostBase>& browser) const;
|
||||
|
||||
private:
|
||||
// RenderProcessHostObserver methods:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
||||
// Store state information about pending popups. Call order is:
|
||||
// - AlloyContentBrowserClient::CanCreateWindow (UIT)
|
||||
// - CanCreateWindow (UIT):
|
||||
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and
|
||||
// creates the new platform delegate for the popup. If the popup owner is
|
||||
// an extension guest view then the popup is canceled and
|
||||
// CefBrowserHostImpl::OpenURLFromTab is called.
|
||||
// WebContentsDelegate::OpenURLFromTab is called via the
|
||||
// CefBrowserHostBase::MaybeAllowNavigation implementation.
|
||||
// And then the following calls may occur at the same time:
|
||||
// - CefBrowserHostImpl::GetCustomWebContentsView (UIT)
|
||||
// - GetCustomWebContentsView (UIT) (alloy runtime only):
|
||||
// Creates the OSR views for windowless popups.
|
||||
// - CefBrowserHostImpl::WebContentsCreated (UIT)
|
||||
// Creates the CefBrowserHostImpl representation for the popup.
|
||||
// - WebContentsCreated (UIT):
|
||||
// Creates the CefBrowserHost representation for the popup.
|
||||
// - CefBrowserMessageFilter::OnGetNewBrowserInfo (IOT)
|
||||
// Passes information about the popup to the renderer process.
|
||||
struct PendingPopup {
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
|
||||
@@ -14,6 +14,13 @@ CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
|
||||
DCHECK(!browser_);
|
||||
}
|
||||
|
||||
content::WebContents* CefBrowserPlatformDelegate::CreateWebContents(
|
||||
CefBrowserCreateParams& create_params,
|
||||
bool& own_web_contents) {
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::CreateViewForWebContents(
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view) {
|
||||
@@ -57,7 +64,7 @@ void CefBrowserPlatformDelegate::RenderViewCreated(
|
||||
|
||||
void CefBrowserPlatformDelegate::RenderViewReady() {}
|
||||
|
||||
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) {
|
||||
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* browser) {
|
||||
// We should have an associated WebContents at this point.
|
||||
DCHECK(web_contents_);
|
||||
|
||||
@@ -83,7 +90,7 @@ void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
|
||||
|
||||
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
||||
|
||||
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) {
|
||||
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostBase* browser) {
|
||||
// WebContentsDestroyed should already be called.
|
||||
DCHECK(!web_contents_);
|
||||
|
||||
@@ -100,6 +107,11 @@ void CefBrowserPlatformDelegate::CloseHostWindow() {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegate::GetHostWindowHandle() const {
|
||||
NOTREACHED();
|
||||
return kNullWindowHandle;
|
||||
}
|
||||
|
||||
#if defined(USE_AURA)
|
||||
views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
|
||||
NOTREACHED();
|
||||
@@ -120,9 +132,49 @@ void CefBrowserPlatformDelegate::PopupWebContentsCreated(
|
||||
bool is_devtools) {}
|
||||
|
||||
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
||||
CefBrowserHostImpl* new_browser,
|
||||
CefBrowserHostBase* new_browser,
|
||||
bool is_devtools) {}
|
||||
|
||||
SkColor CefBrowserPlatformDelegate::GetBackgroundColor() const {
|
||||
NOTREACHED();
|
||||
return SkColor();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::WasResized() {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendKeyEvent(const CefKeyEvent& event) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendMouseClickEvent(
|
||||
const CefMouseEvent& event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp,
|
||||
int clickCount) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendMouseMoveEvent(const CefMouseEvent& event,
|
||||
bool mouseLeave) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendTouchEvent(const CefTouchEvent& event) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendFocusEvent(bool setFocus) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
@@ -133,6 +185,22 @@ void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {}
|
||||
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
|
||||
#endif
|
||||
|
||||
gfx::Point CefBrowserPlatformDelegate::GetScreenPoint(
|
||||
const gfx::Point& view) const {
|
||||
NOTREACHED();
|
||||
return gfx::Point();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::ViewText(const std::string& text) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegate::HandleKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
|
||||
content::WebContents* source,
|
||||
const blink::WebGestureEvent& event) {
|
||||
@@ -144,6 +212,12 @@ bool CefBrowserPlatformDelegate::IsNeverComposited(
|
||||
return false;
|
||||
}
|
||||
|
||||
CefEventHandle CefBrowserPlatformDelegate::GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const {
|
||||
NOTREACHED();
|
||||
return kNullEventHandle;
|
||||
}
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner>
|
||||
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
||||
NOTIMPLEMENTED();
|
||||
@@ -156,6 +230,19 @@ CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner> CefBrowserPlatformDelegate::CreateMenuRunner() {
|
||||
NOTIMPLEMENTED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegate::IsWindowless() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegate::IsViewsHosted() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
|
||||
NOTREACHED();
|
||||
}
|
||||
@@ -222,16 +309,16 @@ void CefBrowserPlatformDelegate::DragTargetDrop(const CefMouseEvent& event) {
|
||||
|
||||
void CefBrowserPlatformDelegate::StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
blink::DragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
const blink::mojom::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::UpdateDragCursor(
|
||||
blink::WebDragOperation operation) {
|
||||
blink::DragOperation operation) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
|
@@ -13,12 +13,18 @@
|
||||
#include "include/cef_drag_data.h"
|
||||
#include "include/internal/cef_types.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/callback_forward.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/view_type.h"
|
||||
#include "third_party/blink/public/common/page/drag_operation.h"
|
||||
#include "third_party/blink/public/mojom/page/drag.mojom-forward.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
|
||||
class GURL;
|
||||
|
||||
namespace blink {
|
||||
class WebGestureEvent;
|
||||
class WebMouseEvent;
|
||||
class WebMouseWheelEvent;
|
||||
class WebInputEvent;
|
||||
@@ -26,15 +32,29 @@ class WebTouchEvent;
|
||||
} // namespace blink
|
||||
|
||||
namespace content {
|
||||
struct AXEventNotificationDetails;
|
||||
struct AXLocationChangeNotificationDetails;
|
||||
struct DropData;
|
||||
struct NativeWebKeyboardEvent;
|
||||
class RenderViewHost;
|
||||
class RenderViewHostDelegateView;
|
||||
class RenderWidgetHostImpl;
|
||||
class WebContents;
|
||||
class WebContentsView;
|
||||
} // namespace content
|
||||
|
||||
namespace extensions {
|
||||
class Extension;
|
||||
class ExtensionHost;
|
||||
}
|
||||
} // namespace extensions
|
||||
|
||||
namespace gfx {
|
||||
class ImageSkia;
|
||||
class Point;
|
||||
class Rect;
|
||||
class Size;
|
||||
class Vector2d;
|
||||
} // namespace gfx
|
||||
|
||||
#if defined(USE_AURA)
|
||||
namespace views {
|
||||
@@ -42,6 +62,8 @@ class Widget;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct CefBrowserCreateParams;
|
||||
class CefBrowserHostBase;
|
||||
class CefFileDialogRunner;
|
||||
class CefJavaScriptDialogRunner;
|
||||
class CefMenuRunner;
|
||||
@@ -54,14 +76,14 @@ class CefBrowserPlatformDelegate {
|
||||
// Create a new CefBrowserPlatformDelegate instance. May be called on multiple
|
||||
// threads.
|
||||
static std::unique_ptr<CefBrowserPlatformDelegate> Create(
|
||||
CefBrowserHostImpl::CreateParams& create_params);
|
||||
const CefBrowserCreateParams& create_params);
|
||||
|
||||
// Called from CefBrowserHostImpl::Create.
|
||||
// Called from AlloyBrowserHostImpl::Create.
|
||||
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
|
||||
// of the resulting WebContents object.
|
||||
virtual content::WebContents* CreateWebContents(
|
||||
CefBrowserHostImpl::CreateParams& create_params,
|
||||
bool& own_web_contents) = 0;
|
||||
CefBrowserCreateParams& create_params,
|
||||
bool& own_web_contents);
|
||||
|
||||
// Called to create the view objects for a new WebContents. Will only be
|
||||
// called a single time per instance. May be called on multiple threads. Only
|
||||
@@ -103,12 +125,12 @@ class CefBrowserPlatformDelegate {
|
||||
// See WebContentsObserver documentation.
|
||||
virtual void RenderViewReady();
|
||||
|
||||
// Called after the owning CefBrowserHostImpl is created. Will only be called
|
||||
// a single time per instance. Do not send any client notifications from this
|
||||
// method.
|
||||
virtual void BrowserCreated(CefBrowserHostImpl* browser);
|
||||
// Called after the owning AlloyBrowserHostImpl is created. Will only be
|
||||
// called a single time per instance. Do not send any client notifications
|
||||
// from this method.
|
||||
virtual void BrowserCreated(CefBrowserHostBase* browser);
|
||||
|
||||
// Called from CefBrowserHostImpl::Create.
|
||||
// Called from AlloyBrowserHostImpl::Create.
|
||||
virtual void CreateExtensionHost(const extensions::Extension* extension,
|
||||
const GURL& url,
|
||||
extensions::ViewType host_type);
|
||||
@@ -124,11 +146,11 @@ class CefBrowserPlatformDelegate {
|
||||
// BrowserDestroyed().
|
||||
virtual void NotifyBrowserDestroyed();
|
||||
|
||||
// Called before the owning CefBrowserHostImpl is destroyed. Will only be
|
||||
// called a single time per instance. All references to the CefBrowserHostImpl
|
||||
// and WebContents should be cleared when this method is called. Do not send
|
||||
// any client notifications from this method.
|
||||
virtual void BrowserDestroyed(CefBrowserHostImpl* browser);
|
||||
// Called before the owning AlloyBrowserHostImpl is destroyed. Will only be
|
||||
// called a single time per instance. All references to the
|
||||
// AlloyBrowserHostImpl and WebContents should be cleared when this method is
|
||||
// called. Do not send any client notifications from this method.
|
||||
virtual void BrowserDestroyed(CefBrowserHostBase* browser);
|
||||
|
||||
// Create the window that hosts the browser. Will only be called a single time
|
||||
// per instance. Only used with windowed rendering.
|
||||
@@ -143,7 +165,7 @@ class CefBrowserPlatformDelegate {
|
||||
// rendering this will return the most immediate parent window handle. For
|
||||
// windowless rendering this will return the parent window handle specified by
|
||||
// the client, which may be NULL. May be called on multiple threads.
|
||||
virtual CefWindowHandle GetHostWindowHandle() const = 0;
|
||||
virtual CefWindowHandle GetHostWindowHandle() const;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
// Returns the Widget owner for the browser window. Only used with windowed
|
||||
@@ -156,7 +178,7 @@ class CefBrowserPlatformDelegate {
|
||||
#endif
|
||||
|
||||
// Called after the WebContents have been created for a new popup browser
|
||||
// parented to this browser but before the CefBrowserHostImpl is created for
|
||||
// parented to this browser but before the AlloyBrowserHostImpl is created for
|
||||
// the popup. |is_devtools| will be true if the popup will host DevTools. This
|
||||
// method will be called before WebContentsCreated() is called on
|
||||
// |new_platform_delegate|. Do not make the new browser visible in this
|
||||
@@ -168,13 +190,13 @@ class CefBrowserPlatformDelegate {
|
||||
CefBrowserPlatformDelegate* new_platform_delegate,
|
||||
bool is_devtools);
|
||||
|
||||
// Called after the CefBrowserHostImpl is created for a new popup browser
|
||||
// Called after the AlloyBrowserHostImpl is created for a new popup browser
|
||||
// parented to this browser. |is_devtools| will be true if the popup will host
|
||||
// DevTools. This method will be called immediately after
|
||||
// CefLifeSpanHandler::OnAfterCreated() for the popup browser. It is safe to
|
||||
// make the new browser visible in this callback (for example, add the browser
|
||||
// to a window and show it).
|
||||
virtual void PopupBrowserCreated(CefBrowserHostImpl* new_browser,
|
||||
virtual void PopupBrowserCreated(CefBrowserHostBase* new_browser,
|
||||
bool is_devtools);
|
||||
|
||||
// Returns the background color for the browser. The alpha component will be
|
||||
@@ -182,27 +204,26 @@ class CefBrowserPlatformDelegate {
|
||||
// fully opaque). SK_AlphaOPAQUE will always be returned for windowed
|
||||
// browsers. SK_ColorTRANSPARENT may be returned for windowless browsers to
|
||||
// enable transparency.
|
||||
virtual SkColor GetBackgroundColor() const = 0;
|
||||
virtual SkColor GetBackgroundColor() const;
|
||||
|
||||
// Notify the window that it was resized.
|
||||
virtual void WasResized() = 0;
|
||||
virtual void WasResized();
|
||||
|
||||
// Send input events.
|
||||
virtual void SendKeyEvent(const CefKeyEvent& event) = 0;
|
||||
virtual void SendKeyEvent(const CefKeyEvent& event);
|
||||
virtual void SendMouseClickEvent(const CefMouseEvent& event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp,
|
||||
int clickCount) = 0;
|
||||
virtual void SendMouseMoveEvent(const CefMouseEvent& event,
|
||||
bool mouseLeave) = 0;
|
||||
int clickCount);
|
||||
virtual void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave);
|
||||
virtual void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) = 0;
|
||||
virtual void SendTouchEvent(const CefTouchEvent& event) = 0;
|
||||
int deltaY);
|
||||
virtual void SendTouchEvent(const CefTouchEvent& event);
|
||||
|
||||
// Send focus event. The browser's WebContents may be NULL when this method is
|
||||
// called.
|
||||
virtual void SendFocusEvent(bool setFocus) = 0;
|
||||
virtual void SendFocusEvent(bool setFocus);
|
||||
|
||||
// Send capture lost event.
|
||||
virtual void SendCaptureLostEvent();
|
||||
@@ -219,15 +240,15 @@ class CefBrowserPlatformDelegate {
|
||||
|
||||
// Convert from view coordinates to screen coordinates. Potential display
|
||||
// scaling will be applied to the result.
|
||||
virtual gfx::Point GetScreenPoint(const gfx::Point& view) const = 0;
|
||||
virtual gfx::Point GetScreenPoint(const gfx::Point& view) const;
|
||||
|
||||
// Open the specified text in the default text editor.
|
||||
virtual void ViewText(const std::string& text) = 0;
|
||||
virtual void ViewText(const std::string& text);
|
||||
|
||||
// Forward the keyboard event to the application or frame window to allow
|
||||
// processing of shortcut keys.
|
||||
virtual bool HandleKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) = 0;
|
||||
const content::NativeWebKeyboardEvent& event);
|
||||
|
||||
// See WebContentsDelegate documentation.
|
||||
virtual bool PreHandleGestureEvent(content::WebContents* source,
|
||||
@@ -241,7 +262,7 @@ class CefBrowserPlatformDelegate {
|
||||
|
||||
// Returns the OS event handle, if any, associated with |event|.
|
||||
virtual CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const = 0;
|
||||
const content::NativeWebKeyboardEvent& event) const;
|
||||
|
||||
// Create the platform-specific file dialog runner.
|
||||
virtual std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner();
|
||||
@@ -251,15 +272,15 @@ class CefBrowserPlatformDelegate {
|
||||
CreateJavaScriptDialogRunner();
|
||||
|
||||
// Create the platform-specific menu runner.
|
||||
virtual std::unique_ptr<CefMenuRunner> CreateMenuRunner() = 0;
|
||||
virtual std::unique_ptr<CefMenuRunner> CreateMenuRunner();
|
||||
|
||||
// Returns true if this delegate implements windowless rendering. May be
|
||||
// called on multiple threads.
|
||||
virtual bool IsWindowless() const = 0;
|
||||
virtual bool IsWindowless() const;
|
||||
|
||||
// Returns true if this delegate implements views-hosted browser handling. May
|
||||
// be called on multiple threads.
|
||||
virtual bool IsViewsHosted() const = 0;
|
||||
virtual bool IsViewsHosted() const;
|
||||
|
||||
// Notify the browser that it was hidden. Only used with windowless rendering.
|
||||
virtual void WasHidden(bool hidden);
|
||||
@@ -299,13 +320,14 @@ class CefBrowserPlatformDelegate {
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
virtual void DragTargetDragLeave();
|
||||
virtual void DragTargetDrop(const CefMouseEvent& event);
|
||||
virtual void StartDragging(const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
virtual void UpdateDragCursor(blink::WebDragOperation operation);
|
||||
virtual void StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::DragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const blink::mojom::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
virtual void UpdateDragCursor(blink::DragOperation operation);
|
||||
virtual void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op);
|
||||
virtual void DragSourceSystemDragEnded();
|
||||
virtual void AccessibilityEventReceived(
|
||||
@@ -343,7 +365,7 @@ class CefBrowserPlatformDelegate {
|
||||
|
||||
// Not owned by this object.
|
||||
content::WebContents* web_contents_ = nullptr;
|
||||
CefBrowserHostImpl* browser_ = nullptr;
|
||||
CefBrowserHostBase* browser_ = nullptr;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate);
|
||||
};
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
|
||||
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
@@ -69,7 +70,7 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
|
||||
|
||||
// static
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
CefBrowserHostImpl::CreateParams& create_params) {
|
||||
const CefBrowserCreateParams& create_params) {
|
||||
const bool is_windowless =
|
||||
create_params.window_info &&
|
||||
create_params.window_info->windowless_rendering_enabled &&
|
||||
@@ -78,7 +79,11 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
|
||||
|
||||
if (cef::IsChromeRuntimeEnabled()) {
|
||||
return std::make_unique<CefBrowserPlatformDelegateChrome>(background_color);
|
||||
// CefWindowInfo is not used in this case.
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||
CreateNativeDelegate(CefWindowInfo(), background_color);
|
||||
return std::make_unique<CefBrowserPlatformDelegateChrome>(
|
||||
std::move(native_delegate));
|
||||
}
|
||||
|
||||
if (create_params.window_info) {
|
||||
|
48
libcef/browser/chrome/browser_delegate.h
Normal file
48
libcef/browser/chrome/browser_delegate.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2020 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_CHROME_BROWSER_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_DELEGATE_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
|
||||
class Browser;
|
||||
|
||||
namespace cef {
|
||||
|
||||
// Delegate for the chrome Browser object. Lifespan is controlled by the Browser
|
||||
// object. See the ChromeBrowserDelegate documentation for additional details.
|
||||
// Only accessed on the UI thread.
|
||||
class BrowserDelegate : public content::WebContentsDelegate {
|
||||
public:
|
||||
// Opaque ref-counted base class for CEF-specific parameters passed via
|
||||
// Browser::CreateParams::cef_params and possibly shared by multiple Browser
|
||||
// instances.
|
||||
class CreateParams : public base::RefCounted<CreateParams> {
|
||||
public:
|
||||
virtual ~CreateParams() {}
|
||||
};
|
||||
|
||||
// Called from the Browser constructor to create a new delegate.
|
||||
static std::unique_ptr<BrowserDelegate> Create(
|
||||
Browser* browser,
|
||||
scoped_refptr<CreateParams> cef_params);
|
||||
|
||||
~BrowserDelegate() override {}
|
||||
|
||||
// Called immediately after |new_contents| is created.
|
||||
virtual void OnWebContentsCreated(content::WebContents* new_contents) = 0;
|
||||
|
||||
// Add or remove ownership of the WebContents.
|
||||
virtual void SetAsDelegate(content::WebContents* web_contents,
|
||||
bool set_delegate) = 0;
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_DELEGATE_H_
|
@@ -4,135 +4,98 @@
|
||||
|
||||
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
#include "chrome/browser/ui/browser_window.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefBrowserPlatformDelegateChrome::CefBrowserPlatformDelegateChrome(
|
||||
SkColor background_color)
|
||||
: background_color_(background_color) {}
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
|
||||
: native_delegate_(std::move(native_delegate)) {
|
||||
native_delegate_->set_windowless_handler(this);
|
||||
}
|
||||
|
||||
content::WebContents* CefBrowserPlatformDelegateChrome::CreateWebContents(
|
||||
CefBrowserHostImpl::CreateParams& create_params,
|
||||
bool& own_web_contents) {
|
||||
// Get or create the request context and profile.
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||
create_params.request_context);
|
||||
CHECK(request_context_impl);
|
||||
auto cef_browser_context = request_context_impl->GetBrowserContext();
|
||||
CHECK(cef_browser_context);
|
||||
auto profile = cef_browser_context->AsProfile();
|
||||
|
||||
if (!create_params.request_context) {
|
||||
// Using the global request context.
|
||||
create_params.request_context = request_context_impl.get();
|
||||
}
|
||||
|
||||
// Create a Browser.
|
||||
Browser::CreateParams params =
|
||||
Browser::CreateParams(profile, /*user_gesture=*/false);
|
||||
chrome_browser_ = new Browser(params);
|
||||
|
||||
chrome::AddTabAt(chrome_browser_, create_params.url, /*idx=*/-1,
|
||||
/*foreground=*/true);
|
||||
|
||||
auto web_contents =
|
||||
chrome_browser_->tab_strip_model()->GetActiveWebContents();
|
||||
CHECK(web_contents);
|
||||
|
||||
own_web_contents = false;
|
||||
return web_contents;
|
||||
void CefBrowserPlatformDelegateChrome::WebContentsCreated(
|
||||
content::WebContents* web_contents,
|
||||
bool owned) {
|
||||
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
|
||||
native_delegate_->WebContentsCreated(web_contents, /*owned=*/false);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::WebContentsDestroyed(
|
||||
content::WebContents* web_contents) {
|
||||
CefBrowserPlatformDelegate::WebContentsDestroyed(web_contents);
|
||||
native_delegate_->WebContentsDestroyed(web_contents);
|
||||
}
|
||||
|
||||
// TODO(chrome-runtime): Find a better way to be notified of Browser
|
||||
// destruction.
|
||||
browser_->WindowDestroyed();
|
||||
void CefBrowserPlatformDelegateChrome::BrowserCreated(
|
||||
CefBrowserHostBase* browser) {
|
||||
CefBrowserPlatformDelegate::BrowserCreated(browser);
|
||||
native_delegate_->BrowserCreated(browser);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
CefBrowserHostBase* browser) {
|
||||
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
|
||||
|
||||
// Release the reference added in CreateHostWindow.
|
||||
browser->Release();
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateChrome::CreateHostWindow() {
|
||||
// Keep a reference to the CEF browser.
|
||||
browser_->AddRef();
|
||||
|
||||
chrome_browser_->window()->Show();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::CloseHostWindow() {}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateChrome::GetHostWindowHandle() const {
|
||||
return kNullWindowHandle;
|
||||
native_delegate_->BrowserDestroyed(browser);
|
||||
}
|
||||
|
||||
SkColor CefBrowserPlatformDelegateChrome::GetBackgroundColor() const {
|
||||
return background_color_;
|
||||
return native_delegate_->GetBackgroundColor();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::WasResized() {}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::SendKeyEvent(const CefKeyEvent& event) {}
|
||||
void CefBrowserPlatformDelegateChrome::SendKeyEvent(const CefKeyEvent& event) {
|
||||
native_delegate_->SendKeyEvent(event);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::SendMouseClickEvent(
|
||||
const CefMouseEvent& event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp,
|
||||
int clickCount) {}
|
||||
int clickCount) {
|
||||
native_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::SendMouseMoveEvent(
|
||||
const CefMouseEvent& event,
|
||||
bool mouseLeave) {}
|
||||
bool mouseLeave) {
|
||||
native_delegate_->SendMouseMoveEvent(event, mouseLeave);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::SendMouseWheelEvent(
|
||||
const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) {}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::SendTouchEvent(
|
||||
const CefTouchEvent& event) {}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::SendFocusEvent(bool setFocus) {}
|
||||
int deltaY) {
|
||||
native_delegate_->SendMouseWheelEvent(event, deltaX, deltaY);
|
||||
}
|
||||
|
||||
gfx::Point CefBrowserPlatformDelegateChrome::GetScreenPoint(
|
||||
const gfx::Point& view) const {
|
||||
return view;
|
||||
auto screen = display::Screen::GetScreen();
|
||||
|
||||
gfx::NativeWindow native_window =
|
||||
chrome_browser_ ? chrome_browser_->window()->GetNativeWindow() : nullptr;
|
||||
|
||||
// Returns screen pixel coordinates.
|
||||
auto screen_rect = screen->DIPToScreenRectInWindow(
|
||||
native_window, gfx::Rect(view, gfx::Size(0, 0)));
|
||||
return screen_rect.origin();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateChrome::ViewText(const std::string& text) {}
|
||||
|
||||
bool CefBrowserPlatformDelegateChrome::HandleKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
return false;
|
||||
void CefBrowserPlatformDelegateChrome::ViewText(const std::string& text) {
|
||||
native_delegate_->ViewText(text);
|
||||
}
|
||||
|
||||
CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const {
|
||||
return kNullEventHandle;
|
||||
CefWindowHandle CefBrowserPlatformDelegateChrome::GetParentWindowHandle()
|
||||
const {
|
||||
return GetHostWindowHandle();
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateChrome::CreateMenuRunner() {
|
||||
NOTIMPLEMENTED();
|
||||
return nullptr;
|
||||
gfx::Point CefBrowserPlatformDelegateChrome::GetParentScreenPoint(
|
||||
const gfx::Point& view) const {
|
||||
return GetScreenPoint(view);
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateChrome::IsWindowless() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateChrome::IsViewsHosted() const {
|
||||
return false;
|
||||
void CefBrowserPlatformDelegateChrome::set_chrome_browser(Browser* browser) {
|
||||
chrome_browser_ = browser;
|
||||
}
|
||||
|
@@ -6,25 +6,25 @@
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
|
||||
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/native/browser_platform_delegate_native.h"
|
||||
|
||||
class Browser;
|
||||
|
||||
// Implementation of Chrome-based browser functionality.
|
||||
class CefBrowserPlatformDelegateChrome : public CefBrowserPlatformDelegate {
|
||||
class CefBrowserPlatformDelegateChrome
|
||||
: public CefBrowserPlatformDelegate,
|
||||
public CefBrowserPlatformDelegateNative::WindowlessHandler {
|
||||
public:
|
||||
explicit CefBrowserPlatformDelegateChrome(SkColor background_color);
|
||||
explicit CefBrowserPlatformDelegateChrome(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate);
|
||||
|
||||
// CefBrowserPlatformDelegate overrides.
|
||||
content::WebContents* CreateWebContents(
|
||||
CefBrowserHostImpl::CreateParams& create_params,
|
||||
bool& own_web_contents) override;
|
||||
void WebContentsCreated(content::WebContents* web_contents,
|
||||
bool owned) override;
|
||||
void WebContentsDestroyed(content::WebContents* web_contents) override;
|
||||
void BrowserDestroyed(CefBrowserHostImpl* browser) override;
|
||||
bool CreateHostWindow() override;
|
||||
void CloseHostWindow() override;
|
||||
CefWindowHandle GetHostWindowHandle() const override;
|
||||
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||
SkColor GetBackgroundColor() const override;
|
||||
void WasResized() override;
|
||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||
void SendMouseClickEvent(const CefMouseEvent& event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
@@ -34,22 +34,19 @@ class CefBrowserPlatformDelegateChrome : public CefBrowserPlatformDelegate {
|
||||
void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX,
|
||||
int deltaY) override;
|
||||
void SendTouchEvent(const CefTouchEvent& event) override;
|
||||
void SendFocusEvent(bool setFocus) override;
|
||||
gfx::Point GetScreenPoint(const gfx::Point& view) const override;
|
||||
void ViewText(const std::string& text) override;
|
||||
bool HandleKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||
bool IsWindowless() const override;
|
||||
bool IsViewsHosted() const override;
|
||||
|
||||
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
||||
CefWindowHandle GetParentWindowHandle() const override;
|
||||
gfx::Point GetParentScreenPoint(const gfx::Point& view) const override;
|
||||
|
||||
void set_chrome_browser(Browser* browser);
|
||||
|
||||
private:
|
||||
const SkColor background_color_;
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
|
||||
|
||||
Browser* chrome_browser_;
|
||||
Browser* chrome_browser_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
|
||||
|
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "libcef/browser/chrome/chrome_browser_context.h"
|
||||
|
||||
#include "libcef/browser/prefs/browser_prefs.h"
|
||||
|
||||
#include "chrome/browser/profiles/profile_manager.h"
|
||||
|
||||
ChromeBrowserContext::ChromeBrowserContext(
|
||||
@@ -28,6 +30,8 @@ void ChromeBrowserContext::Initialize() {
|
||||
// The global ProfileManager instance can be retrieved via
|
||||
// |g_browser_process->profile_manager()|.
|
||||
profile_ = ProfileManager::GetLastUsedProfileAllowedByPolicy();
|
||||
|
||||
browser_prefs::SetLanguagePrefs(profile_);
|
||||
}
|
||||
|
||||
void ChromeBrowserContext::Shutdown() {
|
||||
|
260
libcef/browser/chrome/chrome_browser_delegate.cc
Normal file
260
libcef/browser/chrome/chrome_browser_delegate.cc
Normal file
@@ -0,0 +1,260 @@
|
||||
// Copyright 2020 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 <memory>
|
||||
|
||||
#include "libcef/browser/chrome/chrome_browser_delegate.h"
|
||||
|
||||
#include "libcef/browser/browser_contents_delegate.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
|
||||
using content::KeyboardEventProcessingResult;
|
||||
|
||||
ChromeBrowserDelegate::ChromeBrowserDelegate(
|
||||
Browser* browser,
|
||||
const CefBrowserCreateParams& create_params)
|
||||
: browser_(browser), create_params_(create_params) {
|
||||
DCHECK(browser_);
|
||||
}
|
||||
|
||||
ChromeBrowserDelegate::~ChromeBrowserDelegate() = default;
|
||||
|
||||
void ChromeBrowserDelegate::OnWebContentsCreated(
|
||||
content::WebContents* new_contents) {
|
||||
// Necessary to receive LoadingStateChanged calls during initial navigation.
|
||||
// This will be called again in Browser::SetAsDelegate, which should be fine.
|
||||
new_contents->SetDelegate(browser_);
|
||||
|
||||
SetAsDelegate(new_contents, /*set_delegate=*/true);
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
|
||||
bool set_delegate) {
|
||||
DCHECK(web_contents);
|
||||
auto browser_host =
|
||||
ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
|
||||
// |set_delegate=false| only makes sense if we already have a browser host.
|
||||
DCHECK(browser_host || set_delegate);
|
||||
|
||||
if (browser_host) {
|
||||
// We already have a browser host, so just change the associated Browser.
|
||||
browser_host->SetBrowser(set_delegate ? browser_ : nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
auto platform_delegate = CefBrowserPlatformDelegate::Create(create_params_);
|
||||
CHECK(platform_delegate);
|
||||
|
||||
auto browser_info = CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
||||
/*is_popup=*/false, /*is_windowless=*/false, create_params_.extra_info);
|
||||
|
||||
auto request_context_impl =
|
||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||
create_params_.request_context);
|
||||
|
||||
CreateBrowser(web_contents, create_params_.settings, create_params_.client,
|
||||
std::move(platform_delegate), browser_info,
|
||||
request_context_impl);
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) {
|
||||
CefBrowserSettings settings;
|
||||
CefRefPtr<CefClient> client;
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
|
||||
CefRefPtr<CefDictionaryValue> extra_info;
|
||||
|
||||
CefBrowserInfoManager::GetInstance()->WebContentsCreated(
|
||||
target_url, opener_render_process_id, opener_render_frame_id, settings,
|
||||
client, platform_delegate, extra_info);
|
||||
|
||||
auto opener = ChromeBrowserHostImpl::GetBrowserForContents(source_contents);
|
||||
if (!opener) {
|
||||
LOG(ERROR) << "No opener found for chrome popup browser";
|
||||
return;
|
||||
}
|
||||
|
||||
auto browser_info =
|
||||
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
|
||||
new_contents, /*is_windowless=*/false, extra_info);
|
||||
CHECK(browser_info->is_popup());
|
||||
|
||||
// Popups must share the same RequestContext as the parent.
|
||||
auto request_context_impl = opener->request_context();
|
||||
CHECK(request_context_impl);
|
||||
|
||||
// We don't officially own |new_contents| until AddNewContents() is called.
|
||||
// However, we need to install observers/delegates here.
|
||||
CreateBrowser(new_contents, settings, client, std::move(platform_delegate),
|
||||
browser_info, request_context_impl);
|
||||
}
|
||||
|
||||
content::WebContents* ChromeBrowserDelegate::OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
// Return nullptr to cancel the navigation. Otherwise, proceed with default
|
||||
// chrome handling.
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
return delegate->OpenURLFromTab(source, params);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::LoadingStateChanged(content::WebContents* source,
|
||||
bool to_different_document) {
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
delegate->LoadingStateChanged(source, to_different_document);
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::UpdateTargetURL(content::WebContents* source,
|
||||
const GURL& url) {
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
delegate->UpdateTargetURL(source, url);
|
||||
}
|
||||
}
|
||||
|
||||
bool ChromeBrowserDelegate::DidAddMessageToConsole(
|
||||
content::WebContents* source,
|
||||
blink::mojom::ConsoleMessageLevel log_level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) {
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
return delegate->DidAddMessageToConsole(source, log_level, message, line_no,
|
||||
source_id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::DidNavigateMainFramePostCommit(
|
||||
content::WebContents* web_contents) {
|
||||
if (auto delegate = GetDelegateForWebContents(web_contents)) {
|
||||
delegate->DidNavigateMainFramePostCommit(web_contents);
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::EnterFullscreenModeForTab(
|
||||
content::RenderFrameHost* requesting_frame,
|
||||
const blink::mojom::FullscreenOptions& options) {
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(requesting_frame);
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
if (auto delegate = GetDelegateForWebContents(web_contents)) {
|
||||
delegate->EnterFullscreenModeForTab(requesting_frame, options);
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::ExitFullscreenModeForTab(
|
||||
content::WebContents* web_contents) {
|
||||
if (auto delegate = GetDelegateForWebContents(web_contents)) {
|
||||
delegate->ExitFullscreenModeForTab(web_contents);
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardEventProcessingResult ChromeBrowserDelegate::PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
return delegate->PreHandleKeyboardEvent(source, event);
|
||||
}
|
||||
return KeyboardEventProcessingResult::NOT_HANDLED;
|
||||
}
|
||||
|
||||
bool ChromeBrowserDelegate::HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||
return delegate->HandleKeyboardEvent(source, event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::CreateBrowser(
|
||||
content::WebContents* web_contents,
|
||||
CefBrowserSettings settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(web_contents);
|
||||
DCHECK(platform_delegate);
|
||||
DCHECK(browser_info);
|
||||
DCHECK(request_context_impl);
|
||||
|
||||
if (!client) {
|
||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||
if (auto bph = app->GetBrowserProcessHandler()) {
|
||||
client = bph->GetDefaultClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!client) {
|
||||
LOG(WARNING) << "Creating a chrome browser without a client";
|
||||
}
|
||||
|
||||
// Check if chrome and CEF are using the same browser context.
|
||||
// TODO(chrome-runtime): Verify if/when this might occur.
|
||||
auto chrome_browser_context =
|
||||
CefBrowserContext::FromBrowserContext(browser_->create_params().profile);
|
||||
if (chrome_browser_context != request_context_impl->GetBrowserContext()) {
|
||||
LOG(WARNING) << "Creating a chrome browser with mismatched context";
|
||||
}
|
||||
|
||||
// Remains alive until the associated WebContents is destroyed.
|
||||
CefRefPtr<ChromeBrowserHostImpl> browser_host =
|
||||
new ChromeBrowserHostImpl(settings, client, std::move(platform_delegate),
|
||||
browser_info, request_context_impl);
|
||||
browser_host->Attach(browser_, web_contents);
|
||||
}
|
||||
|
||||
CefBrowserContentsDelegate* ChromeBrowserDelegate::GetDelegateForWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
auto browser_host =
|
||||
ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (browser_host)
|
||||
return browser_host->contents_delegate();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
namespace cef {
|
||||
|
||||
// static
|
||||
std::unique_ptr<BrowserDelegate> BrowserDelegate::Create(
|
||||
Browser* browser,
|
||||
scoped_refptr<CreateParams> cef_params) {
|
||||
CefBrowserCreateParams create_params;
|
||||
|
||||
// Parameters from ChromeBrowserHostImpl::Create, or nullptr if the Browser
|
||||
// was created from somewhere else.
|
||||
auto params = static_cast<ChromeBrowserHostImpl::DelegateCreateParams*>(
|
||||
cef_params.get());
|
||||
if (params) {
|
||||
create_params = params->create_params_;
|
||||
}
|
||||
|
||||
return std::make_unique<ChromeBrowserDelegate>(browser, create_params);
|
||||
}
|
||||
|
||||
} // namespace cef
|
104
libcef/browser/chrome/chrome_browser_delegate.h
Normal file
104
libcef/browser/chrome/chrome_browser_delegate.h
Normal file
@@ -0,0 +1,104 @@
|
||||
// Copyright 2020 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_CHROME_CHROME_BROWSER_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_DELEGATE_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/chrome/browser_delegate.h"
|
||||
|
||||
#include "base/optional.h"
|
||||
|
||||
class CefBrowserContentsDelegate;
|
||||
class CefRequestContextImpl;
|
||||
class ChromeBrowserHostImpl;
|
||||
|
||||
// Implementation of the cef::BrowserDelegate interface. Lifespan is controlled
|
||||
// by the Browser object. Only accessed on the UI thread.
|
||||
//
|
||||
// The Browser object represents the top-level Chrome browser window. One or
|
||||
// more tabs (WebContents) are then owned by the Browser object via
|
||||
// TabStripModel. A new Browser object can be created programmatically using
|
||||
// "new Browser" or Browser::Create, or as a result of user action such as
|
||||
// dragging a tab out of an existing window. New or existing tabs can also be
|
||||
// added to an already existing Browser object.
|
||||
//
|
||||
// The Browser object acts as the WebContentsDelegate for all attached tabs. CEF
|
||||
// integration requires WebContentsDelegate callbacks and notification of tab
|
||||
// attach/detach. To support this integration a cef::BrowserDelegate
|
||||
// (ChromeBrowserDelegate) member is created in the Browser constructor and
|
||||
// receives delegation for the Browser callbacks. ChromeBrowserDelegate creates
|
||||
// a new ChromeBrowserHostImpl when a tab is added to a Browser for the first
|
||||
// time, and that ChromeBrowserHostImpl continues to exist until the tab's
|
||||
// WebContents is destroyed. The associated WebContents object does not change,
|
||||
// but the Browser object will change when the tab is dragged between windows.
|
||||
class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
public:
|
||||
ChromeBrowserDelegate(Browser* browser,
|
||||
const CefBrowserCreateParams& create_params);
|
||||
~ChromeBrowserDelegate() override;
|
||||
|
||||
// cef::BrowserDelegate methods:
|
||||
void OnWebContentsCreated(content::WebContents* new_contents) override;
|
||||
void SetAsDelegate(content::WebContents* web_contents,
|
||||
bool set_delegate) override;
|
||||
|
||||
// WebContentsDelegate methods:
|
||||
void WebContentsCreated(content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents) override;
|
||||
content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool to_different_document) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
blink::mojom::ConsoleMessageLevel log_level,
|
||||
const base::string16& message,
|
||||
int32_t line_no,
|
||||
const base::string16& source_id) override;
|
||||
void DidNavigateMainFramePostCommit(
|
||||
content::WebContents* web_contents) override;
|
||||
void EnterFullscreenModeForTab(
|
||||
content::RenderFrameHost* requesting_frame,
|
||||
const blink::mojom::FullscreenOptions& options) override;
|
||||
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
|
||||
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
bool HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
|
||||
Browser* browser() const { return browser_; }
|
||||
|
||||
private:
|
||||
void CreateBrowser(
|
||||
content::WebContents* web_contents,
|
||||
CefBrowserSettings settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl);
|
||||
|
||||
CefBrowserContentsDelegate* GetDelegateForWebContents(
|
||||
content::WebContents* web_contents);
|
||||
|
||||
Browser* const browser_;
|
||||
|
||||
// Used when creating a new browser host.
|
||||
const CefBrowserCreateParams create_params_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserDelegate);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_DELEGATE_H_
|
502
libcef/browser/chrome/chrome_browser_host_impl.cc
Normal file
502
libcef/browser/chrome/chrome_browser_host_impl.cc
Normal file
@@ -0,0 +1,502 @@
|
||||
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
||||
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/notreached.h"
|
||||
#include "chrome/browser/printing/print_view_manager_common.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_commands.h"
|
||||
#include "chrome/browser/ui/browser_navigator.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
#include "chrome/browser/ui/browser_window.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
|
||||
const CefBrowserCreateParams& params) {
|
||||
// Get or create the request context and profile.
|
||||
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||
params.request_context);
|
||||
CHECK(request_context_impl);
|
||||
auto cef_browser_context = request_context_impl->GetBrowserContext();
|
||||
CHECK(cef_browser_context);
|
||||
auto profile = cef_browser_context->AsProfile();
|
||||
|
||||
Browser::CreateParams chrome_params =
|
||||
Browser::CreateParams(profile, /*user_gesture=*/false);
|
||||
|
||||
// Pass |params| to cef::BrowserDelegate::Create from the Browser constructor.
|
||||
chrome_params.cef_params = base::MakeRefCounted<DelegateCreateParams>(params);
|
||||
|
||||
// Create the Browser. This will indirectly create the ChomeBrowserDelegate.
|
||||
// The same params will be used to create a new Browser if the tab is dragged
|
||||
// out of the existing Browser.
|
||||
auto browser = new Browser(chrome_params);
|
||||
|
||||
GURL url = params.url;
|
||||
if (url.is_empty()) {
|
||||
// Chrome will navigate to kChromeUINewTabURL by default. We want to keep
|
||||
// the current CEF behavior of not navigating at all. Use a special URL that
|
||||
// will be recognized in HandleNonNavigationAboutURL.
|
||||
url = GURL("chrome://ignore/");
|
||||
}
|
||||
|
||||
// Add a new tab. This will indirectly create a new tab WebContents and
|
||||
// call ChromeBrowserDelegate::OnWebContentsCreated to create the associated
|
||||
// ChromeBrowserHostImpl.
|
||||
chrome::AddTabAt(browser, url, /*idx=*/-1, /*foreground=*/true);
|
||||
|
||||
// The new tab WebContents.
|
||||
auto web_contents = browser->tab_strip_model()->GetActiveWebContents();
|
||||
CHECK(web_contents);
|
||||
|
||||
// The associated ChromeBrowserHostImpl.
|
||||
auto browser_host =
|
||||
ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
CHECK(browser_host);
|
||||
|
||||
browser->window()->Show();
|
||||
|
||||
return browser_host;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderViewHost* host) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForHost(
|
||||
const content::RenderFrameHost* host) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForHost(host);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForContents(
|
||||
const content::WebContents* contents) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(contents);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl>
|
||||
ChromeBrowserHostImpl::GetBrowserForFrameTreeNode(int frame_tree_node_id) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser =
|
||||
CefBrowserHostBase::GetBrowserForFrameTreeNode(frame_tree_node_id);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
auto browser = CefBrowserHostBase::GetBrowserForFrameRoute(render_process_id,
|
||||
render_routing_id);
|
||||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
}
|
||||
|
||||
ChromeBrowserHostImpl::~ChromeBrowserHostImpl() = default;
|
||||
|
||||
void ChromeBrowserHostImpl::OnWebContentsDestroyed(
|
||||
content::WebContents* web_contents) {
|
||||
platform_delegate_->WebContentsDestroyed(web_contents);
|
||||
DestroyBrowser();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&ChromeBrowserHostImpl::OnSetFocus,
|
||||
this, source));
|
||||
return;
|
||||
}
|
||||
|
||||
if (contents_delegate_->OnSetFocus(source))
|
||||
return;
|
||||
|
||||
if (browser_) {
|
||||
const int tab_index = GetCurrentTabIndex();
|
||||
if (tab_index != TabStripModel::kNoTab) {
|
||||
chrome::SelectNumberedTab(browser_, tab_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::CloseBrowser(bool force_close) {
|
||||
// Always do this asynchronously because TabStripModel is not re-entrant.
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&ChromeBrowserHostImpl::DoCloseBrowser,
|
||||
this, force_close));
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::TryCloseBrowser() {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetFocus(bool focus) {
|
||||
if (focus) {
|
||||
OnSetFocus(FOCUS_SOURCE_SYSTEM);
|
||||
}
|
||||
}
|
||||
|
||||
CefWindowHandle ChromeBrowserHostImpl::GetWindowHandle() {
|
||||
NOTIMPLEMENTED();
|
||||
return kNullWindowHandle;
|
||||
}
|
||||
|
||||
CefWindowHandle ChromeBrowserHostImpl::GetOpenerWindowHandle() {
|
||||
NOTIMPLEMENTED();
|
||||
return kNullWindowHandle;
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::HasView() {
|
||||
// TODO(chrome-runtime): Support Views-hosted browsers.
|
||||
return false;
|
||||
}
|
||||
|
||||
double ChromeBrowserHostImpl::GetZoomLevel() {
|
||||
NOTIMPLEMENTED();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetZoomLevel(double zoomLevel) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::RunFileDialog(
|
||||
FileDialogMode mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) {
|
||||
NOTIMPLEMENTED();
|
||||
callback->OnFileDialogDismissed(0, {});
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::Print() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&ChromeBrowserHostImpl::Print, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_) {
|
||||
// Like chrome::Print() but specifying the WebContents.
|
||||
printing::StartPrint(GetWebContents(),
|
||||
/*print_renderer=*/mojo::NullAssociatedRemote(),
|
||||
browser_->profile()->GetPrefs()->GetBoolean(
|
||||
prefs::kPrintPreviewDisabled),
|
||||
/*has_selection=*/false);
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::PrintToPDF(
|
||||
const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
NOTIMPLEMENTED();
|
||||
callback->OnPdfPrintFinished(CefString(), false);
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::Find(int identifier,
|
||||
const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
bool findNext) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::StopFinding(bool clearSelection) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::ShowDevTools(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings,
|
||||
const CefPoint& inspect_element_at) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::CloseDevTools() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::HasDevTools() {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::SendDevToolsMessage(const void* message,
|
||||
size_t message_size) {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
int ChromeBrowserHostImpl::ExecuteDevToolsMethod(
|
||||
int message_id,
|
||||
const CefString& method,
|
||||
CefRefPtr<CefDictionaryValue> params) {
|
||||
NOTIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRegistration> ChromeBrowserHostImpl::AddDevToolsMessageObserver(
|
||||
CefRefPtr<CefDevToolsMessageObserver> observer) {
|
||||
NOTIMPLEMENTED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::IsWindowRenderingDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::WasResized() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::WasHidden(bool hidden) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::NotifyScreenInfoChanged() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::Invalidate(PaintElementType type) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SendExternalBeginFrame() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SendFocusEvent(bool setFocus) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SendCaptureLostEvent() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::NotifyMoveOrResizeStarted() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
int ChromeBrowserHostImpl::GetWindowlessFrameRate() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {}
|
||||
|
||||
void ChromeBrowserHostImpl::ImeSetComposition(
|
||||
const CefString& text,
|
||||
const std::vector<CefCompositionUnderline>& underlines,
|
||||
const CefRange& replacement_range,
|
||||
const CefRange& selection_range) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::ImeCommitText(const CefString& text,
|
||||
const CefRange& replacement_range,
|
||||
int relative_cursor_pos) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void ChromeBrowserHostImpl::ImeFinishComposingText(bool keep_selection) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::ImeCancelComposition() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DragTargetDragEnter(
|
||||
CefRefPtr<CefDragData> drag_data,
|
||||
const CefMouseEvent& event,
|
||||
DragOperationsMask allowed_ops) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DragTargetDragOver(const CefMouseEvent& event,
|
||||
DragOperationsMask allowed_ops) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DragTargetDragLeave() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DragTargetDrop(const CefMouseEvent& event) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DragSourceSystemDragEnded() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DragSourceEndedAt(int x,
|
||||
int y,
|
||||
DragOperationsMask op) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetAudioMuted(bool mute) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::IsAudioMuted() {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetAccessibilityState(
|
||||
cef_state_t accessibility_state) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
|
||||
const CefSize& min_size,
|
||||
const CefSize& max_size) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
CefRefPtr<CefExtension> ChromeBrowserHostImpl::GetExtension() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::IsBackgroundHost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChromeBrowserHostImpl::Navigate(const content::OpenURLParams& params) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (GetCurrentTabIndex() == TabStripModel::kNoTab) {
|
||||
// We can't navigate via the Browser because we don't have a current tab.
|
||||
return CefBrowserHostBase::Navigate(params);
|
||||
}
|
||||
|
||||
if (browser_) {
|
||||
// This is generally equivalent to calling Browser::OpenURL, except:
|
||||
// 1. It doesn't trigger a call to CefRequestHandler::OnOpenURLFromTab, and
|
||||
// 2. It navigates in this CefBrowserHost's WebContents instead of
|
||||
// (a) creating a new WebContents, or (b) using the Browser's active
|
||||
// WebContents (which may not be the same), and
|
||||
// 3. There is no risk of triggering chrome's popup blocker.
|
||||
NavigateParams nav_params(browser_, params.url, params.transition);
|
||||
nav_params.FillNavigateParamsFromOpenURLParams(params);
|
||||
|
||||
// Always navigate in the current tab.
|
||||
nav_params.disposition = WindowOpenDisposition::CURRENT_TAB;
|
||||
nav_params.source_contents = GetWebContents();
|
||||
|
||||
nav_params.tabstrip_add_types = TabStripModel::ADD_NONE;
|
||||
if (params.user_gesture)
|
||||
nav_params.window_action = NavigateParams::SHOW_WINDOW;
|
||||
::Navigate(&nav_params);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ChromeBrowserHostImpl::ChromeBrowserHostImpl(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefRequestContextImpl> request_context)
|
||||
: CefBrowserHostBase(settings,
|
||||
client,
|
||||
std::move(platform_delegate),
|
||||
browser_info,
|
||||
request_context) {}
|
||||
|
||||
void ChromeBrowserHostImpl::Attach(Browser* browser,
|
||||
content::WebContents* web_contents) {
|
||||
DCHECK(browser);
|
||||
DCHECK(web_contents);
|
||||
|
||||
platform_delegate_->WebContentsCreated(web_contents,
|
||||
/*own_web_contents=*/false);
|
||||
|
||||
SetBrowser(browser);
|
||||
contents_delegate_->ObserveWebContents(web_contents);
|
||||
InitializeBrowser();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::SetBrowser(Browser* browser) {
|
||||
CEF_REQUIRE_UIT();
|
||||
browser_ = browser;
|
||||
static_cast<CefBrowserPlatformDelegateChrome*>(platform_delegate_.get())
|
||||
->set_chrome_browser(browser);
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::InitializeBrowser() {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(browser_);
|
||||
|
||||
// Associate the platform delegate with this browser.
|
||||
platform_delegate_->BrowserCreated(this);
|
||||
|
||||
CefBrowserHostBase::InitializeBrowser();
|
||||
|
||||
// The WebContents won't be added to the Browser's TabStripModel until later
|
||||
// in the current call stack. Block navigation until that time.
|
||||
auto navigation_lock = browser_info_->CreateNavigationLock();
|
||||
OnAfterCreated();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DestroyBrowser() {
|
||||
CEF_REQUIRE_UIT();
|
||||
browser_ = nullptr;
|
||||
|
||||
OnBeforeClose();
|
||||
OnBrowserDestroyed();
|
||||
|
||||
// Disassociate the platform delegate from this browser.
|
||||
platform_delegate_->BrowserDestroyed(this);
|
||||
|
||||
CefBrowserHostBase::DestroyBrowser();
|
||||
}
|
||||
|
||||
void ChromeBrowserHostImpl::DoCloseBrowser(bool force_close) {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (browser_) {
|
||||
// Like chrome::CloseTab() but specifying the WebContents.
|
||||
const int tab_index = GetCurrentTabIndex();
|
||||
if (tab_index != TabStripModel::kNoTab) {
|
||||
browser_->tab_strip_model()->CloseWebContentsAt(
|
||||
tab_index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB |
|
||||
TabStripModel::CLOSE_USER_GESTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ChromeBrowserHostImpl::GetCurrentTabIndex() const {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (browser_) {
|
||||
return browser_->tab_strip_model()->GetIndexOfWebContents(GetWebContents());
|
||||
}
|
||||
return TabStripModel::kNoTab;
|
||||
}
|
174
libcef/browser/chrome/chrome_browser_host_impl.h
Normal file
174
libcef/browser/chrome/chrome_browser_host_impl.h
Normal file
@@ -0,0 +1,174 @@
|
||||
// Copyright 2020 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_CHROME_CHROME_BROWSER_HOST_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_HOST_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/chrome/browser_delegate.h"
|
||||
|
||||
class Browser;
|
||||
class ChromeBrowserDelegate;
|
||||
|
||||
// CefBrowser implementation for the chrome runtime. Method calls are delegated
|
||||
// to the chrome Browser object or the WebContents as appropriate. See the
|
||||
// ChromeBrowserDelegate documentation for additional details. All methods are
|
||||
// thread-safe unless otherwise indicated.
|
||||
class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
public:
|
||||
// CEF-specific parameters passed via Browser::CreateParams::cef_params and
|
||||
// possibly shared by multiple Browser instances.
|
||||
class DelegateCreateParams : public cef::BrowserDelegate::CreateParams {
|
||||
public:
|
||||
DelegateCreateParams(const CefBrowserCreateParams& create_params)
|
||||
: create_params_(create_params) {}
|
||||
|
||||
CefBrowserCreateParams create_params_;
|
||||
};
|
||||
|
||||
// Create a new Browser with a single tab (WebContents) and associated
|
||||
// ChromeBrowserHostImpl instance.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> Create(
|
||||
const CefBrowserCreateParams& params);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForHost(
|
||||
const content::RenderViewHost* host);
|
||||
// Returns the browser associated with the specified RenderFrameHost.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForHost(
|
||||
const content::RenderFrameHost* host);
|
||||
// Returns the browser associated with the specified WebContents.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForContents(
|
||||
const content::WebContents* contents);
|
||||
// Returns the browser associated with the specified FrameTreeNode ID.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForFrameTreeNode(
|
||||
int frame_tree_node_id);
|
||||
// Returns the browser associated with the specified frame routing IDs.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id);
|
||||
|
||||
~ChromeBrowserHostImpl() override;
|
||||
|
||||
// CefBrowserContentsDelegate::Observer methods:
|
||||
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
|
||||
|
||||
// CefBrowserHostBase methods called from CefFrameHostImpl:
|
||||
void OnSetFocus(cef_focus_source_t source) override;
|
||||
|
||||
// CefBrowserHost methods:
|
||||
void CloseBrowser(bool force_close) override;
|
||||
bool TryCloseBrowser() override;
|
||||
void SetFocus(bool focus) override;
|
||||
CefWindowHandle GetWindowHandle() override;
|
||||
CefWindowHandle GetOpenerWindowHandle() override;
|
||||
bool HasView() override;
|
||||
double GetZoomLevel() override;
|
||||
void SetZoomLevel(double zoomLevel) override;
|
||||
void RunFileDialog(FileDialogMode mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) override;
|
||||
void Find(int identifier,
|
||||
const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
bool findNext) override;
|
||||
void StopFinding(bool clearSelection) override;
|
||||
void ShowDevTools(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings,
|
||||
const CefPoint& inspect_element_at) override;
|
||||
void CloseDevTools() override;
|
||||
bool HasDevTools() override;
|
||||
bool SendDevToolsMessage(const void* message, size_t message_size) override;
|
||||
int ExecuteDevToolsMethod(int message_id,
|
||||
const CefString& method,
|
||||
CefRefPtr<CefDictionaryValue> params) override;
|
||||
CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
|
||||
CefRefPtr<CefDevToolsMessageObserver> observer) override;
|
||||
bool IsWindowRenderingDisabled() override;
|
||||
void WasResized() override;
|
||||
void WasHidden(bool hidden) override;
|
||||
void NotifyScreenInfoChanged() override;
|
||||
void Invalidate(PaintElementType type) override;
|
||||
void SendExternalBeginFrame() override;
|
||||
void SendTouchEvent(const CefTouchEvent& event) override;
|
||||
void SendFocusEvent(bool setFocus) override;
|
||||
void SendCaptureLostEvent() override;
|
||||
void NotifyMoveOrResizeStarted() override;
|
||||
int GetWindowlessFrameRate() override;
|
||||
void SetWindowlessFrameRate(int frame_rate) override;
|
||||
void ImeSetComposition(const CefString& text,
|
||||
const std::vector<CefCompositionUnderline>& underlines,
|
||||
const CefRange& replacement_range,
|
||||
const CefRange& selection_range) override;
|
||||
void ImeCommitText(const CefString& text,
|
||||
const CefRange& replacement_range,
|
||||
int relative_cursor_pos) override;
|
||||
void ImeFinishComposingText(bool keep_selection) override;
|
||||
void ImeCancelComposition() override;
|
||||
void DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
|
||||
const CefMouseEvent& event,
|
||||
DragOperationsMask allowed_ops) override;
|
||||
void DragTargetDragOver(const CefMouseEvent& event,
|
||||
DragOperationsMask allowed_ops) override;
|
||||
void DragTargetDragLeave() override;
|
||||
void DragTargetDrop(const CefMouseEvent& event) override;
|
||||
void DragSourceSystemDragEnded() override;
|
||||
void DragSourceEndedAt(int x, int y, DragOperationsMask op) override;
|
||||
void SetAudioMuted(bool mute) override;
|
||||
bool IsAudioMuted() override;
|
||||
void SetAccessibilityState(cef_state_t accessibility_state) override;
|
||||
void SetAutoResizeEnabled(bool enabled,
|
||||
const CefSize& min_size,
|
||||
const CefSize& max_size) override;
|
||||
CefRefPtr<CefExtension> GetExtension() override;
|
||||
bool IsBackgroundHost() override;
|
||||
|
||||
protected:
|
||||
bool Navigate(const content::OpenURLParams& params) override;
|
||||
|
||||
private:
|
||||
friend class ChromeBrowserDelegate;
|
||||
|
||||
ChromeBrowserHostImpl(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefRequestContextImpl> request_context);
|
||||
|
||||
// Called from ChromeBrowserDelegate::SetAsDelegate when this object is first
|
||||
// created. Must be called on the UI thread.
|
||||
void Attach(Browser* browser, content::WebContents* web_contents);
|
||||
|
||||
// Called from ChromeBrowserDelegate::SetAsDelegate when this object changes
|
||||
// Browser ownership (e.g. dragging between windows). The old Browser will be
|
||||
// cleared before the new Browser is added. Must be called on the UI thread.
|
||||
void SetBrowser(Browser* browser);
|
||||
|
||||
// CefBrowserHostBase methods:
|
||||
void InitializeBrowser() override;
|
||||
void DestroyBrowser() override;
|
||||
|
||||
void DoCloseBrowser(bool force_close);
|
||||
|
||||
// Returns the current tab index for the associated WebContents, or
|
||||
// TabStripModel::kNoTab if not found.
|
||||
int GetCurrentTabIndex() const;
|
||||
|
||||
Browser* browser_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_HOST_IMPL_H_
|
@@ -21,7 +21,7 @@ void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
|
||||
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
||||
}
|
||||
|
||||
void ChromeBrowserMainExtraPartsCef::PostMainMessageLoopRun() {
|
||||
void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
||||
background_task_runner_ = base::CreateSingleThreadTaskRunner(
|
||||
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
||||
|
@@ -37,7 +37,7 @@ class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
|
||||
private:
|
||||
// ChromeBrowserMainExtraParts overrides.
|
||||
void PostProfileInit() override;
|
||||
void PostMainMessageLoopRun() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
|
||||
CefRefPtr<CefRequestContextImpl> global_request_context_;
|
||||
|
||||
|
@@ -5,14 +5,48 @@
|
||||
|
||||
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
||||
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_message_filter.h"
|
||||
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
|
||||
#include "libcef/browser/net/throttle_handler.h"
|
||||
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
||||
#include "libcef/browser/net_service/login_delegate.h"
|
||||
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
||||
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/command_line_impl.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/path_service.h"
|
||||
#include "chrome/browser/chrome_browser_main.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "content/public/browser/navigation_throttle.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void HandleExternalProtocolHelper(
|
||||
ChromeContentBrowserClientCef* self,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
content::NavigationUIData* navigation_data,
|
||||
const network::ResourceRequest& resource_request) {
|
||||
// Match the logic of the original call in
|
||||
// NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
|
||||
self->HandleExternalProtocol(
|
||||
resource_request.url, std::move(web_contents_getter),
|
||||
content::ChildProcessHost::kInvalidUniqueID, navigation_data,
|
||||
resource_request.resource_type ==
|
||||
static_cast<int>(blink::mojom::ResourceType::kMainFrame),
|
||||
static_cast<ui::PageTransition>(resource_request.transition_type),
|
||||
resource_request.has_user_gesture, resource_request.request_initiator,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef(
|
||||
StartupData* startup_data)
|
||||
@@ -46,6 +80,200 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
|
||||
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
||||
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
||||
}
|
||||
|
||||
const base::CommandLine* browser_cmd = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
const std::string& process_type =
|
||||
command_line->GetSwitchValueASCII(switches::kProcessType);
|
||||
if (process_type == switches::kRendererProcess) {
|
||||
// Propagate the following switches to the renderer command line (along with
|
||||
// any associated values) if present in the browser command line.
|
||||
static const char* const kSwitchNames[] = {
|
||||
switches::kUncaughtExceptionStackSize,
|
||||
};
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||
base::size(kSwitchNames));
|
||||
}
|
||||
|
||||
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
|
||||
if (app.get()) {
|
||||
CefRefPtr<CefBrowserProcessHandler> handler =
|
||||
app->GetBrowserProcessHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
||||
new CefCommandLineImpl(command_line, false, false));
|
||||
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
|
||||
commandLinePtr->Detach(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeContentBrowserClientCef::RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host) {
|
||||
const int id = host->GetID();
|
||||
host->AddFilter(new CefBrowserMessageFilter(id));
|
||||
|
||||
// If the renderer process crashes then the host may already have
|
||||
// CefBrowserInfoManager as an observer. Try to remove it first before adding
|
||||
// to avoid DCHECKs.
|
||||
host->RemoveObserver(CefBrowserInfoManager::GetInstance());
|
||||
host->AddObserver(CefBrowserInfoManager::GetInstance());
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClientCef::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) {
|
||||
// The chrome layer has popup blocker, extensions, etc.
|
||||
if (!ChromeContentBrowserClient::CanCreateWindow(
|
||||
opener, opener_url, opener_top_level_frame_url, source_origin,
|
||||
container_type, target_url, referrer, frame_name, disposition,
|
||||
features, user_gesture, opener_suppressed, no_javascript_access)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CefBrowserInfoManager::GetInstance()->CanCreateWindow(
|
||||
opener, target_url, referrer, frame_name, disposition, features,
|
||||
user_gesture, opener_suppressed, no_javascript_access);
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
|
||||
content::BrowserContext* browser_context,
|
||||
content::RenderFrameHost* frame,
|
||||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
base::UkmSourceId ukm_source_id,
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
bool* bypass_redirect_checks,
|
||||
bool* disable_secure_dns,
|
||||
network::mojom::URLLoaderFactoryOverridePtr* factory_override) {
|
||||
bool use_proxy = ChromeContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
browser_context, frame, render_process_id, type, request_initiator,
|
||||
navigation_id, ukm_source_id, factory_receiver, header_client,
|
||||
bypass_redirect_checks, disable_secure_dns, factory_override);
|
||||
if (use_proxy) {
|
||||
// The chrome layer will handle the request.
|
||||
return use_proxy;
|
||||
}
|
||||
|
||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||
browser_context, frame, render_process_id,
|
||||
type == URLLoaderFactoryType::kNavigation,
|
||||
type == URLLoaderFactoryType::kDownload, request_initiator);
|
||||
|
||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||
browser_context, factory_receiver, header_client,
|
||||
std::move(request_handler));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClientCef::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
int child_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition page_transition,
|
||||
bool has_user_gesture,
|
||||
const base::Optional<url::Origin>& initiating_origin,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||
// |out_factory| will be non-nullptr when this method is initially called
|
||||
// from NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
|
||||
if (out_factory) {
|
||||
// Let the other HandleExternalProtocol variant handle the request.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The request was unhandled and we've recieved a callback from
|
||||
// HandleExternalProtocolHelper. Forward to the chrome layer for default
|
||||
// handling.
|
||||
return ChromeContentBrowserClient::HandleExternalProtocol(
|
||||
url, std::move(web_contents_getter), child_id, navigation_data,
|
||||
is_main_frame, page_transition, has_user_gesture, initiating_origin,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClientCef::HandleExternalProtocol(
|
||||
content::WebContents::Getter web_contents_getter,
|
||||
int frame_tree_node_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
const network::ResourceRequest& resource_request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
|
||||
out_factory->InitWithNewPipeAndPassReceiver();
|
||||
|
||||
// HandleExternalProtocolHelper may be called if nothing handles the request.
|
||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||
web_contents_getter, frame_tree_node_id, resource_request,
|
||||
base::Bind(HandleExternalProtocolHelper, base::Unretained(this),
|
||||
web_contents_getter, navigation_data, resource_request));
|
||||
|
||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||
web_contents_getter, std::move(receiver), std::move(request_handler));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||
ChromeContentBrowserClientCef::CreateThrottlesForNavigation(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
auto throttles = ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
||||
navigation_handle);
|
||||
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
|
||||
return throttles;
|
||||
}
|
||||
|
||||
void ChromeContentBrowserClientCef::ConfigureNetworkContextParams(
|
||||
content::BrowserContext* context,
|
||||
bool in_memory,
|
||||
const base::FilePath& relative_partition_path,
|
||||
network::mojom::NetworkContextParams* network_context_params,
|
||||
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
|
||||
ChromeContentBrowserClient::ConfigureNetworkContextParams(
|
||||
context, in_memory, relative_partition_path, network_context_params,
|
||||
cert_verifier_creation_params);
|
||||
|
||||
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
||||
network_context_params->cookieable_schemes =
|
||||
cef_context ? cef_context->GetCookieableSchemes()
|
||||
: CefCookieManagerImpl::GetGlobalCookieableSchemes();
|
||||
}
|
||||
|
||||
std::unique_ptr<content::LoginDelegate>
|
||||
ChromeContentBrowserClientCef::CreateLoginDelegate(
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
content::WebContents* web_contents,
|
||||
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) {
|
||||
// |web_contents| is nullptr for CefURLRequests without an associated frame.
|
||||
if (!web_contents || base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kDisableChromeLoginPrompt)) {
|
||||
// Delegate auth callbacks to GetAuthCredentials.
|
||||
return std::make_unique<net_service::LoginDelegate>(
|
||||
auth_info, web_contents, request_id, url,
|
||||
std::move(auth_required_callback));
|
||||
}
|
||||
|
||||
return ChromeContentBrowserClient::CreateLoginDelegate(
|
||||
auth_info, web_contents, request_id, is_request_for_main_frame, url,
|
||||
response_headers, first_auth_attempt, std::move(auth_required_callback));
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContextImpl>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
class ChromeBrowserMainExtraPartsCef;
|
||||
|
||||
// CEF override of ChromeContentBrowserClient
|
||||
// CEF override of ChromeContentBrowserClient.
|
||||
class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
||||
public:
|
||||
explicit ChromeContentBrowserClientCef(StartupData* startup_data = nullptr);
|
||||
@@ -26,6 +26,71 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
||||
const content::MainFunctionParams& parameters) override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
void RenderProcessWillLaunch(content::RenderProcessHost* host) 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;
|
||||
bool WillCreateURLLoaderFactory(
|
||||
content::BrowserContext* browser_context,
|
||||
content::RenderFrameHost* frame,
|
||||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
base::UkmSourceId ukm_source_id,
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
bool* bypass_redirect_checks,
|
||||
bool* disable_secure_dns,
|
||||
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
|
||||
bool HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
int child_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
ui::PageTransition page_transition,
|
||||
bool has_user_gesture,
|
||||
const base::Optional<url::Origin>& initiating_origin,
|
||||
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,
|
||||
const network::ResourceRequest& request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
||||
override;
|
||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||
CreateThrottlesForNavigation(
|
||||
content::NavigationHandle* navigation_handle) override;
|
||||
void ConfigureNetworkContextParams(
|
||||
content::BrowserContext* context,
|
||||
bool in_memory,
|
||||
const base::FilePath& relative_partition_path,
|
||||
network::mojom::NetworkContextParams* network_context_params,
|
||||
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params)
|
||||
override;
|
||||
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
content::WebContents* web_contents,
|
||||
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;
|
||||
|
||||
CefRefPtr<CefRequestContextImpl> request_context() const;
|
||||
|
||||
|
@@ -17,14 +17,11 @@
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class CefBrowserInfoManager;
|
||||
class CefTraceSubscriber;
|
||||
|
||||
class CefContext {
|
||||
public:
|
||||
typedef std::list<CefRefPtr<CefBrowserHostImpl>> BrowserList;
|
||||
|
||||
// Interface to implement for observers that wish to be informed of changes
|
||||
// to the context. All methods will be called on the UI thread.
|
||||
class Observer {
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "libcef/browser/devtools/devtools_file_manager.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/callback.h"
|
||||
@@ -39,8 +39,9 @@ void AppendToFile(const base::FilePath& path, const std::string& content) {
|
||||
|
||||
} // namespace
|
||||
|
||||
CefDevToolsFileManager::CefDevToolsFileManager(CefBrowserHostImpl* browser_impl,
|
||||
PrefService* prefs)
|
||||
CefDevToolsFileManager::CefDevToolsFileManager(
|
||||
AlloyBrowserHostImpl* browser_impl,
|
||||
PrefService* prefs)
|
||||
: browser_impl_(browser_impl),
|
||||
prefs_(prefs),
|
||||
file_task_runner_(base::CreateSequencedTaskRunner(
|
||||
|
@@ -18,7 +18,7 @@ class SequencedTaskRunner;
|
||||
class Value;
|
||||
} // namespace base
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
class PrefService;
|
||||
|
||||
// File management helper for DevTools.
|
||||
@@ -26,7 +26,8 @@ class PrefService;
|
||||
// chrome/browser/devtools/devtools_file_helper.cc.
|
||||
class CefDevToolsFileManager {
|
||||
public:
|
||||
CefDevToolsFileManager(CefBrowserHostImpl* browser_impl, PrefService* prefs);
|
||||
CefDevToolsFileManager(AlloyBrowserHostImpl* browser_impl,
|
||||
PrefService* prefs);
|
||||
|
||||
void SaveToFile(const std::string& url,
|
||||
const std::string& content,
|
||||
@@ -68,7 +69,7 @@ class CefDevToolsFileManager {
|
||||
const base::Value* arg3);
|
||||
|
||||
// Guaranteed to outlive this object.
|
||||
CefBrowserHostImpl* browser_impl_;
|
||||
AlloyBrowserHostImpl* browser_impl_;
|
||||
PrefService* prefs_;
|
||||
|
||||
typedef std::map<std::string, base::FilePath> PathsMap;
|
||||
|
@@ -54,6 +54,7 @@
|
||||
#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"
|
||||
|
||||
@@ -235,7 +236,7 @@ const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
||||
|
||||
// static
|
||||
CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
CefBrowserHostImpl* inspected_browser,
|
||||
AlloyBrowserHostImpl* inspected_browser,
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings,
|
||||
@@ -249,7 +250,7 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
new_settings.background_color = SK_ColorWHITE;
|
||||
}
|
||||
|
||||
CefBrowserHostImpl::CreateParams create_params;
|
||||
CefBrowserCreateParams create_params;
|
||||
if (!inspected_browser->IsViewsHosted())
|
||||
create_params.window_info.reset(new CefWindowInfo(windowInfo));
|
||||
create_params.client = client;
|
||||
@@ -258,15 +259,15 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
create_params.request_context = inspected_browser->GetRequestContext();
|
||||
create_params.extra_info = inspected_browser->browser_info()->extra_info();
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser =
|
||||
CefBrowserHostImpl::Create(create_params);
|
||||
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(
|
||||
static_cast<CefBrowserHostImpl*>(frontend_browser.get()),
|
||||
static_cast<AlloyBrowserHostImpl*>(frontend_browser.get()),
|
||||
inspected_contents, inspect_element_at,
|
||||
std::move(frontend_destroyed_callback));
|
||||
|
||||
@@ -293,12 +294,12 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
|
||||
|
||||
void CefDevToolsFrontend::Close() {
|
||||
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
|
||||
base::Bind(&CefBrowserHostImpl::CloseBrowser,
|
||||
base::Bind(&AlloyBrowserHostImpl::CloseBrowser,
|
||||
frontend_browser_.get(), true));
|
||||
}
|
||||
|
||||
CefDevToolsFrontend::CefDevToolsFrontend(
|
||||
CefBrowserHostImpl* frontend_browser,
|
||||
AlloyBrowserHostImpl* frontend_browser,
|
||||
content::WebContents* inspected_contents,
|
||||
const CefPoint& inspect_element_at,
|
||||
base::OnceClosure frontend_destroyed_callback)
|
||||
@@ -445,15 +446,15 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
resource_request->site_for_cookies = net::SiteForCookies::FromUrl(gurl);
|
||||
resource_request->headers.AddHeadersFromString(headers);
|
||||
|
||||
std::unique_ptr<network::mojom::URLLoaderFactory> file_url_loader_factory;
|
||||
scoped_refptr<network::SharedURLLoaderFactory> network_url_loader_factory;
|
||||
std::unique_ptr<network::mojom::URLLoaderFactory> webui_url_loader_factory;
|
||||
network::mojom::URLLoaderFactory* url_loader_factory;
|
||||
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory;
|
||||
if (gurl.SchemeIsFile()) {
|
||||
file_url_loader_factory = content::CreateFileURLLoaderFactory(
|
||||
base::FilePath() /* profile_path */,
|
||||
nullptr /* shared_cors_origin_access_list */);
|
||||
url_loader_factory = file_url_loader_factory.get();
|
||||
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::DictionaryValue response;
|
||||
response.SetInteger("statusCode", 403);
|
||||
@@ -462,15 +463,13 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
} else {
|
||||
auto* partition = content::BrowserContext::GetStoragePartitionForSite(
|
||||
web_contents()->GetBrowserContext(), gurl);
|
||||
network_url_loader_factory =
|
||||
partition->GetURLLoaderFactoryForBrowserProcess();
|
||||
url_loader_factory = network_url_loader_factory.get();
|
||||
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,
|
||||
stream_id, this, std::move(simple_url_loader), url_loader_factory.get(),
|
||||
request_id);
|
||||
loaders_.insert(std::move(resource_loader));
|
||||
return;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/devtools/devtools_file_manager.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
@@ -42,7 +42,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
public content::DevToolsAgentHostClient {
|
||||
public:
|
||||
static CefDevToolsFrontend* Show(
|
||||
CefBrowserHostImpl* inspected_browser,
|
||||
AlloyBrowserHostImpl* inspected_browser,
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings,
|
||||
@@ -60,7 +60,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
const base::Value* arg3);
|
||||
|
||||
private:
|
||||
CefDevToolsFrontend(CefBrowserHostImpl* frontend_browser,
|
||||
CefDevToolsFrontend(AlloyBrowserHostImpl* frontend_browser,
|
||||
content::WebContents* inspected_contents,
|
||||
const CefPoint& inspect_element_at,
|
||||
base::OnceClosure destroyed_callback);
|
||||
@@ -87,7 +87,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
|
||||
PrefService* GetPrefs() const;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser_;
|
||||
CefRefPtr<AlloyBrowserHostImpl> frontend_browser_;
|
||||
content::WebContents* inspected_contents_;
|
||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||
CefPoint inspect_element_at_;
|
||||
|
@@ -31,7 +31,7 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
|
||||
controller_->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void Initialize(CefBrowserHostImpl* browser,
|
||||
void Initialize(AlloyBrowserHostImpl* browser,
|
||||
base::WeakPtr<CefDevToolsController> controller) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(browser && controller);
|
||||
@@ -83,7 +83,7 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
|
||||
|
||||
CefRefPtr<CefDevToolsMessageObserver> observer_;
|
||||
|
||||
CefBrowserHostImpl* browser_ = nullptr;
|
||||
AlloyBrowserHostImpl* browser_ = nullptr;
|
||||
base::WeakPtr<CefDevToolsController> controller_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefDevToolsRegistrationImpl);
|
||||
@@ -92,7 +92,7 @@ class CefDevToolsRegistrationImpl : public CefRegistration,
|
||||
|
||||
} // namespace
|
||||
|
||||
CefDevToolsManager::CefDevToolsManager(CefBrowserHostImpl* inspected_browser)
|
||||
CefDevToolsManager::CefDevToolsManager(AlloyBrowserHostImpl* inspected_browser)
|
||||
: inspected_browser_(inspected_browser), weak_ptr_factory_(this) {
|
||||
CEF_REQUIRE_UIT();
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
class CefDevToolsController;
|
||||
class CefDevToolsFrontend;
|
||||
|
||||
@@ -23,7 +23,7 @@ class WebContents;
|
||||
class CefDevToolsManager {
|
||||
public:
|
||||
// |inspected_browser| will outlive this object.
|
||||
explicit CefDevToolsManager(CefBrowserHostImpl* inspected_browser);
|
||||
explicit CefDevToolsManager(AlloyBrowserHostImpl* inspected_browser);
|
||||
~CefDevToolsManager();
|
||||
|
||||
// See CefBrowserHost methods of the same name for documentation.
|
||||
@@ -52,7 +52,7 @@ class CefDevToolsManager {
|
||||
|
||||
bool EnsureController();
|
||||
|
||||
CefBrowserHostImpl* const inspected_browser_;
|
||||
AlloyBrowserHostImpl* const inspected_browser_;
|
||||
|
||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
||||
// destroyed.
|
||||
|
@@ -8,8 +8,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/atomicops.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
|
||||
#include "include/cef_download_handler.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/download_item_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
@@ -30,7 +31,7 @@ namespace {
|
||||
|
||||
// Helper function to retrieve the CefDownloadHandler.
|
||||
CefRefPtr<CefDownloadHandler> GetDownloadHandler(
|
||||
CefRefPtr<CefBrowserHostImpl> browser) {
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser) {
|
||||
CefRefPtr<CefClient> client = browser->GetClient();
|
||||
if (client.get())
|
||||
return client->GetDownloadHandler();
|
||||
@@ -124,8 +125,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
if (show_dialog) {
|
||||
WebContents* web_contents =
|
||||
content::DownloadItemUtils::GetWebContents(item);
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (browser.get()) {
|
||||
handled = true;
|
||||
|
||||
@@ -275,7 +276,7 @@ CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
|
||||
}
|
||||
|
||||
void CefDownloadManagerDelegate::OnDownloadUpdated(DownloadItem* download) {
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser(download);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetBrowser(download);
|
||||
CefRefPtr<CefDownloadHandler> handler;
|
||||
if (browser.get())
|
||||
handler = GetDownloadHandler(browser);
|
||||
@@ -295,7 +296,7 @@ void CefDownloadManagerDelegate::OnDownloadUpdated(DownloadItem* download) {
|
||||
void CefDownloadManagerDelegate::OnDownloadDestroyed(DownloadItem* item) {
|
||||
item->RemoveObserver(this);
|
||||
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
AlloyBrowserHostImpl* browser = nullptr;
|
||||
|
||||
ItemBrowserMap::iterator it = item_browser_map_.find(item);
|
||||
DCHECK(it != item_browser_map_.end());
|
||||
@@ -325,7 +326,7 @@ void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager,
|
||||
DownloadItem* item) {
|
||||
// This callback may arrive after DetermineDownloadTarget, so we allow
|
||||
// association from either method.
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetOrAssociateBrowser(item);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetOrAssociateBrowser(item);
|
||||
if (!browser) {
|
||||
// If the download is rejected (e.g. ALT+click on an invalid protocol link)
|
||||
// then an "interrupted" download will be started via DownloadManagerImpl::
|
||||
@@ -364,7 +365,7 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
||||
|
||||
// This callback may arrive before OnDownloadCreated, so we allow association
|
||||
// from either method.
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetOrAssociateBrowser(item);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetOrAssociateBrowser(item);
|
||||
CefRefPtr<CefDownloadHandler> handler;
|
||||
if (browser.get())
|
||||
handler = GetDownloadHandler(browser);
|
||||
@@ -405,7 +406,7 @@ std::string CefDownloadManagerDelegate::ApplicationClientIdForFileScanning() {
|
||||
}
|
||||
|
||||
void CefDownloadManagerDelegate::OnBrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
CefBrowserHostBase* browser) {
|
||||
ItemBrowserMap::iterator it = item_browser_map_.begin();
|
||||
for (; it != item_browser_map_.end(); ++it) {
|
||||
if (it->second == browser) {
|
||||
@@ -417,17 +418,17 @@ void CefDownloadManagerDelegate::OnBrowserDestroyed(
|
||||
}
|
||||
}
|
||||
|
||||
CefBrowserHostImpl* CefDownloadManagerDelegate::GetOrAssociateBrowser(
|
||||
AlloyBrowserHostImpl* CefDownloadManagerDelegate::GetOrAssociateBrowser(
|
||||
download::DownloadItem* item) {
|
||||
ItemBrowserMap::const_iterator it = item_browser_map_.find(item);
|
||||
if (it != item_browser_map_.end())
|
||||
return it->second;
|
||||
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
AlloyBrowserHostImpl* browser = nullptr;
|
||||
content::WebContents* contents =
|
||||
content::DownloadItemUtils::GetWebContents(item);
|
||||
if (contents) {
|
||||
browser = CefBrowserHostImpl::GetBrowserForContents(contents).get();
|
||||
browser = AlloyBrowserHostImpl::GetBrowserForContents(contents).get();
|
||||
DCHECK(browser);
|
||||
}
|
||||
if (!browser)
|
||||
@@ -445,7 +446,8 @@ CefBrowserHostImpl* CefDownloadManagerDelegate::GetOrAssociateBrowser(
|
||||
return browser;
|
||||
}
|
||||
|
||||
CefBrowserHostImpl* CefDownloadManagerDelegate::GetBrowser(DownloadItem* item) {
|
||||
AlloyBrowserHostImpl* CefDownloadManagerDelegate::GetBrowser(
|
||||
DownloadItem* item) {
|
||||
ItemBrowserMap::const_iterator it = item_browser_map_.find(item);
|
||||
if (it != item_browser_map_.end())
|
||||
return it->second;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
@@ -16,10 +16,12 @@
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/download_manager_delegate.h"
|
||||
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
|
||||
public content::DownloadManager::Observer,
|
||||
public content::DownloadManagerDelegate,
|
||||
public CefBrowserHostImpl::Observer {
|
||||
public CefBrowserHostBase::Observer {
|
||||
public:
|
||||
explicit CefDownloadManagerDelegate(content::DownloadManager* manager);
|
||||
~CefDownloadManagerDelegate() override;
|
||||
@@ -41,19 +43,20 @@ class CefDownloadManagerDelegate : public download::DownloadItem::Observer,
|
||||
void GetNextId(content::DownloadIdCallback callback) override;
|
||||
std::string ApplicationClientIdForFileScanning() override;
|
||||
|
||||
// CefBrowserHostImpl::Observer methods.
|
||||
void OnBrowserDestroyed(CefBrowserHostImpl* browser) override;
|
||||
// CefBrowserHostBase::Observer methods.
|
||||
void OnBrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||
|
||||
CefBrowserHostImpl* GetOrAssociateBrowser(download::DownloadItem* item);
|
||||
CefBrowserHostImpl* GetBrowser(download::DownloadItem* item);
|
||||
AlloyBrowserHostImpl* GetOrAssociateBrowser(download::DownloadItem* item);
|
||||
AlloyBrowserHostImpl* GetBrowser(download::DownloadItem* item);
|
||||
|
||||
content::DownloadManager* manager_;
|
||||
base::WeakPtrFactory<content::DownloadManager> manager_ptr_factory_;
|
||||
|
||||
// Map of DownloadItem to originating CefBrowserHostImpl. Maintaining this
|
||||
// Map of DownloadItem to originating AlloyBrowserHostImpl. Maintaining this
|
||||
// map is necessary because DownloadItem::GetWebContents() may return NULL if
|
||||
// the browser navigates while the download is in progress.
|
||||
typedef std::map<download::DownloadItem*, CefBrowserHostImpl*> ItemBrowserMap;
|
||||
typedef std::map<download::DownloadItem*, AlloyBrowserHostImpl*>
|
||||
ItemBrowserMap;
|
||||
ItemBrowserMap item_browser_map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
||||
|
@@ -119,7 +119,7 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
|
||||
// Find a browser that we can access, or fail with error.
|
||||
std::string error;
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error);
|
||||
if (!browser)
|
||||
return set_init_result_error(error);
|
||||
@@ -130,10 +130,18 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
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<CefBrowserHostImpl> browser =
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
|
||||
if (!browser)
|
||||
return false;
|
||||
@@ -188,7 +196,7 @@ ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor(
|
||||
std::string* error) {
|
||||
CHECK_GE(execute_tab_id_, 0);
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
|
||||
if (!browser)
|
||||
return nullptr;
|
||||
@@ -225,11 +233,11 @@ void ExecuteCodeInTabFunction::LoadFileComplete(
|
||||
DidLoadAndLocalizeFile(file, success, std::move(data));
|
||||
}
|
||||
|
||||
bool TabsExecuteScriptFunction::ShouldInsertCSS() const {
|
||||
return false;
|
||||
bool TabsInsertCSSFunction::ShouldInsertCSS() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TabsInsertCSSFunction::ShouldInsertCSS() const {
|
||||
bool TabsRemoveCSSFunction::ShouldRemoveCSS() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -237,7 +245,7 @@ ZoomAPIFunction::ZoomAPIFunction() : cef_details_(this) {}
|
||||
|
||||
content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
|
||||
// Find a browser that we can access, or set |error_| and return nullptr.
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error_);
|
||||
if (!browser)
|
||||
return nullptr;
|
||||
|
@@ -42,7 +42,7 @@ class TabsCreateFunction : public ExtensionFunction {
|
||||
const CefExtensionFunctionDetails cef_details_;
|
||||
};
|
||||
|
||||
// Implement API call tabs.executeScript and tabs.insertCSS.
|
||||
// Implement API calls tabs.executeScript, tabs.insertCSS, and tabs.removeCSS.
|
||||
class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
||||
public:
|
||||
ExecuteCodeInTabFunction();
|
||||
@@ -52,6 +52,8 @@ class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
||||
|
||||
// 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;
|
||||
@@ -69,9 +71,6 @@ class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
||||
};
|
||||
|
||||
class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
|
||||
protected:
|
||||
bool ShouldInsertCSS() const override;
|
||||
|
||||
private:
|
||||
~TabsExecuteScriptFunction() override {}
|
||||
|
||||
@@ -87,6 +86,15 @@ class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.insertCSS", TABS_INSERTCSS)
|
||||
};
|
||||
|
||||
class TabsRemoveCSSFunction : public ExecuteCodeInTabFunction {
|
||||
private:
|
||||
~TabsRemoveCSSFunction() override {}
|
||||
|
||||
bool ShouldRemoveCSS() const override;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.removeCSS", TABS_INSERTCSS)
|
||||
};
|
||||
|
||||
// Based on ChromeAsyncExtensionFunction.
|
||||
class ZoomAPIFunction : public ExtensionFunction {
|
||||
public:
|
||||
|
@@ -4,10 +4,13 @@
|
||||
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/printing/print_preview_dialog_controller.h"
|
||||
@@ -16,6 +19,8 @@
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_plugin_guest_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
|
||||
namespace extensions {
|
||||
@@ -59,8 +64,7 @@ content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {
|
||||
content::BrowserPluginGuest* plugin_guest =
|
||||
guest_impl->GetBrowserPluginGuest();
|
||||
if (plugin_guest) {
|
||||
return content::WebContents::FromRenderFrameHost(
|
||||
plugin_guest->GetEmbedderFrame());
|
||||
return plugin_guest->owner_web_contents();
|
||||
}
|
||||
|
||||
// Maybe it's a print preview dialog.
|
||||
@@ -69,7 +73,7 @@ content::WebContents* GetOwnerForGuestContents(content::WebContents* guest) {
|
||||
return print_preview_controller->GetInitiator(guest);
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id,
|
||||
bool* is_guest_view) {
|
||||
@@ -86,7 +90,7 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoForFrameRoute(
|
||||
render_process_id, render_routing_id, is_guest_view);
|
||||
if (info.get()) {
|
||||
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
|
||||
CefRefPtr<CefBrowserHostBase> browser = info->browser();
|
||||
if (!browser.get()) {
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id()
|
||||
<< " but no browser object matching view process id "
|
||||
@@ -99,20 +103,20 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::RenderViewHost* host,
|
||||
bool* is_guest_view) {
|
||||
if (is_guest_view)
|
||||
*is_guest_view = false;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForHost(host);
|
||||
CefRefPtr<CefBrowserHostBase> browser =
|
||||
CefBrowserHostBase::GetBrowserForHost(host);
|
||||
if (!browser.get() && ExtensionsEnabled()) {
|
||||
// Retrieve the owner browser, if any.
|
||||
content::WebContents* owner = GetOwnerForGuestContents(
|
||||
content::WebContents::FromRenderViewHost(host));
|
||||
if (owner) {
|
||||
browser = CefBrowserHostImpl::GetBrowserForContents(owner);
|
||||
browser = CefBrowserHostBase::GetBrowserForContents(owner);
|
||||
if (browser.get() && is_guest_view)
|
||||
*is_guest_view = true;
|
||||
}
|
||||
@@ -120,20 +124,20 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
|
||||
return browser;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::RenderFrameHost* host,
|
||||
bool* is_guest_view) {
|
||||
if (is_guest_view)
|
||||
*is_guest_view = false;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::GetBrowserForHost(host);
|
||||
CefRefPtr<CefBrowserHostBase> browser =
|
||||
CefBrowserHostBase::GetBrowserForHost(host);
|
||||
if (!browser.get() && ExtensionsEnabled()) {
|
||||
// Retrieve the owner browser, if any.
|
||||
content::WebContents* owner = GetOwnerForGuestContents(
|
||||
content::WebContents::FromRenderFrameHost(host));
|
||||
if (owner) {
|
||||
browser = CefBrowserHostImpl::GetBrowserForContents(owner);
|
||||
browser = CefBrowserHostBase::GetBrowserForContents(owner);
|
||||
if (browser.get() && is_guest_view)
|
||||
*is_guest_view = true;
|
||||
}
|
||||
@@ -141,9 +145,10 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
|
||||
return browser;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabId(
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
|
||||
int tab_id,
|
||||
content::BrowserContext* browser_context) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(browser_context);
|
||||
if (tab_id < 0 || !browser_context)
|
||||
@@ -154,7 +159,8 @@ CefRefPtr<CefBrowserHostImpl> GetBrowserForTabId(
|
||||
|
||||
for (const auto& browser_info :
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
|
||||
CefRefPtr<CefBrowserHostImpl> current_browser = browser_info->browser();
|
||||
CefRefPtr<AlloyBrowserHostImpl> current_browser =
|
||||
static_cast<AlloyBrowserHostImpl*>(browser_info->browser().get());
|
||||
if (current_browser && current_browser->GetIdentifier() == tab_id) {
|
||||
// Make sure we're operating in the same CefBrowserContext.
|
||||
if (CefBrowserContext::FromBrowserContext(
|
||||
|
@@ -7,16 +7,20 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "include/internal/cef_ptr.h"
|
||||
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
class RenderFrameHost;
|
||||
class RenderViewHost;
|
||||
class WebContents;
|
||||
} // namespace content
|
||||
|
||||
class CefBrowserHostBase;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class Extension;
|
||||
@@ -32,31 +36,31 @@ void GetAllGuestsForOwnerContents(content::WebContents* owner,
|
||||
// Returns the WebContents that owns the specified |guest|, if any.
|
||||
content::WebContents* GetOwnerForGuestContents(content::WebContents* guest);
|
||||
|
||||
// Returns the CefBrowserHostImpl that owns the host identified by the specified
|
||||
// Returns the CefBrowserHostBase that owns the host identified by the specified
|
||||
// routing IDs, if any. |is_guest_view| will be set to true if the IDs
|
||||
// match a guest view associated with the returned browser instead of the
|
||||
// browser itself.
|
||||
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrameRoute(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForFrameRoute(
|
||||
int render_process_id,
|
||||
int render_routing_id,
|
||||
bool* is_guest_view);
|
||||
|
||||
// Returns the CefBrowserHostImpl that owns the specified |host|, if any.
|
||||
// Returns the CefBrowserHostBase that owns the specified |host|, if any.
|
||||
// |is_guest_view| will be set to true if the host matches a guest view
|
||||
// associated with the returned browser instead of the browser itself.
|
||||
// TODO(cef): Delete the RVH variant once the remaining use case
|
||||
// (via AlloyContentBrowserClient::OverrideWebkitPrefs) has been removed.
|
||||
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::RenderViewHost* host,
|
||||
bool* is_guest_view);
|
||||
CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForHost(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::RenderFrameHost* host,
|
||||
bool* is_guest_view);
|
||||
|
||||
// Returns the browser matching |tab_id| and |browser_context|. Returns false if
|
||||
// |tab_id| is < 0 or a matching browser cannot be found within
|
||||
// |browser_context|. Similar in concept to ExtensionTabUtil::GetTabById.
|
||||
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabId(
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
|
||||
int tab_id,
|
||||
content::BrowserContext* browser_context);
|
||||
|
||||
|
@@ -6,8 +6,9 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
@@ -15,6 +16,7 @@
|
||||
CefBrowserPlatformDelegateBackground::CefBrowserPlatformDelegateBackground(
|
||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
|
||||
: native_delegate_(std::move(native_delegate)) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
native_delegate_->set_windowless_handler(this);
|
||||
}
|
||||
|
||||
@@ -27,7 +29,8 @@ void CefBrowserPlatformDelegateBackground::CloseHostWindow() {
|
||||
// No host window, so continue browser destruction now. Do it asynchronously
|
||||
// so the call stack has a chance to unwind.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::WindowDestroyed, browser_));
|
||||
base::Bind(&AlloyBrowserHostImpl::WindowDestroyed,
|
||||
static_cast<AlloyBrowserHostImpl*>(browser_)));
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle()
|
||||
@@ -115,14 +118,6 @@ CefBrowserPlatformDelegateBackground::CreateMenuRunner() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateBackground::IsWindowless() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateBackground::IsViewsHosted() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateBackground::GetParentWindowHandle()
|
||||
const {
|
||||
return GetHostWindowHandle();
|
||||
|
@@ -44,8 +44,6 @@ class CefBrowserPlatformDelegateBackground
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
||||
override;
|
||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||
bool IsWindowless() const override;
|
||||
bool IsViewsHosted() const override;
|
||||
|
||||
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
||||
CefWindowHandle GetParentWindowHandle() const override;
|
||||
|
@@ -53,6 +53,7 @@ const char* const kSupportedAPIs[] = {
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsCreateFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsExecuteScriptFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsInsertCSSFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsRemoveCSSFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
|
||||
@@ -91,6 +92,7 @@ void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) {
|
||||
registry->RegisterFunction<StorageStorageAreaGetBytesInUseFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsExecuteScriptFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsInsertCSSFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsRemoveCSSFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsGetFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsCreateFunction>();
|
||||
registry->RegisterFunction<cefimpl::TabsSetZoomFunction>();
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "libcef/browser/extensions/extension_background_host.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/extensions/extension_host_delegate.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace extensions {
|
||||
|
||||
CefExtensionBackgroundHost::CefExtensionBackgroundHost(
|
||||
CefBrowserHostImpl* browser,
|
||||
AlloyBrowserHostImpl* browser,
|
||||
base::OnceClosure deleted_callback,
|
||||
const Extension* extension,
|
||||
content::WebContents* host_contents,
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "extensions/browser/extension_host.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
@@ -24,7 +24,7 @@ namespace extensions {
|
||||
// is managed by ProcessManager.
|
||||
class CefExtensionBackgroundHost : public ExtensionHost {
|
||||
public:
|
||||
CefExtensionBackgroundHost(CefBrowserHostImpl* browser,
|
||||
CefExtensionBackgroundHost(AlloyBrowserHostImpl* browser,
|
||||
base::OnceClosure deleted_callback,
|
||||
const Extension* extension,
|
||||
content::WebContents* host_contents,
|
||||
|
@@ -143,18 +143,18 @@ Profile* CefExtensionFunctionDetails::GetProfile() const {
|
||||
return Profile::FromBrowserContext(function_->browser_context());
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetSenderBrowser()
|
||||
CefRefPtr<AlloyBrowserHostImpl> CefExtensionFunctionDetails::GetSenderBrowser()
|
||||
const {
|
||||
content::WebContents* web_contents = function_->GetSenderWebContents();
|
||||
if (web_contents)
|
||||
return CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
return AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
|
||||
CefRefPtr<AlloyBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
|
||||
const {
|
||||
// Start with the browser hosting the extension.
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetSenderBrowser();
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetSenderBrowser();
|
||||
if (browser && browser->client()) {
|
||||
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
|
||||
if (handler) {
|
||||
@@ -163,8 +163,8 @@ CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
|
||||
handler->GetActiveBrowser(GetCefExtension(), browser.get(),
|
||||
function_->include_incognito_information());
|
||||
if (active_browser && active_browser != browser) {
|
||||
CefRefPtr<CefBrowserHostImpl> active_browser_impl =
|
||||
static_cast<CefBrowserHostImpl*>(active_browser.get());
|
||||
CefRefPtr<AlloyBrowserHostImpl> active_browser_impl =
|
||||
static_cast<AlloyBrowserHostImpl*>(active_browser.get());
|
||||
|
||||
// Make sure we're operating in the same CefBrowserContext.
|
||||
if (CefBrowserContext::FromBrowserContext(
|
||||
@@ -187,11 +187,11 @@ CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
|
||||
}
|
||||
|
||||
bool CefExtensionFunctionDetails::CanAccessBrowser(
|
||||
CefRefPtr<CefBrowserHostImpl> target) const {
|
||||
CefRefPtr<AlloyBrowserHostImpl> target) const {
|
||||
DCHECK(target);
|
||||
|
||||
// Start with the browser hosting the extension.
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetSenderBrowser();
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetSenderBrowser();
|
||||
if (browser == target) {
|
||||
// A sender can always access itself.
|
||||
return true;
|
||||
@@ -210,14 +210,14 @@ bool CefExtensionFunctionDetails::CanAccessBrowser(
|
||||
return true;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl>
|
||||
CefRefPtr<AlloyBrowserHostImpl>
|
||||
CefExtensionFunctionDetails::GetBrowserForTabIdFirstTime(
|
||||
int tab_id,
|
||||
std::string* error_message) const {
|
||||
DCHECK(!get_browser_called_first_time_);
|
||||
get_browser_called_first_time_ = true;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser;
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser;
|
||||
|
||||
if (tab_id >= 0) {
|
||||
// May be an invalid tabId or in the wrong BrowserContext.
|
||||
@@ -243,7 +243,7 @@ CefExtensionFunctionDetails::GetBrowserForTabIdFirstTime(
|
||||
return browser;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl>
|
||||
CefRefPtr<AlloyBrowserHostImpl>
|
||||
CefExtensionFunctionDetails::GetBrowserForTabIdAgain(
|
||||
int tab_id,
|
||||
std::string* error_message) const {
|
||||
@@ -251,7 +251,7 @@ CefExtensionFunctionDetails::GetBrowserForTabIdAgain(
|
||||
DCHECK(get_browser_called_first_time_);
|
||||
|
||||
// May return NULL during shutdown.
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
GetBrowserForTabId(tab_id, function_->browser_context());
|
||||
if (!browser || !browser->web_contents()) {
|
||||
if (error_message) {
|
||||
@@ -265,7 +265,7 @@ CefExtensionFunctionDetails::GetBrowserForTabIdAgain(
|
||||
bool CefExtensionFunctionDetails::LoadFile(const std::string& file,
|
||||
LoadFileCallback callback) const {
|
||||
// Start with the browser hosting the extension.
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetSenderBrowser();
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetSenderBrowser();
|
||||
if (browser && browser->client()) {
|
||||
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
|
||||
if (handler) {
|
||||
@@ -290,7 +290,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
||||
const OpenTabParams& params,
|
||||
bool user_gesture,
|
||||
std::string* error_message) const {
|
||||
CefRefPtr<CefBrowserHostImpl> sender_browser = GetSenderBrowser();
|
||||
CefRefPtr<AlloyBrowserHostImpl> sender_browser = GetSenderBrowser();
|
||||
if (!sender_browser)
|
||||
return nullptr;
|
||||
|
||||
@@ -301,7 +301,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
||||
|
||||
// CEF doesn't have the concept of windows containing tab strips so we'll
|
||||
// select an "active browser" for BrowserContext sharing instead.
|
||||
CefRefPtr<CefBrowserHostImpl> active_browser =
|
||||
CefRefPtr<AlloyBrowserHostImpl> active_browser =
|
||||
GetBrowserForTabIdFirstTime(window_id, error_message);
|
||||
if (!active_browser)
|
||||
return nullptr;
|
||||
@@ -365,7 +365,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
||||
if (!request_context)
|
||||
return nullptr;
|
||||
|
||||
CefBrowserHostImpl::CreateParams create_params;
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.url = url;
|
||||
create_params.request_context = request_context;
|
||||
create_params.window_info.reset(new CefWindowInfo);
|
||||
@@ -394,8 +394,8 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
||||
}
|
||||
|
||||
// Browser creation may fail under certain rare circumstances.
|
||||
CefRefPtr<CefBrowserHostImpl> new_browser =
|
||||
CefBrowserHostImpl::Create(create_params);
|
||||
CefRefPtr<AlloyBrowserHostImpl> new_browser =
|
||||
AlloyBrowserHostImpl::Create(create_params);
|
||||
if (!new_browser)
|
||||
return nullptr;
|
||||
|
||||
@@ -412,7 +412,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
||||
}
|
||||
|
||||
std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::CreateTabObject(
|
||||
CefRefPtr<CefBrowserHostImpl> new_browser,
|
||||
CefRefPtr<AlloyBrowserHostImpl> new_browser,
|
||||
int opener_browser_id,
|
||||
bool active,
|
||||
int index) const {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DETAILS_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DETAILS_H_
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
|
||||
#include "include/cef_extension.h"
|
||||
|
||||
@@ -36,7 +36,7 @@ class CefExtensionFunctionDetails {
|
||||
|
||||
// Get the "sender" browser that is hosting the extension. May return NULL
|
||||
// during startup/shutdown.
|
||||
CefRefPtr<CefBrowserHostImpl> GetSenderBrowser() const;
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetSenderBrowser() const;
|
||||
|
||||
// Get the "current" browser that will be acted on by this extension function,
|
||||
// if any. When mapping from a tabId use the GetBrowserForTabId* methods
|
||||
@@ -57,12 +57,12 @@ class CefExtensionFunctionDetails {
|
||||
// This method can return NULL if there is no matching browser, which can
|
||||
// happen if only incognito windows are open, or early in startup or shutdown
|
||||
// shutdown when there are no active windows.
|
||||
CefRefPtr<CefBrowserHostImpl> GetCurrentBrowser() const;
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetCurrentBrowser() const;
|
||||
|
||||
// Returns true if the sender browser can access |target|. When mapping from a
|
||||
// tabId use the GetBrowserForTabId* methods instead of calling this method
|
||||
// directly.
|
||||
bool CanAccessBrowser(CefRefPtr<CefBrowserHostImpl> target) const;
|
||||
bool CanAccessBrowser(CefRefPtr<AlloyBrowserHostImpl> target) const;
|
||||
|
||||
// Returns the browser matching |tab_id| or NULL if the browser cannot be
|
||||
// found or does not have a WebContents. If |tab_id| is < 0 the "current"
|
||||
@@ -70,7 +70,7 @@ class CefExtensionFunctionDetails {
|
||||
// will be set with an appropriate message on error. This method should only
|
||||
// be called one time per extension function and will check all necessary
|
||||
// client permissions.
|
||||
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabIdFirstTime(
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabIdFirstTime(
|
||||
int tab_id,
|
||||
std::string* error_message) const;
|
||||
|
||||
@@ -79,7 +79,7 @@ class CefExtensionFunctionDetails {
|
||||
// |error_message| can optionally be passed in and will be set with an
|
||||
// appropriate message on error. This method should be called only after
|
||||
// GetBrowserForTabIdFirstTime() has succeeded for the same |tab_id|.
|
||||
CefRefPtr<CefBrowserHostImpl> GetBrowserForTabIdAgain(
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabIdAgain(
|
||||
int tab_id,
|
||||
std::string* error_message) const;
|
||||
|
||||
@@ -114,7 +114,7 @@ class CefExtensionFunctionDetails {
|
||||
// permissions of the extension, the object may or may not include sensitive
|
||||
// data such as the tab's URL.
|
||||
std::unique_ptr<api::tabs::Tab> CreateTabObject(
|
||||
CefRefPtr<CefBrowserHostImpl> new_browser,
|
||||
CefRefPtr<AlloyBrowserHostImpl> new_browser,
|
||||
int opener_browser_id,
|
||||
bool active,
|
||||
int index) const;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
namespace extensions {
|
||||
|
||||
CefExtensionHostDelegate::CefExtensionHostDelegate(
|
||||
CefBrowserHostImpl* browser) {}
|
||||
AlloyBrowserHostImpl* browser) {}
|
||||
|
||||
CefExtensionHostDelegate::~CefExtensionHostDelegate() {}
|
||||
|
||||
@@ -25,7 +25,7 @@ void CefExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
|
||||
|
||||
content::JavaScriptDialogManager*
|
||||
CefExtensionHostDelegate::GetJavaScriptDialogManager() {
|
||||
// Never routed here from CefBrowserHostImpl.
|
||||
// Never routed here from AlloyBrowserHostImpl.
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ void CefExtensionHostDelegate::ProcessMediaAccessRequest(
|
||||
const content::MediaStreamRequest& request,
|
||||
content::MediaResponseCallback callback,
|
||||
const Extension* extension) {
|
||||
// Never routed here from CefBrowserHostImpl.
|
||||
// Never routed here from AlloyBrowserHostImpl.
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ bool CefExtensionHostDelegate::CheckMediaAccessPermission(
|
||||
const GURL& security_origin,
|
||||
blink::mojom::MediaStreamType type,
|
||||
const Extension* extension) {
|
||||
// Never routed here from CefBrowserHostImpl.
|
||||
// Never routed here from AlloyBrowserHostImpl.
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
@@ -8,13 +8,13 @@
|
||||
#include "base/macros.h"
|
||||
#include "extensions/browser/extension_host_delegate.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class CefExtensionHostDelegate : public ExtensionHostDelegate {
|
||||
public:
|
||||
explicit CefExtensionHostDelegate(CefBrowserHostImpl* browser);
|
||||
explicit CefExtensionHostDelegate(AlloyBrowserHostImpl* browser);
|
||||
~CefExtensionHostDelegate() override;
|
||||
|
||||
// ExtensionHostDelegate implementation.
|
||||
|
@@ -21,7 +21,7 @@ using content::WebContentsObserver;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
CefExtensionViewHost::CefExtensionViewHost(CefBrowserHostImpl* browser,
|
||||
CefExtensionViewHost::CefExtensionViewHost(AlloyBrowserHostImpl* browser,
|
||||
const Extension* extension,
|
||||
content::WebContents* host_contents,
|
||||
const GURL& url,
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "extensions/browser/extension_host.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
@@ -22,12 +22,12 @@ namespace extensions {
|
||||
|
||||
// The ExtensionHost for an extension that backs a view in the browser UI. For
|
||||
// example, this could be an extension popup or dialog, but not a background
|
||||
// page. Object lifespan is managed by CefBrowserHostImpl. Based on
|
||||
// page. Object lifespan is managed by AlloyBrowserHostImpl. Based on
|
||||
// chrome/browser/extensions/extension_view_host.h.
|
||||
class CefExtensionViewHost : public ExtensionHost,
|
||||
public content::NotificationObserver {
|
||||
public:
|
||||
CefExtensionViewHost(CefBrowserHostImpl* browser,
|
||||
CefExtensionViewHost(AlloyBrowserHostImpl* browser,
|
||||
const Extension* extension,
|
||||
content::WebContents* host_contents,
|
||||
const GURL& url,
|
||||
|
@@ -7,8 +7,8 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/extensions/component_extension_resource_manager.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/extensions/extension_system_factory.h"
|
||||
@@ -250,7 +250,7 @@ bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
|
||||
return true;
|
||||
}
|
||||
|
||||
CefBrowserHostImpl::CreateParams create_params;
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.url = url;
|
||||
create_params.request_context = request_context;
|
||||
|
||||
@@ -269,8 +269,8 @@ bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
|
||||
|
||||
// Browser creation may fail under certain rare circumstances. Fail the
|
||||
// background host creation in that case.
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::Create(create_params);
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
AlloyBrowserHostImpl::Create(create_params);
|
||||
if (browser) {
|
||||
*host = browser->GetExtensionHost();
|
||||
DCHECK(*host);
|
||||
|
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_content_browser_client.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/osr/web_contents_view_osr.h"
|
||||
|
||||
@@ -27,8 +27,8 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
|
||||
content::WebContents::CreateParams* params) {
|
||||
DCHECK(params->guest_delegate);
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> owner_browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
DCHECK(owner_browser);
|
||||
|
||||
if (owner_browser->IsWindowless()) {
|
||||
@@ -43,8 +43,8 @@ void CefMimeHandlerViewGuestDelegate::OnGuestAttached() {
|
||||
content::WebContents* web_contents = guest_->web_contents();
|
||||
DCHECK(web_contents);
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> owner_browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
DCHECK(owner_browser);
|
||||
|
||||
// Associate guest state information with the owner browser.
|
||||
@@ -56,8 +56,8 @@ void CefMimeHandlerViewGuestDelegate::OnGuestDetached() {
|
||||
content::WebContents* web_contents = guest_->web_contents();
|
||||
DCHECK(web_contents);
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> owner_browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
DCHECK(owner_browser);
|
||||
|
||||
// Disassociate guest state information with the owner browser.
|
||||
@@ -78,8 +78,8 @@ bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
|
||||
new_params.x += guest_coordinates.x();
|
||||
new_params.y += guest_coordinates.y();
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> owner_browser =
|
||||
CefBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
|
||||
DCHECK(owner_browser);
|
||||
|
||||
return owner_browser->HandleContextMenu(web_contents, new_params);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "include/cef_dialog_handler.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "content/public/browser/file_select_listener.h"
|
||||
@@ -140,7 +140,7 @@ class UploadFolderHelper
|
||||
} // namespace
|
||||
|
||||
CefFileDialogManager::CefFileDialogManager(
|
||||
CefBrowserHostImpl* browser,
|
||||
AlloyBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefFileDialogRunner> runner)
|
||||
: browser_(browser),
|
||||
runner_(std::move(runner)),
|
||||
|
@@ -23,19 +23,19 @@ namespace net {
|
||||
class DirectoryLister;
|
||||
}
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
class CefFileDialogManager {
|
||||
public:
|
||||
// |runner| may be NULL if the platform doesn't implement dialogs.
|
||||
CefFileDialogManager(CefBrowserHostImpl* browser,
|
||||
CefFileDialogManager(AlloyBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefFileDialogRunner> runner);
|
||||
~CefFileDialogManager();
|
||||
|
||||
// Delete the runner to free any platform constructs.
|
||||
void Destroy();
|
||||
|
||||
// Called from CefBrowserHostImpl::RunFileChooser.
|
||||
// Called from AlloyBrowserHostImpl::RunFileChooser.
|
||||
// See CefBrowserHost::RunFileDialog documentation.
|
||||
void RunFileDialog(cef_file_dialog_mode_t mode,
|
||||
const CefString& title,
|
||||
@@ -44,7 +44,7 @@ class CefFileDialogManager {
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback);
|
||||
|
||||
// Called from CefBrowserHostImpl::RunFileChooser.
|
||||
// Called from AlloyBrowserHostImpl::RunFileChooser.
|
||||
// See WebContentsDelegate::RunFileChooser documentation.
|
||||
void RunFileChooser(scoped_refptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params);
|
||||
@@ -86,8 +86,8 @@ class CefFileDialogManager {
|
||||
// Clean up state associated with the last run.
|
||||
void Cleanup();
|
||||
|
||||
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
|
||||
CefBrowserHostImpl* browser_;
|
||||
// AlloyBrowserHostImpl pointer is guaranteed to outlive this object.
|
||||
AlloyBrowserHostImpl* browser_;
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner> runner_;
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
class CefFileDialogRunner {
|
||||
public:
|
||||
@@ -34,7 +34,7 @@ class CefFileDialogRunner {
|
||||
RunFileChooserCallback;
|
||||
|
||||
// Display the file chooser dialog. Execute |callback| on completion.
|
||||
virtual void Run(CefBrowserHostImpl* browser,
|
||||
virtual void Run(AlloyBrowserHostImpl* browser,
|
||||
const FileChooserParams& params,
|
||||
RunFileChooserCallback callback) = 0;
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "include/cef_stream.h"
|
||||
#include "include/cef_v8.h"
|
||||
#include "include/test/cef_test_helpers.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/navigate_params.h"
|
||||
#include "libcef/browser/net_service/browser_urlrequest_impl.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/task_runner_impl.h"
|
||||
|
||||
#include "content/browser/frame_host/frame_tree_node.h"
|
||||
#include "content/browser/renderer_host/frame_tree_node.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
|
||||
@@ -45,7 +45,7 @@ class ViewTextHandler : public CefResponseManager::Handler {
|
||||
void OnResponse(const Cef_Response_Params& params) override {
|
||||
CefRefPtr<CefBrowser> browser = frame_->GetBrowser();
|
||||
if (browser.get()) {
|
||||
static_cast<CefBrowserHostImpl*>(browser.get())
|
||||
static_cast<CefBrowserHostBase*>(browser.get())
|
||||
->ViewText(params.response);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ void CefFrameHostImpl::SetRenderFrameHost(content::RenderFrameHost* host) {
|
||||
}
|
||||
|
||||
bool CefFrameHostImpl::IsValid() {
|
||||
return !!GetBrowserHostImpl();
|
||||
return !!GetBrowserHostBase();
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::Undo() {
|
||||
@@ -203,7 +203,7 @@ CefRefPtr<CefFrame> CefFrameHostImpl::GetParent() {
|
||||
parent_frame_id = parent_frame_id_;
|
||||
}
|
||||
|
||||
auto browser = GetBrowserHostImpl();
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (browser)
|
||||
return browser->GetFrame(parent_frame_id);
|
||||
|
||||
@@ -216,7 +216,7 @@ CefString CefFrameHostImpl::GetURL() {
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefFrameHostImpl::GetBrowser() {
|
||||
return GetBrowserHostImpl().get();
|
||||
return GetBrowserHostBase().get();
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Context> CefFrameHostImpl::GetV8Context() {
|
||||
@@ -239,7 +239,7 @@ CefRefPtr<CefURLRequest> CefFrameHostImpl::CreateURLRequest(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto browser = GetBrowserHostImpl();
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (!browser)
|
||||
return nullptr;
|
||||
|
||||
@@ -306,8 +306,7 @@ void CefFrameHostImpl::Navigate(const CefNavigateParams& params) {
|
||||
CefMsg_LoadRequest_Params request;
|
||||
request.url = params.url;
|
||||
if (!request.url.is_valid()) {
|
||||
LOG(ERROR) << "Invalid URL passed to CefFrameHostImpl::Navigate: "
|
||||
<< params.url;
|
||||
LOG(ERROR) << "Invalid URL: " << params.url;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -323,7 +322,7 @@ void CefFrameHostImpl::Navigate(const CefNavigateParams& params) {
|
||||
|
||||
Send(new CefMsg_LoadRequest(MSG_ROUTING_NONE, request));
|
||||
|
||||
auto browser = GetBrowserHostImpl();
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (browser)
|
||||
browser->OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
||||
}
|
||||
@@ -337,14 +336,30 @@ void CefFrameHostImpl::LoadURLWithExtras(const std::string& url,
|
||||
if (frame_id < CefFrameHostImpl::kMainFrameId)
|
||||
return;
|
||||
|
||||
GURL gurl(url);
|
||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||
// Try to add "http://" at the beginning.
|
||||
std::string new_url = std::string("http://") + url;
|
||||
gurl = GURL(new_url);
|
||||
}
|
||||
if (!gurl.is_valid()) {
|
||||
LOG(ERROR) << "Invalid URL: " << url;
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame_id == CefFrameHostImpl::kMainFrameId) {
|
||||
// Load via the browser using NavigationController.
|
||||
auto browser = GetBrowserHostImpl();
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (browser) {
|
||||
browser->LoadMainFrameURL(url, referrer, transition, extra_headers);
|
||||
content::OpenURLParams params(
|
||||
gurl, referrer, WindowOpenDisposition::CURRENT_TAB, transition,
|
||||
/*is_renderer_initiated=*/false);
|
||||
params.extra_headers = extra_headers;
|
||||
|
||||
browser->LoadMainFrameURL(params);
|
||||
}
|
||||
} else {
|
||||
CefNavigateParams params(GURL(url), transition);
|
||||
CefNavigateParams params(gurl, transition);
|
||||
params.referrer = referrer;
|
||||
params.headers = extra_headers;
|
||||
Navigate(params);
|
||||
@@ -553,7 +568,7 @@ int64 CefFrameHostImpl::GetFrameId() const {
|
||||
return is_main_frame_ ? kMainFrameId : frame_id_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> CefFrameHostImpl::GetBrowserHostImpl() const {
|
||||
CefRefPtr<CefBrowserHostBase> CefFrameHostImpl::GetBrowserHostBase() const {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
if (browser_info_)
|
||||
return browser_info_->browser();
|
||||
@@ -572,14 +587,14 @@ void CefFrameHostImpl::OnAttached() {
|
||||
|
||||
void CefFrameHostImpl::OnDidFinishLoad(const GURL& validated_url,
|
||||
int http_status_code) {
|
||||
auto browser = GetBrowserHostImpl();
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (browser)
|
||||
browser->OnDidFinishLoad(this, validated_url, http_status_code);
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::OnUpdateDraggableRegions(
|
||||
const std::vector<Cef_DraggableRegion_Params>& regions) {
|
||||
auto browser = GetBrowserHostImpl();
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (!browser)
|
||||
return;
|
||||
|
||||
@@ -611,12 +626,12 @@ void CefFrameHostImpl::OnRequest(const Cef_Request_Params& params) {
|
||||
bool expect_response_ack = false;
|
||||
|
||||
if (params.user_initiated) {
|
||||
auto browser = GetBrowserHostImpl();
|
||||
if (browser && browser->client()) {
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (browser && browser->GetClient()) {
|
||||
// Give the user a chance to handle the request.
|
||||
CefRefPtr<CefProcessMessageImpl> message(new CefProcessMessageImpl(
|
||||
const_cast<Cef_Request_Params*>(¶ms), false, true));
|
||||
success = browser->client()->OnProcessMessageReceived(
|
||||
success = browser->GetClient()->OnProcessMessageReceived(
|
||||
browser.get(), this, PID_RENDERER, message.get());
|
||||
message->Detach(nullptr);
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ struct Cef_DraggableRegion_Params;
|
||||
struct Cef_Request_Params;
|
||||
struct Cef_Response_Params;
|
||||
class CefBrowserInfo;
|
||||
class CefBrowserHostImpl;
|
||||
class CefBrowserHostBase;
|
||||
struct CefNavigateParams;
|
||||
|
||||
// Implementation of CefFrame. CefFrameHostImpl objects should always be created
|
||||
@@ -112,10 +112,10 @@ class CefFrameHostImpl : public CefFrame {
|
||||
const std::string& scriptUrl,
|
||||
int startLine);
|
||||
|
||||
// Called from CefBrowserHostImpl::DidStopLoading.
|
||||
// Called from CefBrowserHostBase::DidStopLoading.
|
||||
void MaybeSendDidStopLoading();
|
||||
|
||||
// Called from CefBrowserHostImpl::OnMessageReceived.
|
||||
// Called from CefBrowserHostBase::OnMessageReceived.
|
||||
bool OnMessageReceived(const IPC::Message& message);
|
||||
|
||||
void ExecuteJavaScriptWithUserGestureForTests(const CefString& javascript);
|
||||
@@ -145,7 +145,7 @@ class CefFrameHostImpl : public CefFrame {
|
||||
|
||||
private:
|
||||
int64 GetFrameId() const;
|
||||
CefRefPtr<CefBrowserHostImpl> GetBrowserHostImpl() const;
|
||||
CefRefPtr<CefBrowserHostBase> GetBrowserHostBase() const;
|
||||
|
||||
// OnMessageReceived message handlers.
|
||||
void OnAttached();
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
@@ -63,7 +63,7 @@ class CefJSDialogCallbackImpl : public CefJSDialogCallback {
|
||||
} // namespace
|
||||
|
||||
CefJavaScriptDialogManager::CefJavaScriptDialogManager(
|
||||
CefBrowserHostImpl* browser,
|
||||
AlloyBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> runner)
|
||||
: browser_(browser),
|
||||
runner_(std::move(runner)),
|
||||
@@ -144,7 +144,7 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
bool is_reload,
|
||||
DialogClosedCallback callback) {
|
||||
if (browser_->destruction_state() >=
|
||||
CefBrowserHostImpl::DESTRUCTION_STATE_ACCEPTED) {
|
||||
AlloyBrowserHostImpl::DESTRUCTION_STATE_ACCEPTED) {
|
||||
// Currently destroying the browser. Accept the unload without showing
|
||||
// the prompt.
|
||||
std::move(callback).Run(true, base::string16());
|
||||
|
@@ -15,12 +15,12 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/public/browser/javascript_dialog_manager.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
public:
|
||||
// |runner| may be NULL if the platform doesn't implement dialogs.
|
||||
CefJavaScriptDialogManager(CefBrowserHostImpl* browser,
|
||||
CefJavaScriptDialogManager(AlloyBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> runner);
|
||||
~CefJavaScriptDialogManager() override;
|
||||
|
||||
@@ -48,8 +48,8 @@ class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
bool success,
|
||||
const base::string16& user_input);
|
||||
|
||||
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
|
||||
CefBrowserHostImpl* browser_;
|
||||
// AlloyBrowserHostImpl pointer is guaranteed to outlive this object.
|
||||
AlloyBrowserHostImpl* browser_;
|
||||
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> runner_;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include "base/strings/string16.h"
|
||||
#include "content/public/common/javascript_dialog_type.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class AlloyBrowserHostImpl;
|
||||
|
||||
class CefJavaScriptDialogRunner {
|
||||
public:
|
||||
@@ -20,7 +20,7 @@ class CefJavaScriptDialogRunner {
|
||||
DialogClosedCallback;
|
||||
|
||||
// Run the dialog. Execute |callback| on completion.
|
||||
virtual void Run(CefBrowserHostImpl* browser,
|
||||
virtual void Run(AlloyBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
|
@@ -21,11 +21,12 @@
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "content/app/content_service_manager_main_delegate.h"
|
||||
#include "content/app/content_main_runner_impl.h"
|
||||
#include "content/browser/scheduler/browser_task_executor.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
#include "content/public/app/content_main_runner.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "services/service_manager/embedder/main.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <Objbase.h>
|
||||
@@ -362,7 +363,10 @@ int CefMainRunner::ContentMainInitialize(const CefMainArgs& args,
|
||||
main_delegate_->BeforeMainThreadInitialize(args);
|
||||
|
||||
// Initialize the content runner.
|
||||
content::ContentMainParams params(main_delegate_->GetContentMainDelegate());
|
||||
main_runner_ = content::ContentMainRunner::Create();
|
||||
main_params_ = std::make_unique<content::ContentMainParams>(
|
||||
main_delegate_->GetContentMainDelegate());
|
||||
|
||||
#if defined(OS_WIN)
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
||||
if (windows_sandbox_info == nullptr) {
|
||||
@@ -370,25 +374,15 @@ int CefMainRunner::ContentMainInitialize(const CefMainArgs& args,
|
||||
*no_sandbox = true;
|
||||
}
|
||||
|
||||
params.instance = args.instance;
|
||||
params.sandbox_info =
|
||||
main_params_->instance = args.instance;
|
||||
main_params_->sandbox_info =
|
||||
static_cast<sandbox::SandboxInterfaceInfo*>(windows_sandbox_info);
|
||||
#else
|
||||
params.argc = args.argc;
|
||||
params.argv = const_cast<const char**>(args.argv);
|
||||
main_params_->argc = args.argc;
|
||||
main_params_->argv = const_cast<const char**>(args.argv);
|
||||
#endif
|
||||
|
||||
sm_main_delegate_.reset(
|
||||
new content::ContentServiceManagerMainDelegate(params));
|
||||
sm_main_params_.reset(
|
||||
new service_manager::MainParams(sm_main_delegate_.get()));
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
sm_main_params_->argc = params.argc;
|
||||
sm_main_params_->argv = params.argv;
|
||||
#endif
|
||||
|
||||
return service_manager::MainInitialize(*sm_main_params_);
|
||||
return content::ContentMainInitialize(*main_params_, main_runner_.get());
|
||||
}
|
||||
|
||||
bool CefMainRunner::ContentMainRun(bool* initialized,
|
||||
@@ -402,7 +396,8 @@ bool CefMainRunner::ContentMainRun(bool* initialized,
|
||||
|
||||
if (!CreateUIThread(base::BindOnce(
|
||||
[](CefMainRunner* runner, base::WaitableEvent* event) {
|
||||
service_manager::MainRun(*runner->sm_main_params_);
|
||||
content::ContentMainRun(*runner->main_params_,
|
||||
runner->main_runner_.get());
|
||||
event->Signal();
|
||||
},
|
||||
base::Unretained(this),
|
||||
@@ -412,11 +407,11 @@ bool CefMainRunner::ContentMainRun(bool* initialized,
|
||||
|
||||
*initialized = true;
|
||||
|
||||
// We need to wait until service_manager::MainRun has finished.
|
||||
// We need to wait until content::ContentMainRun has finished.
|
||||
uithread_startup_event.Wait();
|
||||
} else {
|
||||
*initialized = true;
|
||||
service_manager::MainRun(*sm_main_params_);
|
||||
content::ContentMainRun(*main_params_, main_runner_.get());
|
||||
}
|
||||
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
@@ -484,7 +479,8 @@ void CefMainRunner::FinishShutdownOnUIThread(
|
||||
base::WaitableEvent* uithread_shutdown_event) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
sm_main_delegate_->ShutdownOnUIThread();
|
||||
static_cast<content::ContentMainRunnerImpl*>(main_runner_.get())
|
||||
->ShutdownOnUIThread();
|
||||
|
||||
std::move(shutdown_on_ui_thread).Run();
|
||||
main_delegate_->AfterUIThreadShutdown();
|
||||
@@ -508,10 +504,10 @@ void CefMainRunner::FinalizeShutdown(base::OnceClosure finalize_shutdown) {
|
||||
}
|
||||
|
||||
// Shut down the content runner.
|
||||
service_manager::MainShutdown(*sm_main_params_);
|
||||
content::ContentMainShutdown(*main_params_, main_runner_.get());
|
||||
|
||||
sm_main_params_.reset();
|
||||
sm_main_delegate_.reset();
|
||||
main_params_.reset();
|
||||
main_runner_.reset();
|
||||
|
||||
std::move(finalize_shutdown).Run();
|
||||
main_delegate_->AfterMainThreadShutdown();
|
||||
|
@@ -20,15 +20,10 @@ class WaitableEvent;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
class ContentMainDelegate;
|
||||
class ContentServiceManagerMainDelegate;
|
||||
struct MainFunctionParams;
|
||||
class ContentMainRunner;
|
||||
struct ContentMainParams;
|
||||
} // namespace content
|
||||
|
||||
namespace service_manager {
|
||||
struct MainParams;
|
||||
}
|
||||
|
||||
class CefUIThread;
|
||||
|
||||
// Manages the main process lifespan and related objects.
|
||||
@@ -87,8 +82,8 @@ class CefMainRunner : public CefMainRunnerHandler {
|
||||
const bool external_message_pump_;
|
||||
|
||||
std::unique_ptr<CefMainRunnerDelegate> main_delegate_;
|
||||
std::unique_ptr<content::ContentServiceManagerMainDelegate> sm_main_delegate_;
|
||||
std::unique_ptr<service_manager::MainParams> sm_main_params_;
|
||||
std::unique_ptr<content::ContentMainRunner> main_runner_;
|
||||
std::unique_ptr<content::ContentMainParams> main_params_;
|
||||
|
||||
std::unique_ptr<content::BrowserMainRunner> browser_runner_;
|
||||
std::unique_ptr<CefUIThread> ui_thread_;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "include/cef_media_router.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
|
||||
#include "chrome/common/media_router/media_route.h"
|
||||
#include "components/media_router/common/media_route.h"
|
||||
|
||||
// Implementation of the CefMediaRoute interface. Only created on the UI thread.
|
||||
class CefMediaRouteImpl : public CefMediaRoute {
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "include/cef_media_router.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
|
||||
#include "chrome/common/media_router/mojom/media_router.mojom.h"
|
||||
#include "components/media_router/common/mojom/media_router.mojom.h"
|
||||
|
||||
class CefRegistrationImpl;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user