Compare commits

..

55 Commits
3440 ... 3497

Author SHA1 Message Date
Marshall Greenblatt
7f37a0a130 Fix substitution of localized strings for directory listings (issue #2412) 2018-10-19 14:43:31 -04:00
Marshall Greenblatt
cd24143111 Fix ArrayBuffer crashes and add performance test (issue #2521) 2018-10-10 16:15:25 +03:00
Marshall Greenblatt
ead5caf25a Windows: Fix crashes when dragging an image with OSR enabled (issue #2525) 2018-10-10 14:47:18 +03:00
Marshall Greenblatt
c6dbc58c5f Linux: cefclient: Fix crash when creating popup window (issue #2512) 2018-10-10 13:50:37 +03:00
Marshall Greenblatt
00188c7052 Fix crash using CefCookieManager::SetStoragePath (issue #2522) 2018-10-08 19:22:38 +03:00
Marshall Greenblatt
b472a8d9ea macOS: Fix crash when showing a select popup with CefDoMessageLoopWork (issue #2495) 2018-09-28 16:31:53 +02:00
Marshall Greenblatt
847fd4fd63 Add missing include for DISALLOW_COPY_AND_ASSIGN 2018-09-28 15:51:57 +02:00
Marshall Greenblatt
0a87d5f25f Fix redraw of OSR PDF viewer (issue #2507) 2018-09-27 16:05:22 +02:00
Marshall Greenblatt
13f506f92a Fix crash when high contrast themes are enabled (issue #2508) 2018-09-21 16:36:00 +02:00
Marshall Greenblatt
4c165056e1 Windows: cmake: Add VS2017 15.8 build support 2018-09-21 11:12:42 +02:00
Marshall Greenblatt
461fa1fe83 Update to Chromium version 69.0.3497.100 2018-09-20 17:12:42 +02:00
Marshall Greenblatt
bf8b64d70e Linux: Add multi-threaded message loop support (issue #2512) 2018-09-20 06:10:45 -07:00
Marshall Greenblatt
004ef913a2 Fix crash when hovering buttons in OSR PDF viewer (issue #2488) 2018-09-14 11:19:53 +02:00
Marshall Greenblatt
9df58650e1 RTL document in <iframe> should have left-hand scrollbar (see https://crbug.com/250514#c34) 2018-09-14 10:29:55 +02:00
Marshall Greenblatt
a4f7e361be Remove Singleton patches which are no longer required (issue #2362) 2018-09-06 21:57:52 +02:00
Marshall Greenblatt
52427ce97f Windows: Fix DCHECKs during shutdown with multi-threaded message loop mode (issue #2362) 2018-09-06 17:39:11 +02:00
Marshall Greenblatt
01f9a30b1d Fix external message pump (issue #2493) 2018-09-06 14:52:58 +02:00
Marshall Greenblatt
fd089efa24 Linux: Zero initialize MwmHints (issue #2492) 2018-09-06 13:51:06 +02:00
Marshall Greenblatt
3f956461bb macOS: Fix crash when closing full-screen window (issue #2491) 2018-09-06 13:50:59 +02:00
Marshall Greenblatt
4f87de9f52 Linux: Fix compile error 2018-09-06 10:33:28 +02:00
Marshall Greenblatt
532ce6b99c Update to Chromium version 69.0.3497.81 2018-09-05 19:30:35 +02:00
Marshall Greenblatt
633c181700 macOS: Fix compile error (issue #2489) 2018-08-17 11:08:41 -04:00
Marshall Greenblatt
7ed3a545e9 Update to Chromium version 69.0.3497.32 2018-08-15 17:01:54 -04:00
Marshall Greenblatt
17f0192053 macOS: Update README.txt for distribution content changes 2018-07-30 16:23:39 -04:00
Marshall Greenblatt
f7ae4ed0da Update to Chromium version 69.0.3497.12 2018-07-25 20:00:11 -04:00
Marshall Greenblatt
0fb03e7aa1 macOS: Fix OSR configuration of device scale factor 2018-07-25 16:55:11 -04:00
Marshall Greenblatt
7f3c21b64a macOS: Add angle and swiftshader libraries to the app bundle (issue #2446)" 2018-07-25 15:18:24 -04:00
Marshall Greenblatt
339ce47575 macOS: Add the LSEnvironment variable MallocNanoZone=0 (see https://crbug.com/861939) 2018-07-25 14:23:54 -04:00
Marshall Greenblatt
7d09642925 Update to Chromium version 69.0.3497.0 (#576753) 2018-07-24 12:15:30 -04:00
Alexander Guettler
fad6aec5d0 Add MouseWheelPhaseHandler for OSR (issue #2214) 2018-07-13 15:50:16 -04:00
Marshall Greenblatt
96bd993d99 Update to Chromium version 69.0.3489.0 (#574445) 2018-07-13 15:29:39 -04:00
Marshall Greenblatt
8e9d736cda Windows: Fix failure in tools/clang/scripts/update.py with custom VS toolchain (issue #2474) 2018-07-12 14:53:36 -04:00
Marshall Greenblatt
6a76bdb040 Revert "Disable cfi-icall which is not supported by the CEF bindings layer (issue #2472)"
This reverts commit 66b5dc3d55.
2018-07-12 10:58:49 -07:00
Marshall Greenblatt
cf5b322efc Linux: Fix cfi-icall failure in atk_util_auralinux_gtk2.cc (issue #2472) 2018-07-12 10:58:29 -07:00
Marshall Greenblatt
7139f01103 Fix cfi-cast failure in CefBrowserMessageLoop::current (issue #2472) 2018-07-12 10:58:29 -07:00
Marshall Greenblatt
0d12959a50 Disable cfi-icall checks for CEF bindings (issue #2472) 2018-07-12 10:58:29 -07:00
Marshall Greenblatt
10c01ff43e Remove include/base/cef_thread_collision_warner.h which is unused and causes linker errors with CFI builds (issue #2472) 2018-07-12 10:58:29 -07:00
Marshall Greenblatt
66b5dc3d55 Disable cfi-icall which is not supported by the CEF bindings layer (issue #2472) 2018-07-11 12:32:48 -04:00
Marshall Greenblatt
f12ad6b634 Add missing include 2018-07-09 16:12:39 -04:00
Marshall Greenblatt
5bf4d4febd Fix passing of lang command-line flag to the renderer (issue #2468) 2018-07-09 16:10:03 -04:00
Marshall Greenblatt
448a112352 CefFrame::GetURL in the renderer process should return the provisional URL for popups during loading (issue #2448) 2018-07-09 14:36:37 -04:00
Marshall Greenblatt
9229cdd0eb Remove CefSettings.single_process. This mode is not supported and CefSettings makes it too easy to enable. The command-line flag still exists. 2018-07-09 13:31:32 -04:00
Alexander Guettler
9e22c975fa Windows: Remove /llvmlibthin from link command (issue #2470) 2018-07-09 11:37:13 -04:00
Marshall Greenblatt
6301e06c8a Update to Chromium version 69.0.3483.0 (#572879) 2018-07-09 11:23:23 -04:00
Kudo Chien
123324f5f9 Fix PDF print and save buttons (issue #2463). 2018-07-05 18:32:01 +00:00
Marshall Greenblatt
eb3325a9ae Fix application of DEPS.patch for 3029 branch 2018-07-05 14:24:49 -04:00
Marshall Greenblatt
2d48a07bec Update to Chromium version 69.0.3476.0 (#571360) 2018-07-03 13:48:07 -04:00
Marshall Greenblatt
669e8673ce Linux: cmake: Don't warn about code in comments (issue #2346) 2018-06-27 12:47:39 -04:00
Marshall Greenblatt
b03c54bfbe Linux: Use poll instead of select to fix crash during startup (issue #2466) 2018-06-27 12:40:59 -04:00
Marshall Greenblatt
35830c88e5 Update to Chromium version 69.0.3464.0 (#567918) 2018-06-19 15:49:32 -04:00
Cristian Amarie
3c3045a5cb Add http:// prefix to browser creation URLs if necessary (issue #2427) 2018-06-15 20:14:47 +00:00
Marshall Greenblatt
b25374c8e7 Pass BrowserProcessSubThread to ContentMainDelegate::RunProcess (issue #2456) 2018-06-15 15:55:54 -04:00
Marshall Greenblatt
4f28c5ffff Windows: cmake: Add VS2017 15.6 & 15.7 build support 2018-06-12 14:40:30 -04:00
Marshall Greenblatt
12043b16e7 Update to Chromium version 69.0.3453.0 (#565531) 2018-06-12 14:16:03 -04:00
Marshall Greenblatt
d9ebd4c50f Switch DevTools to the default view that doesn't show screencast 2018-06-07 12:57:46 -04:00
324 changed files with 5166 additions and 3390 deletions

View File

@@ -112,6 +112,7 @@ import("//third_party/widevine/cdm/widevine.gni")
import("//tools/grit/repack.gni") import("//tools/grit/repack.gni")
import("//tools/grit/grit_rule.gni") import("//tools/grit/grit_rule.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni") import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//ui/gl/features.gni")
import("//v8/gni/v8.gni") import("//v8/gni/v8.gni")
if (is_clang) { if (is_clang) {
import("//build/config/clang/clang.gni") import("//build/config/clang/clang.gni")
@@ -402,6 +403,8 @@ static_library("libcef_static") {
"libcef/browser/net/chrome_scheme_handler.h", "libcef/browser/net/chrome_scheme_handler.h",
"libcef/browser/net/cookie_store_proxy.cc", "libcef/browser/net/cookie_store_proxy.cc",
"libcef/browser/net/cookie_store_proxy.h", "libcef/browser/net/cookie_store_proxy.h",
"libcef/browser/net/cookie_store_source.cc",
"libcef/browser/net/cookie_store_source.h",
"libcef/browser/net/crlset_file_util_impl.cc", "libcef/browser/net/crlset_file_util_impl.cc",
"libcef/browser/net/devtools_scheme_handler.cc", "libcef/browser/net/devtools_scheme_handler.cc",
"libcef/browser/net/devtools_scheme_handler.h", "libcef/browser/net/devtools_scheme_handler.h",
@@ -706,8 +709,7 @@ static_library("libcef_static") {
"//media", "//media",
"//media/blink", "//media/blink",
"//net", "//net",
"//net:net_browser_services", "//net/dns:mojo_client",
"//net:net_utility_services",
"//net:net_with_v8", "//net:net_with_v8",
"//pdf", "//pdf",
"//ppapi/buildflags", "//ppapi/buildflags",
@@ -777,6 +779,8 @@ static_library("libcef_static") {
libs = [ libs = [
"comctl32.lib", "comctl32.lib",
# For D3D11_DECODER_PROFILE_H264_VLD_NOFGT.
"dxguid.lib",
] ]
} }
@@ -1386,11 +1390,58 @@ if (is_mac) {
] ]
} }
if (use_egl) {
# Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_angle_binaries") {
sources = [
"$root_out_dir/egl_intermediates/libEGL.dylib",
"$root_out_dir/egl_intermediates/libGLESv2.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:angle_library_copy",
]
}
# Add the SwiftShader .dylibs in the MODULE_DIR of the Framework app bundle.
bundle_data("cef_framework_swiftshader_binaries") {
sources = [
"$root_out_dir/egl_intermediates/libswiftshader_libEGL.dylib",
"$root_out_dir/egl_intermediates/libswiftshader_libGLESv2.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Libraries/{{source_file_part}}",
]
public_deps = [
"//ui/gl:swiftshader_library_copy",
]
}
}
group("cef_framework_angle_library") {
if (use_egl) {
deps = [
":cef_framework_angle_binaries",
]
}
}
group("cef_framework_swiftshader_library") {
if (use_egl) {
deps = [
":cef_framework_swiftshader_binaries",
]
}
}
mac_framework_bundle("cef_framework") { mac_framework_bundle("cef_framework") {
output_name = cef_framework_name output_name = cef_framework_name
framework_version = "A" framework_version = "A"
framework_contents = [ framework_contents = [
"Libraries",
"Resources", "Resources",
] ]
@@ -1407,8 +1458,10 @@ if (is_mac) {
# - crash_report_sender.app # - crash_report_sender.app
deps = [ deps = [
":cef_framework_angle_library",
":cef_framework_locales", ":cef_framework_locales",
":cef_framework_resources", ":cef_framework_resources",
":cef_framework_swiftshader_library",
":libcef_static", ":libcef_static",
] ]
@@ -1450,7 +1503,6 @@ if (is_mac) {
deps = [ deps = [
":libcef_static", ":libcef_static",
"//build/config:exe_and_shlib_deps",
] ]
if (is_win) { if (is_win) {
@@ -1845,7 +1897,6 @@ if (is_mac) {
deps = [ deps = [
":libcef", ":libcef",
":libcef_dll_wrapper", ":libcef_dll_wrapper",
"//build/config:exe_and_shlib_deps",
] ]
if (is_win) { if (is_win) {
@@ -1919,7 +1970,6 @@ if (is_mac) {
deps = [ deps = [
":libcef", ":libcef",
":libcef_dll_wrapper", ":libcef_dll_wrapper",
"//build/config:exe_and_shlib_deps",
] ]
if (is_win) { if (is_win) {
@@ -1988,7 +2038,6 @@ if (is_mac) {
deps = [ deps = [
":libcef", ":libcef",
":libcef_dll_wrapper", ":libcef_dll_wrapper",
"//build/config:exe_and_shlib_deps",
"//testing/gtest", "//testing/gtest",
] ]

View File

@@ -7,5 +7,5 @@
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding # https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
{ {
'chromium_checkout': 'refs/tags/68.0.3440.106', 'chromium_checkout': 'refs/tags/69.0.3497.100',
} }

View File

@@ -41,9 +41,11 @@
'chrome/renderer/chrome_content_renderer_client.*', 'chrome/renderer/chrome_content_renderer_client.*',
'chrome/renderer/extensions/chrome_extensions_renderer_client.*', 'chrome/renderer/extensions/chrome_extensions_renderer_client.*',
'content/browser/renderer_host/render_widget_host_view_base.*', 'content/browser/renderer_host/render_widget_host_view_base.*',
'content/public/browser/content_browser_client.*',
'content/public/browser/render_widget_host_view.h', 'content/public/browser/render_widget_host_view.h',
'content/public/browser/storage_partition.h', 'content/public/browser/storage_partition.h',
'content/public/browser/web_contents_delegate.h', 'content/public/browser/web_contents_delegate.h',
'content/public/common/content_features.cc',
'content/shell/BUILD.gn', 'content/shell/BUILD.gn',
'content/shell/app/*', 'content/shell/app/*',
'content/shell/browser/shell_*', 'content/shell/browser/shell_*',

View File

@@ -26,7 +26,6 @@
'include/base/cef_string16.h', 'include/base/cef_string16.h',
'include/base/cef_template_util.h', 'include/base/cef_template_util.h',
'include/base/cef_thread_checker.h', 'include/base/cef_thread_checker.h',
'include/base/cef_thread_collision_warner.h',
'include/base/cef_trace_event.h', 'include/base/cef_trace_event.h',
'include/base/cef_tuple.h', 'include/base/cef_tuple.h',
'include/base/cef_weak_ptr.h', 'include/base/cef_weak_ptr.h',
@@ -115,7 +114,6 @@
'libcef_dll/base/cef_ref_counted.cc', 'libcef_dll/base/cef_ref_counted.cc',
'libcef_dll/base/cef_string16.cc', 'libcef_dll/base/cef_string16.cc',
'libcef_dll/base/cef_thread_checker_impl.cc', 'libcef_dll/base/cef_thread_checker_impl.cc',
'libcef_dll/base/cef_thread_collision_warner.cc',
'libcef_dll/base/cef_weak_ptr.cc', 'libcef_dll/base/cef_weak_ptr.cc',
], ],
'libcef_dll_wrapper_sources_common': [ 'libcef_dll_wrapper_sources_common': [
@@ -370,6 +368,8 @@
'tests/cefclient/browser/dialog_handler_gtk.cc', 'tests/cefclient/browser/dialog_handler_gtk.cc',
'tests/cefclient/browser/dialog_handler_gtk.h', 'tests/cefclient/browser/dialog_handler_gtk.h',
'tests/cefclient/browser/main_context_impl_posix.cc', 'tests/cefclient/browser/main_context_impl_posix.cc',
'tests/cefclient/browser/main_message_loop_multithreaded_gtk.cc',
'tests/cefclient/browser/main_message_loop_multithreaded_gtk.h',
'tests/cefclient/browser/print_handler_gtk.cc', 'tests/cefclient/browser/print_handler_gtk.cc',
'tests/cefclient/browser/print_handler_gtk.h', 'tests/cefclient/browser/print_handler_gtk.h',
'tests/cefclient/browser/resource_util_linux.cc', 'tests/cefclient/browser/resource_util_linux.cc',
@@ -379,6 +379,8 @@
'tests/cefclient/browser/root_window_views.h', 'tests/cefclient/browser/root_window_views.h',
'tests/cefclient/browser/temp_window_x11.cc', 'tests/cefclient/browser/temp_window_x11.cc',
'tests/cefclient/browser/temp_window_x11.h', 'tests/cefclient/browser/temp_window_x11.h',
'tests/cefclient/browser/util_gtk.cc',
'tests/cefclient/browser/util_gtk.h',
'tests/cefclient/browser/views_menu_bar.cc', 'tests/cefclient/browser/views_menu_bar.cc',
'tests/cefclient/browser/views_menu_bar.h', 'tests/cefclient/browser/views_menu_bar.h',
'tests/cefclient/browser/views_style.cc', 'tests/cefclient/browser/views_style.cc',

View File

@@ -346,6 +346,7 @@ if(OS_WINDOWS)
1912 # VS2017 version 15.5 1912 # VS2017 version 15.5
1913 # VS2017 version 15.6 1913 # VS2017 version 15.6
1914 # VS2017 version 15.7 1914 # VS2017 version 15.7
1915 # VS2017 version 15.8
) )
list(FIND supported_msvc_versions ${MSVC_VERSION} _index) list(FIND supported_msvc_versions ${MSVC_VERSION} _index)
if (${_index} EQUAL -1) if (${_index} EQUAL -1)

View File

@@ -162,6 +162,16 @@
#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
#endif #endif
// Sanitizers annotations.
#if defined(__has_attribute)
#if __has_attribute(no_sanitize)
#define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
#endif
#endif
#if !defined(NO_SANITIZE)
#define NO_SANITIZE(what)
#endif
#endif // !USING_CHROMIUM_INCLUDES #endif // !USING_CHROMIUM_INCLUDES
// Annotate a virtual method indicating it must be overriding a virtual method // Annotate a virtual method indicating it must be overriding a virtual method

View File

@@ -51,7 +51,7 @@
#include "include/base/cef_atomic_ref_count.h" #include "include/base/cef_atomic_ref_count.h"
#include "include/base/cef_build.h" #include "include/base/cef_build.h"
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/base/cef_thread_collision_warner.h" #include "include/base/cef_macros.h"
namespace base { namespace base {
@@ -78,10 +78,6 @@ class RefCountedBase {
} }
void AddRef() const { void AddRef() const {
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(!in_dtor_); DCHECK(!in_dtor_);
#endif #endif
@@ -90,10 +86,6 @@ class RefCountedBase {
// Returns true if the object should self-delete. // Returns true if the object should self-delete.
bool Release() const { bool Release() const {
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(!in_dtor_); DCHECK(!in_dtor_);
#endif #endif
@@ -112,8 +104,6 @@ class RefCountedBase {
mutable bool in_dtor_; mutable bool in_dtor_;
#endif #endif
DFAKE_MUTEX(add_release_);
DISALLOW_COPY_AND_ASSIGN(RefCountedBase); DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
}; };

View File

@@ -1,276 +0,0 @@
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
// Google Inc. 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_BASE_CEF_THREAD_COLLISION_WARNER_H_
#define CEF_INCLUDE_BASE_CEF_THREAD_COLLISION_WARNER_H_
#pragma once
#if defined(BASE_THREADING_THREAD_COLLISION_WARNER_H_)
// Do nothing if the Chromium header has already been included.
// This can happen in cases where Chromium code is used directly by the
// client application. When using Chromium code directly always include
// the Chromium header first to avoid type conflicts.
#elif defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/threading/thread_collision_warner.h"
#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.
#include <memory>
#include "include/base/cef_atomicops.h"
#include "include/base/cef_basictypes.h"
#include "include/base/cef_build.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
// A helper class alongside macros to be used to verify assumptions about thread
// safety of a class.
//
// Example: Queue implementation non thread-safe but still usable if clients
// are synchronized somehow.
//
// In this case the macro DFAKE_SCOPED_LOCK has to be
// used, it checks that if a thread is inside the push/pop then
// noone else is still inside the pop/push
//
// class NonThreadSafeQueue {
// public:
// ...
// void push(int) { DFAKE_SCOPED_LOCK(push_pop_); ... }
// int pop() { DFAKE_SCOPED_LOCK(push_pop_); ... }
// ...
// private:
// DFAKE_MUTEX(push_pop_);
// };
//
//
// Example: Queue implementation non thread-safe but still usable if clients
// are synchronized somehow, it calls a method to "protect" from
// a "protected" method
//
// In this case the macro DFAKE_SCOPED_RECURSIVE_LOCK
// has to be used, it checks that if a thread is inside the push/pop
// then noone else is still inside the pop/push
//
// class NonThreadSafeQueue {
// public:
// void push(int) {
// DFAKE_SCOPED_LOCK(push_pop_);
// ...
// }
// int pop() {
// DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_);
// bar();
// ...
// }
// void bar() { DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); ... }
// ...
// private:
// DFAKE_MUTEX(push_pop_);
// };
//
//
// Example: Queue implementation not usable even if clients are synchronized,
// so only one thread in the class life cycle can use the two members
// push/pop.
//
// In this case the macro DFAKE_SCOPED_LOCK_THREAD_LOCKED pins the
// specified
// critical section the first time a thread enters push or pop, from
// that time on only that thread is allowed to execute push or pop.
//
// class NonThreadSafeQueue {
// public:
// ...
// void push(int) { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... }
// int pop() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... }
// ...
// private:
// DFAKE_MUTEX(push_pop_);
// };
//
//
// Example: Class that has to be contructed/destroyed on same thread, it has
// a "shareable" method (with external synchronization) and a not
// shareable method (even with external synchronization).
//
// In this case 3 Critical sections have to be defined
//
// class ExoticClass {
// public:
// ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
// ~ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
//
// void Shareable() { DFAKE_SCOPED_LOCK(shareable_section_); ... }
// void NotShareable() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
// ...
// private:
// DFAKE_MUTEX(ctor_dtor_);
// DFAKE_MUTEX(shareable_section_);
// };
#if DCHECK_IS_ON()
// Defines a class member that acts like a mutex. It is used only as a
// verification tool.
#define DFAKE_MUTEX(obj) mutable base::ThreadCollisionWarner obj
// Asserts the call is never called simultaneously in two threads. Used at
// member function scope.
#define DFAKE_SCOPED_LOCK(obj) \
base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj)
// Asserts the call is never called simultaneously in two threads. Used at
// member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks.
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \
base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj)
// Asserts the code is always executed in the same thread.
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \
base::ThreadCollisionWarner::Check check_##obj(&obj)
#else
#define DFAKE_MUTEX(obj) typedef void InternalFakeMutexType##obj
#define DFAKE_SCOPED_LOCK(obj) ((void)0)
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) ((void)0)
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) ((void)0)
#endif
namespace base {
// The class ThreadCollisionWarner uses an Asserter to notify the collision
// AsserterBase is the interfaces and DCheckAsserter is the default asserter
// used. During the unit tests is used another class that doesn't "DCHECK"
// in case of collision (check thread_collision_warner_unittests.cc)
struct AsserterBase {
virtual ~AsserterBase() {}
virtual void warn() = 0;
};
struct DCheckAsserter : public AsserterBase {
virtual ~DCheckAsserter() {}
virtual void warn() OVERRIDE;
};
class ThreadCollisionWarner {
public:
// The parameter asserter is there only for test purpose
explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter())
: valid_thread_id_(0), counter_(0), asserter_(asserter) {}
~ThreadCollisionWarner() { delete asserter_; }
// This class is meant to be used through the macro
// DFAKE_SCOPED_LOCK_THREAD_LOCKED
// it doesn't leave the critical section, as opposed to ScopedCheck,
// because the critical section being pinned is allowed to be used only
// from one thread
class Check {
public:
explicit Check(ThreadCollisionWarner* warner) : warner_(warner) {
warner_->EnterSelf();
}
~Check() {}
private:
ThreadCollisionWarner* warner_;
DISALLOW_COPY_AND_ASSIGN(Check);
};
// This class is meant to be used through the macro
// DFAKE_SCOPED_LOCK
class ScopedCheck {
public:
explicit ScopedCheck(ThreadCollisionWarner* warner) : warner_(warner) {
warner_->Enter();
}
~ScopedCheck() { warner_->Leave(); }
private:
ThreadCollisionWarner* warner_;
DISALLOW_COPY_AND_ASSIGN(ScopedCheck);
};
// This class is meant to be used through the macro
// DFAKE_SCOPED_RECURSIVE_LOCK
class ScopedRecursiveCheck {
public:
explicit ScopedRecursiveCheck(ThreadCollisionWarner* warner)
: warner_(warner) {
warner_->EnterSelf();
}
~ScopedRecursiveCheck() { warner_->Leave(); }
private:
ThreadCollisionWarner* warner_;
DISALLOW_COPY_AND_ASSIGN(ScopedRecursiveCheck);
};
private:
// This method stores the current thread identifier and does a DCHECK
// if a another thread has already done it, it is safe if same thread
// calls this multiple time (recursion allowed).
void EnterSelf();
// Same as EnterSelf but recursion is not allowed.
void Enter();
// Removes the thread_id stored in order to allow other threads to
// call EnterSelf or Enter.
void Leave();
// This stores the thread id that is inside the critical section, if the
// value is 0 then no thread is inside.
volatile subtle::Atomic32 valid_thread_id_;
// Counter to trace how many time a critical section was "pinned"
// (when allowed) in order to unpin it when counter_ reaches 0.
volatile subtle::Atomic32 counter_;
// Here only for class unit tests purpose, during the test I need to not
// DCHECK but notify the collision with something else.
AsserterBase* asserter_;
DISALLOW_COPY_AND_ASSIGN(ThreadCollisionWarner);
};
} // namespace base
#endif // !USING_CHROMIUM_INCLUDES
#endif // CEF_INCLUDE_BASE_CEF_THREAD_COLLISION_WARNER_H_

View File

@@ -181,7 +181,7 @@ typedef struct _cef_settings_t {
// Set to true (1) to have the browser process message loop run in a separate // Set to true (1) to have the browser process message loop run in a separate
// thread. If false (0) than the CefDoMessageLoopWork() function must be // thread. If false (0) than the CefDoMessageLoopWork() function must be
// called from your application message loop. This option is only supported on // called from your application message loop. This option is only supported on
// Windows. // Windows and Linux.
/// ///
int multi_threaded_message_loop; int multi_threaded_message_loop;

View File

@@ -130,6 +130,12 @@ ChromeZoomLevelPrefs* CefBrowserContext::GetZoomLevelPrefs() {
GetStoragePartition(this, NULL)->GetZoomLevelDelegate()); GetStoragePartition(this, NULL)->GetZoomLevelDelegate());
} }
scoped_refptr<network::SharedURLLoaderFactory>
CefBrowserContext::GetURLLoaderFactory() {
return GetDefaultStoragePartition(this)
->GetURLLoaderFactoryForBrowserProcess();
}
void CefBrowserContext::OnRenderFrameDeleted(int render_process_id, void CefBrowserContext::OnRenderFrameDeleted(int render_process_id,
int render_frame_id, int render_frame_id,
bool is_main_frame, bool is_main_frame,

View File

@@ -146,6 +146,7 @@ class CefBrowserContext : public ChromeProfileStub {
// Profile methods. // Profile methods.
ChromeZoomLevelPrefs* GetZoomLevelPrefs() override; ChromeZoomLevelPrefs* GetZoomLevelPrefs() override;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
// Returns a RequestContext associated with this object. If this object is a // Returns a RequestContext associated with this object. If this object is a
// *Proxy then it will return the single associated proxy RequestContext. If // *Proxy then it will return the single associated proxy RequestContext. If

View File

@@ -418,7 +418,8 @@ CefBrowserContextImpl::GetSSLHostStateDelegate() {
return ssl_host_state_delegate_.get(); return ssl_host_state_delegate_.get();
} }
content::PermissionManager* CefBrowserContextImpl::GetPermissionManager() { content::PermissionControllerDelegate*
CefBrowserContextImpl::GetPermissionControllerDelegate() {
return nullptr; return nullptr;
} }

View File

@@ -67,7 +67,8 @@ class CefBrowserContextImpl : public CefBrowserContext,
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override; content::PushMessagingService* GetPushMessagingService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionManager* GetPermissionManager() override; content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override; content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override; content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate() content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()

View File

@@ -153,8 +153,9 @@ CefBrowserContextProxy::GetSSLHostStateDelegate() {
return parent_->GetSSLHostStateDelegate(); return parent_->GetSSLHostStateDelegate();
} }
content::PermissionManager* CefBrowserContextProxy::GetPermissionManager() { content::PermissionControllerDelegate*
return parent_->GetPermissionManager(); CefBrowserContextProxy::GetPermissionControllerDelegate() {
return parent_->GetPermissionControllerDelegate();
} }
content::BackgroundFetchDelegate* content::BackgroundFetchDelegate*

View File

@@ -42,7 +42,8 @@ class CefBrowserContextProxy : public CefBrowserContext {
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override; content::PushMessagingService* GetPushMessagingService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionManager* GetPermissionManager() override; content::PermissionControllerDelegate* GetPermissionControllerDelegate()
override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override; content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
content::BackgroundSyncController* GetBackgroundSyncController() override; content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate() content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()

View File

@@ -224,10 +224,17 @@ bool CefBrowserHost::CreateBrowser(
return false; return false;
} }
if (windowInfo.windowless_rendering_enabled &&
!CefContext::Get()->settings().windowless_rendering_enabled) {
LOG(ERROR) << "Creating a windowless browser without setting "
"CefSettings.windowless_rendering_enabled may result in "
"reduced performance or runtime errors.";
}
// Create the browser on the UI thread. // Create the browser on the UI thread.
CreateBrowserHelper* helper = new CreateBrowserHelper( CreateBrowserHelper* helper = new CreateBrowserHelper(
windowInfo, client, url, settings, request_context); windowInfo, client, url, settings, request_context);
CEF_POST_TASK(CEF_UIT, base::Bind(CreateBrowserWithHelper, helper)); CEF_POST_TASK(CEF_UIT, base::BindOnce(CreateBrowserWithHelper, helper));
return true; return true;
} }
@@ -268,6 +275,11 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
create_params.window_info.reset(new CefWindowInfo(windowInfo)); create_params.window_info.reset(new CefWindowInfo(windowInfo));
create_params.client = client; create_params.client = client;
create_params.url = GURL(url.ToString()); create_params.url = GURL(url.ToString());
if (!url.empty() && !create_params.url.is_valid() &&
!create_params.url.has_scheme()) {
std::string new_url = std::string("http://") + url.ToString();
create_params.url = GURL(new_url);
}
create_params.settings = settings; create_params.settings = settings;
create_params.request_context = request_context; create_params.request_context = request_context;
@@ -615,8 +627,8 @@ void CefBrowserHostImpl::CloseBrowser(bool force_close) {
CloseContents(contents); CloseContents(contents);
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::CloseBrowser, this, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::CloseBrowser,
force_close)); this, force_close));
} }
} }
@@ -644,7 +656,7 @@ bool CefBrowserHostImpl::TryCloseBrowser() {
void CefBrowserHostImpl::SetFocus(bool focus) { void CefBrowserHostImpl::SetFocus(bool focus) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::SetFocus, this, focus)); base::BindOnce(&CefBrowserHostImpl::SetFocus, this, focus));
return; return;
} }
@@ -698,8 +710,8 @@ void CefBrowserHostImpl::SetZoomLevel(double zoomLevel) {
if (web_contents()) if (web_contents())
content::HostZoomMap::SetZoomLevel(web_contents(), zoomLevel); content::HostZoomMap::SetZoomLevel(web_contents(), zoomLevel);
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SetZoomLevel, this, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::SetZoomLevel,
zoomLevel)); this, zoomLevel));
} }
} }
@@ -712,7 +724,7 @@ void CefBrowserHostImpl::RunFileDialog(
CefRefPtr<CefRunFileDialogCallback> callback) { CefRefPtr<CefRunFileDialogCallback> callback) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::RunFileDialog, this, mode, base::BindOnce(&CefBrowserHostImpl::RunFileDialog, this, mode,
title, default_file_path, accept_filters, title, default_file_path, accept_filters,
selected_accept_filter, callback)); selected_accept_filter, callback));
return; return;
@@ -726,8 +738,8 @@ void CefBrowserHostImpl::RunFileDialog(
void CefBrowserHostImpl::StartDownload(const CefString& url) { void CefBrowserHostImpl::StartDownload(const CefString& url) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(
base::Bind(&CefBrowserHostImpl::StartDownload, this, url)); CEF_UIT, base::BindOnce(&CefBrowserHostImpl::StartDownload, this, url));
return; return;
} }
@@ -761,9 +773,10 @@ void CefBrowserHostImpl::DownloadImage(
bool bypass_cache, bool bypass_cache,
CefRefPtr<CefDownloadImageCallback> callback) { CefRefPtr<CefDownloadImageCallback> callback) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::DownloadImage, this, CEF_POST_TASK(
image_url, is_favicon, max_image_size, CEF_UIT,
bypass_cache, callback)); base::BindOnce(&CefBrowserHostImpl::DownloadImage, this, image_url,
is_favicon, max_image_size, bypass_cache, callback));
return; return;
} }
@@ -779,7 +792,7 @@ void CefBrowserHostImpl::DownloadImage(
web_contents()->DownloadImage( web_contents()->DownloadImage(
gurl, is_favicon, max_image_size * gfx::ImageSkia::GetMaxSupportedScale(), gurl, is_favicon, max_image_size * gfx::ImageSkia::GetMaxSupportedScale(),
bypass_cache, base::Bind(OnDownloadImage, max_image_size, callback)); bypass_cache, base::BindOnce(OnDownloadImage, max_image_size, callback));
} }
void CefBrowserHostImpl::Print() { void CefBrowserHostImpl::Print() {
@@ -790,7 +803,7 @@ void CefBrowserHostImpl::Print() {
printing::CefPrintViewManager::FromWebContents(actionable_contents) printing::CefPrintViewManager::FromWebContents(actionable_contents)
->PrintNow(actionable_contents->GetRenderViewHost()->GetMainFrame()); ->PrintNow(actionable_contents->GetRenderViewHost()->GetMainFrame());
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::Print, this)); CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::Print, this));
} }
} }
@@ -811,7 +824,7 @@ void CefBrowserHostImpl::PrintToPDF(const CefString& path,
->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path), ->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path),
settings, pdf_callback); settings, pdf_callback);
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::PrintToPDF, this, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::PrintToPDF, this,
path, settings, callback)); path, settings, callback));
} }
} }
@@ -840,7 +853,7 @@ void CefBrowserHostImpl::Find(int identifier,
web_contents()->Find(identifier, searchText, options); web_contents()->Find(identifier, searchText, options);
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::Find, this, identifier, base::BindOnce(&CefBrowserHostImpl::Find, this, identifier,
searchText, forward, matchCase, findNext)); searchText, forward, matchCase, findNext));
} }
} }
@@ -855,8 +868,8 @@ void CefBrowserHostImpl::StopFinding(bool clearSelection) {
: content::STOP_FIND_ACTION_KEEP_SELECTION; : content::STOP_FIND_ACTION_KEEP_SELECTION;
web_contents()->StopFinding(action); web_contents()->StopFinding(action);
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::StopFinding, this, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::StopFinding,
clearSelection)); this, clearSelection));
} }
} }
@@ -884,7 +897,7 @@ void CefBrowserHostImpl::ShowDevTools(const CefWindowInfo& windowInfo,
} else { } else {
ShowDevToolsHelper* helper = new ShowDevToolsHelper( ShowDevToolsHelper* helper = new ShowDevToolsHelper(
this, windowInfo, client, settings, inspect_element_at); this, windowInfo, client, settings, inspect_element_at);
CEF_POST_TASK(CEF_UIT, base::Bind(ShowDevToolsWithHelper, helper)); CEF_POST_TASK(CEF_UIT, base::BindOnce(ShowDevToolsWithHelper, helper));
} }
} }
@@ -895,7 +908,7 @@ void CefBrowserHostImpl::CloseDevTools() {
devtools_frontend_->Close(); devtools_frontend_->Close();
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::CloseDevTools, this)); base::BindOnce(&CefBrowserHostImpl::CloseDevTools, this));
} }
} }
@@ -916,8 +929,9 @@ void CefBrowserHostImpl::GetNavigationEntries(
return; return;
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::GetNavigationEntries, CEF_POST_TASK(
this, visitor, current_only)); CEF_UIT, base::BindOnce(&CefBrowserHostImpl::GetNavigationEntries, this,
visitor, current_only));
return; return;
} }
@@ -973,8 +987,8 @@ void CefBrowserHostImpl::SetAccessibilityState(
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::SetAccessibilityState, this, base::BindOnce(&CefBrowserHostImpl::SetAccessibilityState,
accessibility_state)); this, accessibility_state));
return; return;
} }
@@ -997,8 +1011,9 @@ void CefBrowserHostImpl::SetAutoResizeEnabled(bool enabled,
const CefSize& min_size, const CefSize& min_size,
const CefSize& max_size) { const CefSize& max_size) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SetAutoResizeEnabled, CEF_POST_TASK(
this, enabled, min_size, max_size)); CEF_UIT, base::BindOnce(&CefBrowserHostImpl::SetAutoResizeEnabled, this,
enabled, min_size, max_size));
return; return;
} }
@@ -1039,8 +1054,9 @@ bool CefBrowserHostImpl::IsWindowRenderingDisabled() {
void CefBrowserHostImpl::ReplaceMisspelling(const CefString& word) { void CefBrowserHostImpl::ReplaceMisspelling(const CefString& word) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::ReplaceMisspelling, CEF_POST_TASK(
this, word)); CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::ReplaceMisspelling, this, word));
return; return;
} }
@@ -1050,8 +1066,9 @@ void CefBrowserHostImpl::ReplaceMisspelling(const CefString& word) {
void CefBrowserHostImpl::AddWordToDictionary(const CefString& word) { void CefBrowserHostImpl::AddWordToDictionary(const CefString& word) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::AddWordToDictionary, CEF_POST_TASK(
this, word)); CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::AddWordToDictionary, this, word));
return; return;
} }
@@ -1073,7 +1090,8 @@ void CefBrowserHostImpl::AddWordToDictionary(const CefString& word) {
void CefBrowserHostImpl::WasResized() { void CefBrowserHostImpl::WasResized() {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::WasResized, this)); CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::WasResized, this));
return; return;
} }
@@ -1091,7 +1109,7 @@ void CefBrowserHostImpl::WasHidden(bool hidden) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHost::WasHidden, this, hidden)); base::BindOnce(&CefBrowserHost::WasHidden, this, hidden));
return; return;
} }
@@ -1110,7 +1128,7 @@ void CefBrowserHostImpl::NotifyScreenInfoChanged() {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefBrowserHostImpl::NotifyScreenInfoChanged, this)); base::BindOnce(&CefBrowserHostImpl::NotifyScreenInfoChanged, this));
return; return;
} }
@@ -1128,7 +1146,7 @@ void CefBrowserHostImpl::Invalidate(PaintElementType type) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::Invalidate, this, type)); base::BindOnce(&CefBrowserHostImpl::Invalidate, this, type));
return; return;
} }
@@ -1140,8 +1158,8 @@ void CefBrowserHostImpl::Invalidate(PaintElementType type) {
void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) { void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::SendKeyEvent,
base::Bind(&CefBrowserHostImpl::SendKeyEvent, this, event)); this, event));
return; return;
} }
@@ -1160,8 +1178,9 @@ void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
bool mouseUp, bool mouseUp,
int clickCount) { int clickCount) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SendMouseClickEvent, CEF_POST_TASK(CEF_UIT,
this, event, type, mouseUp, clickCount)); base::BindOnce(&CefBrowserHostImpl::SendMouseClickEvent, this,
event, type, mouseUp, clickCount));
return; return;
} }
@@ -1177,8 +1196,9 @@ void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event, void CefBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
bool mouseLeave) { bool mouseLeave) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SendMouseMoveEvent, CEF_POST_TASK(CEF_UIT,
this, event, mouseLeave)); base::BindOnce(&CefBrowserHostImpl::SendMouseMoveEvent, this,
event, mouseLeave));
return; return;
} }
@@ -1194,8 +1214,9 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
int deltaX, int deltaX,
int deltaY) { int deltaY) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SendMouseWheelEvent, CEF_POST_TASK(CEF_UIT,
this, event, deltaX, deltaY)); base::BindOnce(&CefBrowserHostImpl::SendMouseWheelEvent, this,
event, deltaX, deltaY));
return; return;
} }
@@ -1213,8 +1234,9 @@ void CefBrowserHostImpl::SendFocusEvent(bool setFocus) {
void CefBrowserHostImpl::SendCaptureLostEvent() { void CefBrowserHostImpl::SendCaptureLostEvent() {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(
base::Bind(&CefBrowserHostImpl::SendCaptureLostEvent, this)); CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::SendCaptureLostEvent, this));
return; return;
} }
@@ -1229,7 +1251,7 @@ void CefBrowserHostImpl::NotifyMoveOrResizeStarted() {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefBrowserHostImpl::NotifyMoveOrResizeStarted, this)); base::BindOnce(&CefBrowserHostImpl::NotifyMoveOrResizeStarted, this));
return; return;
} }
@@ -1253,8 +1275,8 @@ int CefBrowserHostImpl::GetWindowlessFrameRate() {
void CefBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) { void CefBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::SetWindowlessFrameRate, this, base::BindOnce(&CefBrowserHostImpl::SetWindowlessFrameRate,
frame_rate)); this, frame_rate));
return; return;
} }
@@ -1278,16 +1300,17 @@ bool CefBrowserHostImpl::CanGoBack() {
void CefBrowserHostImpl::GoBack() { void CefBrowserHostImpl::GoBack() {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) { if (navigation_locked()) {
// Try again after frame destruction has completed. // Try again after the lock has been released.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::GoBack, this)); set_pending_navigation_action(
base::BindOnce(&CefBrowserHostImpl::GoBack, this));
return; return;
} }
if (web_contents() && web_contents()->GetController().CanGoBack()) if (web_contents() && web_contents()->GetController().CanGoBack())
web_contents()->GetController().GoBack(); web_contents()->GetController().GoBack();
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::GoBack, this)); CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::GoBack, this));
} }
} }
@@ -1298,16 +1321,18 @@ bool CefBrowserHostImpl::CanGoForward() {
void CefBrowserHostImpl::GoForward() { void CefBrowserHostImpl::GoForward() {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) { if (navigation_locked()) {
// Try again after frame destruction has completed. // Try again after the lock has been released.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::GoForward, this)); set_pending_navigation_action(
base::BindOnce(&CefBrowserHostImpl::GoForward, this));
return; return;
} }
if (web_contents() && web_contents()->GetController().CanGoForward()) if (web_contents() && web_contents()->GetController().CanGoForward())
web_contents()->GetController().GoForward(); web_contents()->GetController().GoForward();
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::GoForward, this)); CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::GoForward, this));
} }
} }
@@ -1318,25 +1343,26 @@ bool CefBrowserHostImpl::IsLoading() {
void CefBrowserHostImpl::Reload() { void CefBrowserHostImpl::Reload() {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) { if (navigation_locked()) {
// Try again after frame destruction has completed. // Try again after the lock has been released.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::Reload, this)); set_pending_navigation_action(
base::BindOnce(&CefBrowserHostImpl::Reload, this));
return; return;
} }
if (web_contents()) if (web_contents())
web_contents()->GetController().Reload(content::ReloadType::NORMAL, true); web_contents()->GetController().Reload(content::ReloadType::NORMAL, true);
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::Reload, this)); CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::Reload, this));
} }
} }
void CefBrowserHostImpl::ReloadIgnoreCache() { void CefBrowserHostImpl::ReloadIgnoreCache() {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) { if (navigation_locked()) {
// Try again after frame destruction has completed. // Try again after the lock has been released.
CEF_POST_TASK(CEF_UIT, set_pending_navigation_action(
base::Bind(&CefBrowserHostImpl::ReloadIgnoreCache, this)); base::BindOnce(&CefBrowserHostImpl::ReloadIgnoreCache, this));
return; return;
} }
@@ -1346,22 +1372,23 @@ void CefBrowserHostImpl::ReloadIgnoreCache() {
} }
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::ReloadIgnoreCache, this)); base::BindOnce(&CefBrowserHostImpl::ReloadIgnoreCache, this));
} }
} }
void CefBrowserHostImpl::StopLoad() { void CefBrowserHostImpl::StopLoad() {
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) { if (navigation_locked()) {
// Try again after frame destruction has completed. // Try again after the lock has been released.
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::StopLoad, this)); set_pending_navigation_action(
base::BindOnce(&CefBrowserHostImpl::StopLoad, this));
return; return;
} }
if (web_contents()) if (web_contents())
web_contents()->Stop(); web_contents()->Stop();
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::StopLoad, this)); CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::StopLoad, this));
} }
} }
@@ -1650,11 +1677,11 @@ void CefBrowserHostImpl::LoadURL(int64 frame_id,
if (frame_id == CefFrameHostImpl::kMainFrameId) { if (frame_id == CefFrameHostImpl::kMainFrameId) {
// Go through the navigation controller. // Go through the navigation controller.
if (CEF_CURRENTLY_ON_UIT()) { if (CEF_CURRENTLY_ON_UIT()) {
if (frame_destruction_pending_) { if (navigation_locked()) {
// Try again after frame destruction has completed. // Try again after the lock has been released.
CEF_POST_TASK(CEF_UIT, set_pending_navigation_action(
base::Bind(&CefBrowserHostImpl::LoadURL, this, frame_id, base::BindOnce(&CefBrowserHostImpl::LoadURL, this, frame_id, url,
url, referrer, transition, extra_headers)); referrer, transition, extra_headers));
return; return;
} }
@@ -1678,9 +1705,9 @@ void CefBrowserHostImpl::LoadURL(int64 frame_id,
OnSetFocus(FOCUS_SOURCE_NAVIGATION); OnSetFocus(FOCUS_SOURCE_NAVIGATION);
} }
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(CEF_UIT,
CEF_UIT, base::Bind(&CefBrowserHostImpl::LoadURL, this, frame_id, url, base::BindOnce(&CefBrowserHostImpl::LoadURL, this, frame_id,
referrer, transition, extra_headers)); url, referrer, transition, extra_headers));
} }
} else { } else {
CefNavigateParams params(GURL(url), transition); CefNavigateParams params(GURL(url), transition);
@@ -1739,7 +1766,8 @@ void CefBrowserHostImpl::SendCommand(
Send(new CefMsg_Request(MSG_ROUTING_NONE, params)); Send(new CefMsg_Request(MSG_ROUTING_NONE, params));
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SendCommand, this, CEF_POST_TASK(CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::SendCommand, this,
frame_id, command, responseHandler)); frame_id, command, responseHandler));
} }
} }
@@ -1780,8 +1808,9 @@ void CefBrowserHostImpl::SendCode(
Send(new CefMsg_Request(MSG_ROUTING_NONE, params)); Send(new CefMsg_Request(MSG_ROUTING_NONE, params));
} else { } else {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::SendCode, this, CEF_POST_TASK(CEF_UIT,
frame_id, is_javascript, code, script_url, base::BindOnce(&CefBrowserHostImpl::SendCode, this, frame_id,
is_javascript, code, script_url,
script_start_line, responseHandler)); script_start_line, responseHandler));
} }
} }
@@ -1794,7 +1823,7 @@ void CefBrowserHostImpl::ExecuteJavaScriptWithUserGestureForTests(
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind( base::BindOnce(
&CefBrowserHostImpl::ExecuteJavaScriptWithUserGestureForTests, this, &CefBrowserHostImpl::ExecuteJavaScriptWithUserGestureForTests, this,
frame_id, javascript)); frame_id, javascript));
return; return;
@@ -1818,7 +1847,7 @@ void CefBrowserHostImpl::ExecuteJavaScriptWithUserGestureForTests(
void CefBrowserHostImpl::ViewText(const std::string& text) { void CefBrowserHostImpl::ViewText(const std::string& text) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::ViewText, this, text)); base::BindOnce(&CefBrowserHostImpl::ViewText, this, text));
return; return;
} }
@@ -1841,7 +1870,7 @@ void CefBrowserHostImpl::HandleExternalProtocol(const GURL& url) {
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefBrowserHostImpl::HandleExternalProtocol, this, url)); base::BindOnce(&CefBrowserHostImpl::HandleExternalProtocol, this, url));
} }
} }
@@ -1883,8 +1912,8 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
if (platform_delegate_) if (platform_delegate_)
platform_delegate_->SendFocusEvent(true); platform_delegate_->SendFocusEvent(true);
} else { } else {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(
base::Bind(&CefBrowserHostImpl::OnSetFocus, this, source)); CEF_UIT, base::BindOnce(&CefBrowserHostImpl::OnSetFocus, this, source));
} }
} }
@@ -1952,8 +1981,9 @@ void CefBrowserHostImpl::ImeSetComposition(
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(
base::Bind(&CefBrowserHostImpl::ImeSetComposition, this, text, CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::ImeSetComposition, this, text,
underlines, replacement_range, selection_range)); underlines, replacement_range, selection_range));
return; return;
} }
@@ -1975,7 +2005,7 @@ void CefBrowserHostImpl::ImeCommitText(const CefString& text,
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::ImeCommitText, this, text, base::BindOnce(&CefBrowserHostImpl::ImeCommitText, this, text,
replacement_range, relative_cursor_pos)); replacement_range, relative_cursor_pos));
return; return;
} }
@@ -1995,8 +2025,8 @@ void CefBrowserHostImpl::ImeFinishComposingText(bool keep_selection) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserHostImpl::ImeFinishComposingText, this, base::BindOnce(&CefBrowserHostImpl::ImeFinishComposingText,
keep_selection)); this, keep_selection));
return; return;
} }
@@ -2013,8 +2043,9 @@ void CefBrowserHostImpl::ImeCancelComposition() {
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(
base::Bind(&CefBrowserHostImpl::ImeCancelComposition, this)); CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::ImeCancelComposition, this));
return; return;
} }
@@ -2034,8 +2065,9 @@ void CefBrowserHostImpl::DragTargetDragEnter(
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::DragTargetDragEnter, CEF_POST_TASK(CEF_UIT,
this, drag_data, event, allowed_ops)); base::BindOnce(&CefBrowserHostImpl::DragTargetDragEnter, this,
drag_data, event, allowed_ops));
return; return;
} }
@@ -2059,8 +2091,9 @@ void CefBrowserHostImpl::DragTargetDragOver(
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::DragTargetDragOver, CEF_POST_TASK(CEF_UIT,
this, event, allowed_ops)); base::BindOnce(&CefBrowserHostImpl::DragTargetDragOver, this,
event, allowed_ops));
return; return;
} }
@@ -2077,8 +2110,8 @@ void CefBrowserHostImpl::DragTargetDragLeave() {
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::BindOnce(
base::Bind(&CefBrowserHostImpl::DragTargetDragLeave, this)); &CefBrowserHostImpl::DragTargetDragLeave, this));
return; return;
} }
@@ -2095,8 +2128,8 @@ void CefBrowserHostImpl::DragTargetDrop(const CefMouseEvent& event) {
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostImpl::DragTargetDrop,
base::Bind(&CefBrowserHostImpl::DragTargetDrop, this, event)); this, event));
return; return;
} }
@@ -2115,7 +2148,7 @@ void CefBrowserHostImpl::DragSourceSystemDragEnded() {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::Bind(&CefBrowserHostImpl::DragSourceSystemDragEnded, this)); base::BindOnce(&CefBrowserHostImpl::DragSourceSystemDragEnded, this));
return; return;
} }
@@ -2135,8 +2168,9 @@ void CefBrowserHostImpl::DragSourceEndedAt(
} }
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::DragSourceEndedAt, CEF_POST_TASK(
this, x, y, op)); CEF_UIT,
base::BindOnce(&CefBrowserHostImpl::DragSourceEndedAt, this, x, y, op));
return; return;
} }
@@ -2552,7 +2586,7 @@ void CefBrowserHostImpl::ResizeDueToAutoResize(content::WebContents* source,
void CefBrowserHostImpl::RequestMediaAccessPermission( void CefBrowserHostImpl::RequestMediaAccessPermission(
content::WebContents* web_contents, content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) { content::MediaResponseCallback callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
content::MediaStreamDevices devices; content::MediaStreamDevices devices;
@@ -2561,7 +2595,7 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kEnableMediaStream)) { if (!command_line->HasSwitch(switches::kEnableMediaStream)) {
// Cancel the request. // Cancel the request.
callback.Run(devices, content::MEDIA_DEVICE_PERMISSION_DENIED, std::move(callback).Run(devices, content::MEDIA_DEVICE_PERMISSION_DENIED,
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
return; return;
} }
@@ -2599,7 +2633,7 @@ void CefBrowserHostImpl::RequestMediaAccessPermission(
} }
} }
callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(callback).Run(devices, content::MEDIA_DEVICE_OK,
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
} }
@@ -2752,9 +2786,8 @@ void CefBrowserHostImpl::RenderProcessGone(base::TerminationStatus status) {
if (client_.get()) { if (client_.get()) {
CefRefPtr<CefRequestHandler> handler = client_->GetRequestHandler(); CefRefPtr<CefRequestHandler> handler = client_->GetRequestHandler();
if (handler.get()) { if (handler.get()) {
frame_destruction_pending_ = true; std::unique_ptr<NavigationLock> navigation_lock = CreateNavigationLock();
handler->OnRenderProcessTerminated(this, ts); handler->OnRenderProcessTerminated(this, ts);
frame_destruction_pending_ = false;
} }
} }
} }
@@ -2900,13 +2933,13 @@ bool CefBrowserHostImpl::OnMessageReceived(
} }
void CefBrowserHostImpl::AccessibilityEventReceived( void CefBrowserHostImpl::AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& eventData) { const content::AXEventNotificationDetails& content_event_bundle) {
// Only needed in windowless mode. // Only needed in windowless mode.
if (IsWindowless()) { if (IsWindowless()) {
if (!web_contents() || !platform_delegate_) if (!web_contents() || !platform_delegate_)
return; return;
platform_delegate_->AccessibilityEventReceived(eventData); platform_delegate_->AccessibilityEventReceived(content_event_bundle);
} }
} }
@@ -2945,6 +2978,38 @@ bool CefBrowserHostImpl::HasObserver(Observer* observer) const {
return observers_.HasObserver(observer); return observers_.HasObserver(observer);
} }
CefBrowserHostImpl::NavigationLock::NavigationLock(
CefRefPtr<CefBrowserHostImpl> browser)
: browser_(browser) {
CEF_REQUIRE_UIT();
browser_->navigation_lock_count_++;
}
CefBrowserHostImpl::NavigationLock::~NavigationLock() {
CEF_REQUIRE_UIT();
if (--browser_->navigation_lock_count_ == 0) {
if (!browser_->pending_navigation_action_.is_null()) {
CEF_POST_TASK(CEF_UIT, std::move(browser_->pending_navigation_action_));
}
}
}
std::unique_ptr<CefBrowserHostImpl::NavigationLock>
CefBrowserHostImpl::CreateNavigationLock() {
return base::WrapUnique(new NavigationLock(this));
}
bool CefBrowserHostImpl::navigation_locked() const {
CEF_REQUIRE_UIT();
return navigation_lock_count_ > 0;
}
void CefBrowserHostImpl::set_pending_navigation_action(
base::OnceClosure action) {
CEF_REQUIRE_UIT();
pending_navigation_action_ = std::move(action);
}
// content::WebContentsObserver::OnMessageReceived() message handlers. // content::WebContentsObserver::OnMessageReceived() message handlers.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -3118,7 +3183,6 @@ CefBrowserHostImpl::CefBrowserHostImpl(
main_frame_id_(CefFrameHostImpl::kInvalidFrameId), main_frame_id_(CefFrameHostImpl::kInvalidFrameId),
focused_frame_id_(CefFrameHostImpl::kInvalidFrameId), focused_frame_id_(CefFrameHostImpl::kInvalidFrameId),
destruction_state_(DESTRUCTION_STATE_NONE), destruction_state_(DESTRUCTION_STATE_NONE),
frame_destruction_pending_(false),
window_destroyed_(false), window_destroyed_(false),
is_in_onsetfocus_(false), is_in_onsetfocus_(false),
focus_on_editable_field_(false), focus_on_editable_field_(false),
@@ -3483,12 +3547,11 @@ void CefBrowserHostImpl::OnLoadError(CefRefPtr<CefFrame> frame,
if (client_.get()) { if (client_.get()) {
CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler(); CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler();
if (handler.get()) { if (handler.get()) {
frame_destruction_pending_ = true; std::unique_ptr<NavigationLock> navigation_lock = CreateNavigationLock();
// Notify the handler that loading has failed. // Notify the handler that loading has failed.
handler->OnLoadError(this, frame, handler->OnLoadError(this, frame,
static_cast<cef_errorcode_t>(error_code), static_cast<cef_errorcode_t>(error_code),
net::ErrorToShortString(error_code), url.spec()); net::ErrorToShortString(error_code), url.spec());
frame_destruction_pending_ = false;
} }
} }
} }
@@ -3554,9 +3617,9 @@ void CefBrowserHostImpl::ConfigureAutoResize() {
bool CefBrowserHostImpl::Send(IPC::Message* message) { bool CefBrowserHostImpl::Send(IPC::Message* message) {
if (!CEF_CURRENTLY_ON_UIT()) { if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK( CEF_POST_TASK(CEF_UIT,
CEF_UIT, base::Bind(base::IgnoreResult(&CefBrowserHostImpl::Send), this, base::BindOnce(base::IgnoreResult(&CefBrowserHostImpl::Send),
message)); this, message));
return true; return true;
} }

View File

@@ -474,7 +474,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void RequestMediaAccessPermission( void RequestMediaAccessPermission(
content::WebContents* web_contents, content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) override; content::MediaResponseCallback callback) override;
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) override; content::MediaStreamType type) override;
@@ -506,8 +506,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
bool OnMessageReceived(const IPC::Message& message, bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override; content::RenderFrameHost* render_frame_host) override;
void AccessibilityEventReceived( void AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& eventData) const content::AXEventNotificationDetails& content_event_bundle) override;
override;
void AccessibilityLocationChangesReceived( void AccessibilityLocationChangesReceived(
const std::vector<content::AXLocationChangeNotificationDetails>& locData) const std::vector<content::AXLocationChangeNotificationDetails>& locData)
override; override;
@@ -522,6 +521,20 @@ class CefBrowserHostImpl : public CefBrowserHost,
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const; bool HasObserver(Observer* observer) const;
class NavigationLock final {
private:
friend class CefBrowserHostImpl;
friend std::unique_ptr<NavigationLock>::deleter_type;
explicit NavigationLock(CefRefPtr<CefBrowserHostImpl> browser);
~NavigationLock();
CefRefPtr<CefBrowserHostImpl> browser_;
};
// Block navigation-related events on NavigationLock life span.
std::unique_ptr<NavigationLock> CreateNavigationLock();
private: private:
class DevToolsWebContentsObserver; class DevToolsWebContentsObserver;
@@ -581,6 +594,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
void DestroyExtensionHost(); void DestroyExtensionHost();
void OnExtensionHostDeleted(); void OnExtensionHostDeleted();
// Returns true if navigation actions are currently locked.
bool navigation_locked() const;
// Action to be executed once the navigation lock is released.
void set_pending_navigation_action(base::OnceClosure action);
// Update or create a frame object. |frame_id| (renderer routing id) will be // Update or create a frame object. |frame_id| (renderer routing id) will be
// >= 0 if the frame currently exists in the renderer process. |frame_id| will // >= 0 if the frame currently exists in the renderer process. |frame_id| will
// be < 0 for the main frame if it has not yet navigated for the first time, // be < 0 for the main frame if it has not yet navigated for the first time,
@@ -687,9 +705,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
// thread. // thread.
DestructionState destruction_state_; DestructionState destruction_state_;
// True if frame destruction is currently pending. Navigation should not occur // Navigation will not occur while |navigation_lock_count_| > 0.
// while this flag is true. // |pending_navigation_action_| will be executed when the lock is released.
bool frame_destruction_pending_; // Only accessed on the UI thread.
int navigation_lock_count_ = 0;
base::OnceClosure pending_navigation_action_;
// True if the OS window hosting the browser has been destroyed. Only accessed // True if the OS window hosting the browser has been destroyed. Only accessed
// on the UI thread. // on the UI thread.

