mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5891c702da | ||
|
30ad80538e | ||
|
c10d4193c4 | ||
|
78d7da8ddb | ||
|
20ed841c87 | ||
|
e1054005e4 | ||
|
f7fefe5539 | ||
|
e73afd80e4 | ||
|
1389ac0dcd | ||
|
cbdc66c0ab | ||
|
ce13240080 | ||
|
354064ae76 | ||
|
b945c64d32 | ||
|
7898ddafeb | ||
|
3c626b5d6e | ||
|
e893e40d43 | ||
|
bb70d0418f | ||
|
51a21c3607 | ||
|
9068a8ec76 | ||
|
06acb7e3d3 | ||
|
4e748875b3 | ||
|
90cb746cdc | ||
|
d763e7c065 | ||
|
a24774f12c | ||
|
b10a8226b5 | ||
|
29106f2834 | ||
|
333b8be6e7 | ||
|
358d7731b2 | ||
|
ce39d6e185 | ||
|
7c525b84aa | ||
|
2301d8d345 |
45
BUILD.gn
45
BUILD.gn
@@ -106,7 +106,6 @@ import("//media/media_options.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
import("//ppapi/buildflags/buildflags.gni")
|
||||
import("//printing/buildflags/buildflags.gni")
|
||||
import("//rlz/buildflags/buildflags.gni")
|
||||
import("//testing/test.gni")
|
||||
import("//third_party/icu/config.gni")
|
||||
import("//third_party/widevine/cdm/widevine.gni")
|
||||
@@ -258,14 +257,6 @@ assert(enable_print_preview)
|
||||
# Enable support for Widevine CDM.
|
||||
assert(enable_widevine)
|
||||
|
||||
if (is_mac || is_win) {
|
||||
# Enable Widevine CDM host verification and storage ID.
|
||||
assert(enable_cdm_host_verification)
|
||||
assert(enable_cdm_storage_id)
|
||||
assert(alternate_cdm_storage_id_key != "")
|
||||
assert(enable_rlz)
|
||||
}
|
||||
|
||||
# Enable Views UI framework.
|
||||
assert(toolkit_views)
|
||||
|
||||
@@ -611,8 +602,6 @@ source_set("libcef_static") {
|
||||
"libcef/browser/frame_host_impl.cc",
|
||||
"libcef/browser/frame_host_impl.h",
|
||||
"libcef/browser/frame_service_base.h",
|
||||
"libcef/browser/global_preference_manager_impl.cc",
|
||||
"libcef/browser/global_preference_manager_impl.h",
|
||||
"libcef/browser/image_impl.cc",
|
||||
"libcef/browser/image_impl.h",
|
||||
"libcef/browser/iothread_state.cc",
|
||||
@@ -711,18 +700,14 @@ source_set("libcef_static") {
|
||||
"libcef/browser/permission_prompt.h",
|
||||
"libcef/browser/prefs/browser_prefs.cc",
|
||||
"libcef/browser/prefs/browser_prefs.h",
|
||||
"libcef/browser/prefs/pref_helper.cc",
|
||||
"libcef/browser/prefs/pref_helper.h",
|
||||
"libcef/browser/prefs/pref_registrar.cc",
|
||||
"libcef/browser/prefs/pref_registrar.h",
|
||||
"libcef/browser/prefs/pref_store.cc",
|
||||
"libcef/browser/prefs/pref_store.h",
|
||||
"libcef/browser/prefs/renderer_prefs.cc",
|
||||
"libcef/browser/prefs/renderer_prefs.h",
|
||||
"libcef/browser/print_settings_impl.cc",
|
||||
"libcef/browser/print_settings_impl.h",
|
||||
"libcef/browser/printing/print_util.cc",
|
||||
"libcef/browser/printing/print_util.h",
|
||||
"libcef/browser/printing/print_view_manager.cc",
|
||||
"libcef/browser/printing/print_view_manager.h",
|
||||
"libcef/browser/process_util_impl.cc",
|
||||
"libcef/browser/request_context_handler_map.cc",
|
||||
"libcef/browser/request_context_handler_map.h",
|
||||
@@ -1180,13 +1165,6 @@ source_set("libcef_static") {
|
||||
"//ui/wm/public",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_cdm_host_verification) {
|
||||
sources += [
|
||||
"libcef/common/cdm_host_file_path.cc",
|
||||
"libcef/common/cdm_host_file_path.h",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1216,21 +1194,6 @@ config("libcef_dll_wrapper_config") {
|
||||
]
|
||||
|
||||
configs = [ ":libcef_autogen_config" ]
|
||||
|
||||
if (is_win) {
|
||||
if (current_cpu == "x86") {
|
||||
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
|
||||
# needed by CEF's main thread. This saves significant memory on threads
|
||||
# (like those in the Windows thread pool, and others) whose stack size we
|
||||
# can only control through this setting. The main thread (in 32-bit builds
|
||||
# only) uses fibers to switch to a 4MiB stack at runtime via
|
||||
# CefRunWinMainWithPreferredStackSize().
|
||||
ldflags = [ "/STACK:0x80000" ]
|
||||
} else {
|
||||
# Increase the initial stack size to 8MiB from the default 1MiB.
|
||||
ldflags = [ "/STACK:0x800000" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# libcef_dll_wrapper target.
|
||||
@@ -1398,7 +1361,7 @@ make_pack_header("strings") {
|
||||
"$root_gen_dir/chrome/grit/generated_resources.h",
|
||||
"$root_gen_dir/chrome/grit/locale_settings.h",
|
||||
"$root_gen_dir/chrome/grit/platform_locale_settings.h",
|
||||
"$root_gen_dir/components/omnibox/resources/grit/omnibox_pedal_synonyms.h",
|
||||
"$root_gen_dir/components/omnibox/resources/grit/omnibox_resources.h",
|
||||
"$root_gen_dir/components/strings/grit/components_chromium_strings.h",
|
||||
"$root_gen_dir/components/strings/grit/components_strings.h",
|
||||
"$root_gen_dir/extensions/strings/grit/extensions_strings.h",
|
||||
@@ -1414,7 +1377,7 @@ make_pack_header("strings") {
|
||||
"//chrome/app:generated_resources",
|
||||
"//chrome/app/resources:locale_settings",
|
||||
"//chrome/app/resources:platform_locale_settings",
|
||||
"//components/omnibox/resources:omnibox_pedal_synonyms",
|
||||
"//components/omnibox/resources:omnibox_resources",
|
||||
"//components/strings:components_chromium_strings",
|
||||
"//components/strings:components_locale_settings",
|
||||
"//components/strings:components_strings",
|
||||
|
@@ -7,6 +7,6 @@
|
||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||
|
||||
{
|
||||
'chromium_checkout': 'refs/tags/108.0.5359.125',
|
||||
'depot_tools_checkout': '64b6175557'
|
||||
'chromium_checkout': 'refs/tags/106.0.5249.119',
|
||||
'depot_tools_checkout': 'b7ec673ccc'
|
||||
}
|
||||
|
@@ -33,6 +33,8 @@
|
||||
'chrome/browser/extensions/chrome_extension_web_contents_observer.*',
|
||||
'chrome/browser/extensions/component_loader.*',
|
||||
'chrome/browser/extensions/extension_service.*',
|
||||
'chrome/browser/printing/print_view_manager*',
|
||||
'chrome/browser/printing/printing_message_filter*',
|
||||
'chrome/browser/profiles/profile.h',
|
||||
'chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.*',
|
||||
'chrome/common/extensions/api/*_features.json',
|
||||
|
3
Doxyfile
3
Doxyfile
@@ -2375,8 +2375,7 @@ PREDEFINED = USING_CEF_SHARED \
|
||||
OS_WIN \
|
||||
OS_LINUX \
|
||||
CEF_X11 \
|
||||
OS_MAC \
|
||||
ARCH_CPU_32_BITS
|
||||
OS_MAC
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
|
@@ -8,7 +8,7 @@
|
||||
# by hand. See the translator.README.txt file in the tools directory for
|
||||
# more information.
|
||||
#
|
||||
# $hash=0373d7e3fc02d16a128a5891aac70af56fb9ddc1$
|
||||
# $hash=ffc0502a0275b74228f1fd642566d3f020e538a0$
|
||||
#
|
||||
|
||||
{
|
||||
@@ -56,7 +56,6 @@
|
||||
'include/cef_parser.h',
|
||||
'include/cef_path_util.h',
|
||||
'include/cef_permission_handler.h',
|
||||
'include/cef_preference.h',
|
||||
'include/cef_print_handler.h',
|
||||
'include/cef_print_settings.h',
|
||||
'include/cef_process_message.h',
|
||||
@@ -160,7 +159,6 @@
|
||||
'include/capi/cef_parser_capi.h',
|
||||
'include/capi/cef_path_util_capi.h',
|
||||
'include/capi/cef_permission_handler_capi.h',
|
||||
'include/capi/cef_preference_capi.h',
|
||||
'include/capi/cef_print_handler_capi.h',
|
||||
'include/capi/cef_print_settings_capi.h',
|
||||
'include/capi/cef_process_message_capi.h',
|
||||
@@ -384,10 +382,6 @@
|
||||
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
||||
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
|
||||
'libcef_dll/cpptoc/preference_manager_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/preference_manager_cpptoc.h',
|
||||
'libcef_dll/cpptoc/preference_registrar_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/preference_registrar_cpptoc.h',
|
||||
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
||||
@@ -712,10 +706,6 @@
|
||||
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
||||
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
|
||||
'libcef_dll/ctocpp/preference_manager_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/preference_manager_ctocpp.h',
|
||||
'libcef_dll/ctocpp/preference_registrar_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/preference_registrar_ctocpp.h',
|
||||
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
||||
|
@@ -79,7 +79,6 @@
|
||||
'include/internal/cef_win.h',
|
||||
],
|
||||
'includes_win_capi': [
|
||||
'include/internal/cef_app_win.h',
|
||||
'include/internal/cef_types_win.h',
|
||||
],
|
||||
'includes_mac': [
|
||||
@@ -234,8 +233,6 @@
|
||||
'tests/cefclient/browser/client_handler_osr.h',
|
||||
'tests/cefclient/browser/client_handler_std.cc',
|
||||
'tests/cefclient/browser/client_handler_std.h',
|
||||
'tests/cefclient/browser/client_prefs.cc',
|
||||
'tests/cefclient/browser/client_prefs.h',
|
||||
'tests/cefclient/browser/client_types.h',
|
||||
'tests/cefclient/browser/dialog_test.cc',
|
||||
'tests/cefclient/browser/dialog_test.h',
|
||||
|
@@ -448,23 +448,6 @@ if(OS_WINDOWS)
|
||||
NDEBUG _NDEBUG # Not a debug build
|
||||
)
|
||||
|
||||
if(PROJECT_ARCH STREQUAL "x86")
|
||||
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
|
||||
# needed by CEF's main thread. This saves significant memory on threads
|
||||
# (like those in the Windows thread pool, and others) whose stack size we
|
||||
# can only control through this setting. The main thread (in 32-bit builds
|
||||
# only) uses fibers to switch to a 4MiB stack at runtime via
|
||||
# CefRunWinMainWithPreferredStackSize().
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||
/STACK:0x8000
|
||||
)
|
||||
else()
|
||||
# Increase the initial stack size to 8MiB from the default 1MiB.
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||
/STACK:0x800000
|
||||
)
|
||||
endif()
|
||||
|
||||
# Standard libraries.
|
||||
set(CEF_STANDARD_LIBS
|
||||
comctl32.lib
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=2f4bdc6adde5defdc86dbb5c998266d6372dd164$
|
||||
// $hash=7c6894aae3e508aaa42a376532328316d9bd509c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||
@@ -183,6 +183,19 @@ CEF_EXPORT void cef_run_message_loop(void);
|
||||
///
|
||||
CEF_EXPORT void cef_quit_message_loop(void);
|
||||
|
||||
///
|
||||
/// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
|
||||
/// modal message loop. Set to false (0) after exiting the modal message loop.
|
||||
///
|
||||
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
|
||||
|
||||
///
|
||||
/// Call during process startup to enable High-DPI support on Windows 7 or
|
||||
/// newer. Older versions of Windows should be left DPI-unaware because they do
|
||||
/// not support DirectWrite and GDI fonts are kerned very badly.
|
||||
///
|
||||
CEF_EXPORT void cef_enable_highdpi_support(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=a4d3026623111f1ba226d1579c6b03de3b924457$
|
||||
// $hash=c4ed4278e513daa2a1ccf42e50e242d61dfbb86f$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
@@ -43,7 +43,6 @@
|
||||
#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_preference_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -61,33 +60,6 @@ typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Provides an opportunity to register custom preferences prior to global and
|
||||
/// request context initialization.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
|
||||
/// OnContextInitialized is called. Global preferences are registered a single
|
||||
/// time at application startup. See related cef_settings_t.cache_path and
|
||||
/// cef_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||
/// accessed via the cef_request_context_t after
|
||||
/// cef_request_context_handler_t::OnRequestContextInitialized is called.
|
||||
/// Request context preferences are registered each time a new
|
||||
/// cef_request_context_t is created. It is intended but not required that all
|
||||
/// request contexts have the same registered preferences. See related
|
||||
/// cef_request_context_settings_t.cache_path and
|
||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// Do not keep a reference to the |registrar| object. This function is called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
void(CEF_CALLBACK* on_register_custom_preferences)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
cef_preferences_type_t type,
|
||||
struct _cef_preference_registrar_t* registrar);
|
||||
|
||||
///
|
||||
/// Called on the browser process UI thread immediately after the CEF context
|
||||
/// has been initialized.
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=f6dfdfa5b8c77931d8e083a66f5a9445a2fdbf45$
|
||||
// $hash=a6cb0abd77320cfd9ddfa3f16ca0a6ff3987521a$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_
|
||||
@@ -46,14 +46,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Combines specified |base_url| and |relative_url| into |resolved_url|.
|
||||
/// Returns false (0) if one of the URLs is NULL or invalid.
|
||||
///
|
||||
CEF_EXPORT int cef_resolve_url(const cef_string_t* base_url,
|
||||
const cef_string_t* relative_url,
|
||||
cef_string_t* resolved_url);
|
||||
|
||||
///
|
||||
/// Parse the specified |url| into its component parts. Returns false (0) if the
|
||||
/// URL is NULL or invalid.
|
||||
|
@@ -1,148 +0,0 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=eac0782793e7b9c64668f2a22a859357257140ea$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Structure that manages custom preference registrations.
|
||||
///
|
||||
typedef struct _cef_preference_registrar_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_scoped_t base;
|
||||
|
||||
///
|
||||
/// Register a preference with the specified |name| and |default_value|. To
|
||||
/// avoid conflicts with built-in preferences the |name| value should contain
|
||||
/// an application-specific prefix followed by a period (e.g. "myapp.value").
|
||||
/// The contents of |default_value| will be copied. The data type for the
|
||||
/// preference will be inferred from |default_value|'s type and cannot be
|
||||
/// changed after registration. Returns true (1) on success. Returns false (0)
|
||||
/// if |name| is already registered or if |default_value| has an invalid type.
|
||||
/// This function must be called from within the scope of the
|
||||
/// cef_browser_process_handler_t::OnRegisterCustomPreferences callback.
|
||||
///
|
||||
int(CEF_CALLBACK* add_preference)(struct _cef_preference_registrar_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* default_value);
|
||||
} cef_preference_registrar_t;
|
||||
|
||||
///
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
/// cef_browser_process_handler_t::OnRegisterCustomPreferences.
|
||||
///
|
||||
typedef struct _cef_preference_manager_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This function must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
int include_defaults);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* can_set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true (1) if the
|
||||
/// value is set successfully and false (0) otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* value,
|
||||
cef_string_t* error);
|
||||
} cef_preference_manager_t;
|
||||
|
||||
///
|
||||
/// Returns the global preference manager object.
|
||||
///
|
||||
CEF_EXPORT cef_preference_manager_t* cef_preference_manager_get_global(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
|
@@ -1,116 +0,0 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=1f5dd49cfc5aeb4b673c10750de01768f5cd2694$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Manage access to preferences.
|
||||
///
|
||||
typedef struct _cef_preference_manager_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This function must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
int include_defaults);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* can_set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true (1) if the
|
||||
/// value is set successfully and false (0) otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* value,
|
||||
cef_string_t* error);
|
||||
} cef_preference_manager_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=62f9dd603840149334ecd1f25222dbda0682b0e6$
|
||||
// $hash=0c12192146d0ecf006c1f3f294a4c2fd4bec484b$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "include/capi/cef_extension_capi.h"
|
||||
#include "include/capi/cef_extension_handler_capi.h"
|
||||
#include "include/capi/cef_media_router_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -93,7 +93,7 @@ typedef struct _cef_request_context_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_preference_manager_t base;
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is pointing to the same context as |that|
|
||||
@@ -165,6 +165,58 @@ typedef struct _cef_request_context_t {
|
||||
int(CEF_CALLBACK* clear_scheme_handler_factories)(
|
||||
struct _cef_request_context_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_preference)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
|
||||
struct _cef_request_context_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This function must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
|
||||
struct _cef_request_context_t* self,
|
||||
int include_defaults);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* can_set_preference)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true (1) if the
|
||||
/// value is set successfully and false (0) otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* set_preference)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* value,
|
||||
cef_string_t* error);
|
||||
|
||||
///
|
||||
/// Clears all certificate exceptions that were added as part of handling
|
||||
/// cef_request_handler_t::on_certificate_error(). If you call this it is
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=c25acf0c0dde9bbd8b9b3526e161aaa9e00445c8$
|
||||
// $hash=e2a1abf4d73bb90fb077cc5642d7b95ac5c11c14$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/capi/cef_request_capi.h"
|
||||
#include "include/capi/cef_resource_request_handler_capi.h"
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=b8af0d090bcb54f99d98804f7e3aaa0eab24449a$
|
||||
// $hash=98f6d1c93609958fa457c15d7f6fef56fac7e3f6$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_
|
||||
@@ -454,11 +454,6 @@ typedef struct _cef_v8value_t {
|
||||
///
|
||||
int(CEF_CALLBACK* is_function)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
/// True if the value type is a Promise.
|
||||
///
|
||||
int(CEF_CALLBACK* is_promise)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
@@ -723,27 +718,6 @@ typedef struct _cef_v8value_t {
|
||||
struct _cef_v8value_t* object,
|
||||
size_t argumentsCount,
|
||||
struct _cef_v8value_t* const* arguments);
|
||||
|
||||
///
|
||||
/// Resolve the Promise using the current V8 context. This function should
|
||||
/// only be called from within the scope of a cef_v8handler_t or
|
||||
/// cef_v8accessor_t callback, or in combination with calling enter() and
|
||||
/// exit() on a stored cef_v8context_t reference. |arg| is the argument passed
|
||||
/// to the resolved promise. Returns true (1) on success. Returns false (0) if
|
||||
/// this function is called incorrectly or an exception is thrown.
|
||||
///
|
||||
int(CEF_CALLBACK* resolve_promise)(struct _cef_v8value_t* self,
|
||||
struct _cef_v8value_t* arg);
|
||||
|
||||
///
|
||||
/// Reject the Promise using the current V8 context. This function should only
|
||||
/// be called from within the scope of a cef_v8handler_t or cef_v8accessor_t
|
||||
/// callback, or in combination with calling enter() and exit() on a stored
|
||||
/// cef_v8context_t reference. Returns true (1) on success. Returns false (0)
|
||||
/// if this function is called incorrectly or an exception is thrown.
|
||||
///
|
||||
int(CEF_CALLBACK* reject_promise)(struct _cef_v8value_t* self,
|
||||
const cef_string_t* errorMsg);
|
||||
} cef_v8value_t;
|
||||
|
||||
///
|
||||
@@ -834,14 +808,6 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_array_buffer(
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name,
|
||||
cef_v8handler_t* handler);
|
||||
|
||||
///
|
||||
/// Create a new cef_v8value_t object of type Promise. This function should only
|
||||
/// be called from within the scope of a cef_render_process_handler_t,
|
||||
/// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
|
||||
/// enter() and exit() on a stored cef_v8context_t reference.
|
||||
///
|
||||
CEF_EXPORT cef_v8value_t* cef_v8value_create_promise(void);
|
||||
|
||||
///
|
||||
/// Structure representing a V8 stack trace handle. V8 handles can only be
|
||||
/// accessed from the thread on which they are created. Valid threads for
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=912c23bc842c87aeca79780746c31e3fe848013a$
|
||||
// $hash=6eed21d200bad5e898dfbe2701ad327cc1e4cc5c$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_DISPLAY_CAPI_H_
|
||||
@@ -154,20 +154,6 @@ cef_display_convert_screen_point_to_pixels(const cef_point_t* point);
|
||||
CEF_EXPORT cef_point_t
|
||||
cef_display_convert_screen_point_from_pixels(const cef_point_t* point);
|
||||
|
||||
///
|
||||
/// Convert |rect| from DIP screen coordinates to pixel screen coordinates. This
|
||||
/// function is only used on Windows.
|
||||
///
|
||||
CEF_EXPORT cef_rect_t
|
||||
cef_display_convert_screen_rect_to_pixels(const cef_rect_t* rect);
|
||||
|
||||
///
|
||||
/// Convert |rect| from pixel screen coordinates to DIP screen coordinates. This
|
||||
/// function is only used on Windows.
|
||||
///
|
||||
CEF_EXPORT cef_rect_t
|
||||
cef_display_convert_screen_rect_from_pixels(const cef_rect_t* rect);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e1657ed68132b846ad638dc87bc5ee9b9c10f014$
|
||||
// $hash=ea84b76b6965d1419e416581d87e82f74680bd07$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
|
||||
@@ -65,12 +65,6 @@ typedef struct _cef_window_delegate_t {
|
||||
void(CEF_CALLBACK* on_window_created)(struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window);
|
||||
|
||||
///
|
||||
/// Called when |window| is closing.
|
||||
///
|
||||
void(CEF_CALLBACK* on_window_closing)(struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window);
|
||||
|
||||
///
|
||||
/// Called when |window| is destroyed. Release all references to |window| and
|
||||
/// do not attempt to execute any functions on |window| after this callback
|
||||
@@ -87,15 +81,6 @@ typedef struct _cef_window_delegate_t {
|
||||
struct _cef_window_t* window,
|
||||
int active);
|
||||
|
||||
///
|
||||
/// Called when |window| bounds have changed. |new_bounds| will be in DIP
|
||||
/// screen coordinates.
|
||||
///
|
||||
void(CEF_CALLBACK* on_window_bounds_changed)(
|
||||
struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window,
|
||||
const cef_rect_t* new_bounds);
|
||||
|
||||
///
|
||||
/// Return the parent for |window| or NULL if the |window| does not have a
|
||||
/// parent. Windows with parents will not get a taskbar button. Set |is_menu|
|
||||
|
@@ -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 "e92cde673e73851d8841e2f3c4f38bcd0f6ed2bb"
|
||||
#define CEF_API_HASH_UNIVERSAL "a63640eaa583092b069ec9895526b3e9e4932f6a"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "162bfdae56cbfd7f76fd4178be019f0dba512c40"
|
||||
#define CEF_API_HASH_PLATFORM "510cec552fbcfb4b7d47853ddfccd91f1e4f4c7b"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "31c5680dbc8d80fffc14214dd1ce4126a08e38d3"
|
||||
#define CEF_API_HASH_PLATFORM "ad36f5b62d9c4c2100859abb6b5b9fcedf8934ef"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "9682b2251f9973ee9eee0940eb9c773e522c2975"
|
||||
#define CEF_API_HASH_PLATFORM "d9657b0023ae05b5b92787b5e7da70893caf15af"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -123,6 +123,21 @@ void CefRunMessageLoop();
|
||||
/*--cef()--*/
|
||||
void CefQuitMessageLoop();
|
||||
|
||||
///
|
||||
/// Set to true before calling Windows APIs like TrackPopupMenu that enter a
|
||||
/// modal message loop. Set to false after exiting the modal message loop.
|
||||
///
|
||||
/*--cef()--*/
|
||||
void CefSetOSModalLoop(bool osModalLoop);
|
||||
|
||||
///
|
||||
/// Call during process startup to enable High-DPI support on Windows 7 or
|
||||
/// newer. Older versions of Windows should be left DPI-unaware because they do
|
||||
/// not support DirectWrite and GDI fonts are kerned very badly.
|
||||
///
|
||||
/*--cef(capi_name=cef_enable_highdpi_support)--*/
|
||||
void CefEnableHighDPISupport();
|
||||
|
||||
///
|
||||
/// Implement this interface to provide handler implementations. Methods will be
|
||||
/// called by the process and/or thread indicated.
|
||||
|
@@ -41,7 +41,6 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
@@ -52,33 +51,6 @@
|
||||
/*--cef(source=client,no_debugct_check)--*/
|
||||
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
/// Provides an opportunity to register custom preferences prior to
|
||||
/// global and request context initialization.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||
/// accessed via CefPreferenceManager::GetGlobalPreferences after
|
||||
/// OnContextInitialized is called. Global preferences are registered a single
|
||||
/// time at application startup. See related cef_settings_t.cache_path and
|
||||
/// cef_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||
/// accessed via the CefRequestContext after
|
||||
/// CefRequestContextHandler::OnRequestContextInitialized is called. Request
|
||||
/// context preferences are registered each time a new CefRequestContext is
|
||||
/// created. It is intended but not required that all request contexts have
|
||||
/// the same registered preferences. See related
|
||||
/// cef_request_context_settings_t.cache_path and
|
||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// Do not keep a reference to the |registrar| object. This method is called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnRegisterCustomPreferences(
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) {}
|
||||
|
||||
///
|
||||
/// Called on the browser process UI thread immediately after the CEF context
|
||||
/// has been initialized.
|
||||
|
@@ -43,15 +43,6 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
/// Combines specified |base_url| and |relative_url| into |resolved_url|.
|
||||
/// Returns false if one of the URLs is empty or invalid.
|
||||
///
|
||||
/*--cef()--*/
|
||||
bool CefResolveURL(const CefString& base_url,
|
||||
const CefString& relative_url,
|
||||
CefString& resolved_url);
|
||||
|
||||
///
|
||||
/// Parse the specified |url| into its component parts.
|
||||
/// Returns false if the URL is empty or invalid.
|
||||
|
@@ -1,134 +0,0 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file must follow a specific format in order to
|
||||
// support the CEF translator tool. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CEF_PREFERENCE_H_
|
||||
#define CEF_INCLUDE_CEF_PREFERENCE_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
/// Class that manages custom preference registrations.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefPreferenceRegistrar : public CefBaseScoped {
|
||||
public:
|
||||
///
|
||||
/// Register a preference with the specified |name| and |default_value|. To
|
||||
/// avoid conflicts with built-in preferences the |name| value should contain
|
||||
/// an application-specific prefix followed by a period (e.g. "myapp.value").
|
||||
/// The contents of |default_value| will be copied. The data type for the
|
||||
/// preference will be inferred from |default_value|'s type and cannot be
|
||||
/// changed after registration. Returns true on success. Returns false if
|
||||
/// |name| is already registered or if |default_value| has an invalid type.
|
||||
/// This method must be called from within the scope of the
|
||||
/// CefBrowserProcessHandler::OnRegisterCustomPreferences callback.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool AddPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> default_value) = 0;
|
||||
};
|
||||
|
||||
///
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
/// CefBrowserProcessHandler::OnRegisterCustomPreferences.
|
||||
///
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefPreferenceManager : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
/// Returns the global preference manager object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefPreferenceManager> GetGlobalPreferenceManager();
|
||||
|
||||
///
|
||||
/// Returns true if a preference with the specified |name| exists. This method
|
||||
/// must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool HasPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This method must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefValue> GetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This method must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) = 0;
|
||||
|
||||
///
|
||||
/// Returns true if the preference with the specified |name| can be modified
|
||||
/// using SetPreference. As one example preferences set via the command-line
|
||||
/// usually cannot be modified. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanSetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true if the
|
||||
/// value is set successfully and false otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef(optional_param=value)--*/
|
||||
virtual bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_PREFERENCE_H_
|
@@ -45,7 +45,7 @@
|
||||
#include "include/cef_extension.h"
|
||||
#include "include/cef_extension_handler.h"
|
||||
#include "include/cef_media_router.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
class CefRequestContextHandler;
|
||||
class CefSchemeHandlerFactory;
|
||||
@@ -84,7 +84,7 @@ class CefResolveCallback : public virtual CefBaseRefCounted {
|
||||
/// all other request context objects will be ignored.
|
||||
///
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefRequestContext : public CefPreferenceManager {
|
||||
class CefRequestContext : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
/// Returns the global context object.
|
||||
@@ -179,6 +179,57 @@ class CefRequestContext : public CefPreferenceManager {
|
||||
/*--cef()--*/
|
||||
virtual bool ClearSchemeHandlerFactories() = 0;
|
||||
|
||||
///
|
||||
/// Returns true if a preference with the specified |name| exists. This method
|
||||
/// must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool HasPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This method must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefValue> GetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This method must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) = 0;
|
||||
|
||||
///
|
||||
/// Returns true if the preference with the specified |name| can be modified
|
||||
/// using SetPreference. As one example preferences set via the command-line
|
||||
/// usually cannot be modified. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanSetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true if the
|
||||
/// value is set successfully and false otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef(optional_param=value)--*/
|
||||
virtual bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) = 0;
|
||||
|
||||
///
|
||||
/// Clears all certificate exceptions that were added as part of handling
|
||||
/// CefRequestHandler::OnCertificateError(). If you call this it is
|
||||
|
@@ -41,7 +41,6 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_resource_request_handler.h"
|
||||
|
||||
|
@@ -536,15 +536,6 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
|
||||
CefRefPtr<CefV8Handler> handler);
|
||||
|
||||
///
|
||||
/// Create a new CefV8Value object of type Promise. This method should only be
|
||||
/// called from within the scope of a CefRenderProcessHandler, CefV8Handler or
|
||||
/// CefV8Accessor callback, or in combination with calling Enter() and Exit()
|
||||
/// on a stored CefV8Context reference.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefV8Value> CreatePromise();
|
||||
|
||||
///
|
||||
/// Returns true if the underlying handle is valid and it can be accessed on
|
||||
/// the current thread. Do not call any other methods if this method returns
|
||||
@@ -625,12 +616,6 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
virtual bool IsFunction() = 0;
|
||||
|
||||
///
|
||||
/// True if the value type is a Promise.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsPromise() = 0;
|
||||
|
||||
///
|
||||
/// Returns true if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
@@ -908,29 +893,6 @@ class CefV8Value : public virtual CefBaseRefCounted {
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments) = 0;
|
||||
|
||||
// PROMISE METHODS - These methods are only available on Promises.
|
||||
|
||||
///
|
||||
/// Resolve the Promise using the current V8 context. This method should only
|
||||
/// be called from within the scope of a CefV8Handler or CefV8Accessor
|
||||
/// callback, or in combination with calling Enter() and Exit() on a stored
|
||||
/// CefV8Context reference. |arg| is the argument passed to the resolved
|
||||
/// promise. Returns true on success. Returns false if this method is called
|
||||
/// incorrectly or an exception is thrown.
|
||||
///
|
||||
/*--cef(optional_param=arg)--*/
|
||||
virtual bool ResolvePromise(CefRefPtr<CefV8Value> arg) = 0;
|
||||
|
||||
///
|
||||
/// Reject the Promise using the current V8 context. This method should only
|
||||
/// be called from within the scope of a CefV8Handler or CefV8Accessor
|
||||
/// callback, or in combination with calling Enter() and Exit() on a stored
|
||||
/// CefV8Context reference. Returns true on success. Returns false if this
|
||||
/// method is called incorrectly or an exception is thrown.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool RejectPromise(const CefString& errorMsg) = 0;
|
||||
};
|
||||
|
||||
///
|
||||
|
@@ -1,107 +0,0 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
typedef int(APIENTRY* wWinMainPtr)(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow);
|
||||
typedef int (*mainPtr)(int argc, char* argv[]);
|
||||
|
||||
///
|
||||
/// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB
|
||||
/// stack size. This function must be called at the top of the executable entry
|
||||
/// point function (`main()` or `wWinMain()`). It is used in combination with
|
||||
/// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker
|
||||
/// flag on executable targets. This saves significant memory on threads (like
|
||||
/// those in the Windows thread pool, and others) whose stack size can only be
|
||||
/// controlled via the linker flag.
|
||||
///
|
||||
/// CEF's main thread needs at least a 1.5 MiB stack size in order to avoid
|
||||
/// stack overflow crashes. However, if this is set in the PE file then other
|
||||
/// threads get this size as well, leading to address-space exhaustion in 32-bit
|
||||
/// CEF. This function uses fibers to switch the main thread to a 4 MiB stack
|
||||
/// (roughly the same effective size as the 64-bit build's 8 MiB stack) before
|
||||
/// running any other code.
|
||||
///
|
||||
/// Choose the function variant that matches the entry point function type used
|
||||
/// by the executable. Reusing the entry point minimizes confusion when
|
||||
/// examining call stacks in crash reports.
|
||||
///
|
||||
/// If this function is already running on the fiber it will return -1
|
||||
/// immediately, meaning that execution should proceed with the remainder of the
|
||||
/// entry point function. Otherwise, this function will block until the entry
|
||||
/// point function has completed execution on the fiber and then return a result
|
||||
/// >= 0, meaning that the entry point function should return the result
|
||||
/// immediately without proceeding with execution.
|
||||
///
|
||||
CEF_EXPORT int cef_run_winmain_with_preferred_stack_size(wWinMainPtr wWinMain,
|
||||
HINSTANCE hInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow);
|
||||
CEF_EXPORT int cef_run_main_with_preferred_stack_size(mainPtr main,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
#endif // defined(ARCH_CPU_32_BITS)
|
||||
|
||||
///
|
||||
/// Call during process startup to enable High-DPI support on Windows 7 or
|
||||
/// newer. Older versions of Windows should be left DPI-unaware because they do
|
||||
/// not support DirectWrite and GDI fonts are kerned very badly.
|
||||
///
|
||||
CEF_EXPORT void cef_enable_highdpi_support(void);
|
||||
|
||||
///
|
||||
/// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
|
||||
/// modal message loop. Set to false (0) after exiting the modal message loop.
|
||||
///
|
||||
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_APP_WIN_H_
|
@@ -2480,7 +2480,7 @@ typedef enum {
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
/// Default margins of 1cm (~0.4 inches).
|
||||
/// Default margins.
|
||||
///
|
||||
PDF_PRINT_MARGIN_DEFAULT,
|
||||
|
||||
@@ -2489,6 +2489,11 @@ typedef enum {
|
||||
///
|
||||
PDF_PRINT_MARGIN_NONE,
|
||||
|
||||
///
|
||||
/// Minimum margins.
|
||||
///
|
||||
PDF_PRINT_MARGIN_MINIMUM,
|
||||
|
||||
///
|
||||
/// Custom margins using the |margin_*| values from cef_pdf_print_settings_t.
|
||||
///
|
||||
@@ -2496,41 +2501,43 @@ typedef enum {
|
||||
} cef_pdf_print_margin_type_t;
|
||||
|
||||
///
|
||||
/// Structure representing PDF print settings. These values match the parameters
|
||||
/// supported by the DevTools Page.printToPDF function. See
|
||||
/// https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
|
||||
/// Structure representing PDF print settings.
|
||||
///
|
||||
typedef struct _cef_pdf_print_settings_t {
|
||||
///
|
||||
/// Set to true (1) for landscape mode or false (0) for portrait mode.
|
||||
/// Page title to display in the header. Only used if |header_footer_enabled|
|
||||
/// is set to true (1).
|
||||
///
|
||||
int landscape;
|
||||
cef_string_t header_footer_title;
|
||||
|
||||
///
|
||||
/// Set to true (1) to print background graphics.
|
||||
/// URL to display in the footer. Only used if |header_footer_enabled| is set
|
||||
/// to true (1).
|
||||
///
|
||||
int print_background;
|
||||
cef_string_t header_footer_url;
|
||||
|
||||
///
|
||||
/// The percentage to scale the PDF by before printing (e.g. .5 is 50%).
|
||||
/// If this value is less than or equal to zero the default value of 1.0
|
||||
/// Output page size in microns. If either of these values is less than or
|
||||
/// equal to zero then the default paper size (A4) will be used.
|
||||
///
|
||||
int page_width;
|
||||
int page_height;
|
||||
|
||||
///
|
||||
/// The percentage to scale the PDF by before printing (e.g. 50 is 50%).
|
||||
/// If this value is less than or equal to zero the default value of 100
|
||||
/// will be used.
|
||||
///
|
||||
double scale;
|
||||
int scale_factor;
|
||||
|
||||
///
|
||||
/// Output paper size in inches. If either of these values is less than or
|
||||
/// equal to zero then the default paper size (letter, 8.5 x 11 inches) will
|
||||
/// be used.
|
||||
/// Margins in points. Only used if |margin_type| is set to
|
||||
/// PDF_PRINT_MARGIN_CUSTOM.
|
||||
///
|
||||
double paper_width;
|
||||
double paper_height;
|
||||
|
||||
///
|
||||
/// Set to true (1) to prefer page size as defined by css. Defaults to false
|
||||
/// (0), in which case the content will be scaled to fit the paper size.
|
||||
///
|
||||
int prefer_css_page_size;
|
||||
int margin_top;
|
||||
int margin_right;
|
||||
int margin_bottom;
|
||||
int margin_left;
|
||||
|
||||
///
|
||||
/// Margin type.
|
||||
@@ -2538,53 +2545,27 @@ typedef struct _cef_pdf_print_settings_t {
|
||||
cef_pdf_print_margin_type_t margin_type;
|
||||
|
||||
///
|
||||
/// Margins in inches. Only used if |margin_type| is set to
|
||||
/// PDF_PRINT_MARGIN_CUSTOM.
|
||||
/// Set to true (1) to print headers and footers or false (0) to not print
|
||||
/// headers and footers.
|
||||
///
|
||||
double margin_top;
|
||||
double margin_right;
|
||||
double margin_bottom;
|
||||
double margin_left;
|
||||
int header_footer_enabled;
|
||||
|
||||
///
|
||||
/// Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are printed
|
||||
/// in the document order, not in the order specified, and no more than once.
|
||||
/// Defaults to empty string, which implies the entire document is printed.
|
||||
/// The page numbers are quietly capped to actual page count of the document,
|
||||
/// and ranges beyond the end of the document are ignored. If this results in
|
||||
/// no pages to print, an error is reported. It is an error to specify a range
|
||||
/// with start greater than end.
|
||||
/// Set to true (1) to print the selection only or false (0) to print all.
|
||||
///
|
||||
cef_string_t page_ranges;
|
||||
int selection_only;
|
||||
|
||||
///
|
||||
/// Set to true (1) to display the header and/or footer. Modify
|
||||
/// |header_template| and/or |footer_template| to customize the display.
|
||||
/// Set to true (1) for landscape mode or false (0) for portrait mode.
|
||||
///
|
||||
int display_header_footer;
|
||||
int landscape;
|
||||
|
||||
///
|
||||
/// HTML template for the print header. Only displayed if
|
||||
/// |display_header_footer| is true (1). Should be valid HTML markup with
|
||||
/// the following classes used to inject printing values into them:
|
||||
/// Set to true (1) to print background graphics or false (0) to not print
|
||||
/// background graphics.
|
||||
///
|
||||
/// - date: formatted print date
|
||||
/// - title: document title
|
||||
/// - url: document location
|
||||
/// - pageNumber: current page number
|
||||
/// - totalPages: total pages in the document
|
||||
///
|
||||
/// For example, "<span class=title></span>" would generate a span containing
|
||||
/// the title.
|
||||
///
|
||||
cef_string_t header_template;
|
||||
int backgrounds_enabled;
|
||||
|
||||
///
|
||||
/// HTML template for the print footer. Only displayed if
|
||||
/// |display_header_footer| is true (1). Uses the same format as
|
||||
/// |header_template|.
|
||||
///
|
||||
cef_string_t footer_template;
|
||||
} cef_pdf_print_settings_t;
|
||||
|
||||
///
|
||||
@@ -3384,7 +3365,7 @@ typedef enum {
|
||||
CEF_PERMISSION_TYPE_STORAGE_ACCESS = 1 << 16,
|
||||
CEF_PERMISSION_TYPE_U2F_API_REQUEST = 1 << 17,
|
||||
CEF_PERMISSION_TYPE_VR_SESSION = 1 << 18,
|
||||
CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT = 1 << 19,
|
||||
CEF_PERMISSION_TYPE_WINDOW_PLACEMENT = 1 << 19,
|
||||
} cef_permission_request_types_t;
|
||||
|
||||
///
|
||||
@@ -3431,19 +3412,6 @@ typedef enum {
|
||||
CEF_TEST_CERT_EXPIRED,
|
||||
} cef_test_cert_type_t;
|
||||
|
||||
///
|
||||
/// Preferences type passed to
|
||||
/// CefBrowserProcessHandler::OnRegisterCustomPreferences.
|
||||
///
|
||||
typedef enum {
|
||||
/// Global preferences registered a single time at application startup.
|
||||
CEF_PREFERENCES_TYPE_GLOBAL,
|
||||
|
||||
/// Request context preferences registered each time a new CefRequestContext
|
||||
/// is created.
|
||||
CEF_PREFERENCES_TYPE_REQUEST_CONTEXT,
|
||||
} cef_preferences_type_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -644,35 +644,34 @@ struct CefPdfPrintSettingsTraits {
|
||||
static inline void init(struct_type* s) {}
|
||||
|
||||
static inline void clear(struct_type* s) {
|
||||
cef_string_clear(&s->page_ranges);
|
||||
cef_string_clear(&s->header_template);
|
||||
cef_string_clear(&s->footer_template);
|
||||
cef_string_clear(&s->header_footer_title);
|
||||
cef_string_clear(&s->header_footer_url);
|
||||
}
|
||||
|
||||
static inline void set(const struct_type* src,
|
||||
struct_type* target,
|
||||
bool copy) {
|
||||
target->landscape = src->landscape;
|
||||
target->print_background = src->print_background;
|
||||
target->scale = src->scale;
|
||||
target->paper_width = src->paper_width;
|
||||
target->paper_height = src->paper_height;
|
||||
target->prefer_css_page_size = src->prefer_css_page_size;
|
||||
cef_string_set(src->header_footer_title.str,
|
||||
src->header_footer_title.length,
|
||||
&target->header_footer_title, copy);
|
||||
cef_string_set(src->header_footer_url.str, src->header_footer_url.length,
|
||||
&target->header_footer_url, copy);
|
||||
|
||||
target->page_width = src->page_width;
|
||||
target->page_height = src->page_height;
|
||||
|
||||
target->scale_factor = src->scale_factor;
|
||||
|
||||
target->margin_type = src->margin_type;
|
||||
target->margin_top = src->margin_top;
|
||||
target->margin_right = src->margin_right;
|
||||
target->margin_bottom = src->margin_bottom;
|
||||
target->margin_left = src->margin_left;
|
||||
target->margin_type = src->margin_type;
|
||||
|
||||
cef_string_set(src->page_ranges.str, src->page_ranges.length,
|
||||
&target->page_ranges, copy);
|
||||
|
||||
target->display_header_footer = src->display_header_footer;
|
||||
cef_string_set(src->header_template.str, src->header_template.length,
|
||||
&target->header_template, copy);
|
||||
cef_string_set(src->footer_template.str, src->footer_template.length,
|
||||
&target->footer_template, copy);
|
||||
target->header_footer_enabled = src->header_footer_enabled;
|
||||
target->selection_only = src->selection_only;
|
||||
target->landscape = src->landscape;
|
||||
target->backgrounds_enabled = src->backgrounds_enabled;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/internal/cef_app_win.h"
|
||||
#include "include/internal/cef_types_win.h"
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
|
||||
@@ -133,52 +132,4 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
///
|
||||
/// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB
|
||||
/// stack size. This function must be called at the top of the executable entry
|
||||
/// point function (`main()` or `wWinMain()`). It is used in combination with
|
||||
/// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker
|
||||
/// flag on executable targets. This saves significant memory on threads (like
|
||||
/// those in the Windows thread pool, and others) whose stack size can only be
|
||||
/// controlled via the linker flag.
|
||||
///
|
||||
/// CEF's main thread needs at least a 1.5 MiB stack size in order to avoid
|
||||
/// stack overflow crashes. However, if this is set in the PE file then other
|
||||
/// threads get this size as well, leading to address-space exhaustion in 32-bit
|
||||
/// CEF. This function uses fibers to switch the main thread to a 4 MiB stack
|
||||
/// (roughly the same effective size as the 64-bit build's 8 MiB stack) before
|
||||
/// running any other code.
|
||||
///
|
||||
/// Choose the function variant that matches the entry point function type used
|
||||
/// by the executable. Reusing the entry point minimizes confusion when
|
||||
/// examining call stacks in crash reports.
|
||||
///
|
||||
/// If this function is already running on the fiber it will return -1
|
||||
/// immediately, meaning that execution should proceed with the remainder of the
|
||||
/// entry point function. Otherwise, this function will block until the entry
|
||||
/// point function has completed execution on the fiber and then return a result
|
||||
/// >= 0, meaning that the entry point function should return the result
|
||||
/// immediately without proceeding with execution.
|
||||
///
|
||||
int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain,
|
||||
HINSTANCE hInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow);
|
||||
int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]);
|
||||
#endif // defined(ARCH_CPU_32_BITS)
|
||||
|
||||
///
|
||||
/// Call during process startup to enable High-DPI support on Windows 7 or
|
||||
/// newer. Older versions of Windows should be left DPI-unaware because they do
|
||||
/// not support DirectWrite and GDI fonts are kerned very badly.
|
||||
///
|
||||
void CefEnableHighDPISupport();
|
||||
|
||||
///
|
||||
/// Set to true before calling Windows APIs like TrackPopupMenu that enter a
|
||||
/// modal message loop. Set to false after exiting the modal message loop.
|
||||
///
|
||||
void CefSetOSModalLoop(bool osModalLoop);
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_
|
||||
|
@@ -105,20 +105,6 @@ class CefDisplay : public CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
static CefPoint ConvertScreenPointFromPixels(const CefPoint& point);
|
||||
|
||||
///
|
||||
/// Convert |rect| from DIP screen coordinates to pixel screen coordinates.
|
||||
/// This method is only used on Windows.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRect ConvertScreenRectToPixels(const CefRect& rect);
|
||||
|
||||
///
|
||||
/// Convert |rect| from pixel screen coordinates to DIP screen coordinates.
|
||||
/// This method is only used on Windows.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRect ConvertScreenRectFromPixels(const CefRect& rect);
|
||||
|
||||
///
|
||||
/// Returns the unique identifier for this Display.
|
||||
///
|
||||
|
@@ -55,12 +55,6 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
/*--cef()--*/
|
||||
virtual void OnWindowCreated(CefRefPtr<CefWindow> window) {}
|
||||
|
||||
///
|
||||
/// Called when |window| is closing.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnWindowClosing(CefRefPtr<CefWindow> window) {}
|
||||
|
||||
///
|
||||
/// Called when |window| is destroyed. Release all references to |window| and
|
||||
/// do not attempt to execute any methods on |window| after this callback
|
||||
@@ -76,14 +70,6 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
virtual void OnWindowActivationChanged(CefRefPtr<CefWindow> window,
|
||||
bool active) {}
|
||||
|
||||
///
|
||||
/// Called when |window| bounds have changed. |new_bounds| will be in DIP
|
||||
/// screen coordinates.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnWindowBoundsChanged(CefRefPtr<CefWindow> window,
|
||||
const CefRect& new_bounds) {}
|
||||
|
||||
///
|
||||
/// Return the parent for |window| or NULL if the |window| does not have a
|
||||
/// parent. Windows with parents will not get a taskbar button. Set |is_menu|
|
||||
|
@@ -349,6 +349,30 @@ void AlloyBrowserHostImpl::SetZoomLevel(double zoomLevel) {
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::Print() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::Print, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_)
|
||||
platform_delegate_->Print();
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::PrintToPDF,
|
||||
this, path, settings, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform_delegate_) {
|
||||
platform_delegate_->PrintToPDF(path, settings, callback);
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyBrowserHostImpl::Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
@@ -1012,11 +1036,11 @@ void AlloyBrowserHostImpl::AddNewContents(
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
platform_delegate_->AddNewContents(source, std::move(new_contents),
|
||||
target_url, disposition, window_features,
|
||||
target_url, disposition, initial_rect,
|
||||
user_gesture, was_blocked);
|
||||
}
|
||||
|
||||
|
@@ -82,6 +82,10 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
CefWindowHandle GetOpenerWindowHandle() override;
|
||||
double GetZoomLevel() override;
|
||||
void SetZoomLevel(double zoomLevel) override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) override;
|
||||
void Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
@@ -192,7 +196,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) override;
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#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 "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
@@ -90,7 +91,6 @@
|
||||
#include "ui/linux/linux_ui.h"
|
||||
#include "ui/linux/linux_ui_delegate.h"
|
||||
#include "ui/linux/linux_ui_factory.h"
|
||||
#include "ui/linux/linux_ui_getter.h"
|
||||
#include "ui/ozone/public/ozone_platform.h"
|
||||
#endif // BUILDFLAG(IS_LINUX)
|
||||
|
||||
@@ -106,20 +106,7 @@ namespace {
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
|
||||
class LinuxUiGetterImpl : public ui::LinuxUiGetter {
|
||||
public:
|
||||
LinuxUiGetterImpl() = default;
|
||||
~LinuxUiGetterImpl() override = default;
|
||||
ui::LinuxUiTheme* GetForWindow(aura::Window* window) override {
|
||||
return window ? GetForProfile(GetThemeProfileForWindow(window)) : nullptr;
|
||||
}
|
||||
ui::LinuxUiTheme* GetForProfile(Profile* profile) override {
|
||||
return ui::GetLinuxUiTheme(
|
||||
ThemeServiceAuraLinux::GetSystemThemeForProfile(profile));
|
||||
}
|
||||
};
|
||||
|
||||
ui::LinuxUi* GetLinuxUI() {
|
||||
std::unique_ptr<ui::LinuxUi> BuildLinuxUI() {
|
||||
// We can't use GtkUi in combination with multi-threaded-message-loop because
|
||||
// Chromium's GTK implementation doesn't use GDK threads.
|
||||
if (!!CefContext::Get()->settings().multi_threaded_message_loop)
|
||||
@@ -130,7 +117,31 @@ ui::LinuxUi* GetLinuxUI() {
|
||||
if (!ui::LinuxUiDelegate::GetInstance())
|
||||
return nullptr;
|
||||
|
||||
return ui::GetDefaultLinuxUi();
|
||||
return ui::CreateLinuxUi();
|
||||
}
|
||||
|
||||
// Based on chrome_browser_main_extra_parts_views_linux.cc
|
||||
void ToolkitInitializedLinux() {
|
||||
if (auto linux_ui = BuildLinuxUI()) {
|
||||
linux_ui->SetUseSystemThemeCallback(
|
||||
base::BindRepeating([](aura::Window* window) {
|
||||
if (!window)
|
||||
return true;
|
||||
return ThemeServiceAuraLinux::ShouldUseSystemThemeForProfile(
|
||||
GetThemeProfileForWindow(window));
|
||||
}));
|
||||
|
||||
ui::LinuxUi::SetInstance(std::move(linux_ui));
|
||||
|
||||
// Cursor theme changes are tracked by LinuxUI (via a CursorThemeManager
|
||||
// implementation). Start observing them once it's initialized.
|
||||
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
|
||||
}
|
||||
|
||||
auto printing_delegate = new CefPrintingContextLinuxDelegate();
|
||||
auto default_delegate =
|
||||
printing::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
|
||||
printing_delegate->SetDefaultDelegate(default_delegate);
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_LINUX)
|
||||
@@ -159,21 +170,8 @@ void AlloyBrowserMainParts::ToolkitInitialized() {
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
// Based on chrome_browser_main_extra_parts_views_linux.cc
|
||||
if (auto linux_ui = GetLinuxUI()) {
|
||||
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
|
||||
ui::LinuxUi::SetInstance(linux_ui);
|
||||
|
||||
// Cursor theme changes are tracked by LinuxUI (via a CursorThemeManager
|
||||
// implementation). Start observing them once it's initialized.
|
||||
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
|
||||
}
|
||||
|
||||
auto printing_delegate = new CefPrintingContextLinuxDelegate();
|
||||
auto default_delegate =
|
||||
printing::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
|
||||
printing_delegate->SetDefaultDelegate(default_delegate);
|
||||
#endif // BUILDFLAG(IS_LINUX)
|
||||
ToolkitInitializedLinux();
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (base::FeatureList::IsEnabled(features::kViewsJSAppModalDialog))
|
||||
@@ -301,6 +299,9 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() {
|
||||
base::IsEnterpriseDevice();
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
// Triggers initialization of the singleton instance on UI thread.
|
||||
PluginFinder::GetInstance();
|
||||
|
||||
scheme::RegisterWebUIControllerFactory();
|
||||
file_dialog_runner::RegisterFactory();
|
||||
permission_prompt::RegisterCreateCallback();
|
||||
|
@@ -28,12 +28,6 @@ class LayoutProvider;
|
||||
#endif
|
||||
} // namespace views
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
namespace ui {
|
||||
class LinuxUiGetter;
|
||||
}
|
||||
#endif
|
||||
|
||||
class CefDevToolsDelegate;
|
||||
|
||||
class AlloyBrowserMainParts : public content::BrowserMainParts {
|
||||
@@ -95,10 +89,6 @@ class AlloyBrowserMainParts : public content::BrowserMainParts {
|
||||
std::unique_ptr<display::ScopedNativeScreen> screen_;
|
||||
std::unique_ptr<views::LayoutProvider> layout_provider_;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
std::unique_ptr<ui::LinuxUiGetter> linux_ui_getter_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
||||
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
||||
#include "libcef/browser/prefs/renderer_prefs.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
#include "libcef/browser/speech_recognition_manager_delegate.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/x509_certificate_impl.h"
|
||||
@@ -65,7 +66,6 @@
|
||||
#include "chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.h"
|
||||
#include "chrome/browser/plugins/plugin_utils.h"
|
||||
#include "chrome/browser/predictors/network_hints_handler_impl.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/renderer_updater.h"
|
||||
#include "chrome/browser/profiles/renderer_updater_factory.h"
|
||||
@@ -955,7 +955,7 @@ void AlloyContentBrowserClient::
|
||||
[](content::RenderFrameHost* render_frame_host,
|
||||
mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost>
|
||||
receiver) {
|
||||
printing::PrintViewManager::BindPrintManagerHost(
|
||||
printing::CefPrintViewManager::BindPrintManagerHost(
|
||||
std::move(receiver), render_frame_host);
|
||||
},
|
||||
&render_frame_host));
|
||||
@@ -1019,7 +1019,9 @@ AlloyContentBrowserClient::CreateURLLoaderThrottles(
|
||||
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
||||
AlloyContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
|
||||
content::NavigationUIData* navigation_ui_data,
|
||||
int frame_tree_node_id) {
|
||||
int frame_tree_node_id,
|
||||
const scoped_refptr<network::SharedURLLoaderFactory>&
|
||||
network_loader_factory) {
|
||||
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
||||
interceptors;
|
||||
|
||||
@@ -1370,7 +1372,6 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
||||
|
||||
void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker(
|
||||
content::BrowserContext* browser_context,
|
||||
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
|
||||
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
|
||||
map) {
|
||||
map->Add<blink::mojom::BadgeService>(
|
||||
|
@@ -135,7 +135,9 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
||||
WillCreateURLLoaderRequestInterceptors(
|
||||
content::NavigationUIData* navigation_ui_data,
|
||||
int frame_tree_node_id) override;
|
||||
int frame_tree_node_id,
|
||||
const scoped_refptr<network::SharedURLLoaderFactory>&
|
||||
network_loader_factory) override;
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
void GetAdditionalMappedFilesForChildProcess(
|
||||
@@ -229,7 +231,6 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
|
||||
void RegisterBrowserInterfaceBindersForServiceWorker(
|
||||
content::BrowserContext* browser_context,
|
||||
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
|
||||
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
|
||||
map) override;
|
||||
base::FilePath GetSandboxedStorageServiceDataDirectory() override;
|
||||
|
@@ -11,12 +11,14 @@
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/extensions/extension_view_host.h"
|
||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/net/url_util.h"
|
||||
#include "libcef/features/runtime_checks.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
#include "chrome/browser/printing/print_view_manager_common.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "components/find_in_page/find_tab_helper.h"
|
||||
#include "components/find_in_page/find_types.h"
|
||||
@@ -28,8 +30,18 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "extensions/browser/process_manager.h"
|
||||
#include "pdf/pdf_features.h"
|
||||
#include "printing/mojom/print.mojom.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) {}
|
||||
|
||||
@@ -119,7 +131,7 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
@@ -137,7 +149,7 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
|
||||
|
||||
if (extension_host_) {
|
||||
extension_host_->AddNewContents(source, std::move(new_contents), target_url,
|
||||
disposition, window_features, user_gesture,
|
||||
disposition, initial_rect, user_gesture,
|
||||
was_blocked);
|
||||
}
|
||||
}
|
||||
@@ -169,7 +181,7 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
||||
|
||||
permissions::PermissionRequestManager::CreateForWebContents(web_contents_);
|
||||
PrefsTabHelper::CreateForWebContents(web_contents_);
|
||||
printing::PrintViewManager::CreateForWebContents(web_contents_);
|
||||
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
|
||||
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
// Used by the tabs extension API.
|
||||
@@ -345,6 +357,48 @@ bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
||||
return cef_browser_context->IsPrintPreviewSupported();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::Print() {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
auto contents_to_use = printing::GetWebContentsToUse(web_contents_);
|
||||
if (!contents_to_use)
|
||||
return;
|
||||
|
||||
auto rfh_to_use = printing::GetRenderFrameHostToUse(contents_to_use);
|
||||
if (!rfh_to_use)
|
||||
return;
|
||||
|
||||
if (IsPrintPreviewSupported()) {
|
||||
GetPrintViewManager(contents_to_use)->PrintPreviewNow(rfh_to_use, false);
|
||||
} else {
|
||||
GetPrintViewManager(contents_to_use)->PrintNow(rfh_to_use);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::PrintToPDF(
|
||||
const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
|
||||
auto contents_to_use = printing::GetWebContentsToUse(web_contents_);
|
||||
if (!contents_to_use)
|
||||
return;
|
||||
|
||||
auto rfh_to_use = printing::GetRenderFrameHostToUse(contents_to_use);
|
||||
if (!rfh_to_use)
|
||||
return;
|
||||
|
||||
printing::CefPrintViewManager::PdfPrintCallback pdf_callback;
|
||||
if (callback.get()) {
|
||||
pdf_callback = base::BindOnce(&CefPdfPrintCallback::OnPdfPrintFinished,
|
||||
callback.get(), path);
|
||||
}
|
||||
GetPrintViewManager(contents_to_use)
|
||||
->PrintToPDF(rfh_to_use, base::FilePath(path), settings,
|
||||
std::move(pdf_callback));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateAlloy::Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
|
@@ -30,7 +30,7 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) override;
|
||||
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
||||
@@ -56,6 +56,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||
const CefSize& max_size) override;
|
||||
void SetAccessibilityState(cef_state_t accessibility_state) override;
|
||||
bool IsPrintPreviewSupported() const override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) override;
|
||||
void Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
media::ChannelLayoutConfig TranslateChannelLayout(
|
||||
media::ChannelLayout TranslateChannelLayout(
|
||||
cef_channel_layout_t channel_layout) {
|
||||
// Verify that our enum matches Chromium's values. The enum values match
|
||||
// between those enums and existing values don't ever change, so it's enough
|
||||
@@ -22,9 +22,7 @@ media::ChannelLayoutConfig TranslateChannelLayout(
|
||||
static_cast<int>(CEF_CHANNEL_LAYOUT_MAX) ==
|
||||
static_cast<int>(media::CHANNEL_LAYOUT_MAX),
|
||||
"cef_channel_layout_t must match the ChannelLayout enum in Chromium");
|
||||
|
||||
const auto layout = static_cast<media::ChannelLayout>(channel_layout);
|
||||
return {layout, media::ChannelLayoutToChannelCount(layout)};
|
||||
return static_cast<media::ChannelLayout>(channel_layout);
|
||||
}
|
||||
|
||||
void StreamCreatorHelper(
|
||||
|
@@ -55,11 +55,9 @@ class ImplManager {
|
||||
void RemoveImpl(CefBrowserContext* impl, const base::FilePath& path) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
{
|
||||
Vector::iterator it = GetImplPos(impl);
|
||||
DCHECK(it != all_.end());
|
||||
all_.erase(it);
|
||||
}
|
||||
Vector::iterator it = GetImplPos(impl);
|
||||
DCHECK(it != all_.end());
|
||||
all_.erase(it);
|
||||
|
||||
if (!path.empty()) {
|
||||
PathMap::iterator it = map_.find(path);
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/image_impl.h"
|
||||
#include "libcef/browser/navigation_entry_impl.h"
|
||||
#include "libcef/browser/printing/print_util.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "libcef/common/net/url_util.h"
|
||||
@@ -349,37 +348,6 @@ void CefBrowserHostBase::DownloadImage(
|
||||
max_image_size, callback));
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::Print() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::Print, this));
|
||||
return;
|
||||
}
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
const bool print_preview_disabled =
|
||||
!platform_delegate_ || !platform_delegate_->IsPrintPreviewSupported();
|
||||
print_util::Print(web_contents, print_preview_disabled);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::PrintToPDF, this,
|
||||
path, settings, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
auto web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
print_util::PrintToPDF(web_contents, path, settings, callback);
|
||||
}
|
||||
|
||||
bool CefBrowserHostBase::SendDevToolsMessage(const void* message,
|
||||
size_t message_size) {
|
||||
if (!message || message_size == 0)
|
||||
|
@@ -181,10 +181,6 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
uint32 max_image_size,
|
||||
bool bypass_cache,
|
||||
CefRefPtr<CefDownloadImageCallback> callback) override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) override;
|
||||
void ReplaceMisspelling(const CefString& word) override;
|
||||
void AddWordToDictionary(const CefString& word) override;
|
||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||
|
@@ -223,11 +223,11 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
|
||||
auto it2 = frame_info_set_.find(frame_info);
|
||||
|
||||
// Explicitly Detach everything but the current main frame.
|
||||
const auto& other_frame_info = *it2;
|
||||
if (other_frame_info->frame_ && !other_frame_info->IsCurrentMainFrame()) {
|
||||
if (other_frame_info->frame_->Detach(
|
||||
const auto& frame_info = *it2;
|
||||
if (frame_info->frame_ && !frame_info->IsCurrentMainFrame()) {
|
||||
if (frame_info->frame_->Detach(
|
||||
CefFrameHostImpl::DetachReason::RENDER_FRAME_DELETED)) {
|
||||
MaybeNotifyFrameDetached(browser_, other_frame_info->frame_);
|
||||
MaybeNotifyFrameDetached(browser_, frame_info->frame_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,13 +32,13 @@ const int64_t kNewBrowserInfoResponseTimeoutMs = 2000;
|
||||
|
||||
void TranslatePopupFeatures(const blink::mojom::WindowFeatures& webKitFeatures,
|
||||
CefPopupFeatures& features) {
|
||||
features.x = static_cast<int>(webKitFeatures.bounds.x());
|
||||
features.x = static_cast<int>(webKitFeatures.x);
|
||||
features.xSet = webKitFeatures.has_x;
|
||||
features.y = static_cast<int>(webKitFeatures.bounds.y());
|
||||
features.y = static_cast<int>(webKitFeatures.y);
|
||||
features.ySet = webKitFeatures.has_y;
|
||||
features.width = static_cast<int>(webKitFeatures.bounds.width());
|
||||
features.width = static_cast<int>(webKitFeatures.width);
|
||||
features.widthSet = webKitFeatures.has_width;
|
||||
features.height = static_cast<int>(webKitFeatures.bounds.height());
|
||||
features.height = static_cast<int>(webKitFeatures.height);
|
||||
features.heightSet = webKitFeatures.has_height;
|
||||
|
||||
features.menuBarVisible = webKitFeatures.menu_bar_visible;
|
||||
|
@@ -45,7 +45,7 @@ void CefBrowserPlatformDelegate::AddNewContents(
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
NOTREACHED();
|
||||
@@ -390,6 +390,17 @@ bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::Print() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::PrintToPDF(
|
||||
const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
|
@@ -30,10 +30,6 @@ class WebMouseEvent;
|
||||
class WebMouseWheelEvent;
|
||||
class WebInputEvent;
|
||||
class WebTouchEvent;
|
||||
|
||||
namespace mojom {
|
||||
class WindowFeatures;
|
||||
}
|
||||
} // namespace blink
|
||||
|
||||
namespace content {
|
||||
@@ -118,7 +114,7 @@ class CefBrowserPlatformDelegate {
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked);
|
||||
|
||||
@@ -363,6 +359,10 @@ class CefBrowserPlatformDelegate {
|
||||
const CefSize& max_size);
|
||||
virtual void SetAccessibilityState(cef_state_t accessibility_state);
|
||||
virtual bool IsPrintPreviewSupported() const;
|
||||
virtual void Print();
|
||||
virtual void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback);
|
||||
virtual void Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
|
@@ -6,11 +6,9 @@
|
||||
|
||||
#include "libcef/browser/views/view_util.h"
|
||||
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_window.h"
|
||||
#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
@@ -119,11 +117,6 @@ CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle(
|
||||
return native_delegate_->GetEventHandle(event);
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateChrome::IsPrintPreviewSupported() const {
|
||||
return chrome_browser_ && !chrome_browser_->profile()->GetPrefs()->GetBoolean(
|
||||
prefs::kPrintPreviewDisabled);
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateChrome::GetParentWindowHandle()
|
||||
const {
|
||||
return GetHostWindowHandle();
|
||||
|
@@ -42,7 +42,6 @@ class CefBrowserPlatformDelegateChrome
|
||||
void ViewText(const std::string& text) override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
bool IsPrintPreviewSupported() const override;
|
||||
|
||||
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
||||
CefWindowHandle GetParentWindowHandle() const override;
|
||||
|
@@ -58,19 +58,15 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
|
||||
if (cache_path_ == user_data_dir) {
|
||||
// Use the default disk-based profile.
|
||||
auto profile = profile_manager->GetPrimaryUserProfile();
|
||||
ProfileCreated(Profile::CreateStatus::CREATE_STATUS_INITIALIZED, profile);
|
||||
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED);
|
||||
return;
|
||||
} else if (cache_path_.DirName() == user_data_dir) {
|
||||
// Create or load a specific disk-based profile. May continue
|
||||
// synchronously or asynchronously.
|
||||
profile_manager->CreateProfileAsync(
|
||||
cache_path_,
|
||||
base::BindOnce(&ChromeBrowserContext::ProfileCreated,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
Profile::CreateStatus::CREATE_STATUS_INITIALIZED),
|
||||
base::BindOnce(&ChromeBrowserContext::ProfileCreated,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
Profile::CreateStatus::CREATE_STATUS_CREATED));
|
||||
base::BindRepeating(&ChromeBrowserContext::ProfileCreated,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
return;
|
||||
} else {
|
||||
// All profile directories must be relative to |user_data_dir|.
|
||||
@@ -80,7 +76,7 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
|
||||
}
|
||||
|
||||
// Default to creating a new/unique OffTheRecord profile.
|
||||
ProfileCreated(Profile::CreateStatus::CREATE_STATUS_LOCAL_FAIL, nullptr);
|
||||
ProfileCreated(nullptr, Profile::CreateStatus::CREATE_STATUS_LOCAL_FAIL);
|
||||
}
|
||||
|
||||
void ChromeBrowserContext::Shutdown() {
|
||||
@@ -102,8 +98,8 @@ void ChromeBrowserContext::Shutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeBrowserContext::ProfileCreated(Profile::CreateStatus status,
|
||||
Profile* profile) {
|
||||
void ChromeBrowserContext::ProfileCreated(Profile* profile,
|
||||
Profile::CreateStatus status) {
|
||||
Profile* parent_profile = nullptr;
|
||||
OffTheRecordProfileImpl* otr_profile = nullptr;
|
||||
|
||||
|
@@ -38,7 +38,7 @@ class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
|
||||
private:
|
||||
~ChromeBrowserContext() override;
|
||||
|
||||
void ProfileCreated(Profile::CreateStatus status, Profile* profile);
|
||||
void ProfileCreated(Profile* profile, Profile::CreateStatus status);
|
||||
|
||||
base::OnceClosure initialized_cb_;
|
||||
Profile* profile_ = nullptr;
|
||||
|
@@ -160,7 +160,7 @@ void ChromeBrowserDelegate::AddNewContents(
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
auto new_browser =
|
||||
@@ -173,7 +173,7 @@ void ChromeBrowserDelegate::AddNewContents(
|
||||
|
||||
// Fall back to default behavior from Browser::AddNewContents.
|
||||
chrome::AddWebContents(browser_, source_contents, std::move(new_contents),
|
||||
target_url, disposition, window_features);
|
||||
target_url, disposition, initial_rect);
|
||||
}
|
||||
|
||||
content::WebContents* ChromeBrowserDelegate::OpenURLFromTab(
|
||||
|
@@ -70,7 +70,7 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
const GURL& target_url,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& window_features,
|
||||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) override;
|
||||
content::WebContents* OpenURLFromTab(
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#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"
|
||||
@@ -184,6 +185,30 @@ void ChromeBrowserHostImpl::SetZoomLevel(double zoomLevel) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
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(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
|
@@ -66,6 +66,10 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
||||
CefWindowHandle GetOpenerWindowHandle() override;
|
||||
double GetZoomLevel() override;
|
||||
void SetZoomLevel(double zoomLevel) override;
|
||||
void Print() override;
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) override;
|
||||
void Find(const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
|
@@ -21,12 +21,9 @@
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/debug/alias.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "chrome/chrome_elf/chrome_elf_main.h"
|
||||
#include "chrome/install_static/initialize_from_primary_module.h"
|
||||
#include "include/internal/cef_win.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@@ -42,6 +39,19 @@ class CefShutdownChecker {
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
// VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
|
||||
// of them at the OS level (this is fixed in VS2015). We force off usage of
|
||||
// FMA3 instructions in the CRT to avoid using that path and hitting illegal
|
||||
// instructions when running on CPUs that support FMA3, but OSs that don't.
|
||||
void DisableFMA3() {
|
||||
static bool disabled = false;
|
||||
if (disabled)
|
||||
return;
|
||||
disabled = true;
|
||||
_set_FMA3_enable(0);
|
||||
}
|
||||
#endif // defined(ARCH_CPU_X86_64)
|
||||
|
||||
// Transfer state from chrome_elf.dll to the libcef.dll. Accessed when
|
||||
// loading chrome://system.
|
||||
@@ -62,7 +72,6 @@ void InitCrashReporter() {
|
||||
initialized = true;
|
||||
SignalInitializeCrashReporting();
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) {
|
||||
@@ -161,116 +170,15 @@ base::FilePath NormalizeCachePathAndSet(cef_string_t& path_str,
|
||||
return path;
|
||||
}
|
||||
|
||||
// Based on chrome/app/chrome_exe_main_win.cc.
|
||||
// In 32-bit builds, the main thread starts with the default (small) stack size.
|
||||
// The ARCH_CPU_32_BITS blocks here and below are in support of moving the main
|
||||
// thread to a fiber with a larger stack size.
|
||||
#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_32_BITS)
|
||||
// The information needed to transfer control to the large-stack fiber and later
|
||||
// pass the main routine's exit code back to the small-stack fiber prior to
|
||||
// termination.
|
||||
struct FiberState {
|
||||
FiberState(wWinMainPtr wWinMain,
|
||||
HINSTANCE hInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow) {
|
||||
this->wWinMain = wWinMain;
|
||||
this->hInstance = hInstance;
|
||||
this->lpCmdLine = lpCmdLine;
|
||||
this->nCmdShow = nCmdShow;
|
||||
}
|
||||
|
||||
FiberState(mainPtr main, int argc, char** argv) {
|
||||
this->main = main;
|
||||
this->argc = argc;
|
||||
this->argv = argv;
|
||||
}
|
||||
|
||||
wWinMainPtr wWinMain = nullptr;
|
||||
HINSTANCE hInstance;
|
||||
LPWSTR lpCmdLine;
|
||||
int nCmdShow;
|
||||
|
||||
mainPtr main = nullptr;
|
||||
int argc;
|
||||
char** argv;
|
||||
|
||||
LPVOID original_fiber;
|
||||
int fiber_result;
|
||||
};
|
||||
|
||||
// A PFIBER_START_ROUTINE function run on a large-stack fiber that calls the
|
||||
// main routine, stores its return value, and returns control to the small-stack
|
||||
// fiber. |params| must be a pointer to a FiberState struct.
|
||||
void WINAPI FiberBinder(void* params) {
|
||||
auto* fiber_state = static_cast<FiberState*>(params);
|
||||
// Call the main routine from the fiber. Reusing the entry point minimizes
|
||||
// confusion when examining call stacks in crash reports - seeing wWinMain on
|
||||
// the stack is a handy hint that this is the main thread of the process.
|
||||
if (fiber_state->main) {
|
||||
fiber_state->fiber_result =
|
||||
fiber_state->main(fiber_state->argc, fiber_state->argv);
|
||||
} else {
|
||||
fiber_state->fiber_result =
|
||||
fiber_state->wWinMain(fiber_state->hInstance, nullptr,
|
||||
fiber_state->lpCmdLine, fiber_state->nCmdShow);
|
||||
}
|
||||
|
||||
// Switch back to the main thread to exit.
|
||||
::SwitchToFiber(fiber_state->original_fiber);
|
||||
}
|
||||
|
||||
int RunMainWithPreferredStackSize(FiberState& fiber_state) {
|
||||
enum class FiberStatus { kConvertFailed, kCreateFiberFailed, kSuccess };
|
||||
FiberStatus fiber_status = FiberStatus::kSuccess;
|
||||
// GetLastError result if fiber conversion failed.
|
||||
DWORD fiber_error = ERROR_SUCCESS;
|
||||
if (!::IsThreadAFiber()) {
|
||||
// Make the main thread's stack size 4 MiB so that it has roughly the same
|
||||
// effective size as the 64-bit build's 8 MiB stack.
|
||||
constexpr size_t kStackSize = 4 * 1024 * 1024; // 4 MiB
|
||||
// Leak the fiber on exit.
|
||||
LPVOID original_fiber =
|
||||
::ConvertThreadToFiberEx(nullptr, FIBER_FLAG_FLOAT_SWITCH);
|
||||
if (original_fiber) {
|
||||
fiber_state.original_fiber = original_fiber;
|
||||
// Create a fiber with a bigger stack and switch to it. Leak the fiber on
|
||||
// exit.
|
||||
LPVOID big_stack_fiber = ::CreateFiberEx(
|
||||
0, kStackSize, FIBER_FLAG_FLOAT_SWITCH, FiberBinder, &fiber_state);
|
||||
if (big_stack_fiber) {
|
||||
::SwitchToFiber(big_stack_fiber);
|
||||
// The fibers must be cleaned up to avoid obscure TLS-related shutdown
|
||||
// crashes.
|
||||
::DeleteFiber(big_stack_fiber);
|
||||
::ConvertFiberToThread();
|
||||
// Control returns here after CEF has finished running on FiberMain.
|
||||
return fiber_state.fiber_result;
|
||||
}
|
||||
fiber_status = FiberStatus::kCreateFiberFailed;
|
||||
} else {
|
||||
fiber_status = FiberStatus::kConvertFailed;
|
||||
}
|
||||
// If we reach here then creating and switching to a fiber has failed. This
|
||||
// probably means we are low on memory and will soon crash. Try to report
|
||||
// this error once crash reporting is initialized.
|
||||
fiber_error = ::GetLastError();
|
||||
base::debug::Alias(&fiber_error);
|
||||
}
|
||||
|
||||
// If we are already a fiber then continue normal execution.
|
||||
// Intentionally crash if converting to a fiber failed.
|
||||
CHECK_EQ(fiber_status, FiberStatus::kSuccess);
|
||||
return -1;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_WIN) && defined(ARCH_CPU_32_BITS)
|
||||
|
||||
} // namespace
|
||||
|
||||
int CefExecuteProcess(const CefMainArgs& args,
|
||||
CefRefPtr<CefApp> application,
|
||||
void* windows_sandbox_info) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
DisableFMA3();
|
||||
#endif
|
||||
InitInstallDetails();
|
||||
InitCrashReporter();
|
||||
#endif
|
||||
@@ -284,6 +192,9 @@ bool CefInitialize(const CefMainArgs& args,
|
||||
CefRefPtr<CefApp> application,
|
||||
void* windows_sandbox_info) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
DisableFMA3();
|
||||
#endif
|
||||
InitInstallDetails();
|
||||
InitCrashReporter();
|
||||
#endif
|
||||
@@ -375,30 +286,8 @@ void CefQuitMessageLoop() {
|
||||
g_context->QuitMessageLoop();
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain,
|
||||
HINSTANCE hInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow) {
|
||||
CHECK(wWinMain && hInstance);
|
||||
FiberState fiber_state(wWinMain, hInstance, lpCmdLine, nCmdShow);
|
||||
return RunMainWithPreferredStackSize(fiber_state);
|
||||
}
|
||||
|
||||
int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]) {
|
||||
CHECK(main);
|
||||
FiberState fiber_state(main, argc, argv);
|
||||
return RunMainWithPreferredStackSize(fiber_state);
|
||||
}
|
||||
#endif // defined(ARCH_CPU_32_BITS)
|
||||
|
||||
void CefEnableHighDPISupport() {
|
||||
base::win::EnableHighDPISupport();
|
||||
}
|
||||
|
||||
void CefSetOSModalLoop(bool osModalLoop) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
@@ -411,9 +300,8 @@ void CefSetOSModalLoop(bool osModalLoop) {
|
||||
}
|
||||
|
||||
base::CurrentThread::Get()->set_os_modal_loop(osModalLoop);
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
||||
|
||||
// CefContext
|
||||
|
||||
|
@@ -76,11 +76,12 @@ void CefDevToolsFileManager::Save(const std::string& url,
|
||||
return;
|
||||
}
|
||||
|
||||
const base::Value::Dict& file_map =
|
||||
prefs_->GetDict(prefs::kDevToolsEditedFiles);
|
||||
const base::DictionaryValue* file_map = &base::Value::AsDictionaryValue(
|
||||
*prefs_->GetDictionary(prefs::kDevToolsEditedFiles));
|
||||
base::FilePath initial_path;
|
||||
|
||||
if (const base::Value* path_value = file_map.Find(base::MD5String(url))) {
|
||||
const base::Value* path_value;
|
||||
if (file_map->Get(base::MD5String(url), &path_value)) {
|
||||
absl::optional<base::FilePath> path = base::ValueToFilePath(*path_value);
|
||||
if (path)
|
||||
initial_path = std::move(*path);
|
||||
|
@@ -483,7 +483,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
} else if (*method == "getPreferences") {
|
||||
SendMessageAck(
|
||||
request_id,
|
||||
base::Value(GetPrefs()->GetDict(prefs::kDevToolsPreferences).Clone()));
|
||||
GetPrefs()->GetDictionary(prefs::kDevToolsPreferences)->Clone());
|
||||
return;
|
||||
} else if (*method == "setPreference") {
|
||||
if (params.size() < 2)
|
||||
|
@@ -60,6 +60,14 @@ void ZoomModeToZoomSettings(zoom::ZoomController::ZoomMode zoom_mode,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void AssignOptionalValue(const std::unique_ptr<T>& source,
|
||||
std::unique_ptr<T>& destination) {
|
||||
if (source.get()) {
|
||||
destination.reset(new T(*source));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ExtensionFunction::ResponseAction TabsGetFunction::Run() {
|
||||
@@ -74,23 +82,27 @@ ExtensionFunction::ResponseAction TabsCreateFunction::Run() {
|
||||
EXTENSION_FUNCTION_VALIDATE(params.get());
|
||||
|
||||
CefExtensionFunctionDetails::OpenTabParams options;
|
||||
options.window_id = params->create_properties.window_id;
|
||||
options.opener_tab_id = params->create_properties.opener_tab_id;
|
||||
options.active = params->create_properties.selected;
|
||||
AssignOptionalValue(params->create_properties.window_id, options.window_id);
|
||||
AssignOptionalValue(params->create_properties.opener_tab_id,
|
||||
options.opener_tab_id);
|
||||
AssignOptionalValue(params->create_properties.selected, options.active);
|
||||
// The 'active' property has replaced the 'selected' property.
|
||||
options.active = params->create_properties.active;
|
||||
options.pinned = params->create_properties.pinned;
|
||||
options.index = params->create_properties.index;
|
||||
options.url = params->create_properties.url;
|
||||
AssignOptionalValue(params->create_properties.active, options.active);
|
||||
AssignOptionalValue(params->create_properties.pinned, options.pinned);
|
||||
AssignOptionalValue(params->create_properties.index, options.index);
|
||||
AssignOptionalValue(params->create_properties.url, options.url);
|
||||
|
||||
std::string error;
|
||||
auto result = cef_details_.OpenTab(options, user_gesture(), &error);
|
||||
std::unique_ptr<base::DictionaryValue> result(
|
||||
cef_details_.OpenTab(options, user_gesture(), &error));
|
||||
if (!result)
|
||||
return RespondNow(Error(error));
|
||||
|
||||
// Return data about the newly created tab.
|
||||
return RespondNow(has_callback() ? OneArgument(base::Value(result->ToValue()))
|
||||
: NoArguments());
|
||||
return RespondNow(
|
||||
has_callback()
|
||||
? OneArgument(base::Value::FromUniquePtrValue(std::move(result)))
|
||||
: NoArguments());
|
||||
}
|
||||
|
||||
BaseAPIFunction::BaseAPIFunction() : cef_details_(this) {}
|
||||
@@ -122,7 +134,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
// -favIconUrl
|
||||
|
||||
// Navigate the tab to a new location if the url is different.
|
||||
if (params->update_properties.url.has_value()) {
|
||||
if (params->update_properties.url.get()) {
|
||||
std::string updated_url = *params->update_properties.url;
|
||||
if (!UpdateURL(updated_url, tab_id_, &error_))
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
@@ -131,11 +143,11 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
bool active = false;
|
||||
// TODO(rafaelw): Setting |active| from js doesn't make much sense.
|
||||
// Move tab selection management up to window.
|
||||
if (params->update_properties.selected.has_value())
|
||||
if (params->update_properties.selected.get())
|
||||
active = *params->update_properties.selected;
|
||||
|
||||
// The 'active' property has replaced 'selected'.
|
||||
if (params->update_properties.active.has_value())
|
||||
if (params->update_properties.active.get())
|
||||
active = *params->update_properties.active;
|
||||
|
||||
if (active) {
|
||||
@@ -144,21 +156,21 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
||||
}
|
||||
|
||||
if (params->update_properties.highlighted.has_value() &&
|
||||
if (params->update_properties.highlighted.get() &&
|
||||
*params->update_properties.highlighted) {
|
||||
// TODO: Highlight the tab at |tab_id_|.
|
||||
NOTIMPLEMENTED();
|
||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
||||
}
|
||||
|
||||
if (params->update_properties.pinned.has_value() &&
|
||||
if (params->update_properties.pinned.get() &&
|
||||
*params->update_properties.pinned) {
|
||||
// TODO: Pin the tab at |tab_id_|.
|
||||
NOTIMPLEMENTED();
|
||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
||||
}
|
||||
|
||||
if (params->update_properties.muted.has_value()) {
|
||||
if (params->update_properties.muted.get()) {
|
||||
// TODO: Mute/unmute the tab at |tab_id_|.
|
||||
NOTIMPLEMENTED();
|
||||
return RespondNow(Error(ErrorUtils::FormatErrorMessage(
|
||||
@@ -166,7 +178,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
base::NumberToString(tab_id_))));
|
||||
}
|
||||
|
||||
if (params->update_properties.opener_tab_id.has_value()) {
|
||||
if (params->update_properties.opener_tab_id.get()) {
|
||||
int opener_id = *params->update_properties.opener_tab_id;
|
||||
if (opener_id == tab_id_)
|
||||
return RespondNow(Error("Cannot set a tab's opener to itself."));
|
||||
@@ -176,7 +188,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
return RespondNow(Error(tabs_constants::kTabStripNotEditableError));
|
||||
}
|
||||
|
||||
if (params->update_properties.auto_discardable.has_value()) {
|
||||
if (params->update_properties.auto_discardable.get()) {
|
||||
// TODO: Set auto-discardable state for the tab at |tab_id_|.
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
@@ -230,7 +242,7 @@ ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() {
|
||||
if (!has_callback())
|
||||
return NoArguments();
|
||||
|
||||
return ArgumentList(tabs::Get::Results::Create(cef_details_.CreateTabObject(
|
||||
return ArgumentList(tabs::Get::Results::Create(*cef_details_.CreateTabObject(
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_),
|
||||
/*opener_browser_id=*/-1, /*active=*/true, tab_id_)));
|
||||
}
|
||||
@@ -512,8 +524,8 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
|
||||
ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
|
||||
api::tabs::ZoomSettings zoom_settings;
|
||||
ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
|
||||
zoom_settings.default_zoom_factor =
|
||||
blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel());
|
||||
zoom_settings.default_zoom_factor = std::make_unique<double>(
|
||||
blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()));
|
||||
|
||||
return RespondNow(
|
||||
ArgumentList(api::tabs::GetZoomSettings::Results::Create(zoom_settings)));
|
||||
|
@@ -21,13 +21,14 @@ CefComponentExtensionResourceManager::CefComponentExtensionResourceManager() {
|
||||
kComponentExtensionResourcesSize);
|
||||
AddComponentResourceEntries(kPdfResources, kPdfResourcesSize);
|
||||
|
||||
base::Value::Dict dict;
|
||||
base::Value dict(base::Value::Type::DICTIONARY);
|
||||
pdf_extension_util::AddStrings(
|
||||
pdf_extension_util::PdfViewerContext::kPdfViewer, &dict);
|
||||
pdf_extension_util::AddAdditionalData(/*enable_annotations=*/true, &dict);
|
||||
|
||||
ui::TemplateReplacements pdf_viewer_replacements;
|
||||
ui::TemplateReplacementsFromDictionaryValue(dict, &pdf_viewer_replacements);
|
||||
ui::TemplateReplacementsFromDictionaryValue(dict.GetDict(),
|
||||
&pdf_viewer_replacements);
|
||||
template_replacements_[extension_misc::kPdfExtensionId] =
|
||||
std::move(pdf_viewer_replacements);
|
||||
}
|
||||
|
@@ -288,7 +288,7 @@ CefExtensionFunctionDetails::OpenTabParams::OpenTabParams() {}
|
||||
|
||||
CefExtensionFunctionDetails::OpenTabParams::~OpenTabParams() {}
|
||||
|
||||
std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
||||
const OpenTabParams& params,
|
||||
bool user_gesture,
|
||||
std::string* error_message) const {
|
||||
@@ -298,7 +298,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
|
||||
// windowId defaults to "current" window.
|
||||
int window_id = extension_misc::kCurrentWindowId;
|
||||
if (params.window_id.has_value())
|
||||
if (params.window_id.get())
|
||||
window_id = *params.window_id;
|
||||
|
||||
// CEF doesn't have the concept of windows containing tab strips so we'll
|
||||
@@ -310,7 +310,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
|
||||
// If an opener browser was specified then we expect it to exist.
|
||||
int opener_browser_id = -1;
|
||||
if (params.opener_tab_id.has_value() && *params.opener_tab_id >= 0) {
|
||||
if (params.opener_tab_id.get() && *params.opener_tab_id >= 0) {
|
||||
if (GetBrowserForTabIdAgain(*params.opener_tab_id, error_message)) {
|
||||
opener_browser_id = *params.opener_tab_id;
|
||||
} else {
|
||||
@@ -319,7 +319,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
}
|
||||
|
||||
GURL url;
|
||||
if (params.url.has_value()) {
|
||||
if (params.url.get()) {
|
||||
std::string url_string = *params.url;
|
||||
if (!ExtensionTabUtil::PrepareURLForNavigation(
|
||||
url_string, function()->extension(), &url, error_message)) {
|
||||
@@ -330,12 +330,12 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
// Default to foreground for the new tab. The presence of 'active' property
|
||||
// will override this default.
|
||||
bool active = true;
|
||||
if (params.active.has_value())
|
||||
if (params.active.get())
|
||||
active = *params.active;
|
||||
|
||||
// CEF doesn't use the index value but we let the client see/modify it.
|
||||
int index = 0;
|
||||
if (params.index.has_value())
|
||||
if (params.index.get())
|
||||
index = *params.index;
|
||||
|
||||
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
|
||||
@@ -369,7 +369,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
create_params.settings = active_browser->settings();
|
||||
|
||||
CefRefPtr<CefExtensionHandler> handler = cef_extension->GetHandler();
|
||||
if (handler &&
|
||||
if (handler.get() &&
|
||||
handler->OnBeforeBrowser(cef_extension, sender_browser.get(),
|
||||
active_browser.get(), index, create_params.url,
|
||||
active, *create_params.window_info,
|
||||
@@ -397,12 +397,12 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
auto scrub_tab_behavior = ExtensionTabUtil::GetScrubTabBehavior(
|
||||
extension, extensions::Feature::Context::UNSPECIFIED_CONTEXT,
|
||||
web_contents);
|
||||
ExtensionTabUtil::ScrubTabForExtension(extension, web_contents, &result,
|
||||
ExtensionTabUtil::ScrubTabForExtension(extension, web_contents, result.get(),
|
||||
scrub_tab_behavior);
|
||||
return base::WrapUnique(new api::tabs::Tab(std::move(result)));
|
||||
return result->ToValue().release();
|
||||
}
|
||||
|
||||
api::tabs::Tab CefExtensionFunctionDetails::CreateTabObject(
|
||||
std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::CreateTabObject(
|
||||
CefRefPtr<AlloyBrowserHostImpl> new_browser,
|
||||
int opener_browser_id,
|
||||
bool active,
|
||||
@@ -410,45 +410,47 @@ api::tabs::Tab CefExtensionFunctionDetails::CreateTabObject(
|
||||
content::WebContents* contents = new_browser->web_contents();
|
||||
|
||||
bool is_loading = contents->IsLoading();
|
||||
api::tabs::Tab tab_object;
|
||||
tab_object.id = new_browser->GetIdentifier();
|
||||
tab_object.index = index;
|
||||
tab_object.window_id = *tab_object.id;
|
||||
tab_object.status = is_loading ? api::tabs::TAB_STATUS_LOADING
|
||||
: api::tabs::TAB_STATUS_COMPLETE;
|
||||
tab_object.active = active;
|
||||
tab_object.selected = true;
|
||||
tab_object.highlighted = true;
|
||||
tab_object.pinned = false;
|
||||
auto tab_object = std::make_unique<api::tabs::Tab>();
|
||||
tab_object->id = std::make_unique<int>(new_browser->GetIdentifier());
|
||||
tab_object->index = index;
|
||||
tab_object->window_id = *tab_object->id;
|
||||
tab_object->status = is_loading ? api::tabs::TAB_STATUS_LOADING
|
||||
: api::tabs::TAB_STATUS_COMPLETE;
|
||||
tab_object->active = active;
|
||||
tab_object->selected = true;
|
||||
tab_object->highlighted = true;
|
||||
tab_object->pinned = false;
|
||||
// TODO(extensions): Use RecentlyAudibleHelper to populate |audible|.
|
||||
tab_object.discarded = false;
|
||||
tab_object.auto_discardable = false;
|
||||
tab_object.muted_info = CreateMutedInfo(contents);
|
||||
tab_object.incognito = false;
|
||||
tab_object->discarded = false;
|
||||
tab_object->auto_discardable = false;
|
||||
tab_object->muted_info = CreateMutedInfo(contents);
|
||||
tab_object->incognito = false;
|
||||
gfx::Size contents_size = contents->GetContainerBounds().size();
|
||||
tab_object.width = contents_size.width();
|
||||
tab_object.height = contents_size.height();
|
||||
tab_object.url = contents->GetURL().spec();
|
||||
tab_object.title = base::UTF16ToUTF8(contents->GetTitle());
|
||||
tab_object->width = std::make_unique<int>(contents_size.width());
|
||||
tab_object->height = std::make_unique<int>(contents_size.height());
|
||||
tab_object->url = std::make_unique<std::string>(contents->GetURL().spec());
|
||||
tab_object->title =
|
||||
std::make_unique<std::string>(base::UTF16ToUTF8(contents->GetTitle()));
|
||||
|
||||
content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
|
||||
if (entry && entry->GetFavicon().valid) {
|
||||
tab_object.fav_icon_url = entry->GetFavicon().url.spec();
|
||||
tab_object->fav_icon_url =
|
||||
std::make_unique<std::string>(entry->GetFavicon().url.spec());
|
||||
}
|
||||
|
||||
if (opener_browser_id >= 0)
|
||||
tab_object.opener_tab_id = opener_browser_id;
|
||||
tab_object->opener_tab_id = std::make_unique<int>(opener_browser_id);
|
||||
|
||||
return tab_object;
|
||||
}
|
||||
|
||||
// static
|
||||
api::tabs::MutedInfo CefExtensionFunctionDetails::CreateMutedInfo(
|
||||
content::WebContents* contents) {
|
||||
std::unique_ptr<api::tabs::MutedInfo>
|
||||
CefExtensionFunctionDetails::CreateMutedInfo(content::WebContents* contents) {
|
||||
DCHECK(contents);
|
||||
api::tabs::MutedInfo info;
|
||||
info.muted = contents->IsAudioMuted();
|
||||
// TODO(cef): Maybe populate |info.reason|.
|
||||
std::unique_ptr<api::tabs::MutedInfo> info(new api::tabs::MutedInfo);
|
||||
info->muted = contents->IsAudioMuted();
|
||||
// TODO(cef): Maybe populate |info->reason|.
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@@ -98,35 +98,35 @@ class CefExtensionFunctionDetails {
|
||||
OpenTabParams();
|
||||
~OpenTabParams();
|
||||
|
||||
bool create_browser_if_needed = false;
|
||||
absl::optional<int> window_id;
|
||||
absl::optional<int> opener_tab_id;
|
||||
absl::optional<std::string> url;
|
||||
absl::optional<bool> active;
|
||||
absl::optional<bool> pinned;
|
||||
absl::optional<int> index;
|
||||
absl::optional<int> bookmark_id;
|
||||
std::unique_ptr<int> window_id;
|
||||
std::unique_ptr<int> opener_tab_id;
|
||||
std::unique_ptr<std::string> url;
|
||||
std::unique_ptr<bool> active;
|
||||
std::unique_ptr<bool> pinned;
|
||||
std::unique_ptr<int> index;
|
||||
};
|
||||
|
||||
// Opens a new tab given creation parameters |params|. Returns a Tab object
|
||||
// if successful, or NULL and optionally sets |error_message| if an error
|
||||
// occurs.
|
||||
std::unique_ptr<api::tabs::Tab> OpenTab(const OpenTabParams& params,
|
||||
bool user_gesture,
|
||||
std::string* error_message) const;
|
||||
base::DictionaryValue* OpenTab(const OpenTabParams& params,
|
||||
bool user_gesture,
|
||||
std::string* error_message) const;
|
||||
|
||||
// Creates a Tab object (see chrome/common/extensions/api/tabs.json) with
|
||||
// information about the state of a browser tab. Depending on the
|
||||
// permissions of the extension, the object may or may not include sensitive
|
||||
// data such as the tab's URL.
|
||||
api::tabs::Tab CreateTabObject(CefRefPtr<AlloyBrowserHostImpl> new_browser,
|
||||
int opener_browser_id,
|
||||
bool active,
|
||||
int index) const;
|
||||
std::unique_ptr<api::tabs::Tab> CreateTabObject(
|
||||
CefRefPtr<AlloyBrowserHostImpl> new_browser,
|
||||
int opener_browser_id,
|
||||
bool active,
|
||||
int index) const;
|
||||
|
||||
// Creates a tab MutedInfo object (see chrome/common/extensions/api/tabs.json)
|
||||
// with information about the mute state of a browser tab.
|
||||
static api::tabs::MutedInfo CreateMutedInfo(content::WebContents* contents);
|
||||
static std::unique_ptr<api::tabs::MutedInfo> CreateMutedInfo(
|
||||
content::WebContents* contents);
|
||||
|
||||
// Returns a pointer to the associated ExtensionFunction
|
||||
ExtensionFunction* function() { return function_; }
|
||||
|
@@ -11,9 +11,9 @@
|
||||
#include "libcef/browser/extensions/api/storage/sync_value_store_cache.h"
|
||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
#include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "components/pdf/browser/pdf_web_contents_helper.h"
|
||||
@@ -51,7 +51,7 @@ CefExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
||||
void CefExtensionsAPIClient::AttachWebContentsHelpers(
|
||||
content::WebContents* web_contents) const {
|
||||
PrefsTabHelper::CreateForWebContents(web_contents);
|
||||
printing::PrintViewManager::CreateForWebContents(web_contents);
|
||||
printing::CefPrintViewManager::CreateForWebContents(web_contents);
|
||||
|
||||
// Used by the PDF extension.
|
||||
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
|
||||
|
@@ -143,29 +143,6 @@ BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::BrowserContext*
|
||||
CefExtensionsBrowserClient::GetRedirectedContextInIncognito(
|
||||
content::BrowserContext* context,
|
||||
bool force_guest_profile,
|
||||
bool force_system_profile) {
|
||||
return context;
|
||||
}
|
||||
|
||||
content::BrowserContext*
|
||||
CefExtensionsBrowserClient::GetContextForRegularAndIncognito(
|
||||
content::BrowserContext* context,
|
||||
bool force_guest_profile,
|
||||
bool force_system_profile) {
|
||||
return context;
|
||||
}
|
||||
|
||||
content::BrowserContext* CefExtensionsBrowserClient::GetRegularProfile(
|
||||
content::BrowserContext* context,
|
||||
bool force_guest_profile,
|
||||
bool force_system_profile) {
|
||||
return context;
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsGuestSession(BrowserContext* context) const {
|
||||
return false;
|
||||
}
|
||||
|
@@ -39,18 +39,6 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
content::BrowserContext* context) override;
|
||||
content::BrowserContext* GetOriginalContext(
|
||||
content::BrowserContext* context) override;
|
||||
content::BrowserContext* GetRedirectedContextInIncognito(
|
||||
content::BrowserContext* context,
|
||||
bool force_guest_profile,
|
||||
bool force_system_profile) override;
|
||||
content::BrowserContext* GetContextForRegularAndIncognito(
|
||||
content::BrowserContext* context,
|
||||
bool force_guest_profile,
|
||||
bool force_system_profile) override;
|
||||
content::BrowserContext* GetRegularProfile(
|
||||
content::BrowserContext* context,
|
||||
bool force_guest_profile,
|
||||
bool force_system_profile) override;
|
||||
bool IsGuestSession(content::BrowserContext* context) const override;
|
||||
bool IsExtensionIncognitoEnabled(
|
||||
const std::string& extension_id,
|
||||
|
@@ -68,8 +68,7 @@ class CefSelectFileDialog final : public ui::SelectFileDialog {
|
||||
int file_type_index,
|
||||
const base::FilePath::StringType& default_extension,
|
||||
gfx::NativeWindow owning_window,
|
||||
void* params,
|
||||
const GURL* caller) override {
|
||||
void* params) override {
|
||||
// Try to determine the associated browser (with decreasing levels of
|
||||
// confidence).
|
||||
// 1. Browser associated with the SelectFilePolicy. This is the most
|
||||
|
@@ -1,54 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/global_preference_manager_impl.h"
|
||||
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/prefs/pref_helper.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "chrome/browser/browser_process.h"
|
||||
|
||||
bool CefGlobalPreferenceManagerImpl::HasPreference(const CefString& name) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
return pref_helper::HasPreference(g_browser_process->local_state(), name);
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CefGlobalPreferenceManagerImpl::GetPreference(
|
||||
const CefString& name) {
|
||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||
return pref_helper::GetPreference(g_browser_process->local_state(), name);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> CefGlobalPreferenceManagerImpl::GetAllPreferences(
|
||||
bool include_defaults) {
|
||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||
return pref_helper::GetAllPreferences(g_browser_process->local_state(),
|
||||
include_defaults);
|
||||
}
|
||||
|
||||
bool CefGlobalPreferenceManagerImpl::CanSetPreference(const CefString& name) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
return pref_helper::CanSetPreference(g_browser_process->local_state(), name);
|
||||
}
|
||||
|
||||
bool CefGlobalPreferenceManagerImpl::SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
return pref_helper::SetPreference(g_browser_process->local_state(), name,
|
||||
value, error);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPreferenceManager>
|
||||
CefPreferenceManager::GetGlobalPreferenceManager() {
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new CefGlobalPreferenceManagerImpl();
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_preference.h"
|
||||
|
||||
// Implementation of the CefPreferenceManager interface for global preferences.
|
||||
class CefGlobalPreferenceManagerImpl : public CefPreferenceManager {
|
||||
public:
|
||||
CefGlobalPreferenceManagerImpl() = default;
|
||||
|
||||
CefGlobalPreferenceManagerImpl(const CefGlobalPreferenceManagerImpl&) =
|
||||
delete;
|
||||
CefGlobalPreferenceManagerImpl& operator=(
|
||||
const CefGlobalPreferenceManagerImpl&) = delete;
|
||||
|
||||
// CefPreferenceManager methods.
|
||||
bool HasPreference(const CefString& name) override;
|
||||
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) override;
|
||||
bool CanSetPreference(const CefString& name) override;
|
||||
bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) override;
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(CefGlobalPreferenceManagerImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
|
@@ -150,8 +150,8 @@ void CefMediaRouterImpl::Initialize(
|
||||
|
||||
initialized_ = true;
|
||||
if (!init_callbacks_.empty()) {
|
||||
for (auto& init_callback : init_callbacks_) {
|
||||
std::move(init_callback).Run();
|
||||
for (auto& callback : init_callbacks_) {
|
||||
std::move(callback).Run();
|
||||
}
|
||||
init_callbacks_.clear();
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/base_event_utils.h"
|
||||
#include "ui/events/keycodes/keyboard_codes_posix.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
@@ -145,90 +144,8 @@ constexpr int kDefaultHeight = 750;
|
||||
constexpr int kDefaultWidth = 750;
|
||||
constexpr NSWindowStyleMask kDefaultStyleMask =
|
||||
NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
||||
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
|
||||
|
||||
// Keep the frame bounds inside the display work area.
|
||||
NSRect ClampNSBoundsToWorkArea(const NSRect& frame_bounds,
|
||||
const gfx::Rect& display_bounds,
|
||||
const gfx::Rect& work_area) {
|
||||
NSRect bounds = frame_bounds;
|
||||
|
||||
// Convert from DIP coordinates (top-left origin) to macOS coordinates
|
||||
// (bottom-left origin).
|
||||
const int work_area_y =
|
||||
display_bounds.height() - work_area.height() - work_area.y();
|
||||
|
||||
if (bounds.size.width > work_area.width()) {
|
||||
bounds.size.width = work_area.width();
|
||||
}
|
||||
if (bounds.size.height > work_area.height()) {
|
||||
bounds.size.height = work_area.height();
|
||||
}
|
||||
|
||||
if (bounds.origin.x < work_area.x()) {
|
||||
bounds.origin.x = work_area.x();
|
||||
} else if (bounds.origin.x + bounds.size.width >=
|
||||
work_area.x() + work_area.width()) {
|
||||
bounds.origin.x = work_area.x() + work_area.width() - bounds.size.width;
|
||||
}
|
||||
|
||||
if (bounds.origin.y < work_area_y) {
|
||||
bounds.origin.y = work_area_y;
|
||||
} else if (bounds.origin.y + bounds.size.height >=
|
||||
work_area_y + work_area.height()) {
|
||||
bounds.origin.y = work_area_y + work_area.height() - bounds.size.height;
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
// Get frame and content area rects matching the input DIP screen bounds. The
|
||||
// resulting window frame will be kept inside the closest display work area. If
|
||||
// |input_content_bounds| is true the input size is used for the content area
|
||||
// and the input origin is used for the frame. Otherwise, both input size and
|
||||
// origin are used for the frame.
|
||||
void GetNSBoundsInDisplay(const gfx::Rect& dip_bounds,
|
||||
bool input_content_bounds,
|
||||
NSWindowStyleMask style_mask,
|
||||
NSRect& frame_rect,
|
||||
NSRect& content_rect) {
|
||||
// Identify the closest display.
|
||||
const auto display =
|
||||
display::Screen::GetScreen()->GetDisplayMatching(dip_bounds);
|
||||
const auto& display_bounds = display.bounds();
|
||||
const auto& display_work_area = display.work_area();
|
||||
|
||||
// Convert from DIP coordinates (top-left origin) to macOS coordinates
|
||||
// (bottom-left origin).
|
||||
NSRect requested_rect = NSMakeRect(dip_bounds.x(), dip_bounds.y(),
|
||||
dip_bounds.width(), dip_bounds.height());
|
||||
requested_rect.origin.y = display_bounds.height() -
|
||||
requested_rect.size.height -
|
||||
requested_rect.origin.y;
|
||||
|
||||
// Calculate the equivalent frame and content bounds.
|
||||
if (input_content_bounds) {
|
||||
// Compute frame rect from content rect. Keep the requested origin.
|
||||
content_rect = requested_rect;
|
||||
frame_rect = [NSWindow frameRectForContentRect:content_rect
|
||||
styleMask:style_mask];
|
||||
frame_rect.origin = requested_rect.origin;
|
||||
} else {
|
||||
// Compute content rect from frame rect.
|
||||
frame_rect = requested_rect;
|
||||
content_rect = [NSWindow contentRectForFrameRect:frame_rect
|
||||
styleMask:style_mask];
|
||||
}
|
||||
|
||||
// Keep the frame inside the display work area.
|
||||
const NSRect new_frame_rect =
|
||||
ClampNSBoundsToWorkArea(frame_rect, display_bounds, display_work_area);
|
||||
if (!NSEqualRects(frame_rect, new_frame_rect)) {
|
||||
frame_rect = new_frame_rect;
|
||||
content_rect = [NSWindow contentRectForFrameRect:frame_rect
|
||||
styleMask:style_mask];
|
||||
}
|
||||
}
|
||||
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable |
|
||||
NSWindowStyleMaskUnifiedTitleAndToolbar;
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -251,52 +168,48 @@ void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed(
|
||||
bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
||||
|
||||
NSWindow* new_window = nil;
|
||||
NSWindow* newWnd = nil;
|
||||
|
||||
NSView* parent_view =
|
||||
NSView* parentView =
|
||||
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(window_info_.parent_view);
|
||||
NSRect browser_view_rect =
|
||||
NSMakeRect(window_info_.bounds.x, window_info_.bounds.y,
|
||||
window_info_.bounds.width, window_info_.bounds.height);
|
||||
|
||||
if (parent_view == nil) {
|
||||
// TODO(port): If no x,y position is specified the window will always appear
|
||||
// in the upper-left corner. Maybe there's a better default place to put it?
|
||||
const gfx::Rect dip_bounds(
|
||||
window_info_.bounds.x, window_info_.bounds.y,
|
||||
window_info_.bounds.width <= 0 ? kDefaultWidth
|
||||
: window_info_.bounds.width,
|
||||
window_info_.bounds.height <= 0 ? kDefaultHeight
|
||||
: window_info_.bounds.height);
|
||||
|
||||
// Calculate the equivalent frame and content area bounds.
|
||||
NSRect frame_rect, content_rect;
|
||||
GetNSBoundsInDisplay(dip_bounds, /*input_content_bounds=*/true,
|
||||
kDefaultStyleMask, frame_rect, content_rect);
|
||||
const CGFloat x = static_cast<CGFloat>(window_info_.bounds.x);
|
||||
const CGFloat y = static_cast<CGFloat>(window_info_.bounds.y);
|
||||
const CGFloat width = static_cast<CGFloat>(window_info_.bounds.width);
|
||||
const CGFloat height = static_cast<CGFloat>(window_info_.bounds.height);
|
||||
|
||||
NSRect content_rect = {{x, y}, {width, height}};
|
||||
if (parentView == nil) {
|
||||
// Create a new window.
|
||||
new_window = [[UnderlayOpenGLHostingWindow alloc]
|
||||
initWithContentRect:content_rect
|
||||
NSRect window_rect = {{x, y}, {width, height}};
|
||||
if (window_rect.size.width == 0)
|
||||
window_rect.size.width = kDefaultWidth;
|
||||
if (window_rect.size.height == 0)
|
||||
window_rect.size.height = kDefaultHeight;
|
||||
|
||||
content_rect = {{0, 0}, {window_rect.size.width, window_rect.size.height}};
|
||||
|
||||
newWnd = [[UnderlayOpenGLHostingWindow alloc]
|
||||
initWithContentRect:window_rect
|
||||
styleMask:kDefaultStyleMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
|
||||
// Create the delegate for control and browser window events.
|
||||
[[CefWindowDelegate alloc] initWithWindow:new_window andBrowser:browser_];
|
||||
[[CefWindowDelegate alloc] initWithWindow:newWnd andBrowser:browser_];
|
||||
|
||||
parent_view = [new_window contentView];
|
||||
browser_view_rect = [parent_view bounds];
|
||||
|
||||
window_info_.parent_view = parent_view;
|
||||
parentView = [newWnd contentView];
|
||||
window_info_.parent_view = parentView;
|
||||
|
||||
// Make the content view for the window have a layer. This will make all
|
||||
// sub-views have layers. This is necessary to ensure correct layer
|
||||
// ordering of all child views and their layers.
|
||||
[parent_view setWantsLayer:YES];
|
||||
[parentView setWantsLayer:YES];
|
||||
|
||||
// Place the window at the target point. This is required for proper
|
||||
// placement if the point is on a secondary display.
|
||||
[new_window setFrameOrigin:frame_rect.origin];
|
||||
// Transform input Y coodinate into the MacOS coordinate.
|
||||
NSRect primary_screen_rect = [[[NSScreen screens] firstObject] frame];
|
||||
const CGFloat transformed_y = NSMaxY(primary_screen_rect) - y;
|
||||
[newWnd setFrameTopLeftPoint:NSMakePoint(x, transformed_y)];
|
||||
}
|
||||
|
||||
host_window_created_ = true;
|
||||
@@ -306,14 +219,14 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
|
||||
// Create the browser view.
|
||||
CefBrowserHostView* browser_view =
|
||||
[[CefBrowserHostView alloc] initWithFrame:browser_view_rect];
|
||||
[[CefBrowserHostView alloc] initWithFrame:content_rect];
|
||||
browser_view.browser = browser_;
|
||||
[parent_view addSubview:browser_view];
|
||||
[parentView addSubview:browser_view];
|
||||
[browser_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[browser_view setNeedsDisplay:YES];
|
||||
[browser_view release];
|
||||
|
||||
// Parent the WebContents to the browser view.
|
||||
// Parent the TabContents to the browser view.
|
||||
const NSRect bounds = [browser_view bounds];
|
||||
NSView* native_view = web_contents_->GetNativeView().GetNativeNSView();
|
||||
[browser_view addSubview:native_view];
|
||||
@@ -323,9 +236,9 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
|
||||
window_info_.view = browser_view;
|
||||
|
||||
if (new_window != nil && !window_info_.hidden) {
|
||||
if (newWnd != nil && !window_info_.hidden) {
|
||||
// Show the window.
|
||||
[new_window makeKeyAndOrderFront:nil];
|
||||
[newWnd makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -407,9 +320,9 @@ void CefBrowserPlatformDelegateNativeMac::SetFocus(bool setFocus) {
|
||||
|
||||
if (setFocus) {
|
||||
// Give keyboard focus to the native view.
|
||||
NSView* nsview = web_contents_->GetContentNativeView().GetNativeNSView();
|
||||
DCHECK([nsview canBecomeKeyView]);
|
||||
[[nsview window] makeFirstResponder:nsview];
|
||||
NSView* view = web_contents_->GetContentNativeView().GetNativeNSView();
|
||||
DCHECK([view canBecomeKeyView]);
|
||||
[[view window] makeFirstResponder:view];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#include "ui/base/win/shell.h"
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/display/win/screen_win.h"
|
||||
#include "ui/events/keycodes/dom/dom_key.h"
|
||||
#include "ui/events/keycodes/dom/keycode_converter.h"
|
||||
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
|
||||
@@ -123,65 +122,84 @@ void ExecuteExternalProtocol(const GURL& url) {
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Rect GetDisplayWorkAreaNearestPoint(gfx::Point dip_point) {
|
||||
const auto display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestPoint(dip_point);
|
||||
// Work area in DIP.
|
||||
return display.work_area();
|
||||
// DPI value for 1x scale factor.
|
||||
#define DPI_1X 96.0f
|
||||
|
||||
float GetWindowScaleFactor(HWND hwnd) {
|
||||
DCHECK(hwnd);
|
||||
|
||||
if (base::win::IsProcessPerMonitorDpiAware()) {
|
||||
// Let Windows tell us the correct DPI.
|
||||
static auto get_dpi_for_window_func = []() {
|
||||
return reinterpret_cast<decltype(::GetDpiForWindow)*>(
|
||||
GetProcAddress(GetModuleHandle(L"user32.dll"), "GetDpiForWindow"));
|
||||
}();
|
||||
if (get_dpi_for_window_func)
|
||||
return static_cast<float>(get_dpi_for_window_func(hwnd)) / DPI_1X;
|
||||
}
|
||||
|
||||
// Fallback to the monitor that contains the window center point.
|
||||
RECT cr;
|
||||
GetWindowRect(hwnd, &cr);
|
||||
return display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(
|
||||
gfx::Point((cr.right - cr.left) / 2, (cr.bottom - cr.top) / 2))
|
||||
.device_scale_factor();
|
||||
}
|
||||
|
||||
CefRect GetScreenFrameRectFromDIPContentRect(HWND window,
|
||||
gfx::Rect dip_rect,
|
||||
DWORD style,
|
||||
DWORD ex_style,
|
||||
bool has_menu) {
|
||||
// Convert from DIP using a method that can handle multiple displays with
|
||||
// different DPI. If |window| is nullptr the closest display will be used.
|
||||
const auto screen_rect =
|
||||
display::win::ScreenWin::DIPToScreenRect(window, dip_rect);
|
||||
struct ScreenInfo {
|
||||
float scale_factor;
|
||||
CefRect rect;
|
||||
};
|
||||
|
||||
RECT rect = {screen_rect.x(), screen_rect.y(),
|
||||
screen_rect.x() + screen_rect.width(),
|
||||
screen_rect.y() + screen_rect.height()};
|
||||
ScreenInfo GetScreenInfo(int x, int y) {
|
||||
const auto display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestPoint(gfx::Point(x, y));
|
||||
const auto rect = display.work_area();
|
||||
|
||||
return ScreenInfo{display.device_scale_factor(),
|
||||
CefRect(rect.x(), rect.y(), rect.width(), rect.height())};
|
||||
}
|
||||
|
||||
CefRect GetFrameRectFromLogicalContentRect(CefRect content,
|
||||
DWORD style,
|
||||
DWORD ex_style,
|
||||
bool has_menu,
|
||||
float scale) {
|
||||
const auto scaled_rect = gfx::ScaleToRoundedRect(
|
||||
gfx::Rect(content.x, content.y, content.width, content.height), scale);
|
||||
|
||||
RECT rect = {0, 0, scaled_rect.width(), scaled_rect.height()};
|
||||
|
||||
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
|
||||
|
||||
// Keep the original origin while potentially increasing the size to include
|
||||
// the frame non-client area.
|
||||
return CefRect(screen_rect.x(), screen_rect.y(), rect.right - rect.left,
|
||||
return CefRect(scaled_rect.x(), scaled_rect.y(), rect.right - rect.left,
|
||||
rect.bottom - rect.top);
|
||||
}
|
||||
|
||||
CefRect GetAdjustedScreenFrameRect(CefRect screen_rect,
|
||||
DWORD style,
|
||||
DWORD ex_style,
|
||||
bool has_menu) {
|
||||
// If height or width is not provided let the OS determine the position and
|
||||
// size similar to Chromium behavior. Note that |CW_USEDEFAULT| cannot be
|
||||
// stored in a gfx::Rect due to clamping.
|
||||
if (screen_rect.width == CW_USEDEFAULT ||
|
||||
screen_rect.height == CW_USEDEFAULT) {
|
||||
CefRect GetAdjustedWindowRect(CefRect content,
|
||||
DWORD style,
|
||||
DWORD ex_style,
|
||||
bool has_menu) {
|
||||
// If height or width is not provided, let OS determine position and size,
|
||||
// similarly to Chromium behavior
|
||||
if (content.width == CW_USEDEFAULT || content.height == CW_USEDEFAULT) {
|
||||
return CefRect(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);
|
||||
}
|
||||
|
||||
if (screen_rect.x == CW_USEDEFAULT) {
|
||||
screen_rect.x = 0;
|
||||
if (content.x == CW_USEDEFAULT) {
|
||||
content.x = 0;
|
||||
}
|
||||
|
||||
if (screen_rect.y == CW_USEDEFAULT) {
|
||||
screen_rect.y = 0;
|
||||
if (content.y == CW_USEDEFAULT) {
|
||||
content.y = 0;
|
||||
}
|
||||
|
||||
// Convert to DIP using a method that can handle multiple displays with
|
||||
// different DPI.
|
||||
const auto dip_rect = display::win::ScreenWin::ScreenToDIPRect(
|
||||
nullptr, gfx::Rect(screen_rect.x, screen_rect.y, screen_rect.width,
|
||||
screen_rect.height));
|
||||
const auto visible_dip_rect = MakeVisibleOnScreenRect(
|
||||
dip_rect, GetDisplayWorkAreaNearestPoint(dip_rect.origin()));
|
||||
const ScreenInfo screen = GetScreenInfo(content.x, content.y);
|
||||
const CefRect rect = MakeVisibleOnScreenRect(content, screen.rect);
|
||||
|
||||
return GetScreenFrameRectFromDIPContentRect(
|
||||
/*window=*/nullptr, visible_dip_rect, style, ex_style, has_menu);
|
||||
return GetFrameRectFromLogicalContentRect(rect, style, ex_style, has_menu,
|
||||
screen.scale_factor);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -227,8 +245,8 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
if (!window_info_.parent_window) {
|
||||
const bool has_menu =
|
||||
!(window_info_.style & WS_CHILD) && (window_info_.menu != NULL);
|
||||
window_rect = GetAdjustedScreenFrameRect(window_rect, window_info_.style,
|
||||
window_info_.ex_style, has_menu);
|
||||
window_rect = GetAdjustedWindowRect(window_rect, window_info_.style,
|
||||
window_info_.ex_style, has_menu);
|
||||
}
|
||||
|
||||
// Create the new browser window.
|
||||
@@ -265,13 +283,13 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
|
||||
DCHECK(!window_widget_);
|
||||
|
||||
// Convert from device coordinates to logical coordinates.
|
||||
RECT cr;
|
||||
GetClientRect(window_info_.window, &cr);
|
||||
|
||||
// Convert to DIP using a method that can handle multiple displays with
|
||||
// different DPI. Client coordinates always have origin (0,0).
|
||||
const gfx::Rect dip_rect = display::win::ScreenWin::ScreenToDIPRect(
|
||||
window_info_.window, gfx::Rect(0, 0, cr.right, cr.bottom));
|
||||
gfx::Point point = gfx::Point(cr.right, cr.bottom);
|
||||
const float scale = GetWindowScaleFactor(window_info_.window);
|
||||
point =
|
||||
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
|
||||
|
||||
// Stay on top if top-most window hosting the web view is topmost.
|
||||
HWND top_level_window = GetAncestor(window_info_.window, GA_ROOT);
|
||||
@@ -283,7 +301,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
CefWindowDelegateView* delegate_view = new CefWindowDelegateView(
|
||||
GetBackgroundColor(), always_on_top, GetBoundsChangedCallback());
|
||||
delegate_view->Init(window_info_.window, web_contents_,
|
||||
gfx::Rect(0, 0, dip_rect.width(), dip_rect.height()));
|
||||
gfx::Rect(0, 0, point.x(), point.y()));
|
||||
|
||||
window_widget_ = delegate_view->GetWidget();
|
||||
|
||||
@@ -422,9 +440,11 @@ void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
|
||||
const DWORD style = GetWindowLong(window, GWL_STYLE);
|
||||
const DWORD ex_style = GetWindowLong(window, GWL_EXSTYLE);
|
||||
const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != NULL);
|
||||
const float scale = GetWindowScaleFactor(window);
|
||||
|
||||
const auto frame_rect = GetScreenFrameRectFromDIPContentRect(
|
||||
window, gfx::Rect(0, 0, width, height), style, ex_style, has_menu);
|
||||
const CefRect content_rect(0, 0, width, height);
|
||||
const CefRect frame_rect = GetFrameRectFromLogicalContentRect(
|
||||
content_rect, style, ex_style, has_menu, scale);
|
||||
|
||||
// Size the window. The left/top values may be negative.
|
||||
SetWindowPos(window, NULL, 0, 0, frame_rect.width, frame_rect.height,
|
||||
|
@@ -130,8 +130,8 @@ void CefCookieManagerImpl::Initialize(
|
||||
|
||||
initialized_ = true;
|
||||
if (!init_callbacks_.empty()) {
|
||||
for (auto& init_callback : init_callbacks_) {
|
||||
std::move(init_callback).Run();
|
||||
for (auto& callback : init_callbacks_) {
|
||||
std::move(callback).Run();
|
||||
}
|
||||
init_callbacks_.clear();
|
||||
}
|
||||
|
@@ -227,15 +227,14 @@ class InterceptedRequest : public network::mojom::URLLoader,
|
||||
|
||||
// mojom::URLLoaderClient methods:
|
||||
void OnReceiveEarlyHints(network::mojom::EarlyHintsPtr early_hints) override;
|
||||
void OnReceiveResponse(
|
||||
network::mojom::URLResponseHeadPtr head,
|
||||
mojo::ScopedDataPipeConsumerHandle body,
|
||||
absl::optional<mojo_base::BigBuffer> cached_metadata) override;
|
||||
void OnReceiveResponse(network::mojom::URLResponseHeadPtr head,
|
||||
mojo::ScopedDataPipeConsumerHandle body) override;
|
||||
void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
|
||||
network::mojom::URLResponseHeadPtr head) override;
|
||||
void OnUploadProgress(int64_t current_position,
|
||||
int64_t total_size,
|
||||
OnUploadProgressCallback callback) override;
|
||||
void OnReceiveCachedMetadata(mojo_base::BigBuffer data) override;
|
||||
void OnTransferSizeUpdated(int32_t transfer_size_diff) override;
|
||||
void OnComplete(const network::URLLoaderCompletionStatus& status) override;
|
||||
|
||||
@@ -335,7 +334,6 @@ class InterceptedRequest : public network::mojom::URLLoader,
|
||||
network::ResourceRequest request_;
|
||||
network::mojom::URLResponseHeadPtr current_response_;
|
||||
mojo::ScopedDataPipeConsumerHandle current_body_;
|
||||
absl::optional<mojo_base::BigBuffer> current_cached_metadata_;
|
||||
scoped_refptr<net::HttpResponseHeaders> current_headers_;
|
||||
scoped_refptr<net::HttpResponseHeaders> override_headers_;
|
||||
GURL original_url_;
|
||||
@@ -560,11 +558,9 @@ void InterceptedRequest::OnReceiveEarlyHints(
|
||||
|
||||
void InterceptedRequest::OnReceiveResponse(
|
||||
network::mojom::URLResponseHeadPtr head,
|
||||
mojo::ScopedDataPipeConsumerHandle body,
|
||||
absl::optional<mojo_base::BigBuffer> cached_metadata) {
|
||||
mojo::ScopedDataPipeConsumerHandle body) {
|
||||
current_response_ = std::move(head);
|
||||
current_body_ = std::move(body);
|
||||
current_cached_metadata_ = std::move(cached_metadata);
|
||||
|
||||
// |current_headers_| may be null for cached responses where OnHeadersReceived
|
||||
// is not called.
|
||||
@@ -592,7 +588,6 @@ void InterceptedRequest::OnReceiveRedirect(
|
||||
|
||||
current_response_ = std::move(head);
|
||||
current_body_.reset();
|
||||
current_cached_metadata_.reset();
|
||||
|
||||
// |current_headers_| may be null for synthetic redirects where
|
||||
// OnHeadersReceived is not called.
|
||||
@@ -657,6 +652,10 @@ void InterceptedRequest::OnUploadProgress(int64_t current_position,
|
||||
std::move(callback).Run();
|
||||
}
|
||||
|
||||
void InterceptedRequest::OnReceiveCachedMetadata(mojo_base::BigBuffer data) {
|
||||
target_client_->OnReceiveCachedMetadata(std::move(data));
|
||||
}
|
||||
|
||||
void InterceptedRequest::OnTransferSizeUpdated(int32_t transfer_size_diff) {
|
||||
target_client_->OnTransferSizeUpdated(transfer_size_diff);
|
||||
}
|
||||
@@ -744,7 +743,6 @@ void InterceptedRequest::InterceptResponseReceived(
|
||||
current_response_->request_start = base::TimeTicks::Now();
|
||||
current_response_->response_start = base::TimeTicks::Now();
|
||||
current_body_.reset();
|
||||
current_cached_metadata_.reset();
|
||||
|
||||
auto headers = MakeResponseHeaders(
|
||||
net::HTTP_TEMPORARY_REDIRECT, std::string(), std::string(),
|
||||
@@ -815,7 +813,6 @@ void InterceptedRequest::ContinueAfterInterceptWithOverride(
|
||||
stream_loader_ = new StreamReaderURLLoader(
|
||||
id_, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(),
|
||||
header_client_receiver_.BindNewPipeAndPassRemote(), traffic_annotation_,
|
||||
std::move(current_cached_metadata_),
|
||||
std::make_unique<InterceptDelegate>(std::move(response),
|
||||
weak_factory_.GetWeakPtr()));
|
||||
stream_loader_->Start();
|
||||
@@ -1051,8 +1048,7 @@ void InterceptedRequest::ContinueToResponseStarted(int error_code) {
|
||||
target_client_->OnReceiveResponse(
|
||||
std::move(current_response_),
|
||||
factory_->request_handler_->OnFilterResponseBody(
|
||||
id_, request_, std::move(current_body_)),
|
||||
std::move(current_cached_metadata_));
|
||||
id_, request_, std::move(current_body_)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -466,14 +466,12 @@ StreamReaderURLLoader::StreamReaderURLLoader(
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
mojo::PendingRemote<network::mojom::TrustedHeaderClient> header_client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
absl::optional<mojo_base::BigBuffer> cached_metadata,
|
||||
std::unique_ptr<Delegate> response_delegate)
|
||||
: request_id_(request_id),
|
||||
request_(request),
|
||||
client_(std::move(client)),
|
||||
header_client_(std::move(header_client)),
|
||||
traffic_annotation_(traffic_annotation),
|
||||
cached_metadata_(std::move(cached_metadata)),
|
||||
response_delegate_(std::move(response_delegate)),
|
||||
writable_handle_watcher_(FROM_HERE,
|
||||
mojo::SimpleWatcher::ArmingPolicy::MANUAL,
|
||||
@@ -710,8 +708,7 @@ void StreamReaderURLLoader::ContinueWithResponseHeaders(
|
||||
base::Unretained(this)));
|
||||
|
||||
client_->OnReceiveResponse(std::move(pending_response),
|
||||
std::move(consumer_handle),
|
||||
std::move(cached_metadata_));
|
||||
std::move(consumer_handle));
|
||||
ReadMore();
|
||||
}
|
||||
}
|
||||
|
@@ -117,7 +117,6 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
mojo::PendingRemote<network::mojom::TrustedHeaderClient> header_client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
absl::optional<mojo_base::BigBuffer> cached_metadata,
|
||||
std::unique_ptr<Delegate> response_delegate);
|
||||
|
||||
StreamReaderURLLoader(const StreamReaderURLLoader&) = delete;
|
||||
@@ -173,7 +172,6 @@ class StreamReaderURLLoader : public network::mojom::URLLoader {
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_;
|
||||
mojo::Remote<network::mojom::TrustedHeaderClient> header_client_;
|
||||
const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
|
||||
absl::optional<mojo_base::BigBuffer> cached_metadata_;
|
||||
std::unique_ptr<Delegate> response_delegate_;
|
||||
scoped_refptr<InputStreamReader> input_stream_reader_;
|
||||
|
||||
|
@@ -94,8 +94,6 @@ void CefWebContentsViewOSR::TakeFocus(bool reverse) {
|
||||
web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse);
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::FullscreenStateChanged(bool is_fullscreen) {}
|
||||
|
||||
content::DropData* CefWebContentsViewOSR::GetDropData() const {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -171,13 +169,12 @@ void CefWebContentsViewOSR::StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::DragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& cursor_offset,
|
||||
const gfx::Rect& drag_obj_rect,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const blink::mojom::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh) {
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser = GetBrowser();
|
||||
if (browser.get()) {
|
||||
browser->StartDragging(drop_data, allowed_ops, image, cursor_offset,
|
||||
browser->StartDragging(drop_data, allowed_ops, image, image_offset,
|
||||
event_info, source_rwh);
|
||||
} else if (web_contents_) {
|
||||
static_cast<content::WebContentsImpl*>(web_contents_)
|
||||
|
@@ -72,8 +72,7 @@ class CefWebContentsViewOSR : public content::WebContentsView,
|
||||
void StartDragging(const content::DropData& drop_data,
|
||||
blink::DragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& cursor_offset,
|
||||
const gfx::Rect& drag_obj_rect,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const blink::mojom::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh) override;
|
||||
void UpdateDragCursor(ui::mojom::DragOperation operation) override;
|
||||
@@ -82,7 +81,6 @@ class CefWebContentsViewOSR : public content::WebContentsView,
|
||||
virtual void LostFocus(
|
||||
content::RenderWidgetHostImpl* render_widget_host) override;
|
||||
virtual void TakeFocus(bool reverse) override;
|
||||
virtual void FullscreenStateChanged(bool is_fullscreen) override;
|
||||
|
||||
private:
|
||||
CefRenderWidgetHostViewOSR* GetView() const;
|
||||
|
@@ -117,7 +117,7 @@ class CefPermissionPrompt : public permissions::PermissionPrompt {
|
||||
}
|
||||
|
||||
// PermissionPrompt methods:
|
||||
bool UpdateAnchor() override { return true; }
|
||||
void UpdateAnchor() override { NOTIMPLEMENTED(); }
|
||||
TabSwitchingBehavior GetTabSwitchingBehavior() override {
|
||||
return TabSwitchingBehavior::kKeepPromptAlive;
|
||||
}
|
||||
@@ -219,8 +219,8 @@ cef_permission_request_types_t GetCefRequestType(
|
||||
return CEF_PERMISSION_TYPE_U2F_API_REQUEST;
|
||||
case permissions::RequestType::kVrSession:
|
||||
return CEF_PERMISSION_TYPE_VR_SESSION;
|
||||
case permissions::RequestType::kWindowManagement:
|
||||
return CEF_PERMISSION_TYPE_WINDOW_MANAGEMENT;
|
||||
case permissions::RequestType::kWindowPlacement:
|
||||
return CEF_PERMISSION_TYPE_WINDOW_PLACEMENT;
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||
#include "libcef/browser/prefs/pref_registrar.h"
|
||||
#include "libcef/browser/prefs/pref_store.h"
|
||||
#include "libcef/browser/prefs/renderer_prefs.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
@@ -53,7 +52,6 @@
|
||||
#include "components/prefs/pref_filter.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
|
||||
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
||||
#include "components/proxy_config/proxy_config_dictionary.h"
|
||||
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
|
||||
@@ -119,13 +117,18 @@ std::string GetAcceptLanguageListSetting(CefBrowserContext* browser_context,
|
||||
const char kUserPrefsFileName[] = "UserPrefs.json";
|
||||
const char kLocalPrefsFileName[] = "LocalPrefs.json";
|
||||
|
||||
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
|
||||
pref_registrar::RegisterCustomPrefs(CEF_PREFERENCES_TYPE_GLOBAL, registry);
|
||||
}
|
||||
|
||||
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
|
||||
pref_registrar::RegisterCustomPrefs(CEF_PREFERENCES_TYPE_REQUEST_CONTEXT,
|
||||
registry);
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
|
||||
// Preferences used with unit tests.
|
||||
registry->RegisterBooleanPref("test.bool", true);
|
||||
registry->RegisterIntegerPref("test.int", 2);
|
||||
registry->RegisterDoublePref("test.double", 5.0);
|
||||
registry->RegisterStringPref("test.string", "default");
|
||||
registry->RegisterListPref("test.list");
|
||||
registry->RegisterDictionaryPref("test.dict");
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
@@ -269,9 +272,9 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
PermissionBubbleMediaAccessHandler::RegisterProfilePrefs(registry.get());
|
||||
permissions::PermissionActionsHistory::RegisterProfilePrefs(registry.get());
|
||||
prefetch::RegisterPredictionOptionsProfilePrefs(registry.get());
|
||||
privacy_sandbox::RegisterProfilePrefs(registry.get());
|
||||
ProfileNetworkContextService::RegisterProfilePrefs(registry.get());
|
||||
safe_browsing::RegisterProfilePrefs(registry.get());
|
||||
RegisterProfilePrefs(registry.get());
|
||||
|
||||
const std::string& locale =
|
||||
command_line->GetSwitchValueASCII(switches::kLang);
|
||||
@@ -334,12 +337,6 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
base::Value(accept_language_list));
|
||||
}
|
||||
registry->RegisterListPref(prefs::kWebRtcLocalIpsAllowedUrls);
|
||||
|
||||
// Always do this after all other profile prefs.
|
||||
RegisterProfilePrefs(registry.get());
|
||||
} else {
|
||||
// Always do this after all other local state prefs.
|
||||
RegisterLocalStatePrefs(registry.get());
|
||||
}
|
||||
|
||||
// Build the PrefService that manages the PrefRegistry and PrefStores.
|
||||
|
@@ -23,12 +23,10 @@ namespace browser_prefs {
|
||||
extern const char kUserPrefsFileName[];
|
||||
|
||||
// Register preferences specific to CEF.
|
||||
void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
|
||||
void RegisterProfilePrefs(PrefRegistrySimple* registry);
|
||||
|
||||
// Create the PrefService used to manage pref registration and storage.
|
||||
// |profile| will be nullptr for the system-level PrefService. Used with the
|
||||
// Alloy runtime only.
|
||||
// |profile| will be nullptr for the system-level PrefService.
|
||||
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
const base::FilePath& cache_path,
|
||||
bool persist_user_preferences);
|
||||
|
@@ -1,120 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/prefs/pref_helper.h"
|
||||
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
|
||||
namespace pref_helper {
|
||||
|
||||
namespace {
|
||||
|
||||
const char* GetTypeString(base::Value::Type type) {
|
||||
switch (type) {
|
||||
case base::Value::Type::NONE:
|
||||
return "NULL";
|
||||
case base::Value::Type::BOOLEAN:
|
||||
return "BOOLEAN";
|
||||
case base::Value::Type::INTEGER:
|
||||
return "INTEGER";
|
||||
case base::Value::Type::DOUBLE:
|
||||
return "DOUBLE";
|
||||
case base::Value::Type::STRING:
|
||||
return "STRING";
|
||||
case base::Value::Type::BINARY:
|
||||
return "BINARY";
|
||||
case base::Value::Type::DICTIONARY:
|
||||
return "DICTIONARY";
|
||||
case base::Value::Type::LIST:
|
||||
return "LIST";
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool HasPreference(PrefService* pref_service, const CefString& name) {
|
||||
return (pref_service->FindPreference(name) != nullptr);
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
|
||||
const CefString& name) {
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref)
|
||||
return nullptr;
|
||||
return new CefValueImpl(pref->GetValue()->CreateDeepCopy().release());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
|
||||
bool include_defaults) {
|
||||
base::Value values = pref_service->GetPreferenceValues(
|
||||
include_defaults ? PrefService::INCLUDE_DEFAULTS
|
||||
: PrefService::EXCLUDE_DEFAULTS);
|
||||
|
||||
// CefDictionaryValueImpl takes ownership of |values|.
|
||||
return new CefDictionaryValueImpl(
|
||||
base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(std::move(values)))
|
||||
.release(),
|
||||
true, false);
|
||||
}
|
||||
|
||||
bool CanSetPreference(PrefService* pref_service, const CefString& name) {
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
return (pref && pref->IsUserModifiable());
|
||||
}
|
||||
|
||||
bool SetPreference(PrefService* pref_service,
|
||||
const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
// The below validation logic should match PrefService::SetUserPrefValue.
|
||||
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref) {
|
||||
error = "Trying to modify an unregistered preference";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pref->IsUserModifiable()) {
|
||||
error = "Trying to modify a preference that is not user modifiable";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!value.get()) {
|
||||
// Reset the preference to its default value.
|
||||
pref_service->ClearPref(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!value->IsValid()) {
|
||||
error = "A valid value is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
if (pref->GetType() != impl_value->type()) {
|
||||
error = base::StringPrintf(
|
||||
"Trying to set a preference of type %s to value of type %s",
|
||||
GetTypeString(pref->GetType()), GetTypeString(impl_value->type()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// PrefService will make a DeepCopy of |impl_value|.
|
||||
pref_service->Set(name, *impl_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace pref_helper
|
@@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
|
||||
#define CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
|
||||
|
||||
#include "include/cef_values.h"
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace pref_helper {
|
||||
|
||||
// Function names and arguments match the CefPreferenceManager interface.
|
||||
|
||||
bool HasPreference(PrefService* pref_service, const CefString& name);
|
||||
|
||||
CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
|
||||
const CefString& name);
|
||||
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
|
||||
bool include_defaults);
|
||||
|
||||
bool CanSetPreference(PrefService* pref_service, const CefString& name);
|
||||
|
||||
bool SetPreference(PrefService* pref_service,
|
||||
const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error);
|
||||
|
||||
} // namespace pref_helper
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
|
@@ -1,99 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/prefs/pref_registrar.h"
|
||||
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_browser_process_handler.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_store.h"
|
||||
|
||||
namespace pref_registrar {
|
||||
|
||||
namespace {
|
||||
|
||||
class CefPreferenceRegistrarImpl : public CefPreferenceRegistrar {
|
||||
public:
|
||||
explicit CefPreferenceRegistrarImpl(PrefRegistrySimple* registry)
|
||||
: registry_(registry) {}
|
||||
|
||||
CefPreferenceRegistrarImpl(const CefPreferenceRegistrarImpl&) = delete;
|
||||
CefPreferenceRegistrarImpl& operator=(const CefPreferenceRegistrarImpl&) =
|
||||
delete;
|
||||
|
||||
// CefPreferenceRegistrar methods.
|
||||
bool AddPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> default_value) override {
|
||||
const std::string nameStr = name;
|
||||
if (registry_->defaults()->GetValue(nameStr, nullptr)) {
|
||||
LOG(ERROR) << "Trying to register a previously registered preference: "
|
||||
<< nameStr;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (default_value->GetType()) {
|
||||
case VTYPE_INVALID:
|
||||
case VTYPE_NULL:
|
||||
case VTYPE_BINARY:
|
||||
break;
|
||||
case VTYPE_BOOL:
|
||||
registry_->RegisterBooleanPref(nameStr, default_value->GetBool());
|
||||
return true;
|
||||
case VTYPE_INT:
|
||||
registry_->RegisterIntegerPref(nameStr, default_value->GetInt());
|
||||
return true;
|
||||
case VTYPE_DOUBLE:
|
||||
registry_->RegisterDoublePref(nameStr, default_value->GetDouble());
|
||||
return true;
|
||||
case VTYPE_STRING:
|
||||
registry_->RegisterStringPref(nameStr, default_value->GetString());
|
||||
return true;
|
||||
case VTYPE_DICTIONARY:
|
||||
case VTYPE_LIST:
|
||||
RegisterComplexPref(nameStr, default_value);
|
||||
return true;
|
||||
};
|
||||
|
||||
LOG(ERROR) << "Invalid value type for preference: " << nameStr;
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
void RegisterComplexPref(const std::string& name,
|
||||
CefRefPtr<CefValue> default_value) {
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(default_value.get());
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
// Will make a deep copy of |impl_value|.
|
||||
if (impl_value->type() == base::Value::Type::DICT) {
|
||||
registry_->RegisterDictionaryPref(name, impl_value->Clone());
|
||||
} else if (impl_value->type() == base::Value::Type::LIST) {
|
||||
registry_->RegisterListPref(name, impl_value->Clone());
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
PrefRegistrySimple* const registry_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void RegisterCustomPrefs(cef_preferences_type_t type,
|
||||
PrefRegistrySimple* registry) {
|
||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||
if (auto handler = app->GetBrowserProcessHandler()) {
|
||||
CefPreferenceRegistrarImpl registrar(registry);
|
||||
handler->OnRegisterCustomPreferences(type, ®istrar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pref_registrar
|
@@ -1,19 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
|
||||
#define CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
|
||||
|
||||
#include "include/internal/cef_types.h"
|
||||
|
||||
class PrefRegistrySimple;
|
||||
|
||||
namespace pref_registrar {
|
||||
|
||||
void RegisterCustomPrefs(cef_preferences_type_t type,
|
||||
PrefRegistrySimple* registry);
|
||||
|
||||
} // namespace pref_registrar
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
|
@@ -19,7 +19,7 @@ CefPrefStore::CefPrefStore()
|
||||
init_complete_(false),
|
||||
committed_(true) {}
|
||||
|
||||
bool CefPrefStore::GetValue(base::StringPiece key,
|
||||
bool CefPrefStore::GetValue(const std::string& key,
|
||||
const base::Value** value) const {
|
||||
return prefs_.GetValue(key, value);
|
||||
}
|
||||
@@ -50,18 +50,18 @@ bool CefPrefStore::IsInitializationComplete() const {
|
||||
}
|
||||
|
||||
void CefPrefStore::SetValue(const std::string& key,
|
||||
base::Value value,
|
||||
std::unique_ptr<base::Value> value,
|
||||
uint32_t flags) {
|
||||
if (prefs_.SetValue(key, std::move(value))) {
|
||||
if (prefs_.SetValue(key, base::Value::FromUniquePtrValue(std::move(value)))) {
|
||||
committed_ = false;
|
||||
NotifyPrefValueChanged(key);
|
||||
}
|
||||
}
|
||||
|
||||
void CefPrefStore::SetValueSilently(const std::string& key,
|
||||
base::Value value,
|
||||
std::unique_ptr<base::Value> value,
|
||||
uint32_t flags) {
|
||||
if (prefs_.SetValue(key, std::move(value)))
|
||||
if (prefs_.SetValue(key, base::Value::FromUniquePtrValue(std::move(value))))
|
||||
committed_ = false;
|
||||
}
|
||||
|
||||
@@ -139,15 +139,15 @@ void CefPrefStore::ReportValueChanged(const std::string& key, uint32_t flags) {
|
||||
}
|
||||
|
||||
void CefPrefStore::SetString(const std::string& key, const std::string& value) {
|
||||
SetValue(key, base::Value(value), DEFAULT_PREF_WRITE_FLAGS);
|
||||
SetValue(key, std::make_unique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
void CefPrefStore::SetInteger(const std::string& key, int value) {
|
||||
SetValue(key, base::Value(value), DEFAULT_PREF_WRITE_FLAGS);
|
||||
SetValue(key, std::make_unique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
void CefPrefStore::SetBoolean(const std::string& key, bool value) {
|
||||
SetValue(key, base::Value(value), DEFAULT_PREF_WRITE_FLAGS);
|
||||
SetValue(key, std::make_unique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
bool CefPrefStore::GetString(const std::string& key, std::string* value) const {
|
||||
|
@@ -24,7 +24,7 @@ class CefPrefStore : public PersistentPrefStore {
|
||||
CefPrefStore& operator=(const CefPrefStore&) = delete;
|
||||
|
||||
// Overriden from PrefStore.
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(const std::string& key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
void AddObserver(PrefStore::Observer* observer) override;
|
||||
@@ -36,10 +36,10 @@ class CefPrefStore : public PersistentPrefStore {
|
||||
bool GetMutableValue(const std::string& key, base::Value** result) override;
|
||||
void ReportValueChanged(const std::string& key, uint32_t flags) override;
|
||||
void SetValue(const std::string& key,
|
||||
base::Value value,
|
||||
std::unique_ptr<base::Value> value,
|
||||
uint32_t flags) override;
|
||||
void SetValueSilently(const std::string& key,
|
||||
base::Value value,
|
||||
std::unique_ptr<base::Value> value,
|
||||
uint32_t flags) override;
|
||||
void RemoveValuesByPrefixSilently(const std::string& prefix) override;
|
||||
void RemoveValue(const std::string& key, uint32_t flags) override;
|
||||
|
@@ -172,12 +172,12 @@ void SetExtensionPrefs(content::WebContents* web_contents,
|
||||
void SetString(CommandLinePrefStore* prefs,
|
||||
const std::string& key,
|
||||
const std::string& value) {
|
||||
prefs->SetValue(key, base::Value(value),
|
||||
prefs->SetValue(key, base::WrapUnique(new base::Value(value)),
|
||||
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
void SetBool(CommandLinePrefStore* prefs, const std::string& key, bool value) {
|
||||
prefs->SetValue(key, base::Value(value),
|
||||
prefs->SetValue(key, base::WrapUnique(new base::Value(value)),
|
||||
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
|
@@ -34,10 +34,6 @@ namespace {
|
||||
|
||||
CefRefPtr<CefBrowserHostBase> GetBrowserForContext(
|
||||
printing::PrintingContextLinux* context) {
|
||||
// The print preview dialog won't have a valid child ID.
|
||||
if (!frame_util::IsValidChildId(context->render_process_id()))
|
||||
return nullptr;
|
||||
|
||||
return extensions::GetOwnerBrowserForGlobalId(
|
||||
frame_util::MakeGlobalId(context->render_process_id(),
|
||||
context->render_frame_id()),
|
||||
@@ -196,19 +192,27 @@ void CefPrintingContextLinuxDelegate::SetDefaultDelegate(
|
||||
default_delegate_ = delegate;
|
||||
}
|
||||
|
||||
// static
|
||||
void CefPrintDialogLinux::OnPrintStart(CefRefPtr<CefBrowserHostBase> browser) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(browser);
|
||||
if (browser && browser->GetClient()) {
|
||||
if (auto handler = browser->GetClient()->GetPrintHandler()) {
|
||||
handler->OnPrintStart(browser.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CefPrintDialogLinux::CefPrintDialogLinux(PrintingContextLinux* context,
|
||||
CefRefPtr<CefBrowserHostBase> browser,
|
||||
CefRefPtr<CefPrintHandler> handler)
|
||||
: context_(context), browser_(browser), handler_(handler) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(context_);
|
||||
DCHECK(browser_);
|
||||
DCHECK(handler_);
|
||||
|
||||
// Paired with the ReleaseDialog() call.
|
||||
AddRef();
|
||||
|
||||
handler->OnPrintStart(browser_.get());
|
||||
}
|
||||
|
||||
CefPrintDialogLinux::~CefPrintDialogLinux() {
|
||||
|
@@ -52,6 +52,9 @@ class CefPrintDialogLinux : public printing::PrintDialogLinuxInterface,
|
||||
CefPrintDialogLinux(const CefPrintDialogLinux&) = delete;
|
||||
CefPrintDialogLinux& operator=(const CefPrintDialogLinux&) = delete;
|
||||
|
||||
// Notify the client when printing has started.
|
||||
static void OnPrintStart(CefRefPtr<CefBrowserHostBase> browser);
|
||||
|
||||
// PrintDialogLinuxInterface implementation.
|
||||
void UseDefaultSettings() override;
|
||||
void UpdateSettings(
|
||||
|
@@ -1,143 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/printing/print_util.h"
|
||||
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
#include "chrome/browser/printing/print_view_manager_common.h"
|
||||
#include "components/printing/browser/print_to_pdf/pdf_print_utils.h"
|
||||
|
||||
namespace print_util {
|
||||
|
||||
namespace {
|
||||
|
||||
// Write the PDF file to disk.
|
||||
void SavePdfFile(const CefString& path,
|
||||
CefRefPtr<CefPdfPrintCallback> callback,
|
||||
scoped_refptr<base::RefCountedMemory> data) {
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
DCHECK_GT(data->size(), 0U);
|
||||
|
||||
const bool ok =
|
||||
base::WriteFile(path, reinterpret_cast<const char*>(data->data()),
|
||||
data->size()) == static_cast<int>(data->size());
|
||||
|
||||
if (callback) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::BindOnce(&CefPdfPrintCallback::OnPdfPrintFinished,
|
||||
callback, path, ok));
|
||||
}
|
||||
}
|
||||
|
||||
void OnPDFCreated(const CefString& path,
|
||||
CefRefPtr<CefPdfPrintCallback> callback,
|
||||
print_to_pdf::PdfPrintResult print_result,
|
||||
scoped_refptr<base::RefCountedMemory> data) {
|
||||
if (print_result != print_to_pdf::PdfPrintResult::kPrintSuccess) {
|
||||
LOG(ERROR) << "PrintToPDF failed with error: "
|
||||
<< print_to_pdf::PdfPrintResultToString(print_result);
|
||||
callback->OnPdfPrintFinished(CefString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the PDF file to disk and then execute the callback.
|
||||
CEF_POST_USER_VISIBLE_TASK(
|
||||
base::BindOnce(&SavePdfFile, path, callback, std::move(data)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void Print(content::WebContents* web_contents, bool print_preview_disabled) {
|
||||
// Like chrome::Print() but specifying the WebContents.
|
||||
printing::StartPrint(web_contents,
|
||||
/*print_renderer=*/mojo::NullAssociatedRemote(),
|
||||
print_preview_disabled,
|
||||
/*has_selection=*/false);
|
||||
}
|
||||
|
||||
// Implementation based on PageHandler::PrintToPDF.
|
||||
void PrintToPDF(content::WebContents* web_contents,
|
||||
const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||
const bool display_header_footer = !!settings.display_header_footer;
|
||||
|
||||
// Defaults to no header/footer.
|
||||
absl::optional<std::string> header_template, footer_template;
|
||||
if (display_header_footer) {
|
||||
if (settings.header_template.length > 0)
|
||||
header_template = CefString(&settings.header_template);
|
||||
if (settings.footer_template.length > 0)
|
||||
footer_template = CefString(&settings.footer_template);
|
||||
}
|
||||
|
||||
// Defaults to 1.0.
|
||||
absl::optional<double> scale;
|
||||
if (settings.scale > 0) {
|
||||
scale = settings.scale;
|
||||
}
|
||||
|
||||
// Defaults to letter size.
|
||||
absl::optional<double> paper_width, paper_height;
|
||||
if (settings.paper_width > 0 && settings.paper_height > 0) {
|
||||
paper_width = settings.paper_width;
|
||||
paper_height = settings.paper_height;
|
||||
}
|
||||
|
||||
// Defaults to kDefaultMarginInInches.
|
||||
absl::optional<double> margin_top, margin_bottom, margin_left, margin_right;
|
||||
if (settings.margin_type == PDF_PRINT_MARGIN_NONE) {
|
||||
margin_top = 0;
|
||||
margin_bottom = 0;
|
||||
margin_left = 0;
|
||||
margin_right = 0;
|
||||
} else if (settings.margin_type == PDF_PRINT_MARGIN_CUSTOM) {
|
||||
if (settings.margin_top >= 0)
|
||||
margin_top = settings.margin_top;
|
||||
if (settings.margin_bottom >= 0)
|
||||
margin_bottom = settings.margin_bottom;
|
||||
if (settings.margin_left >= 0)
|
||||
margin_left = settings.margin_left;
|
||||
if (settings.margin_right >= 0)
|
||||
margin_right = settings.margin_right;
|
||||
}
|
||||
|
||||
absl::variant<printing::mojom::PrintPagesParamsPtr, std::string>
|
||||
print_pages_params = print_to_pdf::GetPrintPagesParams(
|
||||
web_contents->GetPrimaryMainFrame()->GetLastCommittedURL(),
|
||||
!!settings.landscape, display_header_footer,
|
||||
!!settings.print_background, scale, paper_width, paper_height,
|
||||
margin_top, margin_bottom, margin_left, margin_right,
|
||||
CefString(&settings.header_template),
|
||||
CefString(&settings.footer_template),
|
||||
!!settings.prefer_css_page_size);
|
||||
|
||||
if (absl::holds_alternative<std::string>(print_pages_params)) {
|
||||
LOG(ERROR) << "PrintToPDF failed with error: "
|
||||
<< absl::get<std::string>(print_pages_params);
|
||||
callback->OnPdfPrintFinished(CefString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(absl::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
|
||||
print_pages_params));
|
||||
|
||||
if (auto* print_manager =
|
||||
printing::PrintViewManager::FromWebContents(web_contents)) {
|
||||
print_manager->PrintToPdf(
|
||||
web_contents->GetPrimaryMainFrame(), CefString(&settings.page_ranges),
|
||||
std::move(absl::get<printing::mojom::PrintPagesParamsPtr>(
|
||||
print_pages_params)),
|
||||
base::BindOnce(&OnPDFCreated, path, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "PrintToPDF was not handled.";
|
||||
callback->OnPdfPrintFinished(CefString(), false);
|
||||
}
|
||||
|
||||
} // namespace print_util
|
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINT_UTIL_H_
|
||||
#define CEF_LIBCEF_BROWSER_PRINTING_PRINT_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace print_util {
|
||||
|
||||
// Called from CefBrowserHostBase::Print.
|
||||
void Print(content::WebContents* web_contents, bool print_preview_disabled);
|
||||
|
||||
// Called from CefBrowserHostBase::PrintToPDF.
|
||||
void PrintToPDF(content::WebContents* web_contents,
|
||||
const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback);
|
||||
|
||||
} // namespace print_util
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_PRINTING_PRINT_UTIL_H_
|
373
libcef/browser/printing/print_view_manager.cc
Normal file
373
libcef/browser/printing/print_view_manager.cc
Normal file
@@ -0,0 +1,373 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "chrome/browser/printing/print_preview_dialog_controller.h"
|
||||
#include "chrome/browser/printing/printer_query.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
|
||||
#include "components/printing/common/print.mojom.h"
|
||||
#include "content/browser/download/download_manager_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "mojo/public/cpp/bindings/associated_remote.h"
|
||||
#include "printing/metafile_skia.h"
|
||||
#include "printing/units.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#include "libcef/browser/printing/print_dialog_linux.h"
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace printing {
|
||||
|
||||
namespace {
|
||||
|
||||
const int PREVIEW_UIID = 12345678;
|
||||
|
||||
// Convert CefPdfPrintSettings into base::Value::Dict.
|
||||
void FillInDictionaryFromPdfPrintSettings(
|
||||
const CefPdfPrintSettings& pdf_settings,
|
||||
int request_id,
|
||||
base::Value::Dict& print_settings) {
|
||||
// Fixed settings.
|
||||
print_settings.Set(kSettingPrinterType,
|
||||
static_cast<int>(mojom::PrinterType::kPdf));
|
||||
print_settings.Set(kSettingColor, static_cast<int>(mojom::ColorModel::kGray));
|
||||
print_settings.Set(kSettingDuplexMode,
|
||||
static_cast<int>(mojom::DuplexMode::kSimplex));
|
||||
print_settings.Set(kSettingCopies, 1);
|
||||
print_settings.Set(kSettingCollate, false);
|
||||
print_settings.Set(kSettingDeviceName, "");
|
||||
print_settings.Set(kSettingRasterizePdf, false);
|
||||
print_settings.Set(kSettingPreviewModifiable, false);
|
||||
print_settings.Set(kSettingDpiHorizontal, printing::kDefaultPdfDpi);
|
||||
print_settings.Set(kSettingDpiVertical, printing::kDefaultPdfDpi);
|
||||
print_settings.Set(kSettingPagesPerSheet, 1);
|
||||
|
||||
// User defined settings.
|
||||
print_settings.Set(kSettingLandscape, !!pdf_settings.landscape);
|
||||
print_settings.Set(kSettingShouldPrintSelectionOnly,
|
||||
!!pdf_settings.selection_only);
|
||||
print_settings.Set(kSettingShouldPrintBackgrounds,
|
||||
!!pdf_settings.backgrounds_enabled);
|
||||
print_settings.Set(kSettingHeaderFooterEnabled,
|
||||
!!pdf_settings.header_footer_enabled);
|
||||
print_settings.Set(kSettingScaleFactor, pdf_settings.scale_factor > 0
|
||||
? pdf_settings.scale_factor
|
||||
: 100);
|
||||
|
||||
if (pdf_settings.header_footer_enabled) {
|
||||
print_settings.Set(
|
||||
kSettingHeaderFooterTitle,
|
||||
CefString(&pdf_settings.header_footer_title).ToString16());
|
||||
print_settings.Set(kSettingHeaderFooterURL,
|
||||
CefString(&pdf_settings.header_footer_url).ToString16());
|
||||
}
|
||||
|
||||
if (pdf_settings.page_width > 0 && pdf_settings.page_height > 0) {
|
||||
base::Value::Dict dict;
|
||||
dict.Set(kSettingMediaSizeWidthMicrons, pdf_settings.page_width);
|
||||
dict.Set(kSettingMediaSizeHeightMicrons, pdf_settings.page_height);
|
||||
print_settings.Set(kSettingMediaSize, std::move(dict));
|
||||
}
|
||||
|
||||
auto margin_type = printing::mojom::MarginType::kDefaultMargins;
|
||||
switch (pdf_settings.margin_type) {
|
||||
case PDF_PRINT_MARGIN_NONE:
|
||||
margin_type = printing::mojom::MarginType::kNoMargins;
|
||||
break;
|
||||
case PDF_PRINT_MARGIN_MINIMUM:
|
||||
margin_type = printing::mojom::MarginType::kPrintableAreaMargins;
|
||||
break;
|
||||
case PDF_PRINT_MARGIN_CUSTOM:
|
||||
margin_type = printing::mojom::MarginType::kCustomMargins;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
print_settings.Set(kSettingMarginsType, static_cast<int>(margin_type));
|
||||
if (margin_type == printing::mojom::MarginType::kCustomMargins) {
|
||||
base::Value::Dict dict;
|
||||
dict.Set(kSettingMarginTop, pdf_settings.margin_top);
|
||||
dict.Set(kSettingMarginRight, pdf_settings.margin_right);
|
||||
dict.Set(kSettingMarginBottom, pdf_settings.margin_bottom);
|
||||
dict.Set(kSettingMarginLeft, pdf_settings.margin_left);
|
||||
print_settings.Set(kSettingMarginsCustom, std::move(dict));
|
||||
}
|
||||
|
||||
// Service settings.
|
||||
print_settings.Set(kPreviewUIID, PREVIEW_UIID);
|
||||
print_settings.Set(kPreviewRequestID, request_id);
|
||||
print_settings.Set(kIsFirstRequest, request_id != 0);
|
||||
}
|
||||
|
||||
void StopWorker(int document_cookie) {
|
||||
if (document_cookie <= 0)
|
||||
return;
|
||||
scoped_refptr<PrintQueriesQueue> queue =
|
||||
g_browser_process->print_job_manager()->queue();
|
||||
std::unique_ptr<PrinterQuery> printer_query =
|
||||
queue->PopPrinterQuery(document_cookie);
|
||||
if (printer_query.get()) {
|
||||
printer_query->StopWorker();
|
||||
}
|
||||
}
|
||||
|
||||
// Write the PDF file to disk.
|
||||
void SavePdfFile(scoped_refptr<base::RefCountedSharedMemoryMapping> data,
|
||||
const base::FilePath& path,
|
||||
CefPrintViewManager::PdfPrintCallback callback) {
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
DCHECK_GT(data->size(), 0U);
|
||||
|
||||
MetafileSkia metafile;
|
||||
metafile.InitFromData(*data);
|
||||
|
||||
base::File file(path,
|
||||
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
|
||||
bool ok = file.IsValid() && metafile.SaveTo(&file);
|
||||
|
||||
if (!callback.is_null()) {
|
||||
content::GetUIThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE, base::BindOnce(std::move(callback), ok));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
struct CefPrintViewManager::PdfPrintState {
|
||||
content::RenderFrameHost* printing_rfh_ = nullptr;
|
||||
base::FilePath output_path_;
|
||||
base::Value::Dict settings_;
|
||||
PdfPrintCallback callback_;
|
||||
};
|
||||
|
||||
CefPrintViewManager::CefPrintViewManager(content::WebContents* web_contents)
|
||||
: PrintViewManager(web_contents) {}
|
||||
|
||||
CefPrintViewManager::~CefPrintViewManager() {
|
||||
TerminatePdfPrintJob();
|
||||
}
|
||||
|
||||
// static
|
||||
void CefPrintViewManager::BindPrintManagerHost(
|
||||
mojo::PendingAssociatedReceiver<mojom::PrintManagerHost> receiver,
|
||||
content::RenderFrameHost* rfh) {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
if (!web_contents)
|
||||
return;
|
||||
auto* print_manager = CefPrintViewManager::FromWebContents(web_contents);
|
||||
if (!print_manager)
|
||||
return;
|
||||
print_manager->BindReceiver(std::move(receiver), rfh);
|
||||
}
|
||||
|
||||
bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh,
|
||||
const base::FilePath& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
PdfPrintCallback callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
// Don't start print again while printing is currently in progress.
|
||||
if (pdf_print_state_)
|
||||
return false;
|
||||
|
||||
// Don't print crashed tabs.
|
||||
if (!web_contents() || web_contents()->IsCrashed() ||
|
||||
!rfh->IsRenderFrameLive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pdf_print_state_.reset(new PdfPrintState);
|
||||
pdf_print_state_->printing_rfh_ = rfh;
|
||||
pdf_print_state_->output_path_ = path;
|
||||
pdf_print_state_->callback_ = std::move(callback);
|
||||
|
||||
FillInDictionaryFromPdfPrintSettings(settings, ++next_pdf_request_id_,
|
||||
pdf_print_state_->settings_);
|
||||
|
||||
auto& print_render_frame = GetPrintRenderFrame(rfh);
|
||||
if (!pdf_print_receiver_.is_bound()) {
|
||||
print_render_frame->SetPrintPreviewUI(
|
||||
pdf_print_receiver_.BindNewEndpointAndPassRemote());
|
||||
}
|
||||
|
||||
print_render_frame->InitiatePrintPreview({}, !!settings.selection_only);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefPrintViewManager::GetDefaultPrintSettings(
|
||||
GetDefaultPrintSettingsCallback callback) {
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
// Send notification to the client.
|
||||
auto browser = CefBrowserHostBase::GetBrowserForContents(web_contents());
|
||||
if (browser) {
|
||||
CefPrintDialogLinux::OnPrintStart(browser);
|
||||
}
|
||||
#endif
|
||||
PrintViewManager::GetDefaultPrintSettings(std::move(callback));
|
||||
}
|
||||
|
||||
void CefPrintViewManager::DidShowPrintDialog() {
|
||||
if (pdf_print_state_)
|
||||
return;
|
||||
PrintViewManager::DidShowPrintDialog();
|
||||
}
|
||||
|
||||
void CefPrintViewManager::RequestPrintPreview(
|
||||
mojom::RequestPrintPreviewParamsPtr params) {
|
||||
if (!pdf_print_state_) {
|
||||
PrintViewManager::RequestPrintPreview(std::move(params));
|
||||
return;
|
||||
}
|
||||
|
||||
GetPrintRenderFrame(pdf_print_state_->printing_rfh_)
|
||||
->PrintPreview(pdf_print_state_->settings_.Clone());
|
||||
}
|
||||
|
||||
void CefPrintViewManager::CheckForCancel(int32_t preview_ui_id,
|
||||
int32_t request_id,
|
||||
CheckForCancelCallback callback) {
|
||||
if (!pdf_print_state_) {
|
||||
return PrintViewManager::CheckForCancel(preview_ui_id, request_id,
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
std::move(callback).Run(/*cancel=*/false);
|
||||
}
|
||||
|
||||
void CefPrintViewManager::MetafileReadyForPrinting(
|
||||
mojom::DidPreviewDocumentParamsPtr params,
|
||||
int32_t request_id) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
StopWorker(params->document_cookie);
|
||||
|
||||
if (!pdf_print_state_)
|
||||
return;
|
||||
|
||||
GetPrintRenderFrame(pdf_print_state_->printing_rfh_)
|
||||
->OnPrintPreviewDialogClosed();
|
||||
|
||||
auto shared_buf = base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(
|
||||
params->content->metafile_data_region);
|
||||
if (!shared_buf) {
|
||||
TerminatePdfPrintJob();
|
||||
return;
|
||||
}
|
||||
|
||||
const base::FilePath output_path = pdf_print_state_->output_path_;
|
||||
PdfPrintCallback print_callback = std::move(pdf_print_state_->callback_);
|
||||
|
||||
// Reset state information.
|
||||
pdf_print_state_.reset();
|
||||
pdf_print_receiver_.reset();
|
||||
|
||||
// Save the PDF file to disk and then execute the callback.
|
||||
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(
|
||||
&SavePdfFile, shared_buf, output_path, std::move(print_callback)));
|
||||
}
|
||||
|
||||
void CefPrintViewManager::PrintPreviewFailed(int32_t document_cookie,
|
||||
int32_t request_id) {
|
||||
TerminatePdfPrintJob();
|
||||
}
|
||||
|
||||
void CefPrintViewManager::PrintPreviewCancelled(int32_t document_cookie,
|
||||
int32_t request_id) {
|
||||
// Should never be canceled by CheckForCancel().
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefPrintViewManager::RenderFrameDeleted(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
if (pdf_print_state_ &&
|
||||
render_frame_host == pdf_print_state_->printing_rfh_) {
|
||||
TerminatePdfPrintJob();
|
||||
}
|
||||
PrintViewManager::RenderFrameDeleted(render_frame_host);
|
||||
}
|
||||
|
||||
void CefPrintViewManager::NavigationStopped() {
|
||||
TerminatePdfPrintJob();
|
||||
PrintViewManager::NavigationStopped();
|
||||
}
|
||||
|
||||
void CefPrintViewManager::PrimaryMainFrameRenderProcessGone(
|
||||
base::TerminationStatus status) {
|
||||
TerminatePdfPrintJob();
|
||||
PrintViewManager::PrimaryMainFrameRenderProcessGone(status);
|
||||
}
|
||||
|
||||
// static
|
||||
void CefPrintViewManager::CreateForWebContents(content::WebContents* contents) {
|
||||
DCHECK(contents);
|
||||
if (!FromWebContents(contents)) {
|
||||
contents->SetUserData(PrintViewManager::UserDataKey(),
|
||||
base::WrapUnique(new CefPrintViewManager(contents)));
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
CefPrintViewManager* CefPrintViewManager::FromWebContents(
|
||||
content::WebContents* contents) {
|
||||
DCHECK(contents);
|
||||
return static_cast<CefPrintViewManager*>(
|
||||
contents->GetUserData(PrintViewManager::UserDataKey()));
|
||||
}
|
||||
|
||||
// static
|
||||
const CefPrintViewManager* CefPrintViewManager::FromWebContents(
|
||||
const content::WebContents* contents) {
|
||||
DCHECK(contents);
|
||||
return static_cast<const CefPrintViewManager*>(
|
||||
contents->GetUserData(PrintViewManager::UserDataKey()));
|
||||
}
|
||||
|
||||
void CefPrintViewManager::TerminatePdfPrintJob() {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
if (!pdf_print_state_)
|
||||
return;
|
||||
|
||||
if (!pdf_print_state_->callback_.is_null()) {
|
||||
// Execute the callback.
|
||||
content::GetUIThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(std::move(pdf_print_state_->callback_), false));
|
||||
}
|
||||
|
||||
// Reset state information.
|
||||
pdf_print_state_.reset();
|
||||
pdf_print_receiver_.reset();
|
||||
}
|
||||
|
||||
} // namespace printing
|
107
libcef/browser/printing/print_view_manager.h
Normal file
107
libcef/browser/printing/print_view_manager.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|
||||
#define CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|
||||
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
|
||||
#include "base/callback_forward.h"
|
||||
#include "chrome/browser/printing/print_view_manager.h"
|
||||
#include "components/printing/common/print.mojom-forward.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "printing/mojom/print.mojom.h"
|
||||
|
||||
namespace content {
|
||||
class RenderFrameHost;
|
||||
class RenderProcessHost;
|
||||
class WebContentsObserver;
|
||||
} // namespace content
|
||||
|
||||
class CefBrowserInfo;
|
||||
|
||||
namespace printing {
|
||||
|
||||
// CEF handler for print commands.
|
||||
class CefPrintViewManager : public PrintViewManager,
|
||||
public mojom::PrintPreviewUI {
|
||||
public:
|
||||
CefPrintViewManager(const CefPrintViewManager&) = delete;
|
||||
CefPrintViewManager& operator=(const CefPrintViewManager&) = delete;
|
||||
|
||||
~CefPrintViewManager() override;
|
||||
|
||||
static void BindPrintManagerHost(
|
||||
mojo::PendingAssociatedReceiver<mojom::PrintManagerHost> receiver,
|
||||
content::RenderFrameHost* rfh);
|
||||
|
||||
// Callback executed on PDF printing completion.
|
||||
using PdfPrintCallback = base::OnceCallback<void(bool /*ok*/)>;
|
||||
|
||||
// Print the current document to a PDF file. Execute |callback| on completion.
|
||||
bool PrintToPDF(content::RenderFrameHost* rfh,
|
||||
const base::FilePath& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
PdfPrintCallback callback);
|
||||
|
||||
// mojom::PrintManagerHost methods:
|
||||
void GetDefaultPrintSettings(
|
||||
GetDefaultPrintSettingsCallback callback) override;
|
||||
void DidShowPrintDialog() override;
|
||||
void RequestPrintPreview(mojom::RequestPrintPreviewParamsPtr params) override;
|
||||
void CheckForCancel(int32_t preview_ui_id,
|
||||
int32_t request_id,
|
||||
CheckForCancelCallback callback) override;
|
||||
|
||||
// printing::mojo::PrintPreviewUI methods:
|
||||
void SetOptionsFromDocument(const mojom::OptionsFromDocumentParamsPtr params,
|
||||
int32_t request_id) override {}
|
||||
void DidPrepareDocumentForPreview(int32_t document_cookie,
|
||||
int32_t request_id) override {}
|
||||
void DidPreviewPage(mojom::DidPreviewPageParamsPtr params,
|
||||
int32_t request_id) override {}
|
||||
void MetafileReadyForPrinting(mojom::DidPreviewDocumentParamsPtr params,
|
||||
int32_t request_id) override;
|
||||
void PrintPreviewFailed(int32_t document_cookie, int32_t request_id) override;
|
||||
void PrintPreviewCancelled(int32_t document_cookie,
|
||||
int32_t request_id) override;
|
||||
void PrinterSettingsInvalid(int32_t document_cookie,
|
||||
int32_t request_id) override {}
|
||||
void DidGetDefaultPageLayout(mojom::PageSizeMarginsPtr page_layout_in_points,
|
||||
const gfx::Rect& printable_area_in_points,
|
||||
bool has_custom_page_size_style,
|
||||
int32_t request_id) override {}
|
||||
void DidStartPreview(mojom::DidStartPreviewParamsPtr params,
|
||||
int32_t request_id) override {}
|
||||
|
||||
// content::WebContentsObserver methods:
|
||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||
void NavigationStopped() override;
|
||||
void PrimaryMainFrameRenderProcessGone(
|
||||
base::TerminationStatus status) override;
|
||||
|
||||
// Inline versions of the content::WebContentsUserData methods to avoid
|
||||
// ambiguous warnings due to the PrintViewManager base class also extending
|
||||
// WebContentsUserData.
|
||||
static void CreateForWebContents(content::WebContents* contents);
|
||||
static CefPrintViewManager* FromWebContents(content::WebContents* contents);
|
||||
static const CefPrintViewManager* FromWebContents(
|
||||
const content::WebContents* contents);
|
||||
|
||||
private:
|
||||
explicit CefPrintViewManager(content::WebContents* web_contents);
|
||||
|
||||
void TerminatePdfPrintJob();
|
||||
|
||||
// Used for printing to PDF. Only accessed on the browser process UI thread.
|
||||
int next_pdf_request_id_ = content::RenderFrameHost::kNoFrameTreeNodeId;
|
||||
struct PdfPrintState;
|
||||
std::unique_ptr<PdfPrintState> pdf_print_state_;
|
||||
mojo::AssociatedReceiver<mojom::PrintPreviewUI> pdf_print_receiver_{this};
|
||||
};
|
||||
|
||||
} // namespace printing
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|
@@ -5,10 +5,10 @@
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/prefs/pref_helper.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/task_runner_impl.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/atomic_sequence_num.h"
|
||||
#include "base/logging.h"
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/ssl_host_state_delegate.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "net/dns/host_resolver.h"
|
||||
#include "services/network/public/cpp/resolve_host_client_base.h"
|
||||
@@ -30,6 +30,30 @@ namespace {
|
||||
|
||||
base::AtomicSequenceNumber g_next_id;
|
||||
|
||||
const char* GetTypeString(base::Value::Type type) {
|
||||
switch (type) {
|
||||
case base::Value::Type::NONE:
|
||||
return "NULL";
|
||||
case base::Value::Type::BOOLEAN:
|
||||
return "BOOLEAN";
|
||||
case base::Value::Type::INTEGER:
|
||||
return "INTEGER";
|
||||
case base::Value::Type::DOUBLE:
|
||||
return "DOUBLE";
|
||||
case base::Value::Type::STRING:
|
||||
return "STRING";
|
||||
case base::Value::Type::BINARY:
|
||||
return "BINARY";
|
||||
case base::Value::Type::DICTIONARY:
|
||||
return "DICTIONARY";
|
||||
case base::Value::Type::LIST:
|
||||
return "LIST";
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
class ResolveHostHelper : public network::ResolveHostClientBase {
|
||||
public:
|
||||
explicit ResolveHostHelper(CefRefPtr<CefResolveCallback> callback)
|
||||
@@ -42,25 +66,23 @@ class ResolveHostHelper : public network::ResolveHostClientBase {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
browser_context->GetNetworkContext()->CreateHostResolver(
|
||||
net::DnsConfigOverrides(), host_resolver_.BindNewPipeAndPassReceiver());
|
||||
absl::nullopt, host_resolver_.BindNewPipeAndPassReceiver());
|
||||
|
||||
host_resolver_.set_disconnect_handler(base::BindOnce(
|
||||
&ResolveHostHelper::OnComplete, base::Unretained(this), net::ERR_FAILED,
|
||||
net::ResolveErrorInfo(net::ERR_FAILED), absl::nullopt, absl::nullopt));
|
||||
net::ResolveErrorInfo(net::ERR_FAILED), absl::nullopt));
|
||||
|
||||
host_resolver_->ResolveHost(
|
||||
network::mojom::HostResolverHost::NewHostPortPair(
|
||||
net::HostPortPair::FromURL(GURL(origin.ToString()))),
|
||||
net::NetworkAnonymizationKey::CreateTransient(), nullptr,
|
||||
net::HostPortPair::FromURL(GURL(origin.ToString())),
|
||||
net::NetworkIsolationKey::CreateTransient(), nullptr,
|
||||
receiver_.BindNewPipeAndPassRemote());
|
||||
}
|
||||
|
||||
private:
|
||||
void OnComplete(int result,
|
||||
const net::ResolveErrorInfo& resolve_error_info,
|
||||
const absl::optional<net::AddressList>& resolved_addresses,
|
||||
const absl::optional<net::HostResolverEndpointResults>&
|
||||
endpoint_results_with_metadat) override {
|
||||
void OnComplete(
|
||||
int32_t result,
|
||||
const ::net::ResolveErrorInfo& resolve_error_info,
|
||||
const absl::optional<net::AddressList>& resolved_addresses) override {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
host_resolver_.reset();
|
||||
@@ -68,9 +90,9 @@ class ResolveHostHelper : public network::ResolveHostClientBase {
|
||||
|
||||
std::vector<CefString> resolved_ips;
|
||||
|
||||
if (result == net::OK && resolved_addresses.has_value()) {
|
||||
DCHECK(!resolved_addresses->empty());
|
||||
for (const auto& value : *resolved_addresses) {
|
||||
if (result == net::OK) {
|
||||
DCHECK(resolved_addresses && !resolved_addresses->empty());
|
||||
for (const auto& value : resolved_addresses.value()) {
|
||||
resolved_ips.push_back(value.ToStringWithoutPort());
|
||||
}
|
||||
}
|
||||
@@ -83,7 +105,7 @@ class ResolveHostHelper : public network::ResolveHostClientBase {
|
||||
CefRefPtr<CefResolveCallback> callback_;
|
||||
|
||||
mojo::Remote<network::mojom::HostResolver> host_resolver_;
|
||||
mojo::Receiver<network::mojom::ResolveHostClient> receiver_{this};
|
||||
mojo::Receiver<network::mojom::ResolveHostClient> receiver_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -356,7 +378,7 @@ bool CefRequestContextImpl::HasPreference(const CefString& name) {
|
||||
return false;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
return pref_helper::HasPreference(pref_service, name);
|
||||
return (pref_service->FindPreference(name) != nullptr);
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CefRequestContextImpl::GetPreference(
|
||||
@@ -365,7 +387,10 @@ CefRefPtr<CefValue> CefRequestContextImpl::GetPreference(
|
||||
return nullptr;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
return pref_helper::GetPreference(pref_service, name);
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref)
|
||||
return nullptr;
|
||||
return new CefValueImpl(pref->GetValue()->CreateDeepCopy().release());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> CefRequestContextImpl::GetAllPreferences(
|
||||
@@ -374,7 +399,17 @@ CefRefPtr<CefDictionaryValue> CefRequestContextImpl::GetAllPreferences(
|
||||
return nullptr;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
return pref_helper::GetAllPreferences(pref_service, include_defaults);
|
||||
|
||||
base::Value values = pref_service->GetPreferenceValues(
|
||||
include_defaults ? PrefService::INCLUDE_DEFAULTS
|
||||
: PrefService::EXCLUDE_DEFAULTS);
|
||||
|
||||
// CefDictionaryValueImpl takes ownership of |values|.
|
||||
return new CefDictionaryValueImpl(
|
||||
base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(std::move(values)))
|
||||
.release(),
|
||||
true, false);
|
||||
}
|
||||
|
||||
bool CefRequestContextImpl::CanSetPreference(const CefString& name) {
|
||||
@@ -382,7 +417,8 @@ bool CefRequestContextImpl::CanSetPreference(const CefString& name) {
|
||||
return false;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
return pref_helper::CanSetPreference(pref_service, name);
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
return (pref && pref->IsUserModifiable());
|
||||
}
|
||||
|
||||
bool CefRequestContextImpl::SetPreference(const CefString& name,
|
||||
@@ -392,7 +428,46 @@ bool CefRequestContextImpl::SetPreference(const CefString& name,
|
||||
return false;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
return pref_helper::SetPreference(pref_service, name, value, error);
|
||||
|
||||
// The below validation logic should match PrefService::SetUserPrefValue.
|
||||
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref) {
|
||||
error = "Trying to modify an unregistered preference";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pref->IsUserModifiable()) {
|
||||
error = "Trying to modify a preference that is not user modifiable";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!value.get()) {
|
||||
// Reset the preference to its default value.
|
||||
pref_service->ClearPref(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!value->IsValid()) {
|
||||
error = "A valid value is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
if (pref->GetType() != impl_value->type()) {
|
||||
error = base::StringPrintf(
|
||||
"Trying to set a preference of type %s to value of type %s",
|
||||
GetTypeString(pref->GetType()), GetTypeString(impl_value->type()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// PrefService will make a DeepCopy of |impl_value|.
|
||||
pref_service->Set(name, *impl_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefRequestContextImpl::ClearCertificateExceptions(
|
||||
|
@@ -2,8 +2,8 @@
|
||||
// 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_REQUEST_CONTEXT_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
|
||||
#ifndef CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
||||
#define CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_request_context.h"
|
||||
@@ -176,4 +176,4 @@ class CefRequestContextImpl : public CefRequestContext {
|
||||
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefRequestContextImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
|
||||
#endif // CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
||||
|
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int kMinWidth = 0;
|
||||
@@ -27,17 +25,15 @@ int clamp_segment_start(int start, int len, int min, int max) {
|
||||
|
||||
} // namespace
|
||||
|
||||
gfx::Rect MakeVisibleOnScreenRect(const gfx::Rect& rect,
|
||||
const gfx::Rect& screen) {
|
||||
const int width = std::clamp(rect.width(), kMinWidth, screen.width());
|
||||
const int height = std::clamp(rect.height(), kMinHeight, screen.height());
|
||||
CefRect MakeVisibleOnScreenRect(const CefRect& rect, const CefRect& screen) {
|
||||
const int width = std::clamp(rect.width, kMinWidth, screen.width);
|
||||
const int height = std::clamp(rect.height, kMinHeight, screen.height);
|
||||
|
||||
const int right_border = screen.x() + screen.width();
|
||||
const int x = clamp_segment_start(rect.x(), width, screen.x(), right_border);
|
||||
const int right_border = screen.x + screen.width;
|
||||
const int x = clamp_segment_start(rect.x, width, screen.x, right_border);
|
||||
|
||||
const int bottom_border = screen.y() + screen.height();
|
||||
const int y =
|
||||
clamp_segment_start(rect.y(), height, screen.y(), bottom_border);
|
||||
const int bottom_border = screen.y + screen.height;
|
||||
const int y = clamp_segment_start(rect.y, height, screen.y, bottom_border);
|
||||
|
||||
return gfx::Rect(x, y, width, height);
|
||||
return CefRect(x, y, width, height);
|
||||
}
|
||||
|
@@ -6,15 +6,12 @@
|
||||
#define CEF_LIBCEF_BROWSER_SCREEN_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
namespace gfx {
|
||||
class Rect;
|
||||
}
|
||||
#include "include/internal/cef_types_wrappers.h"
|
||||
|
||||
// Create a new rectangle from the input |rect| rectangle that is fully visible
|
||||
// on provided |screen_rect| screen. The width and height of the resulting
|
||||
// rectangle are clamped to the screen width and height respectively if they
|
||||
// would overflow.
|
||||
gfx::Rect MakeVisibleOnScreenRect(const gfx::Rect& rect,
|
||||
const gfx::Rect& screen);
|
||||
CefRect MakeVisibleOnScreenRect(const CefRect& rect, const CefRect& screen);
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_SCREEN_UTIL_H_
|
||||
|
@@ -5,79 +5,77 @@
|
||||
#include "cef/libcef/browser/screen_util.h"
|
||||
#include "tests/gtest/include/gtest/gtest.h"
|
||||
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int kScreenWidth = 1024;
|
||||
constexpr int kScreenHeight = 768;
|
||||
const gfx::Rect kMainScreen(0, 0, kScreenWidth, kScreenHeight);
|
||||
const gfx::Rect kLeftScreen(-1024, 0, kScreenWidth, kScreenHeight);
|
||||
const CefRect kMainScreen(0, 0, kScreenWidth, kScreenHeight);
|
||||
const CefRect kLeftScreen(-1024, 0, kScreenWidth, kScreenHeight);
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(MakeVisibleOnScreenRect, RectSizeIsBiggerThanScreen) {
|
||||
const gfx::Rect rect{400, 500, 1500, 800};
|
||||
const CefRect rect{400, 500, 1500, 800};
|
||||
|
||||
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
|
||||
|
||||
EXPECT_EQ(result.x(), 0);
|
||||
EXPECT_EQ(result.width(), kMainScreen.width());
|
||||
EXPECT_EQ(result.y(), 0);
|
||||
EXPECT_EQ(result.height(), kMainScreen.height());
|
||||
EXPECT_EQ(result.x, 0);
|
||||
EXPECT_EQ(result.width, kMainScreen.width);
|
||||
EXPECT_EQ(result.y, 0);
|
||||
EXPECT_EQ(result.height, kMainScreen.height);
|
||||
}
|
||||
|
||||
TEST(MakeVisibleOnScreenRect, RightBorderIsOutsideTheScreen) {
|
||||
const gfx::Rect rect{600, 400, 500, 300};
|
||||
const CefRect rect{600, 400, 500, 300};
|
||||
|
||||
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
|
||||
|
||||
EXPECT_EQ(result.x(), 524);
|
||||
EXPECT_EQ(result.width(), rect.width());
|
||||
EXPECT_EQ(result.y(), rect.y());
|
||||
EXPECT_EQ(result.height(), rect.height());
|
||||
EXPECT_EQ(result.x, 524);
|
||||
EXPECT_EQ(result.width, rect.width);
|
||||
EXPECT_EQ(result.y, rect.y);
|
||||
EXPECT_EQ(result.height, rect.height);
|
||||
}
|
||||
|
||||
TEST(MakeVisibleOnScreenRect, LeftBorderIsOutsideTheScreen) {
|
||||
const gfx::Rect rect{-400, 400, 500, 300};
|
||||
const CefRect rect{-400, 400, 500, 300};
|
||||
|
||||
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
|
||||
|
||||
EXPECT_EQ(result.x(), 0);
|
||||
EXPECT_EQ(result.width(), rect.width());
|
||||
EXPECT_EQ(result.y(), rect.y());
|
||||
EXPECT_EQ(result.height(), rect.height());
|
||||
EXPECT_EQ(result.x, 0);
|
||||
EXPECT_EQ(result.width, rect.width);
|
||||
EXPECT_EQ(result.y, rect.y);
|
||||
EXPECT_EQ(result.height, rect.height);
|
||||
}
|
||||
|
||||
TEST(MakeVisibleOnScreenRect, BottomBorderIsOutsideTheScreen) {
|
||||
const gfx::Rect rect{600, 500, 300, 300};
|
||||
const CefRect rect{600, 500, 300, 300};
|
||||
|
||||
auto result = MakeVisibleOnScreenRect(rect, kMainScreen);
|
||||
|
||||
EXPECT_EQ(result.x(), 600);
|
||||
EXPECT_EQ(result.width(), rect.width());
|
||||
EXPECT_EQ(result.y(), 468);
|
||||
EXPECT_EQ(result.height(), rect.height());
|
||||
EXPECT_EQ(result.x, 600);
|
||||
EXPECT_EQ(result.width, rect.width);
|
||||
EXPECT_EQ(result.y, 468);
|
||||
EXPECT_EQ(result.height, rect.height);
|
||||
}
|
||||
|
||||
TEST(MakeVisibleOnScreenRect, RectIsVisibleOnTheLeftScreen) {
|
||||
const gfx::Rect rect{-500, 300, 300, 300};
|
||||
const CefRect rect{-500, 300, 300, 300};
|
||||
|
||||
auto result = MakeVisibleOnScreenRect(rect, kLeftScreen);
|
||||
|
||||
EXPECT_EQ(result.x(), rect.x());
|
||||
EXPECT_EQ(result.width(), rect.width());
|
||||
EXPECT_EQ(result.y(), rect.y());
|
||||
EXPECT_EQ(result.height(), rect.height());
|
||||
EXPECT_EQ(result.x, rect.x);
|
||||
EXPECT_EQ(result.width, rect.width);
|
||||
EXPECT_EQ(result.y, rect.y);
|
||||
EXPECT_EQ(result.height, rect.height);
|
||||
}
|
||||
|
||||
TEST(MakeVisibleOnScreenRect, RectSizeIsBiggerThanLeftScreen) {
|
||||
const gfx::Rect rect{-500, 300, 3000, 3000};
|
||||
const CefRect rect{-500, 300, 3000, 3000};
|
||||
|
||||
auto result = MakeVisibleOnScreenRect(rect, kLeftScreen);
|
||||
|
||||
EXPECT_EQ(result.x(), kLeftScreen.x());
|
||||
EXPECT_EQ(result.width(), kLeftScreen.width());
|
||||
EXPECT_EQ(result.y(), kLeftScreen.y());
|
||||
EXPECT_EQ(result.height(), kLeftScreen.height());
|
||||
EXPECT_EQ(result.x, kLeftScreen.x);
|
||||
EXPECT_EQ(result.width, kLeftScreen.width);
|
||||
EXPECT_EQ(result.y, kLeftScreen.y);
|
||||
EXPECT_EQ(result.height, kLeftScreen.height);
|
||||
}
|
@@ -545,9 +545,9 @@ void CefServerImpl::StartOnHandlerThread(const std::string& address,
|
||||
if (socket->ListenWithAddressAndPort(address, port, backlog) == net::OK) {
|
||||
server_.reset(new net::HttpServer(std::move(socket), this));
|
||||
|
||||
net::IPEndPoint ip_address;
|
||||
if (server_->GetLocalAddress(&ip_address) == net::OK)
|
||||
address_ = ip_address.ToString();
|
||||
net::IPEndPoint address;
|
||||
if (server_->GetLocalAddress(&address) == net::OK)
|
||||
address_ = address.ToString();
|
||||
}
|
||||
|
||||
handler_->OnServerCreated(this);
|
||||
|
@@ -75,32 +75,6 @@ CefPoint CefDisplay::ConvertScreenPointFromPixels(const CefPoint& point) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// static
|
||||
CefRect CefDisplay::ConvertScreenRectToPixels(const CefRect& rect) {
|
||||
CEF_REQUIRE_UIT_RETURN(CefRect());
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
const gfx::Rect pix_rect = view_util::ConvertRectToPixels(
|
||||
gfx::Rect(rect.x, rect.y, rect.width, rect.height));
|
||||
return CefRect(pix_rect.x(), pix_rect.y(), pix_rect.width(),
|
||||
pix_rect.height());
|
||||
#else
|
||||
return rect;
|
||||
#endif
|
||||
}
|
||||
|
||||
// static
|
||||
CefRect CefDisplay::ConvertScreenRectFromPixels(const CefRect& rect) {
|
||||
CEF_REQUIRE_UIT_RETURN(CefRect());
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
const gfx::Rect dip_rect = view_util::ConvertRectFromPixels(
|
||||
gfx::Rect(rect.x, rect.y, rect.width, rect.height));
|
||||
return CefRect(dip_rect.x(), dip_rect.y(), dip_rect.width(),
|
||||
dip_rect.height());
|
||||
#else
|
||||
return rect;
|
||||
#endif
|
||||
}
|
||||
|
||||
CefDisplayImpl::CefDisplayImpl(const display::Display& display)
|
||||
: display_(display) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user