View File

@@ -10,7 +10,6 @@
#include "libcef/browser/browser_context_impl.h" #include "libcef/browser/browser_context_impl.h"
#include "libcef/browser/browser_context_keyed_service_factories.h" #include "libcef/browser/browser_context_keyed_service_factories.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/devtools_manager_delegate.h" #include "libcef/browser/devtools_manager_delegate.h"
@@ -34,6 +33,7 @@
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
#include "services/service_manager/embedder/result_codes.h" #include "services/service_manager/embedder/result_codes.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if defined(USE_AURA) #if defined(USE_AURA)
@@ -107,11 +107,6 @@ void CefBrowserMainParts::ToolkitInitialized() {
} }
void CefBrowserMainParts::PreMainMessageLoopStart() { void CefBrowserMainParts::PreMainMessageLoopStart() {
if (!base::MessageLoop::current()) {
// Create the browser message loop.
message_loop_.reset(new CefBrowserMessageLoop());
}
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreMainMessageLoopStart(); chrome_extra_parts_[i]->PreMainMessageLoopStart();
} }
@@ -156,6 +151,8 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
display::Screen::SetScreenInstance(views::CreateDesktopScreen()); display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif #endif
ui::MaterialDesignController::Initialize();
// CEF's profile is a BrowserContext. // CEF's profile is a BrowserContext.
PreProfileInit(); PreProfileInit();

View File

@@ -16,11 +16,6 @@
#include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_main_parts.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
namespace base {
class MessageLoop;
class Thread;
} // namespace base
namespace content { namespace content {
struct MainFunctionParams; struct MainFunctionParams;
} }
@@ -89,7 +84,6 @@ class CefBrowserMainParts : public content::BrowserMainParts {
CefRefPtr<CefRequestContextImpl> global_request_context_; CefRefPtr<CefRequestContextImpl> global_request_context_;
CefDevToolsDelegate* devtools_delegate_; // Deletes itself. CefDevToolsDelegate* devtools_delegate_; // Deletes itself.
std::unique_ptr<base::MessageLoop> message_loop_;
std::unique_ptr<extensions::ExtensionsClient> extensions_client_; std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
std::unique_ptr<extensions::ExtensionsBrowserClient> std::unique_ptr<extensions::ExtensionsBrowserClient>

View File

@@ -196,7 +196,7 @@ void CefBrowserPlatformDelegate::DragSourceSystemDragEnded() {
} }
void CefBrowserPlatformDelegate::AccessibilityEventReceived( void CefBrowserPlatformDelegate::AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& eventData) { const content::AXEventNotificationDetails& eventData) {
NOTREACHED(); NOTREACHED();
} }

View File

@@ -262,7 +262,7 @@ class CefBrowserPlatformDelegate {
virtual void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op); virtual void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op);
virtual void DragSourceSystemDragEnded(); virtual void DragSourceSystemDragEnded();
virtual void AccessibilityEventReceived( virtual void AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& eventData); const content::AXEventNotificationDetails& eventData);
virtual void AccessibilityLocationChangesReceived( virtual void AccessibilityLocationChangesReceived(
const std::vector<content::AXLocationChangeNotificationDetails>& locData); const std::vector<content::AXLocationChangeNotificationDetails>& locData);

View File

@@ -20,7 +20,6 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/url_fetcher.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"

View File

@@ -16,6 +16,7 @@
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
ChromeBrowserProcessStub::ChromeBrowserProcessStub() ChromeBrowserProcessStub::ChromeBrowserProcessStub()
: initialized_(false), : initialized_(false),
@@ -116,6 +117,12 @@ ChromeBrowserProcessStub::network_connection_tracker() {
return NULL; return NULL;
} }
network::NetworkQualityTracker*
ChromeBrowserProcessStub::network_quality_tracker() {
NOTREACHED();
return NULL;
}
WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() { WatchDogThread* ChromeBrowserProcessStub::watchdog_thread() {
NOTREACHED(); NOTREACHED();
return NULL; return NULL;
@@ -138,6 +145,12 @@ ChromeBrowserProcessStub::system_request_context() {
return NULL; return NULL;
} }
scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserProcessStub::shared_url_loader_factory() {
NOTREACHED();
return NULL;
}
variations::VariationsService* ChromeBrowserProcessStub::variations_service() { variations::VariationsService* ChromeBrowserProcessStub::variations_service() {
NOTREACHED(); NOTREACHED();
return NULL; return NULL;

View File

@@ -50,10 +50,13 @@ class ChromeBrowserProcessStub : public BrowserProcess,
IOThread* io_thread() override; IOThread* io_thread() override;
SystemNetworkContextManager* system_network_context_manager() override; SystemNetworkContextManager* system_network_context_manager() override;
content::NetworkConnectionTracker* network_connection_tracker() override; content::NetworkConnectionTracker* network_connection_tracker() override;
network::NetworkQualityTracker* network_quality_tracker() override;
WatchDogThread* watchdog_thread() override; WatchDogThread* watchdog_thread() override;
ProfileManager* profile_manager() override; ProfileManager* profile_manager() override;
PrefService* local_state() override; PrefService* local_state() override;
net::URLRequestContextGetter* system_request_context() override; net::URLRequestContextGetter* system_request_context() override;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory()
override;
variations::VariationsService* variations_service() override; variations::VariationsService* variations_service() override;
BrowserProcessPlatformPart* platform_part() override; BrowserProcessPlatformPart* platform_part() override;
extensions::EventRouterForwarder* extension_event_router_forwarder() override; extensions::EventRouterForwarder* extension_event_router_forwarder() override;

View File

@@ -431,6 +431,11 @@ bool NavigationOnUIThread(
request->Set(params, is_main_frame); request->Set(params, is_main_frame);
request->SetReadOnly(true); request->SetReadOnly(true);
// Initiating a new navigation in OnBeforeBrowse will delete the
// InterceptNavigationThrottle that currently owns this callback,
// resulting in a crash. Use the lock to prevent that.
std::unique_ptr<CefBrowserHostImpl::NavigationLock> navigation_lock =
browser->CreateNavigationLock();
ignore_navigation = handler->OnBeforeBrowse( ignore_navigation = handler->OnBeforeBrowse(
browser.get(), frame, request.get(), params.has_user_gesture(), browser.get(), frame, request.get(), params.has_user_gesture(),
params.is_redirect()); params.is_redirect());
@@ -613,11 +618,12 @@ void CefContentBrowserClient::RegisterInProcessServices(
void CefContentBrowserClient::RegisterOutOfProcessServices( void CefContentBrowserClient::RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) { OutOfProcessServiceMap* services) {
(*services)[printing::mojom::kServiceName] = (*services)[printing::mojom::kServiceName] =
base::ASCIIToUTF16("PDF Compositor Service"); base::BindRepeating(&base::ASCIIToUTF16, "PDF Compositor Service");
(*services)[printing::mojom::kChromePrintingServiceName] = (*services)[printing::mojom::kChromePrintingServiceName] =
base::ASCIIToUTF16("Printing Service"); base::BindRepeating(&base::ASCIIToUTF16, "Printing Service");
(*services)[proxy_resolver::mojom::kProxyResolverServiceName] = (*services)[proxy_resolver::mojom::kProxyResolverServiceName] =
l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_PROXY_RESOLVER_NAME); base::BindRepeating(&l10n_util::GetStringUTF16,
IDS_UTILITY_PROCESS_PROXY_RESOLVER_NAME);
} }
std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay( std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay(
@@ -1065,6 +1071,7 @@ void CefContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
} }
bool CefContentBrowserClient::WillCreateURLLoaderFactory( bool CefContentBrowserClient::WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame, content::RenderFrameHost* frame,
bool is_navigation, bool is_navigation,
network::mojom::URLLoaderFactoryRequest* factory_request) { network::mojom::URLLoaderFactoryRequest* factory_request) {
@@ -1073,7 +1080,7 @@ bool CefContentBrowserClient::WillCreateURLLoaderFactory(
auto* web_request_api = auto* web_request_api =
extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get( extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get(
frame->GetProcess()->GetBrowserContext()); browser_context);
return web_request_api->MaybeProxyURLLoaderFactory(frame, is_navigation, return web_request_api->MaybeProxyURLLoaderFactory(frame, is_navigation,
factory_request); factory_request);
} }

View File

@@ -138,6 +138,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
int render_frame_id, int render_frame_id,
NonNetworkURLLoaderFactoryMap* factories) override; NonNetworkURLLoaderFactoryMap* factories) override;
bool WillCreateURLLoaderFactory( bool WillCreateURLLoaderFactory(
content::BrowserContext* browser_context,
content::RenderFrameHost* frame, content::RenderFrameHost* frame,
bool is_navigation, bool is_navigation,
network::mojom::URLLoaderFactoryRequest* factory_request) override; network::mojom::URLLoaderFactoryRequest* factory_request) override;

View File

@@ -29,6 +29,7 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/main.h" #include "services/service_manager/embedder/main.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#if defined(OS_WIN) #if defined(OS_WIN)
@@ -343,7 +344,7 @@ bool CefContext::Initialize(const CefMainArgs& args,
init_thread_id_ = base::PlatformThread::CurrentId(); init_thread_id_ = base::PlatformThread::CurrentId();
settings_ = settings; settings_ = settings;
#if !defined(OS_WIN) #if !(defined(OS_WIN) || defined(OS_LINUX))
if (settings.multi_threaded_message_loop) { if (settings.multi_threaded_message_loop) {
NOTIMPLEMENTED() << "multi_threaded_message_loop is not supported."; NOTIMPLEMENTED() << "multi_threaded_message_loop is not supported.";
return false; return false;
@@ -526,6 +527,8 @@ void CefContext::FinishShutdownOnUIThread(
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown(); static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Shutdown();
ui::ResourceBundle::GetSharedInstance().CleanupOnUIThread();
if (uithread_shutdown_event) if (uithread_shutdown_event)
uithread_shutdown_event->Signal(); uithread_shutdown_event->Signal();
} }

View File

@@ -10,19 +10,18 @@
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/net/cookie_store_source.h"
#include "libcef/browser/net/network_delegate.h" #include "libcef/browser/net/network_delegate.h"
#include "libcef/common/task_runner_impl.h" #include "libcef/common/task_runner_impl.h"
#include "libcef/common/time_util.h" #include "libcef/common/time_util.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_util.h"
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "content/browser/storage_partition_impl.h" #include "content/browser/storage_partition_impl.h"
#include "net/cookies/cookie_util.h" #include "net/cookies/cookie_util.h"
#include "net/cookies/parsed_cookie.h" #include "net/cookies/parsed_cookie.h"
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "url/gurl.h" #include "url/gurl.h"
@@ -162,7 +161,7 @@ void CefCookieManagerImpl::GetCookieStore(
return; return;
} }
DCHECK(is_blocking_ || cookie_store_.get()); DCHECK(is_blocking_ || cookie_source_);
// Binding ref-counted |this| to CookieStoreGetter may result in // Binding ref-counted |this| to CookieStoreGetter may result in
// heap-use-after-free if (a) the CookieStoreGetter contains the last // heap-use-after-free if (a) the CookieStoreGetter contains the last
@@ -185,8 +184,8 @@ void CefCookieManagerImpl::GetCookieStore(
net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() { net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (cookie_store_.get()) { if (cookie_source_) {
return cookie_store_.get(); return cookie_source_->GetCookieStore();
} else if (request_context_impl_.get()) { } else if (request_context_impl_.get()) {
net::CookieStore* cookie_store = net::CookieStore* cookie_store =
request_context_impl_->GetExistingCookieStore(); request_context_impl_->GetExistingCookieStore();
@@ -287,47 +286,16 @@ bool CefCookieManagerImpl::SetStoragePath(
if (!path.empty()) if (!path.empty())
new_path = base::FilePath(path); new_path = base::FilePath(path);
if (cookie_store_.get() && if (!cookie_source_) {
((storage_path_.empty() && path.empty()) || storage_path_ == new_path)) { cookie_source_.reset(new CefCookieStoreOwnerSource());
// The path has not changed so don't do anything. }
cookie_source_->SetCookieStoragePath(new_path, persist_session_cookies);
RunAsyncCompletionOnIOThread(callback); RunAsyncCompletionOnIOThread(callback);
return true; return true;
} }
scoped_refptr<net::SQLitePersistentCookieStore> persistent_store;
if (!new_path.empty()) {
// TODO(cef): Move directory creation to the blocking pool instead of
// allowing file IO on this thread.
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (base::DirectoryExists(new_path) || base::CreateDirectory(new_path)) {
const base::FilePath& cookie_path = new_path.AppendASCII("Cookies");
persistent_store = new net::SQLitePersistentCookieStore(
cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
// Intentionally using the background task runner exposed by CEF to
// facilitate unit test expectations. This task runner MUST be
// configured with BLOCK_SHUTDOWN.
CefContentBrowserClient::Get()->background_task_runner(),
persist_session_cookies, NULL);
} else {
NOTREACHED() << "The cookie storage directory could not be created";
storage_path_.clear();
}
}
// Set the new cookie store that will be used for all new requests. The old
// cookie store, if any, will be automatically flushed and closed when no
// longer referenced.
cookie_store_.reset(new net::CookieMonster(persistent_store.get(), NULL));
if (persistent_store.get() && persist_session_cookies)
cookie_store_->SetPersistSessionCookies(true);
storage_path_ = new_path;
// Restore the previously supported schemes.
SetSupportedSchemesInternal(supported_schemes_, callback);
return true;
}
bool CefCookieManagerImpl::FlushStore( bool CefCookieManagerImpl::FlushStore(
CefRefPtr<CefCompletionCallback> callback) { CefRefPtr<CefCompletionCallback> callback) {
GetCookieStore( GetCookieStore(
@@ -502,10 +470,9 @@ void CefCookieManagerImpl::SetSupportedSchemesInternal(
return; return;
} }
DCHECK(is_blocking_ || cookie_store_.get()); DCHECK(is_blocking_ || cookie_source_);
if (cookie_store_) { if (cookie_source_) {
supported_schemes_ = schemes; cookie_source_->SetCookieSupportedSchemes(schemes);
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
} }
RunAsyncCompletionOnIOThread(callback); RunAsyncCompletionOnIOThread(callback);

View File

@@ -15,6 +15,8 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_monster.h"
class CefCookieStoreOwnerSource;
// Implementation of the CefCookieManager interface. // Implementation of the CefCookieManager interface.
class CefCookieManagerImpl : public CefCookieManager { class CefCookieManagerImpl : public CefCookieManager {
public: public:
@@ -122,9 +124,7 @@ class CefCookieManagerImpl : public CefCookieManager {
scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_; scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_;
// Used for cookie monsters owned by this object. // Used for cookie monsters owned by this object.
base::FilePath storage_path_; std::unique_ptr<CefCookieStoreOwnerSource> cookie_source_;
std::vector<std::string> supported_schemes_;
std::unique_ptr<net::CookieMonster> cookie_store_;
// Must be the last member. // Must be the last member.
base::WeakPtrFactory<CefCookieManagerImpl> weak_ptr_factory_; base::WeakPtrFactory<CefCookieManagerImpl> weak_ptr_factory_;

View File

@@ -299,9 +299,9 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
setting: setting:
"It's not possible to disable this feature from settings." "It's not possible to disable this feature from settings."
chrome_policy { chrome_policy {
DeveloperToolsDisabled { DeveloperToolsAvailability {
policy_options {mode: MANDATORY} policy_options {mode: MANDATORY}
DeveloperToolsDisabled: true DeveloperToolsAvailability: 2
} }
} }
})"); })");

View File

@@ -3,13 +3,15 @@
// found in the LICENSE file. // found in the LICENSE file.
// APIs must also be registered in // APIs must also be registered in
// libcef/common/extensions/api/_*_features.json files. See // libcef/common/extensions/api/_*_features.json files and possibly
// CefExtensionsDispatcherDelegate::PopulateSourceMap. See
// libcef/common/extensions/api/README.txt for additional details. // libcef/common/extensions/api/README.txt for additional details.
#include "libcef/browser/extensions/chrome_api_registration.h" #include "libcef/browser/extensions/chrome_api_registration.h"
#include "libcef/browser/extensions/api/tabs/tabs_api.h" #include "libcef/browser/extensions/api/tabs/tabs_api.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_api.h"
#include "chrome/browser/extensions/api/resources_private/resources_private_api.h" #include "chrome/browser/extensions/api/resources_private/resources_private_api.h"
#include "chrome/browser/extensions/api/streams_private/streams_private_api.h" #include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
#include "extensions/browser/api/alarms/alarms_api.h" #include "extensions/browser/api/alarms/alarms_api.h"
@@ -37,6 +39,12 @@ const char* const kSupportedAPIs[] = {
EXTENSION_FUNCTION_NAME(AlarmsGetAllFunction), EXTENSION_FUNCTION_NAME(AlarmsGetAllFunction),
EXTENSION_FUNCTION_NAME(AlarmsClearFunction), EXTENSION_FUNCTION_NAME(AlarmsClearFunction),
EXTENSION_FUNCTION_NAME(AlarmsClearAllFunction), EXTENSION_FUNCTION_NAME(AlarmsClearAllFunction),
"contentSettings",
EXTENSION_FUNCTION_NAME(ContentSettingsContentSettingClearFunction),
EXTENSION_FUNCTION_NAME(ContentSettingsContentSettingGetFunction),
EXTENSION_FUNCTION_NAME(ContentSettingsContentSettingSetFunction),
EXTENSION_FUNCTION_NAME(
ContentSettingsContentSettingGetResourceIdentifiersFunction),
"storage", "storage",
EXTENSION_FUNCTION_NAME(StorageStorageAreaGetFunction), EXTENSION_FUNCTION_NAME(StorageStorageAreaGetFunction),
EXTENSION_FUNCTION_NAME(StorageStorageAreaSetFunction), EXTENSION_FUNCTION_NAME(StorageStorageAreaSetFunction),
@@ -75,6 +83,11 @@ void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) {
registry->RegisterFunction<AlarmsGetAllFunction>(); registry->RegisterFunction<AlarmsGetAllFunction>();
registry->RegisterFunction<AlarmsClearFunction>(); registry->RegisterFunction<AlarmsClearFunction>();
registry->RegisterFunction<AlarmsClearAllFunction>(); registry->RegisterFunction<AlarmsClearAllFunction>();
registry->RegisterFunction<ContentSettingsContentSettingClearFunction>();
registry->RegisterFunction<ContentSettingsContentSettingGetFunction>();
registry->RegisterFunction<ContentSettingsContentSettingSetFunction>();
registry->RegisterFunction<
ContentSettingsContentSettingGetResourceIdentifiersFunction>();
registry->RegisterFunction<StorageStorageAreaGetFunction>(); registry->RegisterFunction<StorageStorageAreaGetFunction>();
registry->RegisterFunction<StorageStorageAreaSetFunction>(); registry->RegisterFunction<StorageStorageAreaSetFunction>();
registry->RegisterFunction<StorageStorageAreaRemoveFunction>(); registry->RegisterFunction<StorageStorageAreaRemoveFunction>();

View File

@@ -160,8 +160,9 @@ CefRefPtr<CefBrowserHostImpl> CefExtensionFunctionDetails::GetCurrentBrowser()
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler(); CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
if (handler) { if (handler) {
// Give the handler an opportunity to specify a different browser. // Give the handler an opportunity to specify a different browser.
CefRefPtr<CefBrowser> active_browser = handler->GetActiveBrowser( CefRefPtr<CefBrowser> active_browser =
GetCefExtension(), browser.get(), function_->include_incognito()); handler->GetActiveBrowser(GetCefExtension(), browser.get(),
function_->include_incognito_information());
if (active_browser && active_browser != browser) { if (active_browser && active_browser != browser) {
CefRefPtr<CefBrowserHostImpl> active_browser_impl = CefRefPtr<CefBrowserHostImpl> active_browser_impl =
static_cast<CefBrowserHostImpl*>(active_browser.get()); static_cast<CefBrowserHostImpl*>(active_browser.get());
@@ -200,8 +201,9 @@ bool CefExtensionFunctionDetails::CanAccessBrowser(
if (browser && browser->client()) { if (browser && browser->client()) {
CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler(); CefRefPtr<CefExtensionHandler> handler = GetCefExtension()->GetHandler();
if (handler) { if (handler) {
return handler->CanAccessBrowser(GetCefExtension(), browser.get(), return handler->CanAccessBrowser(
function_->include_incognito(), target); GetCefExtension(), browser.get(),
function_->include_incognito_information(), target);
} }
} }
@@ -425,7 +427,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::CreateTabObject(
tab_object->selected = true; tab_object->selected = true;
tab_object->highlighted = true; tab_object->highlighted = true;
tab_object->pinned = false; tab_object->pinned = false;
tab_object->audible = std::make_unique<bool>(contents->WasRecentlyAudible()); // TODO(extensions): Use RecentlyAudibleHelper to populate |audible|.
tab_object->discarded = false; tab_object->discarded = false;
tab_object->auto_discardable = false; tab_object->auto_discardable = false;
tab_object->muted_info = CreateMutedInfo(contents); tab_object->muted_info = CreateMutedInfo(contents);

View File

@@ -42,7 +42,7 @@ void CefExtensionHostDelegate::CreateTab(
void CefExtensionHostDelegate::ProcessMediaAccessRequest( void CefExtensionHostDelegate::ProcessMediaAccessRequest(
content::WebContents* web_contents, content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback, content::MediaResponseCallback callback,
const Extension* extension) { const Extension* extension) {
// Never routed here from CefBrowserHostImpl. // Never routed here from CefBrowserHostImpl.
NOTREACHED(); NOTREACHED();

View File

@@ -28,7 +28,7 @@ class CefExtensionHostDelegate : public ExtensionHostDelegate {
bool user_gesture) override; bool user_gesture) override;
void ProcessMediaAccessRequest(content::WebContents* web_contents, void ProcessMediaAccessRequest(content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback, content::MediaResponseCallback callback,
const Extension* extension) override; const Extension* extension) override;
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,

View File

@@ -456,6 +456,7 @@ void CefExtensionSystem::InstallUpdate(
const std::string& extension_id, const std::string& extension_id,
const std::string& public_key, const std::string& public_key,
const base::FilePath& temp_dir, const base::FilePath& temp_dir,
bool install_immediately,
InstallUpdateCallback install_update_callback) { InstallUpdateCallback install_update_callback) {
NOTREACHED(); NOTREACHED();
base::DeleteFile(temp_dir, true /* recursive */); base::DeleteFile(temp_dir, true /* recursive */);

View File

@@ -114,6 +114,7 @@ class CefExtensionSystem : public ExtensionSystem {
void InstallUpdate(const std::string& extension_id, void InstallUpdate(const std::string& extension_id,
const std::string& public_key, const std::string& public_key,
const base::FilePath& temp_dir, const base::FilePath& temp_dir,
bool install_immediately,
InstallUpdateCallback install_update_callback) override; InstallUpdateCallback install_update_callback) override;
bool FinishDelayedInstallationIfReady(const std::string& extension_id, bool FinishDelayedInstallationIfReady(const std::string& extension_id,
bool install_immediately) override; bool install_immediately) override;

View File

@@ -46,7 +46,7 @@ void CefExtensionWebContentsObserver::RenderFrameCreated(
// are allowed to use chrome://resources/ URLs. // are allowed to use chrome://resources/ URLs.
if ((extension->is_extension() || extension->is_platform_app()) && if ((extension->is_extension() || extension->is_platform_app()) &&
Manifest::IsComponentLocation(extension->location())) { Manifest::IsComponentLocation(extension->location())) {
policy->GrantOrigin( policy->GrantRequestOrigin(
process_id, url::Origin::Create(GURL(content::kChromeUIResourcesURL))); process_id, url::Origin::Create(GURL(content::kChromeUIResourcesURL)));
} }
} }

View File

@@ -254,6 +254,10 @@ bool CefExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
void CefExtensionsBrowserClient::PermitExternalProtocolHandler() {} void CefExtensionsBrowserClient::PermitExternalProtocolHandler() {}
bool CefExtensionsBrowserClient::IsInDemoMode() {
return false;
}
bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() { bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() {
return false; return false;
} }

View File

@@ -84,6 +84,7 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
ExtensionHost** host) override; ExtensionHost** host) override;
bool DidVersionUpdate(content::BrowserContext* context) override; bool DidVersionUpdate(content::BrowserContext* context) override;
void PermitExternalProtocolHandler() override; void PermitExternalProtocolHandler() override;
bool IsInDemoMode() override;
bool IsRunningInForcedAppMode() override; bool IsRunningInForcedAppMode() override;
bool IsAppModeForcedForApp(const ExtensionId& extension_id) override; bool IsAppModeForcedForApp(const ExtensionId& extension_id) override;
bool IsLoggedInAsPublicAccount() override; bool IsLoggedInAsPublicAccount() override;

View File

@@ -99,6 +99,7 @@
} }
- (void)cleanup:(id)window { - (void)cleanup:(id)window {
[window_ setDelegate:nil];
[self release]; [self release];
} }

View File

@@ -104,6 +104,7 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
InputOutput, InputOutput,
CopyFromParent, // visual CopyFromParent, // visual
CWBackPixmap | CWOverrideRedirect, &swa); CWBackPixmap | CWOverrideRedirect, &swa);
CHECK(xwindow_);
if (ui::PlatformEventSource::GetInstance()) if (ui::PlatformEventSource::GetInstance())
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);

View File

@@ -36,6 +36,7 @@
#include "content/browser/frame_host/debug_urls.h" #include "content/browser/frame_host/debug_urls.h"
#include "content/browser/webui/content_web_ui_controller_factory.h" #include "content/browser/webui/content_web_ui_controller_factory.h"
#include "content/public/browser/browser_url_handler.h" #include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h" #include "content/public/common/url_utils.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
@@ -211,24 +212,20 @@ class CefWebUIControllerFactory : public content::WebUIControllerFactory {
return false; return false;
} }
content::WebUIController* CreateWebUIControllerForURL( std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(
content::WebUI* web_ui, content::WebUI* web_ui,
const GURL& url) const override { const GURL& url) const override {
content::WebUIController* controller = nullptr; std::unique_ptr<content::WebUIController> controller;
if (!AllowWebUIForURL(url)) if (!AllowWebUIForURL(url))
return controller; return controller;
controller = content::ContentWebUIControllerFactory::GetInstance() controller = content::ContentWebUIControllerFactory::GetInstance()
->CreateWebUIControllerForURL(web_ui, url); ->CreateWebUIControllerForURL(web_ui, url);
if (controller != nullptr) if (controller.get())
return controller; return controller;
controller = ChromeWebUIControllerFactory::GetInstance() return ChromeWebUIControllerFactory::GetInstance()
->CreateWebUIControllerForURL(web_ui, url); ->CreateWebUIControllerForURL(web_ui, url);
if (controller != nullptr)
return controller;
return nullptr;
} }
content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,

View File

@@ -4,12 +4,12 @@
#include "libcef/browser/net/cookie_store_proxy.h" #include "libcef/browser/net/cookie_store_proxy.h"
#include "libcef/browser/cookie_manager_impl.h" #include "include/cef_request_context.h"
#include "libcef/browser/net/url_request_context_impl.h" #include "libcef/browser/net/cookie_store_source.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "net/url_request/url_request_context.h" #include "net/cookies/cookie_change_dispatcher.h"
namespace { namespace {
@@ -44,12 +44,10 @@ class NullCookieChangeDispatcher : public net::CookieChangeDispatcher {
} // namespace } // namespace
CefCookieStoreProxy::CefCookieStoreProxy( CefCookieStoreProxy::CefCookieStoreProxy(
CefURLRequestContextImpl* parent, std::unique_ptr<CefCookieStoreSource> source)
CefRefPtr<CefRequestContextHandler> handler) : source_(std::move(source)) {
: parent_(parent), handler_(handler) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
DCHECK(parent_); DCHECK(source_);
DCHECK(handler_.get());
} }
CefCookieStoreProxy::~CefCookieStoreProxy() { CefCookieStoreProxy::~CefCookieStoreProxy() {
@@ -189,24 +187,5 @@ bool CefCookieStoreProxy::IsEphemeral() {
net::CookieStore* CefCookieStoreProxy::GetCookieStore() { net::CookieStore* CefCookieStoreProxy::GetCookieStore() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
return source_->GetCookieStore();
CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager();
if (manager.get()) {
// Use the cookie store provided by the manager. May be nullptr if the
// cookie manager is blocking.
return reinterpret_cast<CefCookieManagerImpl*>(manager.get())
->GetExistingCookieStore();
}
DCHECK(parent_);
if (parent_) {
// Use the cookie store from the parent.
net::CookieStore* cookie_store = parent_->cookie_store();
DCHECK(cookie_store);
if (!cookie_store)
LOG(ERROR) << "Cookie store does not exist";
return cookie_store;
}
return nullptr;
} }

View File

@@ -6,19 +6,15 @@
#define CEF_LIBCEF_BROWSER_COOKIE_STORE_PROXY_H_ #define CEF_LIBCEF_BROWSER_COOKIE_STORE_PROXY_H_
#pragma once #pragma once
#include "include/cef_request_context_handler.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
class CefURLRequestContextImpl; class CefCookieStoreSource;
// Proxies cookie requests to the CefRequestContextHandler or global cookie // Proxies cookie requests to a CefCookieStoreSource (see comments on the
// store. Life span is controlled by CefURLRequestContextProxy. Only accessed on // implementation classes for details). Only accessed on the IO thread.
// the IO thread. See browser_context.h for an object relationship diagram.
class CefCookieStoreProxy : public net::CookieStore { class CefCookieStoreProxy : public net::CookieStore {
public: public:
CefCookieStoreProxy(CefURLRequestContextImpl* parent, explicit CefCookieStoreProxy(std::unique_ptr<CefCookieStoreSource> source);
CefRefPtr<CefRequestContextHandler> handler);
~CefCookieStoreProxy() override; ~CefCookieStoreProxy() override;
// net::CookieStore methods. // net::CookieStore methods.
@@ -52,11 +48,7 @@ class CefCookieStoreProxy : public net::CookieStore {
private: private:
net::CookieStore* GetCookieStore(); net::CookieStore* GetCookieStore();
// The |parent_| pointer is kept alive by CefURLRequestContextGetterProxy std::unique_ptr<CefCookieStoreSource> const source_;
// which has a ref to the owning CefURLRequestContextGetterImpl.
CefURLRequestContextImpl* parent_;
CefRefPtr<CefRequestContextHandler> handler_;
std::unique_ptr<net::CookieChangeDispatcher> null_dispatcher_; std::unique_ptr<net::CookieChangeDispatcher> null_dispatcher_;
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy); DISALLOW_COPY_AND_ASSIGN(CefCookieStoreProxy);

View File

@@ -0,0 +1,110 @@
// Copyright (c) 2018 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/net/cookie_store_source.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/net/url_request_context_impl.h"
#include "libcef/browser/thread_util.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
CefCookieStoreHandlerSource::CefCookieStoreHandlerSource(
CefURLRequestContextImpl* parent,
CefRefPtr<CefRequestContextHandler> handler)
: parent_(parent), handler_(handler) {
DCHECK(parent_);
DCHECK(handler_);
}
net::CookieStore* CefCookieStoreHandlerSource::GetCookieStore() {
CEF_REQUIRE_IOT();
CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager();
if (manager) {
// Use the cookie store provided by the manager. May be nullptr if the
// cookie manager is blocking.
return reinterpret_cast<CefCookieManagerImpl*>(manager.get())
->GetExistingCookieStore();
}
DCHECK(parent_);
if (parent_) {
// Use the cookie store from the parent.
net::CookieStore* cookie_store = parent_->cookie_store();
DCHECK(cookie_store);
if (!cookie_store)
LOG(ERROR) << "Cookie store does not exist";
return cookie_store;
}
return nullptr;
}
CefCookieStoreOwnerSource::CefCookieStoreOwnerSource() {}
void CefCookieStoreOwnerSource::SetCookieStoragePath(
const base::FilePath& path,
bool persist_session_cookies) {
CEF_REQUIRE_IOT();
if (cookie_store_ && ((path_.empty() && path.empty()) || path_ == path)) {
// The path has not changed so don't do anything.
return;
}
scoped_refptr<net::SQLitePersistentCookieStore> persistent_store;
if (!path.empty()) {
// TODO(cef): Move directory creation to the blocking pool instead of
// allowing file IO on this thread.
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (base::DirectoryExists(path) || base::CreateDirectory(path)) {
const base::FilePath& cookie_path = path.AppendASCII("Cookies");
persistent_store = new net::SQLitePersistentCookieStore(
cookie_path,
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO),
// Intentionally using the background task runner exposed by CEF to
// facilitate unit test expectations. This task runner MUST be
// configured with BLOCK_SHUTDOWN.
CefContentBrowserClient::Get()->background_task_runner(),
persist_session_cookies, NULL);
} else {
NOTREACHED() << "The cookie storage directory could not be created";
}
}
// Set the new cookie store that will be used for all new requests. The old
// cookie store, if any, will be automatically flushed and closed when no
// longer referenced.
std::unique_ptr<net::CookieMonster> cookie_monster(
new net::CookieMonster(persistent_store.get(), nullptr));
if (persistent_store.get() && persist_session_cookies)
cookie_monster->SetPersistSessionCookies(true);
path_ = path;
// Restore the previously supported schemes.
CefCookieManagerImpl::SetCookieMonsterSchemes(cookie_monster.get(),
supported_schemes_);
cookie_store_ = std::move(cookie_monster);
}
void CefCookieStoreOwnerSource::SetCookieSupportedSchemes(
const std::vector<std::string>& schemes) {
CEF_REQUIRE_IOT();
supported_schemes_ = schemes;
CefCookieManagerImpl::SetCookieMonsterSchemes(
static_cast<net::CookieMonster*>(cookie_store_.get()),
supported_schemes_);
}
net::CookieStore* CefCookieStoreOwnerSource::GetCookieStore() {
CEF_REQUIRE_IOT();
return cookie_store_.get();
}

View File

@@ -0,0 +1,73 @@
// Copyright (c) 2018 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_COOKIE_STORE_SOURCE_H_
#define CEF_LIBCEF_BROWSER_COOKIE_STORE_SOURCE_H_
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "include/cef_request_context_handler.h"
#include "base/macros.h"
namespace base {
class FilePath;
}
namespace net {
class CookieStore;
}
class CefURLRequestContextImpl;
// Abstract base class for CookieStore sources. Only accessed on the IO thread.
class CefCookieStoreSource {
public:
virtual net::CookieStore* GetCookieStore() = 0;
virtual ~CefCookieStoreSource() {}
};
// Sources a cookie store that is created/owned by a CefCookieManager or the
// parent context. Life span is controlled by CefURLRequestContextProxy. See
// browser_context.h for an object relationship diagram.
class CefCookieStoreHandlerSource : public CefCookieStoreSource {
public:
CefCookieStoreHandlerSource(CefURLRequestContextImpl* parent,
CefRefPtr<CefRequestContextHandler> handler);
net::CookieStore* GetCookieStore() override;
private:
// The |parent_| pointer is kept alive by CefURLRequestContextGetterProxy
// which has a ref to the owning CefURLRequestContextGetterImpl.
CefURLRequestContextImpl* parent_;
CefRefPtr<CefRequestContextHandler> handler_;
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreHandlerSource);
};
// Sources a cookie store that is created/owned by this object. Life span is
// controlled by the owning URLRequestContext.
class CefCookieStoreOwnerSource : public CefCookieStoreSource {
public:
CefCookieStoreOwnerSource();
void SetCookieStoragePath(const base::FilePath& path,
bool persist_session_cookies);
void SetCookieSupportedSchemes(const std::vector<std::string>& schemes);
net::CookieStore* GetCookieStore() override;
private:
std::unique_ptr<net::CookieStore> cookie_store_;
base::FilePath path_;
std::vector<std::string> supported_schemes_;
DISALLOW_COPY_AND_ASSIGN(CefCookieStoreOwnerSource);
};
#endif // CEF_LIBCEF_BROWSER_COOKIE_STORE_SOURCE_H_

View File

@@ -32,18 +32,18 @@ namespace {
class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback { class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
public: public:
typedef net::CompletionCallback CallbackType; typedef net::CompletionOnceCallback CallbackType;
CefBeforeResourceLoadCallbackImpl(CefRefPtr<CefRequestImpl> cef_request, CefBeforeResourceLoadCallbackImpl(CefRefPtr<CefRequestImpl> cef_request,
GURL* new_url, GURL* new_url,
net::URLRequest* url_request, net::URLRequest* url_request,
bool force_google_safesearch, bool force_google_safesearch,
const CallbackType& callback) CallbackType callback)
: cef_request_(cef_request), : cef_request_(cef_request),
new_url_(new_url), new_url_(new_url),
url_request_(url_request), url_request_(url_request),
force_google_safesearch_(force_google_safesearch), force_google_safesearch_(force_google_safesearch),
callback_(callback) { callback_(std::move(callback)) {
DCHECK(new_url); DCHECK(new_url);
DCHECK(url_request_); DCHECK(url_request_);
@@ -56,12 +56,13 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The callback is still pending. Cancel it now. // The callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
RunNow(cef_request_, new_url_, url_request_, callback_, RunNow(cef_request_, new_url_, url_request_, std::move(callback_),
force_google_safesearch_, false); force_google_safesearch_, false);
} else { } else {
CEF_POST_TASK( CEF_POST_TASK(CEF_IOT,
CEF_IOT, base::Bind(&CefBeforeResourceLoadCallbackImpl::RunNow, base::Bind(&CefBeforeResourceLoadCallbackImpl::RunNow,
cef_request_, new_url_, url_request_, callback_, cef_request_, new_url_, url_request_,
base::Passed(std::move(callback_)),
force_google_safesearch_, false)); force_google_safesearch_, false));
} }
} }
@@ -79,12 +80,13 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
void ContinueNow(bool allow) { void ContinueNow(bool allow) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (!callback_.is_null()) { if (!callback_.is_null()) {
RunNow(cef_request_, new_url_, url_request_, callback_, RunNow(cef_request_, new_url_, url_request_, std::move(callback_),
force_google_safesearch_, allow); force_google_safesearch_, allow);
Disconnect(); Disconnect();
} }
} }
private:
void Disconnect() { void Disconnect() {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
cef_request_ = nullptr; cef_request_ = nullptr;
@@ -93,7 +95,6 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
callback_.Reset(); callback_.Reset();
} }
private:
// Used to disconnect the callback when the associated URLRequest is // Used to disconnect the callback when the associated URLRequest is
// destroyed. // destroyed.
class Disconnector : public base::SupportsUserData::Data { class Disconnector : public base::SupportsUserData::Data {
@@ -114,7 +115,7 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
static void RunNow(CefRefPtr<CefRequestImpl> cef_request, static void RunNow(CefRefPtr<CefRequestImpl> cef_request,
GURL* new_url, GURL* new_url,
net::URLRequest* request, net::URLRequest* request,
const CallbackType& callback, CallbackType callback,
bool force_google_safesearch, bool force_google_safesearch,
bool allow) { bool allow) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
@@ -144,7 +145,7 @@ class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
if (force_google_safesearch && allow && new_url->is_empty()) if (force_google_safesearch && allow && new_url->is_empty())
safe_search_util::ForceGoogleSafeSearch(request, new_url); safe_search_util::ForceGoogleSafeSearch(request, new_url);
callback.Run(allow ? net::OK : net::ERR_ABORTED); std::move(callback).Run(allow ? net::OK : net::ERR_ABORTED);
} }
} }
@@ -168,17 +169,18 @@ int CefBeforeResourceLoadCallbackImpl::kLocatorKey = 0;
class CefAuthCallbackImpl : public CefAuthCallback { class CefAuthCallbackImpl : public CefAuthCallback {
public: public:
CefAuthCallbackImpl(const net::NetworkDelegate::AuthCallback& callback, typedef net::NetworkDelegate::AuthCallback CallbackType;
net::AuthCredentials* credentials)
: callback_(callback), credentials_(credentials) {} CefAuthCallbackImpl(CallbackType callback, net::AuthCredentials* credentials)
: callback_(std::move(callback)), credentials_(credentials) {}
~CefAuthCallbackImpl() override { ~CefAuthCallbackImpl() override {
if (!callback_.is_null()) { if (!callback_.is_null()) {
// The auth callback is still pending. Cancel it now. // The auth callback is still pending. Cancel it now.
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
CancelNow(callback_); CancelNow(std::move(callback_));
} else { } else {
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT, base::Bind(&CefAuthCallbackImpl::CancelNow,
base::Bind(&CefAuthCallbackImpl::CancelNow, callback_)); base::Passed(std::move(callback_))));
} }
} }
} }
@@ -187,8 +189,8 @@ class CefAuthCallbackImpl : public CefAuthCallback {
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
credentials_->Set(username, password); credentials_->Set(username, password);
callback_.Run(net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_SET_AUTH); std::move(callback_).Run(
callback_.Reset(); net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_SET_AUTH);
} }
} else { } else {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefAuthCallbackImpl::Continue, this, CEF_POST_TASK(CEF_IOT, base::Bind(&CefAuthCallbackImpl::Continue, this,
@@ -199,23 +201,23 @@ class CefAuthCallbackImpl : public CefAuthCallback {
void Cancel() override { void Cancel() override {
if (CEF_CURRENTLY_ON_IOT()) { if (CEF_CURRENTLY_ON_IOT()) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
CancelNow(callback_); CancelNow(std::move(callback_));
callback_.Reset();
} }
} else { } else {
CEF_POST_TASK(CEF_IOT, base::Bind(&CefAuthCallbackImpl::Cancel, this)); CEF_POST_TASK(CEF_IOT, base::Bind(&CefAuthCallbackImpl::Cancel, this));
} }
} }
void Disconnect() { callback_.Reset(); } CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); }
private: private:
static void CancelNow(const net::NetworkDelegate::AuthCallback& callback) { static void CancelNow(CallbackType callback) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
callback.Run(net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION); std::move(callback).Run(
net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION);
} }
net::NetworkDelegate::AuthCallback callback_; CallbackType callback_;
net::AuthCredentials* credentials_; net::AuthCredentials* credentials_;
IMPLEMENT_REFCOUNTING(CefAuthCallbackImpl); IMPLEMENT_REFCOUNTING(CefAuthCallbackImpl);
@@ -277,9 +279,8 @@ std::unique_ptr<net::SourceStream> CefNetworkDelegate::CreateSourceStream(
return upstream; return upstream;
} }
int CefNetworkDelegate::OnBeforeURLRequest( int CefNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request,
net::URLRequest* request, net::CompletionOnceCallback callback,
const net::CompletionCallback& callback,
GURL* new_url) { GURL* new_url) {
if (net_util::IsInternalRequest(request)) if (net_util::IsInternalRequest(request))
return net::OK; return net::OK;
@@ -312,7 +313,7 @@ int CefNetworkDelegate::OnBeforeURLRequest(
CefRefPtr<CefBeforeResourceLoadCallbackImpl> callbackImpl( CefRefPtr<CefBeforeResourceLoadCallbackImpl> callbackImpl(
new CefBeforeResourceLoadCallbackImpl(requestPtr, new_url, request, new CefBeforeResourceLoadCallbackImpl(requestPtr, new_url, request,
force_google_safesearch, force_google_safesearch,
callback)); std::move(callback)));
// Give the client an opportunity to evaluate the request. // Give the client an opportunity to evaluate the request.
cef_return_value_t retval = handler->OnBeforeResourceLoad( cef_return_value_t retval = handler->OnBeforeResourceLoad(
@@ -338,7 +339,9 @@ int CefNetworkDelegate::OnBeforeURLRequest(
return net::OK; return net::OK;
} }
void CefNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { void CefNetworkDelegate::OnCompleted(net::URLRequest* request,
bool started,
int net_error) {
if (net_util::IsInternalRequest(request)) if (net_util::IsInternalRequest(request))
return; return;
@@ -391,7 +394,7 @@ void CefNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
net::NetworkDelegate::AuthRequiredResponse CefNetworkDelegate::OnAuthRequired( net::NetworkDelegate::AuthRequiredResponse CefNetworkDelegate::OnAuthRequired(
net::URLRequest* request, net::URLRequest* request,
const net::AuthChallengeInfo& auth_info, const net::AuthChallengeInfo& auth_info,
const AuthCallback& callback, AuthCallback callback,
net::AuthCredentials* credentials) { net::AuthCredentials* credentials) {
if (net_util::IsInternalRequest(request)) if (net_util::IsInternalRequest(request))
return AUTH_REQUIRED_RESPONSE_NO_ACTION; return AUTH_REQUIRED_RESPONSE_NO_ACTION;
@@ -406,14 +409,14 @@ net::NetworkDelegate::AuthRequiredResponse CefNetworkDelegate::OnAuthRequired(
CefRefPtr<CefFrame> frame = browser->GetFrameForRequest(request); CefRefPtr<CefFrame> frame = browser->GetFrameForRequest(request);
CefRefPtr<CefAuthCallbackImpl> callbackPtr( CefRefPtr<CefAuthCallbackImpl> callbackPtr(
new CefAuthCallbackImpl(callback, credentials)); new CefAuthCallbackImpl(std::move(callback), credentials));
if (handler->GetAuthCredentials( if (handler->GetAuthCredentials(
browser.get(), frame, auth_info.is_proxy, browser.get(), frame, auth_info.is_proxy,
auth_info.challenger.host(), auth_info.challenger.port(), auth_info.challenger.host(), auth_info.challenger.port(),
auth_info.realm, auth_info.scheme, callbackPtr.get())) { auth_info.realm, auth_info.scheme, callbackPtr.get())) {
return AUTH_REQUIRED_RESPONSE_IO_PENDING; return AUTH_REQUIRED_RESPONSE_IO_PENDING;
} else { } else {
callbackPtr->Disconnect(); callback = callbackPtr->Disconnect();
} }
} }
} }
@@ -426,14 +429,14 @@ net::NetworkDelegate::AuthRequiredResponse CefNetworkDelegate::OnAuthRequired(
CefRefPtr<CefURLRequestClient> client = user_data->GetClient(); CefRefPtr<CefURLRequestClient> client = user_data->GetClient();
if (client.get()) { if (client.get()) {
CefRefPtr<CefAuthCallbackImpl> callbackPtr( CefRefPtr<CefAuthCallbackImpl> callbackPtr(
new CefAuthCallbackImpl(callback, credentials)); new CefAuthCallbackImpl(std::move(callback), credentials));
if (client->GetAuthCredentials( if (client->GetAuthCredentials(
auth_info.is_proxy, auth_info.challenger.host(), auth_info.is_proxy, auth_info.challenger.host(),
auth_info.challenger.port(), auth_info.realm, auth_info.scheme, auth_info.challenger.port(), auth_info.realm, auth_info.scheme,
callbackPtr.get())) { callbackPtr.get())) {
return AUTH_REQUIRED_RESPONSE_IO_PENDING; return AUTH_REQUIRED_RESPONSE_IO_PENDING;
} else { } else {
callbackPtr->Disconnect(); callback = callbackPtr->Disconnect();
} }
} }
} }

View File

@@ -30,14 +30,16 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
net::URLRequest* request, net::URLRequest* request,
std::unique_ptr<net::SourceStream> upstream) override; std::unique_ptr<net::SourceStream> upstream) override;
int OnBeforeURLRequest(net::URLRequest* request, int OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback, net::CompletionOnceCallback callback,
GURL* new_url) override; GURL* new_url) override;
AuthRequiredResponse OnAuthRequired( AuthRequiredResponse OnAuthRequired(
net::URLRequest* request, net::URLRequest* request,
const net::AuthChallengeInfo& auth_info, const net::AuthChallengeInfo& auth_info,
const AuthCallback& callback, AuthCallback callback,
net::AuthCredentials* credentials) override; net::AuthCredentials* credentials) override;
void OnCompleted(net::URLRequest* request, bool started) override; void OnCompleted(net::URLRequest* request,
bool started,
int net_error) override;
bool OnCanGetCookies(const net::URLRequest& request, bool OnCanGetCookies(const net::URLRequest& request,
const net::CookieList& cookie_list) override; const net::CookieList& cookie_list) override;
bool OnCanSetCookie(const net::URLRequest& request, bool OnCanSetCookie(const net::URLRequest& request,

View File

@@ -282,11 +282,14 @@ void CefResourceRequestJob::GetLoadTimingInfo(
load_timing_info->receive_headers_end = receive_headers_end_; load_timing_info->receive_headers_end = receive_headers_end_;
} }
bool CefResourceRequestJob::IsRedirectResponse(GURL* location, bool CefResourceRequestJob::IsRedirectResponse(
int* http_status_code) { GURL* location,
int* http_status_code,
bool* insecure_scheme_was_upgraded) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
bool redirect = false; bool redirect = false;
*insecure_scheme_was_upgraded = false;
if (redirect_url_.is_valid()) { if (redirect_url_.is_valid()) {
// Redirect to the new URL. // Redirect to the new URL.

View File

@@ -38,7 +38,9 @@ class CefResourceRequestJob : public net::URLRequestJob {
int ReadRawData(net::IOBuffer* dest, int dest_size) override; int ReadRawData(net::IOBuffer* dest, int dest_size) override;
void GetResponseInfo(net::HttpResponseInfo* info) override; void GetResponseInfo(net::HttpResponseInfo* info) override;
void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override; void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
bool IsRedirectResponse(GURL* location, int* http_status_code) override; bool IsRedirectResponse(GURL* location,
int* http_status_code,
bool* insecure_scheme_was_upgraded) override;
bool GetMimeType(std::string* mime_type) const override; bool GetMimeType(std::string* mime_type) const override;
bool GetCharset(std::string* charset) override; bool GetCharset(std::string* charset) override;
int GetResponseCode() const override; int GetResponseCode() const override;

View File

@@ -10,6 +10,8 @@
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "libcef/browser/cookie_manager_impl.h" #include "libcef/browser/cookie_manager_impl.h"
#include "libcef/browser/net/cookie_store_proxy.h"
#include "libcef/browser/net/cookie_store_source.h"
#include "libcef/browser/net/network_delegate.h" #include "libcef/browser/net/network_delegate.h"
#include "libcef/browser/net/scheme_handler.h" #include "libcef/browser/net/scheme_handler.h"
#include "libcef/browser/net/url_request_interceptor.h" #include "libcef/browser/net/url_request_interceptor.h"
@@ -18,7 +20,6 @@
#include "libcef/common/content_client.h" #include "libcef/common/content_client.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/stl_util.h" #include "base/stl_util.h"
@@ -43,7 +44,6 @@
#include "net/cert/multi_log_ct_verifier.h" #include "net/cert/multi_log_ct_verifier.h"
#include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_monster.h"
#include "net/dns/host_resolver.h" #include "net/dns/host_resolver.h"
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include "net/ftp/ftp_network_layer.h" #include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h" #include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_preferences.h" #include "net/http/http_auth_preferences.h"
@@ -350,7 +350,7 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
std::move(system_proxy_service)); std::move(system_proxy_service));
io_state_->storage_->set_ssl_config_service( io_state_->storage_->set_ssl_config_service(
new net::SSLConfigServiceDefaults); std::make_unique<net::SSLConfigServiceDefaults>());
std::vector<std::string> supported_schemes; std::vector<std::string> supported_schemes;
supported_schemes.push_back("basic"); supported_schemes.push_back("basic");
@@ -358,18 +358,12 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
supported_schemes.push_back("ntlm"); supported_schemes.push_back("ntlm");
supported_schemes.push_back("negotiate"); supported_schemes.push_back("negotiate");
io_state_->http_auth_preferences_.reset(new net::HttpAuthPreferences( io_state_->http_auth_preferences_.reset(new net::HttpAuthPreferences());
supported_schemes
#if defined(OS_POSIX) && !defined(OS_ANDROID)
,
io_state_->gsapi_library_name_
#endif
));
io_state_->storage_->set_http_auth_handler_factory( io_state_->storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerRegistryFactory::Create( net::HttpAuthHandlerRegistryFactory::Create(
io_state_->http_auth_preferences_.get(), io_state_->url_request_context_->host_resolver(),
io_state_->url_request_context_->host_resolver())); io_state_->http_auth_preferences_.get(), supported_schemes));
io_state_->storage_->set_http_server_properties( io_state_->storage_->set_http_server_properties(
base::WrapUnique(new net::HttpServerPropertiesImpl)); base::WrapUnique(new net::HttpServerPropertiesImpl));
@@ -479,57 +473,21 @@ void CefURLRequestContextGetterImpl::SetCookieStoragePath(
const base::FilePath& path, const base::FilePath& path,
bool persist_session_cookies) { bool persist_session_cookies) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (!io_state_->cookie_source_) {
if (io_state_->url_request_context_->cookie_store() && // Use a proxy because we can't change the URLRequestContext's CookieStore
((io_state_->cookie_store_path_.empty() && path.empty()) || // during runtime.
io_state_->cookie_store_path_ == path)) { io_state_->cookie_source_ = new CefCookieStoreOwnerSource();
// The path has not changed so don't do anything. io_state_->storage_->set_cookie_store(std::make_unique<CefCookieStoreProxy>(
return; base::WrapUnique(io_state_->cookie_source_)));
} }
io_state_->cookie_source_->SetCookieStoragePath(path,
scoped_refptr<net::SQLitePersistentCookieStore> persistent_store; persist_session_cookies);
if (!path.empty()) {
// TODO(cef): Move directory creation to the blocking pool instead of
// allowing file IO on this thread.
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (base::DirectoryExists(path) || base::CreateDirectory(path)) {
const base::FilePath& cookie_path = path.AppendASCII("Cookies");
persistent_store = new net::SQLitePersistentCookieStore(
cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
// Intentionally using the background task runner exposed by CEF to
// facilitate unit test expectations. This task runner MUST be
// configured with BLOCK_SHUTDOWN.
CefContentBrowserClient::Get()->background_task_runner(),
persist_session_cookies, NULL);
} else {
NOTREACHED() << "The cookie storage directory could not be created";
}
}
// Set the new cookie store that will be used for all new requests. The old
// cookie store, if any, will be automatically flushed and closed when no
// longer referenced.
std::unique_ptr<net::CookieMonster> cookie_monster(
new net::CookieMonster(persistent_store.get(), NULL));
if (persistent_store.get() && persist_session_cookies)
cookie_monster->SetPersistSessionCookies(true);
io_state_->cookie_store_path_ = path;
// Restore the previously supported schemes.
CefCookieManagerImpl::SetCookieMonsterSchemes(
cookie_monster.get(), io_state_->cookie_supported_schemes_);
io_state_->storage_->set_cookie_store(std::move(cookie_monster));
} }
void CefURLRequestContextGetterImpl::SetCookieSupportedSchemes( void CefURLRequestContextGetterImpl::SetCookieSupportedSchemes(
const std::vector<std::string>& schemes) { const std::vector<std::string>& schemes) {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
io_state_->cookie_source_->SetCookieSupportedSchemes(schemes);
io_state_->cookie_supported_schemes_ = schemes;
CefCookieManagerImpl::SetCookieMonsterSchemes(
static_cast<net::CookieMonster*>(GetExistingCookieStore()),
io_state_->cookie_supported_schemes_);
} }
void CefURLRequestContextGetterImpl::AddHandler( void CefURLRequestContextGetterImpl::AddHandler(
@@ -546,9 +504,8 @@ void CefURLRequestContextGetterImpl::AddHandler(
net::CookieStore* CefURLRequestContextGetterImpl::GetExistingCookieStore() net::CookieStore* CefURLRequestContextGetterImpl::GetExistingCookieStore()
const { const {
CEF_REQUIRE_IOT(); CEF_REQUIRE_IOT();
if (io_state_->url_request_context_ && if (io_state_->cookie_source_) {
io_state_->url_request_context_->cookie_store()) { return io_state_->cookie_source_->GetCookieStore();
return io_state_->url_request_context_->cookie_store();
} }
LOG(ERROR) << "Cookie store does not exist"; LOG(ERROR) << "Cookie store does not exist";

View File

@@ -22,6 +22,7 @@
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "net/url_request/url_request_job_factory.h" #include "net/url_request/url_request_job_factory.h"
class CefCookieStoreOwnerSource;
class PrefRegistrySimple; class PrefRegistrySimple;
class PrefService; class PrefService;
@@ -113,8 +114,8 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
content::ProtocolHandlerMap protocol_handlers_; content::ProtocolHandlerMap protocol_handlers_;
content::URLRequestInterceptorScopedVector request_interceptors_; content::URLRequestInterceptorScopedVector request_interceptors_;
base::FilePath cookie_store_path_; // Owned by the URLRequestContextStorage.
std::vector<std::string> cookie_supported_schemes_; CefCookieStoreOwnerSource* cookie_source_ = nullptr;
std::vector<CefRefPtr<CefRequestContextHandler>> handler_list_; std::vector<CefRefPtr<CefRequestContextHandler>> handler_list_;

View File

@@ -5,6 +5,7 @@
#include "libcef/browser/net/url_request_context_proxy.h" #include "libcef/browser/net/url_request_context_proxy.h"
#include "libcef/browser/net/cookie_store_proxy.h" #include "libcef/browser/net/cookie_store_proxy.h"
#include "libcef/browser/net/cookie_store_source.h"
#include "libcef/browser/net/url_request_context_impl.h" #include "libcef/browser/net/url_request_context_impl.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
@@ -16,7 +17,8 @@ CefURLRequestContextProxy::CefURLRequestContextProxy(
DCHECK(handler.get()); DCHECK(handler.get());
// Cookie store that proxies to the browser implementation. // Cookie store that proxies to the browser implementation.
cookie_store_proxy_.reset(new CefCookieStoreProxy(parent, handler)); cookie_store_proxy_.reset(new CefCookieStoreProxy(
std::make_unique<CefCookieStoreHandlerSource>(parent, handler)));
set_cookie_store(cookie_store_proxy_.get()); set_cookie_store(cookie_store_proxy_.get());
// All other values refer to the parent request context. // All other values refer to the parent request context.

View File

@@ -535,7 +535,7 @@ void CefBrowserPlatformDelegateOsr::DragSourceSystemDragEnded() {
} }
void CefBrowserPlatformDelegateOsr::AccessibilityEventReceived( void CefBrowserPlatformDelegateOsr::AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& eventData) { const content::AXEventNotificationDetails& eventData) {
CefRefPtr<CefRenderHandler> handler = browser_->client()->GetRenderHandler(); CefRefPtr<CefRenderHandler> handler = browser_->client()->GetRenderHandler();
if (handler.get()) { if (handler.get()) {
CefRefPtr<CefAccessibilityHandler> acchandler = CefRefPtr<CefAccessibilityHandler> acchandler =

View File

@@ -90,8 +90,7 @@ class CefBrowserPlatformDelegateOsr
void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op) override; void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op) override;
void DragSourceSystemDragEnded() override; void DragSourceSystemDragEnded() override;
void AccessibilityEventReceived( void AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& eventData) const content::AXEventNotificationDetails& eventData) override;
override;
void AccessibilityLocationChangesReceived( void AccessibilityLocationChangesReceived(
const std::vector<content::AXLocationChangeNotificationDetails>& locData) const std::vector<content::AXLocationChangeNotificationDetails>& locData)
override; override;

View File

@@ -380,24 +380,53 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXTreeUpdate& update) {
return value; return value;
} }
// Converts AXEvent to CefDictionaryValue.
CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXEvent& event) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (event.event_type != ax::mojom::Event::kNone)
value->SetString("event_type", ToString(event.event_type));
if (event.id != -1)
value->SetInt("id", event.id);
if (event.event_from != ax::mojom::EventFrom::kNone)
value->SetString("event_from", ToString(event.event_from));
if (event.action_request_id != -1)
value->SetInt("action_request_id", event.action_request_id);
return value;
}
// Convert AXEventNotificationDetails to CefDictionaryValue. // Convert AXEventNotificationDetails to CefDictionaryValue.
CefRefPtr<CefDictionaryValue> ToCefValue( CefRefPtr<CefDictionaryValue> ToCefValue(
const content::AXEventNotificationDetails& eventData) { const content::AXEventNotificationDetails& eventData) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create(); CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (eventData.id != -1)
value->SetInt("id", eventData.id);
if (eventData.ax_tree_id != -1) if (eventData.ax_tree_id != -1)
value->SetInt("ax_tree_id", eventData.ax_tree_id); value->SetInt("ax_tree_id", eventData.ax_tree_id);
if (eventData.event_type != ax::mojom::Event::kNone) if (eventData.updates.size() > 0) {
value->SetString("event_type", ToString(eventData.event_type)); CefRefPtr<CefListValue> updates = CefListValue::Create();
updates->SetSize(eventData.updates.size());
size_t i = 0;
for (const auto& update : eventData.updates) {
updates->SetDictionary(i++, ToCefValue(update));
}
value->SetList("updates", updates);
}
if (eventData.event_from != ax::mojom::EventFrom::kNone) if (eventData.events.size() > 0) {
value->SetString("event_from", ToString(eventData.event_from)); CefRefPtr<CefListValue> events = CefListValue::Create();
events->SetSize(eventData.events.size());
size_t i = 0;
for (const auto& event : eventData.events) {
events->SetDictionary(i++, ToCefValue(event));
}
value->SetList("events", events);
}
value->SetDictionary("update", ToCefValue(eventData.update));
return value; return value;
} }
@@ -419,7 +448,7 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXRelativeBounds& location) {
return value; return value;
} }
// Convert AXEventNotificationDetails to CefDictionaryValue. // Convert AXLocationChangeNotificationDetails to CefDictionaryValue.
CefRefPtr<CefDictionaryValue> ToCefValue( CefRefPtr<CefDictionaryValue> ToCefValue(
const content::AXLocationChangeNotificationDetails& locData) { const content::AXLocationChangeNotificationDetails& locData) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create(); CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
@@ -450,9 +479,9 @@ CefRefPtr<CefListValue> ToCefValue(const std::vector<T>& vecData) {
namespace osr_accessibility_util { namespace osr_accessibility_util {
CefRefPtr<CefValue> ParseAccessibilityEventData( CefRefPtr<CefValue> ParseAccessibilityEventData(
const std::vector<content::AXEventNotificationDetails>& data) { const content::AXEventNotificationDetails& data) {
CefRefPtr<CefValue> value = CefValue::Create(); CefRefPtr<CefValue> value = CefValue::Create();
value->SetList(ToCefValue(data)); value->SetDictionary(ToCefValue(data));
return value; return value;
} }

View File

@@ -19,7 +19,7 @@ namespace osr_accessibility_util {
// Convert Accessibility Event and location updates to CefValue, which may be // Convert Accessibility Event and location updates to CefValue, which may be
// consumed or serialized with CefJSONWrite. // consumed or serialized with CefJSONWrite.
CefRefPtr<CefValue> ParseAccessibilityEventData( CefRefPtr<CefValue> ParseAccessibilityEventData(
const std::vector<content::AXEventNotificationDetails>& data); const content::AXEventNotificationDetails& data);
CefRefPtr<CefValue> ParseAccessibilityLocationData( CefRefPtr<CefValue> ParseAccessibilityLocationData(
const std::vector<content::AXLocationChangeNotificationDetails>& data); const std::vector<content::AXLocationChangeNotificationDetails>& data);

View File

@@ -27,6 +27,7 @@
#include "content/browser/bad_message.h" #include "content/browser/bad_message.h"
#include "content/browser/compositor/image_transport_factory.h" #include "content/browser/compositor/image_transport_factory.h"
#include "content/browser/frame_host/render_widget_host_view_guest.h" #include "content/browser/frame_host/render_widget_host_view_guest.h"
#include "content/browser/renderer_host/cursor_manager.h"
#include "content/browser/renderer_host/dip_util.h" #include "content/browser/renderer_host/dip_util.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
@@ -223,6 +224,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
is_showing_(!render_widget_host_->is_hidden()), is_showing_(!render_widget_host_->is_hidden()),
is_destroyed_(false), is_destroyed_(false),
is_scroll_offset_changed_pending_(false), is_scroll_offset_changed_pending_(false),
mouse_wheel_phase_handler_(this),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(render_widget_host_); DCHECK(render_widget_host_);
DCHECK(!render_widget_host_->GetView()); DCHECK(!render_widget_host_->GetView());
@@ -277,6 +279,8 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
if (browser_impl_.get()) if (browser_impl_.get())
ResizeRootLayer(false); ResizeRootLayer(false);
cursor_manager_.reset(new content::CursorManager(this));
// Do this last because it may result in a call to SetNeedsBeginFrames. // Do this last because it may result in a call to SetNeedsBeginFrames.
render_widget_host_->SetView(this); render_widget_host_->SetView(this);
} }
@@ -362,14 +366,14 @@ void CefRenderWidgetHostViewOSR::Show() {
browser_compositor_->SetRenderWidgetHostIsHidden(false); browser_compositor_->SetRenderWidgetHostIsHidden(false);
#else #else
delegated_frame_host_->SetCompositor(compositor_.get()); delegated_frame_host_->SetCompositor(compositor_.get());
delegated_frame_host_->WasShown( delegated_frame_host_->WasShown(GetLocalSurfaceId(),
GetLocalSurfaceId(), GetRootLayer()->bounds().size(), ui::LatencyInfo()); GetRootLayer()->bounds().size(), false);
#endif #endif
// Note that |render_widget_host_| will retrieve size parameters from the // Note that |render_widget_host_| will retrieve size parameters from the
// DelegatedFrameHost, so it must have WasShown called after. // DelegatedFrameHost, so it must have WasShown called after.
if (render_widget_host_) if (render_widget_host_)
render_widget_host_->WasShown(ui::LatencyInfo()); render_widget_host_->WasShown(false);
} }
void CefRenderWidgetHostViewOSR::Hide() { void CefRenderWidgetHostViewOSR::Hide() {
@@ -632,6 +636,10 @@ void CefRenderWidgetHostViewOSR::UpdateCursor(
#endif #endif
} }
content::CursorManager* CefRenderWidgetHostViewOSR::GetCursorManager() {
return cursor_manager_.get();
}
void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) {} void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) {}
void CefRenderWidgetHostViewOSR::RenderProcessGone( void CefRenderWidgetHostViewOSR::RenderProcessGone(
@@ -679,10 +687,6 @@ void CefRenderWidgetHostViewOSR::SetTooltipText(
} }
} }
gfx::Size CefRenderWidgetHostViewOSR::GetRequestedRendererSize() const {
return GetDelegatedFrameHost()->GetRequestedRendererSize();
}
gfx::Size CefRenderWidgetHostViewOSR::GetCompositorViewportPixelSize() const { gfx::Size CefRenderWidgetHostViewOSR::GetCompositorViewportPixelSize() const {
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
current_device_scale_factor_); current_device_scale_factor_);
@@ -859,12 +863,13 @@ void CefRenderWidgetHostViewOSR::SelectionChanged(const base::string16& text,
} }
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
viz::LocalSurfaceId CefRenderWidgetHostViewOSR::GetLocalSurfaceId() const { const viz::LocalSurfaceId& CefRenderWidgetHostViewOSR::GetLocalSurfaceId()
const {
return local_surface_id_; return local_surface_id_;
} }
#endif #endif
viz::FrameSinkId CefRenderWidgetHostViewOSR::GetFrameSinkId() { const viz::FrameSinkId& CefRenderWidgetHostViewOSR::GetFrameSinkId() const {
return GetDelegatedFrameHost()->frame_sink_id(); return GetDelegatedFrameHost()->frame_sink_id();
} }
@@ -1125,21 +1130,32 @@ void CefRenderWidgetHostViewOSR::SendMouseEvent(
void CefRenderWidgetHostViewOSR::SendMouseWheelEvent( void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
const blink::WebMouseWheelEvent& event) { const blink::WebMouseWheelEvent& event) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent"); TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
blink::WebMouseWheelEvent mouse_wheel_event(event);
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded();
mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent(
mouse_wheel_event, false);
if (!IsPopupWidget()) { if (!IsPopupWidget()) {
if (browser_impl_.get()) if (browser_impl_.get())
browser_impl_->CancelContextMenu(); browser_impl_->CancelContextMenu();
if (popup_host_view_) { if (popup_host_view_) {
if (popup_host_view_->popup_position_.Contains( if (popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x, event.PositionInWidget().y)) { mouse_wheel_event.PositionInWidget().x,
blink::WebMouseWheelEvent popup_event(event); mouse_wheel_event.PositionInWidget().y)) {
popup_event.SetPositionInWidget( blink::WebMouseWheelEvent popup_mouse_wheel_event(mouse_wheel_event);
event.PositionInWidget().x - popup_host_view_->popup_position_.x(), popup_mouse_wheel_event.SetPositionInWidget(
event.PositionInWidget().y - popup_host_view_->popup_position_.y()); mouse_wheel_event.PositionInWidget().x -
popup_event.SetPositionInScreen(popup_event.PositionInWidget().x, popup_host_view_->popup_position_.x(),
popup_event.PositionInWidget().y); mouse_wheel_event.PositionInWidget().y -
popup_host_view_->popup_position_.y());
popup_mouse_wheel_event.SetPositionInScreen(
popup_mouse_wheel_event.PositionInWidget().x,
popup_mouse_wheel_event.PositionInWidget().y);
popup_host_view_->SendMouseWheelEvent(popup_event); popup_host_view_->SendMouseWheelEvent(popup_mouse_wheel_event);
return; return;
} else { } else {
// Scrolling outside of the popup widget so destroy it. // Scrolling outside of the popup widget so destroy it.
@@ -1158,16 +1174,17 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
} }
const gfx::Rect& guest_bounds = const gfx::Rect& guest_bounds =
guest_host_view->render_widget_host_->GetView()->GetViewBounds(); guest_host_view->render_widget_host_->GetView()->GetViewBounds();
if (guest_bounds.Contains(event.PositionInWidget().x, if (guest_bounds.Contains(mouse_wheel_event.PositionInWidget().x,
event.PositionInWidget().y)) { mouse_wheel_event.PositionInWidget().y)) {
blink::WebMouseWheelEvent guest_event(event); blink::WebMouseWheelEvent guest_mouse_wheel_event(mouse_wheel_event);
guest_event.SetPositionInWidget( guest_mouse_wheel_event.SetPositionInWidget(
event.PositionInWidget().x - guest_bounds.x(), mouse_wheel_event.PositionInWidget().x - guest_bounds.x(),
event.PositionInWidget().y - guest_bounds.y()); mouse_wheel_event.PositionInWidget().y - guest_bounds.y());
guest_event.SetPositionInScreen(guest_event.PositionInWidget().x, guest_mouse_wheel_event.SetPositionInScreen(
guest_event.PositionInWidget().y); guest_mouse_wheel_event.PositionInWidget().x,
guest_mouse_wheel_event.PositionInWidget().y);
guest_host_view->SendMouseWheelEvent(guest_event); guest_host_view->SendMouseWheelEvent(guest_mouse_wheel_event);
return; return;
} }
} }
@@ -1177,7 +1194,7 @@ void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
if (render_widget_host_ && render_widget_host_->GetView()) { if (render_widget_host_ && render_widget_host_->GetView()) {
// Direct routing requires that mouse events go directly to the View. // Direct routing requires that mouse events go directly to the View.
render_widget_host_->GetView()->ProcessMouseWheelEvent( render_widget_host_->GetView()->ProcessMouseWheelEvent(
event, ui::LatencyInfo(ui::SourceEventType::WHEEL)); mouse_wheel_event, ui::LatencyInfo(ui::SourceEventType::WHEEL));
} }
} }
@@ -1373,7 +1390,7 @@ void CefRenderWidgetHostViewOSR::ResizeRootLayer(bool force) {
PlatformResizeCompositorWidget(size_in_pixels); PlatformResizeCompositorWidget(size_in_pixels);
bool resized = true; bool resized = true;
GetDelegatedFrameHost()->SynchronizeVisualProperties( GetDelegatedFrameHost()->EmbedSurface(
local_surface_id_, size, cc::DeadlinePolicy::UseDefaultDeadline()); local_surface_id_, size, cc::DeadlinePolicy::UseDefaultDeadline());
#endif // !defined(OS_MACOSX) #endif // !defined(OS_MACOSX)

View File

@@ -18,6 +18,7 @@
#include "components/viz/common/frame_sinks/begin_frame_source.h" #include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h" #include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "content/browser/renderer_host/delegated_frame_host.h" #include "content/browser/renderer_host/delegated_frame_host.h"
#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
@@ -38,6 +39,7 @@ class RenderWidgetHost;
class RenderWidgetHostImpl; class RenderWidgetHostImpl;
class RenderWidgetHostViewGuest; class RenderWidgetHostViewGuest;
class BackingStore; class BackingStore;
class CursorManager;
} // namespace content } // namespace content
class CefBeginFrameTimer; class CefBeginFrameTimer;
@@ -146,8 +148,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
int error_code) override; int error_code) override;
void Destroy() override; void Destroy() override;
void SetTooltipText(const base::string16& tooltip_text) override; void SetTooltipText(const base::string16& tooltip_text) override;
content::CursorManager* GetCursorManager() override;
gfx::Size GetRequestedRendererSize() const override;
gfx::Size GetCompositorViewportPixelSize() const override; gfx::Size GetCompositorViewportPixelSize() const override;
void CopyFromSurface( void CopyFromSurface(
const gfx::Rect& src_rect, const gfx::Rect& src_rect,
@@ -156,6 +158,10 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void GetScreenInfo(content::ScreenInfo* results) const override; void GetScreenInfo(content::ScreenInfo* results) const override;
void TransformPointToRootSurface(gfx::PointF* point) override; void TransformPointToRootSurface(gfx::PointF* point) override;
gfx::Rect GetBoundsInRootWindow() override; gfx::Rect GetBoundsInRootWindow() override;
#if defined(OS_MACOSX)
viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties(
const cc::RenderFrameMetadata& metadata) override;
#endif
viz::SurfaceId GetCurrentSurfaceId() const override; viz::SurfaceId GetCurrentSurfaceId() const override;
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager( content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
content::BrowserAccessibilityDelegate* delegate, content::BrowserAccessibilityDelegate* delegate,
@@ -187,8 +193,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
size_t offset, size_t offset,
const gfx::Range& range) override; const gfx::Range& range) override;
viz::LocalSurfaceId GetLocalSurfaceId() const override; const viz::LocalSurfaceId& GetLocalSurfaceId() const override;
viz::FrameSinkId GetFrameSinkId() override; const viz::FrameSinkId& GetFrameSinkId() const override;
// ui::CompositorDelegate implementation. // ui::CompositorDelegate implementation.
std::unique_ptr<viz::SoftwareOutputDevice> CreateSoftwareOutputDevice( std::unique_ptr<viz::SoftwareOutputDevice> CreateSoftwareOutputDevice(
@@ -254,6 +260,12 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
} }
ui::Layer* GetRootLayer() const; ui::Layer* GetRootLayer() const;
#if defined(OS_MACOSX)
content::BrowserCompositorMac* browser_compositor() const {
return browser_compositor_.get();
}
#endif
private: private:
content::DelegatedFrameHost* GetDelegatedFrameHost() const; content::DelegatedFrameHost* GetDelegatedFrameHost() const;
@@ -291,6 +303,10 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void UpdateBackgroundColorFromRenderer(SkColor color); void UpdateBackgroundColorFromRenderer(SkColor color);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
display::Display GetDisplay();
void OnDidUpdateVisualPropertiesComplete(
const cc::RenderFrameMetadata& metadata);
friend class MacHelper; friend class MacHelper;
bool UpdateNSViewAndDisplay(); bool UpdateNSViewAndDisplay();
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
@@ -331,6 +347,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
std::unique_ptr<ui::XScopedCursor> invisible_cursor_; std::unique_ptr<ui::XScopedCursor> invisible_cursor_;
#endif #endif
std::unique_ptr<content::CursorManager> cursor_manager_;
// Used to control the VSync rate in subprocesses when BeginFrame scheduling // Used to control the VSync rate in subprocesses when BeginFrame scheduling
// is enabled. // is enabled.
std::unique_ptr<CefBeginFrameTimer> begin_frame_timer_; std::unique_ptr<CefBeginFrameTimer> begin_frame_timer_;
@@ -370,6 +388,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
gfx::Vector2dF last_scroll_offset_; gfx::Vector2dF last_scroll_offset_;
bool is_scroll_offset_changed_pending_; bool is_scroll_offset_changed_pending_;
content::MouseWheelPhaseHandler mouse_wheel_phase_handler_;
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_ = viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_ =
nullptr; nullptr;

View File

@@ -19,15 +19,6 @@
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
namespace {
display::Display GetDisplay() {
// TODO(cef): Get display info from callbacks.
return display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
}
} // namespace
class MacHelper : public content::BrowserCompositorMacClient, class MacHelper : public content::BrowserCompositorMacClient,
public ui::AcceleratedWidgetMacNSView { public ui::AcceleratedWidgetMacNSView {
public: public:
@@ -53,26 +44,36 @@ class MacHelper : public content::BrowserCompositorMacClient,
view_->render_widget_host()->DidProcessFrame(frame_token); view_->render_widget_host()->DidProcessFrame(frame_token);
} }
// AcceleratedWidgetMacNSView methods:
NSView* AcceleratedWidgetGetNSView() const override {
// Intentionally return nil so that BrowserCompositorMac::GetViewProperties
// uses the layer size instead of the NSView size.
return nil;
}
void AcceleratedWidgetCALayerParamsUpdated() override {}
void DidReceiveFirstFrameAfterNavigation() override { void DidReceiveFirstFrameAfterNavigation() override {
view_->render_widget_host()->DidReceiveFirstFrameAfterNavigation(); view_->render_widget_host()->DidReceiveFirstFrameAfterNavigation();
} }
void DestroyCompositorForShutdown() override {} void DestroyCompositorForShutdown() override {}
bool SynchronizeVisualProperties() override { bool SynchronizeVisualProperties(
const base::Optional<viz::LocalSurfaceId>&
child_allocated_local_surface_id) override {
auto* browser_compositor = view_->browser_compositor();
if (child_allocated_local_surface_id) {
browser_compositor->UpdateRendererLocalSurfaceIdFromChild(
*child_allocated_local_surface_id);
} else {
browser_compositor->AllocateNewRendererLocalSurfaceId();
}
if (auto* host = browser_compositor->GetDelegatedFrameHost()) {
host->EmbedSurface(browser_compositor->GetRendererLocalSurfaceId(),
browser_compositor->GetRendererSize(),
cc::DeadlinePolicy::UseDefaultDeadline());
}
return view_->render_widget_host()->SynchronizeVisualProperties(); return view_->render_widget_host()->SynchronizeVisualProperties();
} }
// AcceleratedWidgetMacNSView methods:
void AcceleratedWidgetCALayerParamsUpdated() override {}
private: private:
// Guaranteed to outlive this object. // Guaranteed to outlive this object.
CefRenderWidgetHostViewOSR* view_; CefRenderWidgetHostViewOSR* view_;
@@ -90,7 +91,48 @@ bool CefRenderWidgetHostViewOSR::ShouldContinueToPauseForFrame() {
return browser_compositor_->ShouldContinueToPauseForFrame(); return browser_compositor_->ShouldContinueToPauseForFrame();
} }
viz::LocalSurfaceId CefRenderWidgetHostViewOSR::GetLocalSurfaceId() const { viz::ScopedSurfaceIdAllocator
CefRenderWidgetHostViewOSR::DidUpdateVisualProperties(
const cc::RenderFrameMetadata& metadata) {
base::OnceCallback<void()> allocation_task = base::BindOnce(
base::IgnoreResult(
&CefRenderWidgetHostViewOSR::OnDidUpdateVisualPropertiesComplete),
weak_ptr_factory_.GetWeakPtr(), metadata);
return browser_compositor_->GetScopedRendererSurfaceIdAllocator(
std::move(allocation_task));
}
display::Display CefRenderWidgetHostViewOSR::GetDisplay() {
content::ScreenInfo screen_info;
GetScreenInfo(&screen_info);
// Start with a reasonable display representation.
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
// Populate attributes based on |screen_info|.
display.set_bounds(screen_info.rect);
display.set_work_area(screen_info.available_rect);
display.set_device_scale_factor(screen_info.device_scale_factor);
display.set_color_space(screen_info.color_space);
display.set_color_depth(screen_info.depth);
display.set_depth_per_component(screen_info.depth_per_component);
display.set_is_monochrome(screen_info.is_monochrome);
display.SetRotationAsDegree(screen_info.orientation_angle);
return display;
}
void CefRenderWidgetHostViewOSR::OnDidUpdateVisualPropertiesComplete(
const cc::RenderFrameMetadata& metadata) {
DCHECK_EQ(current_device_scale_factor_, metadata.device_scale_factor);
browser_compositor_->SynchronizeVisualProperties(
metadata.device_scale_factor, metadata.viewport_size_in_pixels,
metadata.local_surface_id.value_or(viz::LocalSurfaceId()));
}
const viz::LocalSurfaceId& CefRenderWidgetHostViewOSR::GetLocalSurfaceId()
const {
return browser_compositor_->GetRendererLocalSurfaceId(); return browser_compositor_->GetRendererLocalSurfaceId();
} }
@@ -129,8 +171,8 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
mac_helper_ = new MacHelper(this); mac_helper_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac( browser_compositor_.reset(new content::BrowserCompositorMac(
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true, mac_helper_, mac_helper_, render_widget_host_->is_hidden(), GetDisplay(),
GetDisplay(), AllocateFrameSinkId(is_guest_view_hack))); AllocateFrameSinkId(is_guest_view_hack)));
} }
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() { void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {

View File

@@ -135,8 +135,11 @@ void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
view->InstallTransparency(); view->InstallTransparency();
} }
void CefWebContentsViewOSR::RenderViewSwappedIn(content::RenderViewHost* host) { void CefWebContentsViewOSR::RenderViewReady() {}
}
void CefWebContentsViewOSR::RenderViewHostChanged(
content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {}
void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) {} void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) {}

View File

@@ -51,7 +51,9 @@ class CefWebContentsViewOSR : public content::WebContentsView,
content::RenderWidgetHost* render_widget_host) override; content::RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override; void SetPageTitle(const base::string16& title) override;
void RenderViewCreated(content::RenderViewHost* host) override; void RenderViewCreated(content::RenderViewHost* host) override;
void RenderViewSwappedIn(content::RenderViewHost* host) override; void RenderViewReady() override;
void RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) override;
void SetOverscrollControllerEnabled(bool enabled) override; void SetOverscrollControllerEnabled(bool enabled) override;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)

View File

@@ -259,7 +259,9 @@ void CefPrintViewManager::OnRequestPrintPreview(
} }
void CefPrintViewManager::OnMetafileReadyForPrinting( void CefPrintViewManager::OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params& params) { content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPreviewDocument_Params& params,
const PrintHostMsg_PreviewIds& ids) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
StopWorker(params.document_cookie); StopWorker(params.document_cookie);

View File

@@ -14,9 +14,10 @@
namespace content { namespace content {
class RenderFrameHost; class RenderFrameHost;
class RenderProcessHost; class RenderProcessHost;
} } // namespace content
struct PrintHostMsg_DidPreviewDocument_Params; struct PrintHostMsg_DidPreviewDocument_Params;
struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_RequestPrintPreview_Params;
namespace printing { namespace printing {
@@ -52,7 +53,9 @@ class CefPrintViewManager
void OnDidShowPrintDialog(content::RenderFrameHost* rfh); void OnDidShowPrintDialog(content::RenderFrameHost* rfh);
void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&); void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&);
void OnMetafileReadyForPrinting( void OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params&); content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPreviewDocument_Params& params,
const PrintHostMsg_PreviewIds& ids);
void TerminatePdfPrintJob(); void TerminatePdfPrintJob();

View File

@@ -281,8 +281,8 @@ void CefPrintingMessageFilter::OnUpdatePrintSettingsReply(
} }
} }
void CefPrintingMessageFilter::OnCheckForCancel(int32_t preview_ui_id, void CefPrintingMessageFilter::OnCheckForCancel(
int preview_request_id, const PrintHostMsg_PreviewIds& ids,
bool* cancel) { bool* cancel) {
*cancel = false; *cancel = false;
} }

View File

@@ -17,6 +17,7 @@
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "printing/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h"
struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_ScriptedPrint_Params; struct PrintHostMsg_ScriptedPrint_Params;
class Profile; class Profile;
@@ -74,9 +75,7 @@ class CefPrintingMessageFilter : public content::BrowserMessageFilter {
IPC::Message* reply_msg); IPC::Message* reply_msg);
// Check to see if print preview has been cancelled. // Check to see if print preview has been cancelled.
void OnCheckForCancel(int32_t preview_ui_id, void OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, bool* cancel);
int preview_request_id,
bool* cancel);
std::unique_ptr<KeyedServiceShutdownNotifier::Subscription> std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
printing_shutdown_notifier_; printing_shutdown_notifier_;

View File

@@ -66,11 +66,6 @@ void CefResourceContext::RemoveUserData(const void* key) {
content::ResourceContext::RemoveUserData(key); content::ResourceContext::RemoveUserData(key);
} }
net::HostResolver* CefResourceContext::GetHostResolver() {
CHECK(getter_.get());
return getter_->GetHostResolver();
}
net::URLRequestContext* CefResourceContext::GetRequestContext() { net::URLRequestContext* CefResourceContext::GetRequestContext() {
CHECK(getter_.get()); CHECK(getter_.get());
return getter_->GetURLRequestContext(); return getter_->GetURLRequestContext();

View File

@@ -38,7 +38,6 @@ class CefResourceContext : public content::ResourceContext {
void RemoveUserData(const void* key) override; void RemoveUserData(const void* key) override;
// ResourceContext implementation. // ResourceContext implementation.
net::HostResolver* GetHostResolver() override;
net::URLRequestContext* GetRequestContext() override; net::URLRequestContext* GetRequestContext() override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(); std::unique_ptr<net::ClientCertStore> CreateClientCertStore();

View File

@@ -21,8 +21,6 @@
#include "content/public/browser/speech_recognition_manager.h" #include "content/public/browser/speech_recognition_manager.h"
#include "content/public/browser/speech_recognition_session_context.h" #include "content/public/browser/speech_recognition_session_context.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/speech_recognition_error.h"
#include "content/public/common/speech_recognition_result.h"
using content::BrowserThread; using content::BrowserThread;
using content::SpeechRecognitionManager; using content::SpeechRecognitionManager;
@@ -52,11 +50,11 @@ void CefSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) {}
void CefSpeechRecognitionManagerDelegate::OnRecognitionResults( void CefSpeechRecognitionManagerDelegate::OnRecognitionResults(
int session_id, int session_id,
const content::SpeechRecognitionResults& result) {} const std::vector<blink::mojom::SpeechRecognitionResultPtr>& result) {}
void CefSpeechRecognitionManagerDelegate::OnRecognitionError( void CefSpeechRecognitionManagerDelegate::OnRecognitionError(
int session_id, int session_id,
const content::SpeechRecognitionError& error) {} const blink::mojom::SpeechRecognitionError& error) {}
void CefSpeechRecognitionManagerDelegate::OnAudioLevelsChange( void CefSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
int session_id, int session_id,

View File

@@ -31,10 +31,11 @@ class CefSpeechRecognitionManagerDelegate
void OnRecognitionEnd(int session_id) override; void OnRecognitionEnd(int session_id) override;
void OnRecognitionResults( void OnRecognitionResults(
int session_id, int session_id,
const content::SpeechRecognitionResults& result) override; const std::vector<blink::mojom::SpeechRecognitionResultPtr>& result)
override;
void OnRecognitionError( void OnRecognitionError(
int session_id, int session_id,
const content::SpeechRecognitionError& error) override; const blink::mojom::SpeechRecognitionError& error) override;
void OnAudioLevelsChange(int session_id, void OnAudioLevelsChange(int session_id,
float volume, float volume,
float noise_volume) override; float noise_volume) override;

View File

@@ -17,8 +17,7 @@ CertPolicy::~CertPolicy() {}
// For an allowance, we consider a given |cert| to be a match to a saved // For an allowance, we consider a given |cert| to be a match to a saved
// allowed cert if the |error| is an exact match to or subset of the errors // allowed cert if the |error| is an exact match to or subset of the errors
// in the saved CertStatus. // in the saved CertStatus.
bool CertPolicy::Check(const net::X509Certificate& cert, bool CertPolicy::Check(const net::X509Certificate& cert, int error) const {
net::CertStatus error) const {
net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256(); net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256();
const auto& allowed_iter = allowed_.find(fingerprint); const auto& allowed_iter = allowed_.find(fingerprint);
if ((allowed_iter != allowed_.end()) && (allowed_iter->second & error) && if ((allowed_iter != allowed_.end()) && (allowed_iter->second & error) &&
@@ -28,8 +27,7 @@ bool CertPolicy::Check(const net::X509Certificate& cert,
return false; return false;
} }
void CertPolicy::Allow(const net::X509Certificate& cert, void CertPolicy::Allow(const net::X509Certificate& cert, int error) {
net::CertStatus error) {
// If this same cert had already been saved with a different error status, // If this same cert had already been saved with a different error status,
// this will replace it with the new error status. // this will replace it with the new error status.
net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256(); net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256();
@@ -59,7 +57,7 @@ bool CefSSLHostStateDelegate::DidHostRunInsecureContent(
void CefSSLHostStateDelegate::AllowCert(const std::string& host, void CefSSLHostStateDelegate::AllowCert(const std::string& host,
const net::X509Certificate& cert, const net::X509Certificate& cert,
net::CertStatus error) { int error) {
cert_policy_for_host_[host].Allow(cert, error); cert_policy_for_host_[host].Allow(cert, error);
} }
@@ -84,7 +82,7 @@ void CefSSLHostStateDelegate::Clear(
SSLHostStateDelegate::CertJudgment CefSSLHostStateDelegate::QueryPolicy( SSLHostStateDelegate::CertJudgment CefSSLHostStateDelegate::QueryPolicy(
const std::string& host, const std::string& host,
const net::X509Certificate& cert, const net::X509Certificate& cert,
net::CertStatus error, int error,
bool* expired_previous_decision) { bool* expired_previous_decision) {
return cert_policy_for_host_[host].Check(cert, error) return cert_policy_for_host_[host].Check(cert, error)
? SSLHostStateDelegate::ALLOWED ? SSLHostStateDelegate::ALLOWED

View File

@@ -10,7 +10,6 @@
#include "content/public/browser/ssl_host_state_delegate.h" #include "content/public/browser/ssl_host_state_delegate.h"
#include "net/base/hash_value.h" #include "net/base/hash_value.h"
#include "net/cert/cert_status_flags.h"
#include "net/cert/x509_certificate.h" #include "net/cert/x509_certificate.h"
// Implementation based on android_webview/browser/aw_ssl_host_state_delegate.h. // Implementation based on android_webview/browser/aw_ssl_host_state_delegate.h.
@@ -25,11 +24,11 @@ class CertPolicy {
// Returns true if the user has decided to proceed through the ssl error // Returns true if the user has decided to proceed through the ssl error
// before. For a certificate to be allowed, it must not have any // before. For a certificate to be allowed, it must not have any
// *additional* errors from when it was allowed. // *additional* errors from when it was allowed.
bool Check(const net::X509Certificate& cert, net::CertStatus error) const; bool Check(const net::X509Certificate& cert, int error) const;
// Causes the policy to allow this certificate for a given |error|. And // Causes the policy to allow this certificate for a given |error|. And
// remember the user's choice. // remember the user's choice.
void Allow(const net::X509Certificate& cert, net::CertStatus error); void Allow(const net::X509Certificate& cert, int error);
// Returns true if and only if there exists a user allow exception for some // Returns true if and only if there exists a user allow exception for some
// certificate. // certificate.
@@ -37,7 +36,7 @@ class CertPolicy {
private: private:
// The set of fingerprints of allowed certificates. // The set of fingerprints of allowed certificates.
std::map<net::SHA256HashValue, net::CertStatus> allowed_; std::map<net::SHA256HashValue, int> allowed_;
}; };
} // namespace internal } // namespace internal
@@ -50,13 +49,13 @@ class CefSSLHostStateDelegate : public content::SSLHostStateDelegate {
// SSLHostStateDelegate methods: // SSLHostStateDelegate methods:
void AllowCert(const std::string& host, void AllowCert(const std::string& host,
const net::X509Certificate& cert, const net::X509Certificate& cert,
net::CertStatus error) override; int error) override;
void Clear( void Clear(
const base::Callback<bool(const std::string&)>& host_filter) override; const base::Callback<bool(const std::string&)>& host_filter) override;
content::SSLHostStateDelegate::CertJudgment QueryPolicy( content::SSLHostStateDelegate::CertJudgment QueryPolicy(
const std::string& host, const std::string& host,
const net::X509Certificate& cert, const net::X509Certificate& cert,
net::CertStatus error, int error,
bool* expired_previous_decision) override; bool* expired_previous_decision) override;
void HostRanInsecureContent(const std::string& host, void HostRanInsecureContent(const std::string& host,
int child_id, int child_id,

View File

@@ -193,11 +193,6 @@ CefStoragePartitionProxy::GetBluetoothAllowedDevicesMap() {
return parent_->GetBluetoothAllowedDevicesMap(); return parent_->GetBluetoothAllowedDevicesMap();
} }
content::BlobURLLoaderFactory*
CefStoragePartitionProxy::GetBlobURLLoaderFactory() {
return parent_->GetBlobURLLoaderFactory();
}
content::BlobRegistryWrapper* CefStoragePartitionProxy::GetBlobRegistry() { content::BlobRegistryWrapper* CefStoragePartitionProxy::GetBlobRegistry() {
return parent_->GetBlobRegistry(); return parent_->GetBlobRegistry();
} }
@@ -222,7 +217,7 @@ content::BrowserContext* CefStoragePartitionProxy::browser_context() const {
mojo::BindingId CefStoragePartitionProxy::Bind( mojo::BindingId CefStoragePartitionProxy::Bind(
int process_id, int process_id,
mojo::InterfaceRequest<content::mojom::StoragePartitionService> request) { mojo::InterfaceRequest<blink::mojom::StoragePartitionService> request) {
return parent_->Bind(process_id, std::move(request)); return parent_->Bind(process_id, std::move(request));
} }

View File

@@ -77,7 +77,6 @@ class CefStoragePartitionProxy : public content::StoragePartition {
content::PaymentAppContextImpl* GetPaymentAppContext() override; content::PaymentAppContextImpl* GetPaymentAppContext() override;
content::BroadcastChannelProvider* GetBroadcastChannelProvider() override; content::BroadcastChannelProvider* GetBroadcastChannelProvider() override;
content::BluetoothAllowedDevicesMap* GetBluetoothAllowedDevicesMap() override; content::BluetoothAllowedDevicesMap* GetBluetoothAllowedDevicesMap() override;
content::BlobURLLoaderFactory* GetBlobURLLoaderFactory() override;
content::BlobRegistryWrapper* GetBlobRegistry() override; content::BlobRegistryWrapper* GetBlobRegistry() override;
content::PrefetchURLLoaderService* GetPrefetchURLLoaderService() override; content::PrefetchURLLoaderService* GetPrefetchURLLoaderService() override;
content::CookieStoreContext* GetCookieStoreContext() override; content::CookieStoreContext* GetCookieStoreContext() override;
@@ -85,7 +84,7 @@ class CefStoragePartitionProxy : public content::StoragePartition {
content::BrowserContext* browser_context() const override; content::BrowserContext* browser_context() const override;
mojo::BindingId Bind( mojo::BindingId Bind(
int process_id, int process_id,
mojo::InterfaceRequest<content::mojom::StoragePartitionService> request) mojo::InterfaceRequest<blink::mojom::StoragePartitionService> request)
override; override;
void set_site_for_service_worker( void set_site_for_service_worker(
const GURL& site_for_service_worker) override; const GURL& site_for_service_worker) override;

View File

@@ -323,7 +323,7 @@ void CefWindowView::CreateWidget() {
}; };
Atom mwmHintsProperty = XInternAtom(display, "_MOTIF_WM_HINTS", 0); Atom mwmHintsProperty = XInternAtom(display, "_MOTIF_WM_HINTS", 0);
struct MwmHints hints; struct MwmHints hints = {};
hints.flags = MWM_HINTS_DECORATIONS; hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = 0; hints.decorations = 0;
XChangeProperty(display, window, mwmHintsProperty, mwmHintsProperty, 32, XChangeProperty(display, window, mwmHintsProperty, mwmHintsProperty, 32,

View File

@@ -96,9 +96,6 @@ CefString CefDragDataImpl::GetFragmentBaseURL() {
CefString CefDragDataImpl::GetFileName() { CefString CefDragDataImpl::GetFileName() {
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
if (data_.file_contents_content_disposition.empty())
return CefString();
base::Optional<base::FilePath> filename = base::Optional<base::FilePath> filename =
data_.GetSafeFilenameForImageFileContents(); data_.GetSafeFilenameForImageFileContents();
return filename ? CefString(filename->value()) : CefString(); return filename ? CefString(filename->value()) : CefString();

View File

@@ -43,45 +43,34 @@ import("//tools/json_schema_compiler/json_features.gni")
json_features("cef_api_features") { json_features("cef_api_features") {
feature_type = "APIFeature" feature_type = "APIFeature"
provider_class = "CefAPIFeatureProvider" method_name = "AddCEFAPIFeatures"
sources = [ sources = [
"//extensions/common/api/_api_features.json",
"_api_features.json", "_api_features.json",
] ]
} }
json_features("cef_permission_features") { json_features("cef_permission_features") {
feature_type = "PermissionFeature" feature_type = "PermissionFeature"
provider_class = "CefPermissionFeatureProvider" method_name = "AddCEFPermissionFeatures"
sources = [ sources = [
"//extensions/common/api/_permission_features.json",
"_permission_features.json", "_permission_features.json",
] ]
} }
json_features("cef_manifest_features") { json_features("cef_manifest_features") {
feature_type = "ManifestFeature" feature_type = "ManifestFeature"
provider_class = "CefManifestFeatureProvider" method_name = "AddCEFManifestFeatures"
sources = [ sources = [
# Use the same manifest features as Chrome. # Use the same manifest features as Chrome.
"//chrome/common/extensions/api/_manifest_features.json", "//chrome/common/extensions/api/_manifest_features.json",
"//extensions/common/api/_manifest_features.json",
]
}
json_features("cef_behavior_features") {
feature_type = "BehaviorFeature"
provider_class = "CefBehaviorFeatureProvider"
sources = [
"//extensions/common/api/_behavior_features.json",
] ]
} }
group("extensions_features") { group("extensions_features") {
public_deps = [ public_deps = [
":cef_api_features", ":cef_api_features",
":cef_behavior_features",
":cef_manifest_features", ":cef_manifest_features",
":cef_permission_features", ":cef_permission_features",
"//extensions/common/api:extensions_features",
] ]
} }

View File

@@ -12,6 +12,10 @@
{ {
// From chrome/common/extensions/api/_api_features.json. // From chrome/common/extensions/api/_api_features.json.
// Required by the PDF extension which is hosted in a guest view. // Required by the PDF extension which is hosted in a guest view.
"contentSettings": {
"dependencies": ["permission:contentSettings"],
"contexts": ["blessed_extension"]
},
"mimeHandlerViewGuestInternal": { "mimeHandlerViewGuestInternal": {
"internal": true, "internal": true,
"contexts": "all", "contexts": "all",

View File

@@ -12,6 +12,10 @@
{ {
// From chrome/common/extensions/api/_permission_features.json. // From chrome/common/extensions/api/_permission_features.json.
// Required by the PDF extension which is hosted in a guest view. // Required by the PDF extension which is hosted in a guest view.
"contentSettings": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
},
"resourcesPrivate": { "resourcesPrivate": {
"channel": "stable", "channel": "stable",
"extension_types": [ "extension_types": [

View File

@@ -14,16 +14,20 @@
#include "cef/grit/cef_resources.h" #include "cef/grit/cef_resources.h"
//#include "cef/libcef/common/extensions/api/generated_schemas.h" //#include "cef/libcef/common/extensions/api/generated_schemas.h"
#include "cef/libcef/common/extensions/api/cef_api_features.h" #include "cef/libcef/common/extensions/api/cef_api_features.h"
#include "cef/libcef/common/extensions/api/cef_behavior_features.h"
#include "cef/libcef/common/extensions/api/cef_manifest_features.h" #include "cef/libcef/common/extensions/api/cef_manifest_features.h"
#include "cef/libcef/common/extensions/api/cef_permission_features.h" #include "cef/libcef/common/extensions/api/cef_permission_features.h"
#include "chrome/common/extensions/chrome_aliases.h" #include "chrome/common/extensions/chrome_aliases.h"
#include "chrome/common/extensions/chrome_manifest_handlers.h" #include "chrome/common/extensions/chrome_manifest_handlers.h"
#include "chrome/grit/common_resources.h" #include "chrome/grit/common_resources.h"
#include "extensions/common/api/api_features.h"
#include "extensions/common/api/behavior_features.h"
#include "extensions/common/api/generated_schemas.h" #include "extensions/common/api/generated_schemas.h"
#include "extensions/common/api/manifest_features.h"
#include "extensions/common/api/permission_features.h"
#include "extensions/common/common_manifest_handlers.h" #include "extensions/common/common_manifest_handlers.h"
#include "extensions/common/extension_urls.h" #include "extensions/common/extension_urls.h"
#include "extensions/common/extensions_aliases.h" #include "extensions/common/extensions_aliases.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/json_feature_provider_source.h" #include "extensions/common/features/json_feature_provider_source.h"
#include "extensions/common/features/simple_feature.h" #include "extensions/common/features/simple_feature.h"
#include "extensions/common/manifest_handler.h" #include "extensions/common/manifest_handler.h"
@@ -77,15 +81,19 @@ const std::string CefExtensionsClient::GetProductName() {
std::unique_ptr<FeatureProvider> CefExtensionsClient::CreateFeatureProvider( std::unique_ptr<FeatureProvider> CefExtensionsClient::CreateFeatureProvider(
const std::string& name) const { const std::string& name) const {
std::unique_ptr<FeatureProvider> provider; auto provider = std::make_unique<FeatureProvider>();
if (name == "api") { if (name == "api") {
provider.reset(new CefAPIFeatureProvider()); AddCoreAPIFeatures(provider.get());
AddCEFAPIFeatures(provider.get());
} else if (name == "manifest") { } else if (name == "manifest") {
provider.reset(new CefManifestFeatureProvider()); AddCoreManifestFeatures(provider.get());
AddCEFManifestFeatures(provider.get());
} else if (name == "permission") { } else if (name == "permission") {
provider.reset(new CefPermissionFeatureProvider()); AddCorePermissionFeatures(provider.get());
AddCEFPermissionFeatures(provider.get());
} else if (name == "behavior") { } else if (name == "behavior") {
provider.reset(new CefBehaviorFeatureProvider()); // Note: There are no CEF-specific behavior features.
AddCoreBehaviorFeatures(provider.get());
} else { } else {
NOTREACHED(); NOTREACHED();
} }

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "libcef/common/main_delegate.h" #include "libcef/common/main_delegate.h"
#include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/common/cef_switches.h" #include "libcef/common/cef_switches.h"
@@ -12,6 +13,7 @@
#include "libcef/renderer/content_renderer_client.h" #include "libcef/renderer/content_renderer_client.h"
#include "libcef/utility/content_utility_client.h" #include "libcef/utility/content_utility_client.h"
#include "base/at_exit.h"
#include "base/base_switches.h" #include "base/base_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
@@ -39,7 +41,6 @@
#include "pdf/pdf_ppapi.h" #include "pdf/pdf_ppapi.h"
#include "services/service_manager/sandbox/switches.h" #include "services/service_manager/sandbox/switches.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
@@ -244,12 +245,9 @@ bool IsScaleFactorSupported(ui::ScaleFactor scale_factor) {
// Used to run the UI on a separate thread. // Used to run the UI on a separate thread.
class CefUIThread : public base::Thread { class CefUIThread : public base::Thread {
public: public:
CefUIThread( CefUIThread(const content::MainFunctionParams& main_function_params)
const content::MainFunctionParams& main_function_params,
std::unique_ptr<content::BrowserProcessSubThread> service_manager_thread)
: base::Thread("CefUIThread"), : base::Thread("CefUIThread"),
main_function_params_(main_function_params), main_function_params_(main_function_params) {}
service_manager_thread_(std::move(service_manager_thread)) {}
void Init() override { void Init() override {
#if defined(OS_WIN) #if defined(OS_WIN)
@@ -261,8 +259,7 @@ class CefUIThread : public base::Thread {
browser_runner_.reset(content::BrowserMainRunner::Create()); browser_runner_.reset(content::BrowserMainRunner::Create());
// Initialize browser process state. Uses the current thread's mesage loop. // Initialize browser process state. Uses the current thread's mesage loop.
int exit_code = browser_runner_->Initialize( int exit_code = browser_runner_->Initialize(main_function_params_);
main_function_params_, std::move(service_manager_thread_));
CHECK_EQ(exit_code, -1); CHECK_EQ(exit_code, -1);
} }
@@ -270,6 +267,14 @@ class CefUIThread : public base::Thread {
browser_runner_->Shutdown(); browser_runner_->Shutdown();
browser_runner_.reset(NULL); browser_runner_.reset(NULL);
// Release MessagePump resources registered with the AtExitManager.
base::MessageLoop* ml = const_cast<base::MessageLoop*>(message_loop());
base::MessageLoopCurrent::UnbindFromCurrentThreadInternal(ml);
ml->ReleasePump();
// Run exit callbacks on the UI thread to avoid sequence check failures.
base::AtExitManager::ProcessCallbacksNow();
#if defined(OS_WIN) #if defined(OS_WIN)
// Closes the COM library on the current thread. CoInitialize must // Closes the COM library on the current thread. CoInitialize must
// be balanced by a corresponding call to CoUninitialize. // be balanced by a corresponding call to CoUninitialize.
@@ -279,7 +284,6 @@ class CefUIThread : public base::Thread {
protected: protected:
content::MainFunctionParams main_function_params_; content::MainFunctionParams main_function_params_;
std::unique_ptr<content::BrowserProcessSubThread> service_manager_thread_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_; std::unique_ptr<content::BrowserMainRunner> browser_runner_;
}; };
@@ -295,6 +299,11 @@ CefMainDelegate::CefMainDelegate(CefRefPtr<CefApp> application)
CefMainDelegate::~CefMainDelegate() {} CefMainDelegate::~CefMainDelegate() {}
void CefMainDelegate::PreContentInitialization() {
// Create the main message loop.
message_loop_.reset(new CefBrowserMessageLoop());
}
bool CefMainDelegate::BasicStartupComplete(int* exit_code) { bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type = std::string process_type =
@@ -442,15 +451,13 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
base::IntToString(settings.uncaught_exception_stack_size)); base::IntToString(settings.uncaught_exception_stack_size));
} }
#if defined(OS_MACOSX)
std::vector<std::string> disable_features; std::vector<std::string> disable_features;
if (settings.windowless_rendering_enabled) { // TODO: Remove once MacV2Sandbox is supported. See issue #2459.
// Disable AsyncWheelEvents when OSR is enabled to avoid DCHECKs in if (features::kMacV2Sandbox.default_state ==
// MouseWheelEventQueue.
if (features::kAsyncWheelEvents.default_state ==
base::FEATURE_ENABLED_BY_DEFAULT) { base::FEATURE_ENABLED_BY_DEFAULT) {
disable_features.push_back(features::kAsyncWheelEvents.name); disable_features.push_back(features::kMacV2Sandbox.name);
}
} }
if (!disable_features.empty()) { if (!disable_features.empty()) {
@@ -465,6 +472,7 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
command_line->AppendSwitchASCII(switches::kDisableFeatures, command_line->AppendSwitchASCII(switches::kDisableFeatures,
disable_features_str); disable_features_str);
} }
#endif // defined(OS_MACOSX)
} }
if (content_client_.application().get()) { if (content_client_.application().get()) {
@@ -576,13 +584,6 @@ void CefMainDelegate::SandboxInitialized(const std::string& process_type) {
int CefMainDelegate::RunProcess( int CefMainDelegate::RunProcess(
const std::string& process_type, const std::string& process_type,
const content::MainFunctionParams& main_function_params) { const content::MainFunctionParams& main_function_params) {
return RunProcess(process_type, main_function_params, nullptr);
}
int CefMainDelegate::RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params,
std::unique_ptr<content::BrowserProcessSubThread> service_manager_thread) {
if (process_type.empty()) { if (process_type.empty()) {
const CefSettings& settings = CefContext::Get()->settings(); const CefSettings& settings = CefContext::Get()->settings();
if (!settings.multi_threaded_message_loop) { if (!settings.multi_threaded_message_loop) {
@@ -592,15 +593,13 @@ int CefMainDelegate::RunProcess(
// Initialize browser process state. Results in a call to // Initialize browser process state. Results in a call to
// CefBrowserMain::PreMainMessageLoopStart() which creates the UI message // CefBrowserMain::PreMainMessageLoopStart() which creates the UI message
// loop. // loop.
int exit_code = browser_runner_->Initialize( int exit_code = browser_runner_->Initialize(main_function_params);
main_function_params, std::move(service_manager_thread));
if (exit_code >= 0) if (exit_code >= 0)
return exit_code; return exit_code;
} else { } else {
// Run the UI on a separate thread. // Run the UI on a separate thread.
std::unique_ptr<base::Thread> thread; std::unique_ptr<base::Thread> thread;
thread.reset(new CefUIThread(main_function_params, thread.reset(new CefUIThread(main_function_params));
std::move(service_manager_thread)));
base::Thread::Options options; base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_UI; options.message_loop_type = base::MessageLoop::TYPE_UI;
if (!thread->StartWithOptions(options)) { if (!thread->StartWithOptions(options)) {
@@ -651,6 +650,9 @@ void CefMainDelegate::ShutdownBrowser() {
browser_runner_->Shutdown(); browser_runner_->Shutdown();
browser_runner_.reset(NULL); browser_runner_.reset(NULL);
} }
message_loop_.reset();
if (ui_thread_.get()) { if (ui_thread_.get()) {
// Blocks until the thread has stopped. // Blocks until the thread has stopped.
ui_thread_->Stop(); ui_thread_->Stop();
@@ -699,9 +701,6 @@ void CefMainDelegate::InitializeResourceBundle() {
std::string locale = command_line->GetSwitchValueASCII(switches::kLang); std::string locale = command_line->GetSwitchValueASCII(switches::kLang);
DCHECK(!locale.empty()); DCHECK(!locale.empty());
// Avoid DCHECK() in ui::ResourceBundle::LoadChromeResources().
ui::MaterialDesignController::Initialize();
const std::string loaded_locale = const std::string loaded_locale =
ui::ResourceBundle::InitSharedInstanceWithLocale( ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, &content_client_, ui::ResourceBundle::LOAD_COMMON_RESOURCES); locale, &content_client_, ui::ResourceBundle::LOAD_COMMON_RESOURCES);

View File

@@ -16,6 +16,7 @@
namespace base { namespace base {
class CommandLine; class CommandLine;
class MessageLoop;
class Thread; class Thread;
} // namespace base } // namespace base
@@ -32,16 +33,13 @@ class CefMainDelegate : public content::ContentMainDelegate {
explicit CefMainDelegate(CefRefPtr<CefApp> application); explicit CefMainDelegate(CefRefPtr<CefApp> application);
~CefMainDelegate() override; ~CefMainDelegate() override;
void PreContentInitialization() override;
bool BasicStartupComplete(int* exit_code) override; bool BasicStartupComplete(int* exit_code) override;
void PreSandboxStartup() override; void PreSandboxStartup() override;
void SandboxInitialized(const std::string& process_type) override; void SandboxInitialized(const std::string& process_type) override;
int RunProcess( int RunProcess(
const std::string& process_type, const std::string& process_type,
const content::MainFunctionParams& main_function_params) override; const content::MainFunctionParams& main_function_params) override;
int RunProcess(const std::string& process_type,
const content::MainFunctionParams& main_function_params,
std::unique_ptr<content::BrowserProcessSubThread>
service_manager_thread) override;
void ProcessExiting(const std::string& process_type) override; void ProcessExiting(const std::string& process_type) override;
#if defined(OS_LINUX) #if defined(OS_LINUX)
void ZygoteForked() override; void ZygoteForked() override;
@@ -59,6 +57,7 @@ class CefMainDelegate : public content::ContentMainDelegate {
private: private:
void InitializeResourceBundle(); void InitializeResourceBundle();
std::unique_ptr<base::MessageLoop> message_loop_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_; std::unique_ptr<content::BrowserMainRunner> browser_runner_;
std::unique_ptr<base::Thread> ui_thread_; std::unique_ptr<base::Thread> ui_thread_;

View File

@@ -34,7 +34,7 @@ std::string GenerateHeaders(const HeaderMap& map) {
void ParseHeaders(const std::string& header_str, HeaderMap& map) { void ParseHeaders(const std::string& header_str, HeaderMap& map) {
// Parse the request header values // Parse the request header values
for (net::HttpUtil::HeadersIterator i(header_str.begin(), header_str.end(), for (net::HttpUtil::HeadersIterator i(header_str.begin(), header_str.end(),
"\n"); "\n\r");
i.GetNext();) { i.GetNext();) {
map.insert(std::make_pair(i.name(), i.values())); map.insert(std::make_pair(i.name(), i.values()));
} }

View File

@@ -3,8 +3,13 @@
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "libcef/common/net/net_resource_provider.h" #include "libcef/common/net/net_resource_provider.h"
#include "libcef/common/content_client.h"
#include "chrome/common/net/net_resource_provider.h"
base::StringPiece NetResourceProvider(int key) { base::StringPiece NetResourceProvider(int key) {
return CefContentClient::Get()->GetDataResource(key, ui::SCALE_FACTOR_NONE); // Chrome performs substitution of localized strings for directory listings.
base::StringPiece value = chrome_common_net::NetResourceProvider(key);
if (value.empty())
LOG(ERROR) << "No data resource available for id " << key;
return value;
} }

View File

@@ -36,6 +36,7 @@
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h" #include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_error.h" #include "third_party/blink/public/platform/web_url_error.h"
@@ -583,7 +584,7 @@ void CefRequestImpl::Get(const CefMsg_LoadRequest_Params& params,
CefRequest::HeaderMap headerMap; CefRequest::HeaderMap headerMap;
if (!params.headers.empty()) { if (!params.headers.empty()) {
for (net::HttpUtil::HeadersIterator i(params.headers.begin(), for (net::HttpUtil::HeadersIterator i(params.headers.begin(),
params.headers.end(), "\n"); params.headers.end(), "\n\r");
i.GetNext();) { i.GetNext();) {
request.AddHTTPHeaderField(blink::WebString::FromUTF8(i.name()), request.AddHTTPHeaderField(blink::WebString::FromUTF8(i.name()),
blink::WebString::FromUTF8(i.values())); blink::WebString::FromUTF8(i.values()));

View File

@@ -173,7 +173,7 @@ void CefResponseImpl::SetResponseHeaders(
base::AutoLock lock_scope(lock_); base::AutoLock lock_scope(lock_);
CHECK_READONLY_RETURN_VOID(); CHECK_READONLY_RETURN_VOID();
header_map_.empty(); header_map_.clear();
size_t iter = 0; size_t iter = 0;
std::string name, value; std::string name, value;

View File

@@ -20,6 +20,7 @@
"renderer": [ "renderer": [
"blink.mojom.BudgetService", "blink.mojom.BudgetService",
"extensions.KeepAlive", "extensions.KeepAlive",
"extensions.mime_handler.BeforeUnloadControl",
"extensions.mime_handler.MimeHandlerService" "extensions.mime_handler.MimeHandlerService"
] ]
} }

View File

@@ -173,7 +173,7 @@ void CefValueController::TakeFrom(CefValueController* other) {
DCHECK(reference_map_.find(it->first) == reference_map_.end()); DCHECK(reference_map_.find(it->first) == reference_map_.end());
reference_map_.insert(std::make_pair(it->first, it->second)); reference_map_.insert(std::make_pair(it->first, it->second));
} }
other->reference_map_.empty(); other->reference_map_.clear();
} }
if (!other->dependency_map_.empty()) { if (!other->dependency_map_.empty()) {

View File

@@ -100,6 +100,13 @@ const char kCdmSupportedCodecAvc1[] = "avc1";
const char kCdmSupportedEncryptionSchemeCenc[] = "cenc"; const char kCdmSupportedEncryptionSchemeCenc[] = "cenc";
const char kCdmSupportedEncryptionSchemeCbcs[] = "cbcs"; const char kCdmSupportedEncryptionSchemeCbcs[] = "cbcs";
// Arguments passed to MakeCdmInfo.
struct CdmInfoArgs {
base::FilePath path;
std::string version;
content::CdmCapability capability;
};
std::unique_ptr<base::DictionaryValue> ParseManifestFile( std::unique_ptr<base::DictionaryValue> ParseManifestFile(
const base::FilePath& manifest_path) { const base::FilePath& manifest_path) {
CEF_REQUIRE_BLOCKING(); CEF_REQUIRE_BLOCKING();
@@ -183,26 +190,84 @@ bool IsCompatibleWithChrome(const base::DictionaryValue& manifest,
error_message); error_message);
} }
// Determine the set of encryption schemes supported from |manifest|. It is // Returns true and updates |video_codecs| if the appropriate manifest entry is
// assumed that all CDMs support 'cenc', so if the manifest entry // valid. Returns false and does not modify |video_codecs| if the manifest entry
// |kCdmSupportedEncryptionSchemesName| is missing, the result will indicate // is incorrectly formatted.
// support for 'cenc' only. Incorrect types in the manifest entry will log bool GetCodecs(const base::DictionaryValue& manifest,
// the error and return the empty set. Unrecognized values will be reported std::vector<media::VideoCodec>* video_codecs,
// but otherwise ignored.
base::flat_set<media::EncryptionMode> GetSupportedEncryptionSchemes(
const base::DictionaryValue& manifest,
std::string* error_message) { std::string* error_message) {
DCHECK(video_codecs);
const base::Value* value = manifest.FindKey(kCdmCodecsListName);
if (!value) {
std::stringstream ss;
ss << "Widevine CDM component manifest is missing codecs.";
*error_message = ss.str();
return true;
}
if (!value->is_string()) {
std::stringstream ss;
ss << "Manifest entry " << kCdmCodecsListName << " is not a string.";
*error_message = ss.str();
return false;
}
const std::string& codecs = value->GetString();
if (codecs.empty()) {
std::stringstream ss;
ss << "Widevine CDM component manifest has empty codecs list.";
*error_message = ss.str();
return true;
}
std::vector<media::VideoCodec> result;
const std::vector<base::StringPiece> supported_codecs =
base::SplitStringPiece(codecs, kCdmValueDelimiter, base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
for (const auto& codec : supported_codecs) {
if (codec == kCdmSupportedCodecVp8)
result.push_back(media::VideoCodec::kCodecVP8);
else if (codec == kCdmSupportedCodecVp9)
result.push_back(media::VideoCodec::kCodecVP9);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
else if (codec == kCdmSupportedCodecAvc1)
result.push_back(media::VideoCodec::kCodecH264);
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
}
video_codecs->swap(result);
return true;
}
// Returns true and updates |encryption_schemes| if the appropriate manifest
// entry is valid. Returns false and does not modify |encryption_schemes| if the
// manifest entry is incorrectly formatted. It is assumed that all CDMs support
// 'cenc', so if the manifest entry is missing, the result will indicate support
// for 'cenc' only. Incorrect types in the manifest entry will log the error and
// fail. Unrecognized values will be reported but otherwise ignored.
bool GetEncryptionSchemes(
const base::DictionaryValue& manifest,
base::flat_set<media::EncryptionMode>* encryption_schemes,
std::string* error_message) {
DCHECK(encryption_schemes);
const base::Value* value = const base::Value* value =
manifest.FindKey(kCdmSupportedEncryptionSchemesName); manifest.FindKey(kCdmSupportedEncryptionSchemesName);
if (!value) if (!value) {
return {media::EncryptionMode::kCenc}; // No manifest entry found, so assume only 'cenc' supported for backwards
// compatibility.
encryption_schemes->insert(media::EncryptionMode::kCenc);
return true;
}
if (!value->is_list()) { if (!value->is_list()) {
std::stringstream ss; std::stringstream ss;
ss << "Manifest entry " << kCdmSupportedEncryptionSchemesName ss << "Manifest entry " << kCdmSupportedEncryptionSchemesName
<< " is not a list."; << " is not a list.";
*error_message = ss.str(); *error_message = ss.str();
return {}; return false;
} }
const base::Value::ListStorage& list = value->GetList(); const base::Value::ListStorage& list = value->GetList();
@@ -213,7 +278,7 @@ base::flat_set<media::EncryptionMode> GetSupportedEncryptionSchemes(
ss << "Unrecognized item type in manifest entry " ss << "Unrecognized item type in manifest entry "
<< kCdmSupportedEncryptionSchemesName; << kCdmSupportedEncryptionSchemesName;
*error_message = ss.str(); *error_message = ss.str();
return {}; return false;
} }
const std::string& scheme = item.GetString(); const std::string& scheme = item.GetString();
@@ -225,30 +290,52 @@ base::flat_set<media::EncryptionMode> GetSupportedEncryptionSchemes(
std::stringstream ss; std::stringstream ss;
ss << "Unrecognized encryption scheme " << scheme << " in manifest entry " ss << "Unrecognized encryption scheme " << scheme << " in manifest entry "
<< kCdmSupportedEncryptionSchemesName; << kCdmSupportedEncryptionSchemesName;
if (!error_message->empty()) *error_message = ss.str();
*error_message += ", ";
*error_message += ss.str();
} }
} }
return result; // As the manifest entry exists, it must specify at least one valid value.
if (result.empty())
return false;
encryption_schemes->swap(result);
return true;
}
// Returns true and updates |session_types| if the appropriate manifest entry is
// valid. Returns false if the manifest entry is incorrectly formatted.
bool GetSessionTypes(const base::DictionaryValue& manifest,
base::flat_set<media::CdmSessionType>* session_types,
std::string* error_message) {
DCHECK(session_types);
bool is_persistent_license_supported = false;
const base::Value* value = manifest.FindKey(kCdmPersistentLicenseSupportName);
if (value) {
if (!value->is_bool())
return false;
is_persistent_license_supported = value->GetBool();
}
// Temporary session is always supported.
session_types->insert(media::CdmSessionType::kTemporary);
if (is_persistent_license_supported)
session_types->insert(media::CdmSessionType::kPersistentLicense);
return true;
} }
// Verify and load the contents of |base_path|. // Verify and load the contents of |base_path|.
cef_cdm_registration_error_t LoadWidevineCdmInfo( cef_cdm_registration_error_t LoadWidevineCdmInfo(
const base::FilePath& base_path, const base::FilePath& base_path,
base::FilePath* cdm_path, CdmInfoArgs* args,
std::string* cdm_version,
std::string* cdm_codecs,
bool* supports_persistent_license,
base::flat_set<media::EncryptionMode>* supported_encryption_schemes,
std::string* error_message) { std::string* error_message) {
std::stringstream ss; std::stringstream ss;
*cdm_path = base_path.AppendASCII( args->path = base_path.AppendASCII(
base::GetNativeLibraryName(kWidevineCdmLibraryName)); base::GetNativeLibraryName(kWidevineCdmLibraryName));
if (!base::PathExists(*cdm_path)) { if (!base::PathExists(args->path)) {
ss << "Missing file " << cdm_path->value(); ss << "Missing file " << args->path.value();
*error_message = ss.str(); *error_message = ss.str();
return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS; return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS;
} }
@@ -271,22 +358,17 @@ cef_cdm_registration_error_t LoadWidevineCdmInfo(
if (!IsCompatibleWithChrome(*manifest, error_message)) if (!IsCompatibleWithChrome(*manifest, error_message))
return CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE; return CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE;
*cdm_version = GetManifestValue(*manifest, kCdmVersionName, error_message); args->version = GetManifestValue(*manifest, kCdmVersionName, error_message);
if (cdm_version->empty()) if (args->version.empty())
return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS; return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS;
*cdm_codecs = GetManifestValue(*manifest, kCdmCodecsListName, error_message); if (!GetCodecs(*manifest, &args->capability.video_codecs, error_message) ||
if (cdm_codecs->empty()) !GetEncryptionSchemes(*manifest, &args->capability.encryption_schemes,
return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS; error_message) ||
!GetSessionTypes(*manifest, &args->capability.session_types,
const base::Value* value = error_message)) {
manifest->FindKey(kCdmPersistentLicenseSupportName);
*supports_persistent_license = value && value->is_bool() && value->GetBool();
*supported_encryption_schemes =
GetSupportedEncryptionSchemes(*manifest, error_message);
if (supported_encryption_schemes->empty())
return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS; return CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS;
}
return CEF_CDM_REGISTRATION_ERROR_NONE; return CEF_CDM_REGISTRATION_ERROR_NONE;
} }
@@ -305,54 +387,19 @@ void DeliverWidevineCdmCallback(cef_cdm_registration_error_t result,
callback->OnCdmRegistrationComplete(result, error_message); callback->OnCdmRegistrationComplete(result, error_message);
} }
std::vector<media::VideoCodec> ConvertCodecsString(const std::string& codecs) { content::CdmInfo MakeCdmInfo(const CdmInfoArgs& args) {
std::vector<media::VideoCodec> supported_video_codecs; return content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid,
const std::vector<base::StringPiece> supported_codecs = base::Version(args.version), args.path,
base::SplitStringPiece(codecs, kCdmValueDelimiter, base::TRIM_WHITESPACE, kWidevineCdmFileSystemId, args.capability,
base::SPLIT_WANT_NONEMPTY);
for (const auto& codec : supported_codecs) {
if (codec == kCdmSupportedCodecVp8)
supported_video_codecs.push_back(media::VideoCodec::kCodecVP8);
else if (codec == kCdmSupportedCodecVp9)
supported_video_codecs.push_back(media::VideoCodec::kCodecVP9);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
else if (codec == kCdmSupportedCodecAvc1)
supported_video_codecs.push_back(media::VideoCodec::kCodecH264);
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
}
return supported_video_codecs;
}
content::CdmInfo MakeCdmInfo(
const base::FilePath& cdm_path,
const std::string& cdm_version,
const std::string& cdm_codecs,
bool supports_persistent_license,
const base::flat_set<media::EncryptionMode>& supported_encryption_schemes) {
std::vector<media::VideoCodec> supported_video_codecs =
ConvertCodecsString(cdm_codecs);
return content::CdmInfo(
kWidevineCdmDisplayName, kWidevineCdmGuid, base::Version(cdm_version),
cdm_path, kWidevineCdmFileSystemId, supported_video_codecs,
supports_persistent_license, supported_encryption_schemes,
kWidevineKeySystem, false); kWidevineKeySystem, false);
} }
void RegisterWidevineCdmOnUIThread( void RegisterWidevineCdmOnUIThread(std::unique_ptr<CdmInfoArgs> args,
const base::FilePath& cdm_path,
const std::string& cdm_version,
const std::string& cdm_codecs,
bool supports_persistent_license,
const base::flat_set<media::EncryptionMode>& supported_encryption_schemes,
CefRefPtr<CefRegisterCdmCallback> callback) { CefRefPtr<CefRegisterCdmCallback> callback) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
// Register Widevine with the CdmRegistry. // Register Widevine with the CdmRegistry.
content::CdmRegistry::GetInstance()->RegisterCdm( content::CdmRegistry::GetInstance()->RegisterCdm(MakeCdmInfo(*args));
MakeCdmInfo(cdm_path, cdm_version, cdm_codecs,
supports_persistent_license, supported_encryption_schemes));
DeliverWidevineCdmCallback(CEF_CDM_REGISTRATION_ERROR_NONE, std::string(), DeliverWidevineCdmCallback(CEF_CDM_REGISTRATION_ERROR_NONE, std::string(),
callback); callback);
@@ -363,16 +410,10 @@ void LoadWidevineCdmInfoOnBlockingThread(
CefRefPtr<CefRegisterCdmCallback> callback) { CefRefPtr<CefRegisterCdmCallback> callback) {
CEF_REQUIRE_BLOCKING(); CEF_REQUIRE_BLOCKING();
base::FilePath cdm_path; std::unique_ptr<CdmInfoArgs> args = std::make_unique<CdmInfoArgs>();
std::string cdm_version;
std::string cdm_codecs;
bool supports_persistent_license;
base::flat_set<media::EncryptionMode> supported_encryption_schemes;
std::string error_message; std::string error_message;
cef_cdm_registration_error_t result = cef_cdm_registration_error_t result =
LoadWidevineCdmInfo(base_path, &cdm_path, &cdm_version, &cdm_codecs, LoadWidevineCdmInfo(base_path, args.get(), &error_message);
&supports_persistent_license,
&supported_encryption_schemes, &error_message);
if (result != CEF_CDM_REGISTRATION_ERROR_NONE) { if (result != CEF_CDM_REGISTRATION_ERROR_NONE) {
CEF_POST_TASK(CEF_UIT, base::Bind(DeliverWidevineCdmCallback, result, CEF_POST_TASK(CEF_UIT, base::Bind(DeliverWidevineCdmCallback, result,
error_message, callback)); error_message, callback));
@@ -380,10 +421,8 @@ void LoadWidevineCdmInfoOnBlockingThread(
} }
// Continue execution on the UI thread. // Continue execution on the UI thread.
CEF_POST_TASK(CEF_UIT, CEF_POST_TASK(CEF_UIT, base::Bind(RegisterWidevineCdmOnUIThread,
base::Bind(RegisterWidevineCdmOnUIThread, cdm_path, cdm_version, base::Passed(std::move(args)), callback));
cdm_codecs, supports_persistent_license,
supported_encryption_schemes, callback));
} }
} // namespace } // namespace
@@ -445,25 +484,16 @@ void CefWidevineLoader::AddContentDecryptionModules(
// Load contents of the plugin directory synchronously. This only occurs once // Load contents of the plugin directory synchronously. This only occurs once
// on zygote process startup so should not have a huge performance penalty. // on zygote process startup so should not have a huge performance penalty.
base::FilePath cdm_adapter_path; CdmInfoArgs args;
base::FilePath cdm_path;
std::string cdm_version;
std::string cdm_codecs;
bool supports_persistent_license;
base::flat_set<media::EncryptionMode> supported_encryption_schemes;
std::string error_message; std::string error_message;
cef_cdm_registration_error_t result = cef_cdm_registration_error_t result =
LoadWidevineCdmInfo(base_path, &cdm_path, &cdm_version, &cdm_codecs, LoadWidevineCdmInfo(base_path, &args, &error_message);
&supports_persistent_license,
&supported_encryption_schemes, &error_message);
if (result != CEF_CDM_REGISTRATION_ERROR_NONE) { if (result != CEF_CDM_REGISTRATION_ERROR_NONE) {
LOG(ERROR) << "Widevine CDM registration failed; " << error_message; LOG(ERROR) << "Widevine CDM registration failed; " << error_message;
return; return;
} }
cdms->push_back(MakeCdmInfo(cdm_path, cdm_version, cdm_codecs, cdms->push_back(MakeCdmInfo(args));
supports_persistent_license,
supported_encryption_schemes));
} }
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)

View File

@@ -15,9 +15,11 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "third_party/blink/public/web/web_node.h" #include "third_party/blink/public/web/web_node.h"
#include "third_party/blink/public/web/web_view_client.h" #include "third_party/blink/public/web/web_view_client.h"
#include "third_party/blink/renderer/bindings/core/v8/referrer_script_info.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h" #include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h" #include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_code_cache.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node.h" #include "third_party/blink/renderer/core/dom/node.h"
@@ -180,15 +182,15 @@ v8::MaybeLocal<v8::Value> ExecuteV8ScriptAndReturnValue(
// Based on V8ScriptRunner::CompileAndRunInternalScript: // Based on V8ScriptRunner::CompileAndRunInternalScript:
v8::ScriptCompiler::CompileOptions compile_options; v8::ScriptCompiler::CompileOptions compile_options;
blink::V8ScriptRunner::ProduceCacheOptions produce_cache_options; blink::V8CodeCache::ProduceCacheOptions produce_cache_options;
v8::ScriptCompiler::NoCacheReason no_cache_reason; v8::ScriptCompiler::NoCacheReason no_cache_reason;
std::tie(compile_options, produce_cache_options, no_cache_reason) = std::tie(compile_options, produce_cache_options, no_cache_reason) =
blink::V8ScriptRunner::GetCompileOptions(v8CacheOptions, ssc); blink::V8CodeCache::GetCompileOptions(v8CacheOptions, ssc);
// Currently internal scripts don't have cache handlers, so we should not // Currently internal scripts don't have cache handlers, so we should not
// produce cache for them. // produce cache for them.
DCHECK_EQ(produce_cache_options, DCHECK_EQ(produce_cache_options,
blink::V8ScriptRunner::ProduceCacheOptions::kNoProduceCache); blink::V8CodeCache::ProduceCacheOptions::kNoProduceCache);
v8::Local<v8::Script> script; v8::Local<v8::Script> script;
// Use default ReferrerScriptInfo here: // Use default ReferrerScriptInfo here:

View File

@@ -110,7 +110,8 @@ void CefBrowserImpl::Reload() {
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->MainFrame(); WebFrame* main_frame = render_view()->GetWebView()->MainFrame();
if (main_frame && main_frame->IsWebLocalFrame()) { if (main_frame && main_frame->IsWebLocalFrame()) {
main_frame->ToWebLocalFrame()->Reload(blink::WebFrameLoadType::kReload); main_frame->ToWebLocalFrame()->StartReload(
blink::WebFrameLoadType::kReload);
} }
} }
} }
@@ -121,7 +122,7 @@ void CefBrowserImpl::ReloadIgnoreCache() {
if (render_view()->GetWebView()) { if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->MainFrame(); WebFrame* main_frame = render_view()->GetWebView()->MainFrame();
if (main_frame && main_frame->IsWebLocalFrame()) { if (main_frame && main_frame->IsWebLocalFrame()) {
main_frame->ToWebLocalFrame()->Reload( main_frame->ToWebLocalFrame()->StartReload(
blink::WebFrameLoadType::kReloadBypassingCache); blink::WebFrameLoadType::kReloadBypassingCache);
} }
} }
@@ -313,7 +314,7 @@ void CefBrowserImpl::LoadRequest(const CefMsg_LoadRequest_Params& params) {
blink::WebURLRequest request; blink::WebURLRequest request;
CefRequestImpl::Get(params, request); CefRequestImpl::Get(params, request);
web_frame->LoadRequest(request); web_frame->StartNavigation(request);
} }
bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process, bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process,

View File

@@ -4,10 +4,24 @@
#include "libcef/renderer/extensions/extensions_dispatcher_delegate.h" #include "libcef/renderer/extensions/extensions_dispatcher_delegate.h"
#include "base/feature_list.h"
#include "chrome/grit/renderer_resources.h"
#include "extensions/common/extension_features.h"
#include "extensions/renderer/resource_bundle_source_map.h"
namespace extensions { namespace extensions {
CefExtensionsDispatcherDelegate::CefExtensionsDispatcherDelegate() {} CefExtensionsDispatcherDelegate::CefExtensionsDispatcherDelegate() {}
CefExtensionsDispatcherDelegate::~CefExtensionsDispatcherDelegate() {} CefExtensionsDispatcherDelegate::~CefExtensionsDispatcherDelegate() {}
void CefExtensionsDispatcherDelegate::PopulateSourceMap(
extensions::ResourceBundleSourceMap* source_map) {
// These bindings are unnecessary with native bindings enabled.
if (!base::FeatureList::IsEnabled(extensions::features::kNativeCrxBindings)) {
// Custom types sources.
source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS);
}
}
} // namespace extensions } // namespace extensions

View File

@@ -15,6 +15,9 @@ class CefExtensionsDispatcherDelegate : public DispatcherDelegate {
CefExtensionsDispatcherDelegate(); CefExtensionsDispatcherDelegate();
~CefExtensionsDispatcherDelegate() override; ~CefExtensionsDispatcherDelegate() override;
void PopulateSourceMap(
extensions::ResourceBundleSourceMap* source_map) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(CefExtensionsDispatcherDelegate); DISALLOW_COPY_AND_ASSIGN(CefExtensionsDispatcherDelegate);
}; };

View File

@@ -14,6 +14,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_error.h" #include "third_party/blink/public/platform/web_url_error.h"
@@ -116,7 +117,8 @@ class CefRenderURLRequest::Context
loader_ = loader_ =
CefContentRendererClient::Get()->url_loader_factory()->CreateURLLoader( CefContentRendererClient::Get()->url_loader_factory()->CreateURLLoader(
urlRequest, task_runner_.get()); urlRequest, blink::scheduler::WebResourceLoadingTaskRunnerHandle::
CreateUnprioritized(task_runner_.get()));
loader_->LoadAsynchronously(urlRequest, url_client_.get()); loader_->LoadAsynchronously(urlRequest, url_client_.get());
return true; return true;
} }

View File

@@ -314,6 +314,8 @@ class V8TrackArrayBuffer : public CefTrackNode {
buffer_(buffer), buffer_(buffer),
release_callback_(release_callback) { release_callback_(release_callback) {
DCHECK(isolate_); DCHECK(isolate_);
isolate_->AdjustAmountOfExternalAllocatedMemory(
static_cast<int>(sizeof(V8TrackArrayBuffer)));
} }
~V8TrackArrayBuffer() { ~V8TrackArrayBuffer() {
@@ -330,6 +332,13 @@ class V8TrackArrayBuffer : public CefTrackNode {
void Neuter() { buffer_ = nullptr; } void Neuter() { buffer_ = nullptr; }
// Attach this track object to the specified V8 object.
void AttachTo(v8::Local<v8::Context> context,
v8::Local<v8::ArrayBuffer> arrayBuffer) {
SetPrivate(context, arrayBuffer, kCefTrackObject,
v8::External::New(isolate_, this));
}
// Retrieve the track object for the specified V8 object. // Retrieve the track object for the specified V8 object.
static V8TrackArrayBuffer* Unwrap(v8::Local<v8::Context> context, static V8TrackArrayBuffer* Unwrap(v8::Local<v8::Context> context,
v8::Local<v8::Object> object) { v8::Local<v8::Object> object) {
@@ -341,35 +350,10 @@ class V8TrackArrayBuffer : public CefTrackNode {
return nullptr; return nullptr;
} }
// Attach this track object to the specified V8 object.
void AttachTo(v8::Local<v8::Context> context,
v8::Local<v8::ArrayBuffer> arrayBuffer) {
isolate_->AdjustAmountOfExternalAllocatedMemory(
static_cast<int>(sizeof(V8TrackArrayBuffer)));
SetPrivate(context, arrayBuffer, kCefTrackObject,
v8::External::New(isolate_, this));
handle_.Reset(isolate_, arrayBuffer);
handle_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
handle_.MarkIndependent();
}
private: private:
static void FirstWeakCallback(
const v8::WeakCallbackInfo<V8TrackArrayBuffer>& data) {
V8TrackArrayBuffer* wrapper = data.GetParameter();
if (wrapper->buffer_ != nullptr) {
wrapper->release_callback_->ReleaseBuffer(wrapper->buffer_);
wrapper->buffer_ = nullptr;
}
wrapper->handle_.Reset();
}
v8::Isolate* isolate_; v8::Isolate* isolate_;
void* buffer_; void* buffer_;
CefRefPtr<CefV8ArrayBufferReleaseCallback> release_callback_; CefRefPtr<CefV8ArrayBufferReleaseCallback> release_callback_;
v8::Persistent<v8::ArrayBuffer> handle_;
}; };
// Object wrapped in a v8::External and passed as the Data argument to // Object wrapped in a v8::External and passed as the Data argument to

View File

@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "include/base/cef_ref_counted.h" #include "include/base/cef_ref_counted.h"
#include "include/base/cef_thread_collision_warner.h"
namespace base { namespace base {

View File

@@ -1,63 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "include/base/cef_thread_collision_warner.h"
#include "include/base/cef_logging.h"
#include "include/internal/cef_thread_internal.h"
namespace base {
void DCheckAsserter::warn() {
NOTREACHED() << "Thread Collision";
}
static subtle::Atomic32 CurrentThread() {
const cef_platform_thread_id_t current_thread_id =
cef_get_current_platform_thread_id();
// We need to get the thread id into an atomic data type. This might be a
// truncating conversion, but any loss-of-information just increases the
// chance of a fault negative, not a false positive.
const subtle::Atomic32 atomic_thread_id =
static_cast<subtle::Atomic32>(current_thread_id);
return atomic_thread_id;
}
void ThreadCollisionWarner::EnterSelf() {
// If the active thread is 0 then I'll write the current thread ID
// if two or more threads arrive here only one will succeed to
// write on valid_thread_id_ the current thread ID.
subtle::Atomic32 current_thread_id = CurrentThread();
int previous_value =
subtle::NoBarrier_CompareAndSwap(&valid_thread_id_, 0, current_thread_id);
if (previous_value != 0 && previous_value != current_thread_id) {
// gotcha! a thread is trying to use the same class and that is
// not current thread.
asserter_->warn();
}
subtle::NoBarrier_AtomicIncrement(&counter_, 1);
}
void ThreadCollisionWarner::Enter() {
subtle::Atomic32 current_thread_id = CurrentThread();
if (subtle::NoBarrier_CompareAndSwap(&valid_thread_id_, 0,
current_thread_id) != 0) {
// gotcha! another thread is trying to use the same class.
asserter_->warn();
}
subtle::NoBarrier_AtomicIncrement(&counter_, 1);
}
void ThreadCollisionWarner::Leave() {
if (subtle::Barrier_AtomicIncrement(&counter_, -1) == 0) {
subtle::NoBarrier_Store(&valid_thread_id_, 0);
}
}
} // namespace base

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=1c183881e8972b65705223686ac4175b28c766ec$ // $hash=6313603a55de5caa5ab007c5a743a7223fad9717$
// //
#include "libcef_dll/ctocpp/accessibility_handler_ctocpp.h" #include "libcef_dll/ctocpp/accessibility_handler_ctocpp.h"
@@ -17,6 +17,7 @@
// VIRTUAL METHODS - Body may be edited by hand. // VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
void CefAccessibilityHandlerCToCpp::OnAccessibilityTreeChange( void CefAccessibilityHandlerCToCpp::OnAccessibilityTreeChange(
CefRefPtr<CefValue> value) { CefRefPtr<CefValue> value) {
cef_accessibility_handler_t* _struct = GetStruct(); cef_accessibility_handler_t* _struct = GetStruct();
@@ -34,6 +35,7 @@ void CefAccessibilityHandlerCToCpp::OnAccessibilityTreeChange(
_struct->on_accessibility_tree_change(_struct, CefValueCppToC::Wrap(value)); _struct->on_accessibility_tree_change(_struct, CefValueCppToC::Wrap(value));
} }
NO_SANITIZE("cfi-icall")
void CefAccessibilityHandlerCToCpp::OnAccessibilityLocationChange( void CefAccessibilityHandlerCToCpp::OnAccessibilityLocationChange(
CefRefPtr<CefValue> value) { CefRefPtr<CefValue> value) {
cef_accessibility_handler_t* _struct = GetStruct(); cef_accessibility_handler_t* _struct = GetStruct();

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=d5eaa0df7fe556b0149db7c9390935bc42f7f5f0$ // $hash=4eae7e6a1575c4ca6b59433049de3f1d7db747d7$
// //
#include "libcef_dll/ctocpp/app_ctocpp.h" #include "libcef_dll/ctocpp/app_ctocpp.h"
@@ -21,6 +21,7 @@
// VIRTUAL METHODS - Body may be edited by hand. // VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
void CefAppCToCpp::OnBeforeCommandLineProcessing( void CefAppCToCpp::OnBeforeCommandLineProcessing(
const CefString& process_type, const CefString& process_type,
CefRefPtr<CefCommandLine> command_line) { CefRefPtr<CefCommandLine> command_line) {
@@ -42,6 +43,7 @@ void CefAppCToCpp::OnBeforeCommandLineProcessing(
CefCommandLineCppToC::Wrap(command_line)); CefCommandLineCppToC::Wrap(command_line));
} }
NO_SANITIZE("cfi-icall")
void CefAppCToCpp::OnRegisterCustomSchemes( void CefAppCToCpp::OnRegisterCustomSchemes(
CefRawPtr<CefSchemeRegistrar> registrar) { CefRawPtr<CefSchemeRegistrar> registrar) {
cef_app_t* _struct = GetStruct(); cef_app_t* _struct = GetStruct();
@@ -63,6 +65,7 @@ void CefAppCToCpp::OnRegisterCustomSchemes(
_struct->on_register_custom_schemes(_struct, registrarPtr->GetStruct()); _struct->on_register_custom_schemes(_struct, registrarPtr->GetStruct());
} }
NO_SANITIZE("cfi-icall")
CefRefPtr<CefResourceBundleHandler> CefAppCToCpp::GetResourceBundleHandler() { CefRefPtr<CefResourceBundleHandler> CefAppCToCpp::GetResourceBundleHandler() {
cef_app_t* _struct = GetStruct(); cef_app_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_resource_bundle_handler)) if (CEF_MEMBER_MISSING(_struct, get_resource_bundle_handler))
@@ -78,6 +81,7 @@ CefRefPtr<CefResourceBundleHandler> CefAppCToCpp::GetResourceBundleHandler() {
return CefResourceBundleHandlerCToCpp::Wrap(_retval); return CefResourceBundleHandlerCToCpp::Wrap(_retval);
} }
NO_SANITIZE("cfi-icall")
CefRefPtr<CefBrowserProcessHandler> CefAppCToCpp::GetBrowserProcessHandler() { CefRefPtr<CefBrowserProcessHandler> CefAppCToCpp::GetBrowserProcessHandler() {
cef_app_t* _struct = GetStruct(); cef_app_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_browser_process_handler)) if (CEF_MEMBER_MISSING(_struct, get_browser_process_handler))
@@ -93,6 +97,7 @@ CefRefPtr<CefBrowserProcessHandler> CefAppCToCpp::GetBrowserProcessHandler() {
return CefBrowserProcessHandlerCToCpp::Wrap(_retval); return CefBrowserProcessHandlerCToCpp::Wrap(_retval);
} }
NO_SANITIZE("cfi-icall")
CefRefPtr<CefRenderProcessHandler> CefAppCToCpp::GetRenderProcessHandler() { CefRefPtr<CefRenderProcessHandler> CefAppCToCpp::GetRenderProcessHandler() {
cef_app_t* _struct = GetStruct(); cef_app_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_render_process_handler)) if (CEF_MEMBER_MISSING(_struct, get_render_process_handler))

View File

@@ -9,13 +9,14 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=0464376fa24627e57280c81408ff70c3c2768021$ // $hash=9447c20367d0fc32b690d08cfc152531ace25af8$
// //
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h" #include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand. // VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
void CefAuthCallbackCToCpp::Continue(const CefString& username, void CefAuthCallbackCToCpp::Continue(const CefString& username,
const CefString& password) { const CefString& password) {
cef_auth_callback_t* _struct = GetStruct(); cef_auth_callback_t* _struct = GetStruct();
@@ -30,7 +31,7 @@ void CefAuthCallbackCToCpp::Continue(const CefString& username,
_struct->cont(_struct, username.GetStruct(), password.GetStruct()); _struct->cont(_struct, username.GetStruct(), password.GetStruct());
} }
void CefAuthCallbackCToCpp::Cancel() { NO_SANITIZE("cfi-icall") void CefAuthCallbackCToCpp::Cancel() {
cef_auth_callback_t* _struct = GetStruct(); cef_auth_callback_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, cancel)) if (CEF_MEMBER_MISSING(_struct, cancel))
return; return;

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