mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium version 113.0.5672.0 (#1121455)
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
||||
#include "components/os_crypt/os_crypt.h"
|
||||
#include "components/os_crypt/sync/os_crypt.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
@@ -83,7 +83,7 @@
|
||||
#include "chrome/browser/ui/views/theme_profile_key.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/grit/chromium_strings.h"
|
||||
#include "components/os_crypt/key_storage_config_linux.h"
|
||||
#include "components/os_crypt/sync/key_storage_config_linux.h"
|
||||
#include "libcef/browser/printing/print_dialog_linux.h"
|
||||
#include "ui/base/cursor/cursor_factory.h"
|
||||
#include "ui/base/ime/input_method.h"
|
||||
|
@@ -89,6 +89,7 @@
|
||||
#include "components/pdf/browser/pdf_url_loader_request_interceptor.h"
|
||||
#include "components/pdf/browser/pdf_web_contents_helper.h"
|
||||
#include "components/pdf/common/internal_plugin_helpers.h"
|
||||
#include "components/policy/core/common/policy_pref_names.h"
|
||||
#include "components/spellcheck/common/spellcheck.mojom.h"
|
||||
#include "components/version_info/version_info.h"
|
||||
#include "content/browser/plugin_service_impl.h"
|
||||
@@ -923,8 +924,10 @@ AlloyContentBrowserClient::CreateURLLoaderThrottles(
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context);
|
||||
|
||||
chrome::mojom::DynamicParams dynamic_params = {
|
||||
profile->GetPrefs()->GetBoolean(prefs::kForceGoogleSafeSearch),
|
||||
profile->GetPrefs()->GetInteger(prefs::kForceYouTubeRestrict),
|
||||
profile->GetPrefs()->GetBoolean(
|
||||
policy::policy_prefs::kForceGoogleSafeSearch),
|
||||
profile->GetPrefs()->GetInteger(
|
||||
policy::policy_prefs::kForceYouTubeRestrict),
|
||||
profile->GetPrefs()->GetString(prefs::kAllowedDomainsForApps)};
|
||||
result.push_back(
|
||||
std::make_unique<GoogleURLLoaderThrottle>(std::move(dynamic_params)));
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "content/public/browser/network_service_instance.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "net/log/net_log_capture_mode.h"
|
||||
#include "services/device/public/cpp/geolocation/geolocation_manager.h"
|
||||
#include "services/network/public/cpp/network_switches.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
|
||||
@@ -143,6 +144,11 @@ void ChromeBrowserProcessAlloy::FlushLocalStateAndReply(
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
device::GeolocationManager* ChromeBrowserProcessAlloy::geolocation_manager() {
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
metrics_services_manager::MetricsServicesManager*
|
||||
ChromeBrowserProcessAlloy::GetMetricsServicesManager() {
|
||||
NOTREACHED();
|
||||
@@ -222,6 +228,11 @@ ChromeBrowserProcessAlloy::notification_platform_bridge() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ChromeBrowserProcessAlloy::SetGeolocationManager(
|
||||
std::unique_ptr<device::GeolocationManager> geolocation_manager) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
policy::ChromeBrowserPolicyConnector*
|
||||
ChromeBrowserProcessAlloy::browser_policy_connector() {
|
||||
if (!browser_policy_connector_) {
|
||||
@@ -416,12 +427,6 @@ ChromeBrowserProcessAlloy::hid_policy_allowed_devices() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
breadcrumbs::BreadcrumbPersistentStorageManager*
|
||||
ChromeBrowserProcessAlloy::GetBreadcrumbPersistentStorageManager() {
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HidSystemTrayIcon* ChromeBrowserProcessAlloy::hid_system_tray_icon() {
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
|
@@ -51,6 +51,7 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
|
||||
// BrowserProcess implementation.
|
||||
void EndSession() override;
|
||||
void FlushLocalStateAndReply(base::OnceClosure reply) override;
|
||||
device::GeolocationManager* geolocation_manager() override;
|
||||
metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
|
||||
override;
|
||||
metrics::MetricsService* metrics_service() override;
|
||||
@@ -65,6 +66,8 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
|
||||
extensions::EventRouterForwarder* extension_event_router_forwarder() override;
|
||||
NotificationUIManager* notification_ui_manager() override;
|
||||
NotificationPlatformBridge* notification_platform_bridge() override;
|
||||
void SetGeolocationManager(
|
||||
std::unique_ptr<device::GeolocationManager> geolocation_manager) override;
|
||||
policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
|
||||
policy::PolicyService* policy_service() override;
|
||||
IconManager* icon_manager() override;
|
||||
@@ -107,8 +110,6 @@ class ChromeBrowserProcessAlloy : public BrowserProcess {
|
||||
BuildState* GetBuildState() override;
|
||||
SerialPolicyAllowedPorts* serial_policy_allowed_ports() override;
|
||||
HidPolicyAllowedDevices* hid_policy_allowed_devices() override;
|
||||
breadcrumbs::BreadcrumbPersistentStorageManager*
|
||||
GetBreadcrumbPersistentStorageManager() override;
|
||||
HidSystemTrayIcon* hid_system_tray_icon() override;
|
||||
|
||||
private:
|
||||
|
@@ -69,9 +69,9 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() {
|
||||
TabsCreateFunction::TabsCreateFunction() : cef_details_(this) {}
|
||||
|
||||
ExtensionFunction::ResponseAction TabsCreateFunction::Run() {
|
||||
std::unique_ptr<tabs::Create::Params> params(
|
||||
tabs::Create::Params::Create(args()));
|
||||
EXTENSION_FUNCTION_VALIDATE(params.get());
|
||||
absl::optional<tabs::Create::Params> params =
|
||||
tabs::Create::Params::Create(args());
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
CefExtensionFunctionDetails::OpenTabParams options;
|
||||
options.window_id = params->create_properties.window_id;
|
||||
@@ -108,9 +108,9 @@ content::WebContents* BaseAPIFunction::GetWebContents(int tab_id) {
|
||||
}
|
||||
|
||||
ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
std::unique_ptr<tabs::Update::Params> params(
|
||||
tabs::Update::Params::Create(args()));
|
||||
EXTENSION_FUNCTION_VALIDATE(params.get());
|
||||
absl::optional<tabs::Update::Params> params =
|
||||
tabs::Update::Params::Create(args());
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
tab_id_ = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id_);
|
||||
@@ -195,8 +195,8 @@ bool TabsUpdateFunction::UpdateURL(const std::string& url_string,
|
||||
int tab_id,
|
||||
std::string* error) {
|
||||
GURL url;
|
||||
auto url_expected =
|
||||
ExtensionTabUtil::PrepareURLForNavigation(url_string, extension());
|
||||
auto url_expected = ExtensionTabUtil::PrepareURLForNavigation(
|
||||
url_string, extension(), browser_context());
|
||||
if (url_expected.has_value()) {
|
||||
url = *url_expected;
|
||||
} else {
|
||||
@@ -278,7 +278,7 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
}
|
||||
std::unique_ptr<InjectDetails> details(new InjectDetails());
|
||||
if (!InjectDetails::Populate(details_value, details.get())) {
|
||||
if (!InjectDetails::Populate(details_value.GetDict(), *details)) {
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
}
|
||||
|
||||
@@ -419,8 +419,8 @@ bool TabsRemoveCSSFunction::ShouldRemoveCSS() const {
|
||||
}
|
||||
|
||||
ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
|
||||
std::unique_ptr<tabs::SetZoom::Params> params(
|
||||
tabs::SetZoom::Params::Create(args()));
|
||||
absl::optional<tabs::SetZoom::Params> params =
|
||||
tabs::SetZoom::Params::Create(args());
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
@@ -451,8 +451,8 @@ ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
|
||||
}
|
||||
|
||||
ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
|
||||
std::unique_ptr<tabs::GetZoom::Params> params(
|
||||
tabs::GetZoom::Params::Create(args()));
|
||||
absl::optional<tabs::GetZoom::Params> params =
|
||||
tabs::GetZoom::Params::Create(args());
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
@@ -471,8 +471,8 @@ ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
|
||||
ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
|
||||
using api::tabs::ZoomSettings;
|
||||
|
||||
std::unique_ptr<tabs::SetZoomSettings::Params> params(
|
||||
tabs::SetZoomSettings::Params::Create(args()));
|
||||
absl::optional<tabs::SetZoomSettings::Params> params =
|
||||
tabs::SetZoomSettings::Params::Create(args());
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
@@ -522,8 +522,8 @@ ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
|
||||
}
|
||||
|
||||
ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
|
||||
std::unique_ptr<tabs::GetZoomSettings::Params> params(
|
||||
tabs::GetZoomSettings::Params::Create(args()));
|
||||
absl::optional<tabs::GetZoomSettings::Params> params =
|
||||
tabs::GetZoomSettings::Params::Create(args());
|
||||
EXTENSION_FUNCTION_VALIDATE(params);
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
|
@@ -325,7 +325,7 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
GURL url;
|
||||
if (params.url.has_value()) {
|
||||
auto url_expected = ExtensionTabUtil::PrepareURLForNavigation(
|
||||
*params.url, function()->extension());
|
||||
*params.url, function()->extension(), function()->browser_context());
|
||||
if (url_expected.has_value()) {
|
||||
url = *url_expected;
|
||||
} else {
|
||||
|
@@ -385,9 +385,13 @@ int CefMainRunner::ContentMainInitialize(const CefMainArgs& args,
|
||||
|
||||
bool CefMainRunner::ContentMainRun(bool* initialized,
|
||||
base::OnceClosure context_initialized) {
|
||||
main_delegate_->BeforeMainThreadRun();
|
||||
main_delegate_->BeforeMainThreadRun(multi_threaded_message_loop_);
|
||||
|
||||
if (multi_threaded_message_loop_) {
|
||||
// Detach the CommandLine from the main thread so that it can be
|
||||
// attached and modified from the UI thread going forward.
|
||||
base::CommandLine::ForCurrentProcess()->DetachFromCurrentSequence();
|
||||
|
||||
base::WaitableEvent uithread_startup_event(
|
||||
base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
||||
base::WaitableEvent::InitialState::NOT_SIGNALED);
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
#include "third_party/blink/public/common/input/web_mouse_event.h"
|
||||
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/base_event_utils.h"
|
||||
@@ -439,8 +438,7 @@ gfx::Point CefBrowserPlatformDelegateNativeMac::GetScreenPoint(
|
||||
NSPoint view_pt = {static_cast<CGFloat>(view.x()),
|
||||
bounds.size.height - static_cast<CGFloat>(view.y())};
|
||||
NSPoint window_pt = [nsview convertPoint:view_pt toView:nil];
|
||||
NSPoint screen_pt =
|
||||
ui::ConvertPointFromWindowToScreen([nsview window], window_pt);
|
||||
NSPoint screen_pt = [[nsview window] convertPointToScreen:window_pt];
|
||||
return gfx::Point(screen_pt.x, screen_pt.y);
|
||||
}
|
||||
return gfx::Point();
|
||||
|
@@ -35,7 +35,6 @@
|
||||
#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
|
||||
#include "chrome/common/buildflags.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/net/safe_search_util.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/grit/locale_settings.h"
|
||||
#include "components/certificate_transparency/pref_names.h"
|
||||
@@ -48,6 +47,7 @@
|
||||
#include "components/language/core/browser/language_prefs.h"
|
||||
#include "components/language/core/browser/pref_names.h"
|
||||
#include "components/permissions/permission_actions_history.h"
|
||||
#include "components/policy/core/common/policy_pref_names.h"
|
||||
#include "components/pref_registry/pref_registry_syncable.h"
|
||||
#include "components/prefs/json_pref_store.h"
|
||||
#include "components/prefs/pref_filter.h"
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
||||
#include "components/proxy_config/proxy_config_dictionary.h"
|
||||
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
|
||||
#include "components/safe_search_api/safe_search_util.h"
|
||||
#include "components/spellcheck/browser/pref_names.h"
|
||||
#include "components/sync_preferences/pref_service_syncable.h"
|
||||
#include "components/sync_preferences/pref_service_syncable_factory.h"
|
||||
@@ -69,7 +70,7 @@
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "components/os_crypt/os_crypt.h"
|
||||
#include "components/os_crypt/sync/os_crypt.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
||||
@@ -281,9 +282,10 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
|
||||
// Print preferences.
|
||||
// Based on ProfileImpl::RegisterProfilePrefs.
|
||||
registry->RegisterBooleanPref(prefs::kForceGoogleSafeSearch, false);
|
||||
registry->RegisterIntegerPref(prefs::kForceYouTubeRestrict,
|
||||
safe_search_util::YOUTUBE_RESTRICT_OFF);
|
||||
registry->RegisterBooleanPref(policy::policy_prefs::kForceGoogleSafeSearch,
|
||||
false);
|
||||
registry->RegisterIntegerPref(policy::policy_prefs::kForceYouTubeRestrict,
|
||||
safe_search_api::YOUTUBE_RESTRICT_OFF);
|
||||
registry->RegisterStringPref(prefs::kAllowedDomainsForApps, std::string());
|
||||
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
|
||||
registry->RegisterBooleanPref(prefs::kPrintPreviewDisabled,
|
||||
|
@@ -32,7 +32,8 @@ void AlloyMainRunnerDelegate::BeforeMainThreadInitialize(
|
||||
g_browser_process = new ChromeBrowserProcessAlloy();
|
||||
}
|
||||
|
||||
void AlloyMainRunnerDelegate::BeforeMainThreadRun() {
|
||||
void AlloyMainRunnerDelegate::BeforeMainThreadRun(
|
||||
bool multi_threaded_message_loop) {
|
||||
static_cast<ChromeBrowserProcessAlloy*>(g_browser_process)->Initialize();
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class AlloyMainRunnerDelegate : public CefMainRunnerDelegate {
|
||||
// CefMainRunnerDelegate overrides.
|
||||
content::ContentMainDelegate* GetContentMainDelegate() override;
|
||||
void BeforeMainThreadInitialize(const CefMainArgs& args) override;
|
||||
void BeforeMainThreadRun() override;
|
||||
void BeforeMainThreadRun(bool multi_threaded_message_loop) override;
|
||||
void AfterUIThreadInitialize() override;
|
||||
void AfterUIThreadShutdown() override;
|
||||
void BeforeMainThreadShutdown() override;
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "chrome/common/profiler/main_thread_stack_sampling_profiler.h"
|
||||
#include "components/keep_alive_registry/keep_alive_types.h"
|
||||
#include "components/keep_alive_registry/scoped_keep_alive.h"
|
||||
#include "components/metrics/persistent_system_profile.h"
|
||||
|
||||
ChromeMainRunnerDelegate::ChromeMainRunnerDelegate(
|
||||
CefMainRunnerHandler* runner,
|
||||
@@ -42,6 +43,16 @@ void ChromeMainRunnerDelegate::BeforeMainThreadInitialize(
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::BeforeMainThreadRun(
|
||||
bool multi_threaded_message_loop) {
|
||||
if (multi_threaded_message_loop) {
|
||||
// Detach from the main thread so that these objects can be attached and
|
||||
// modified from the UI thread going forward.
|
||||
metrics::GlobalPersistentSystemProfile::GetInstance()
|
||||
->DetachFromCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::BeforeMainMessageLoopRun(
|
||||
base::RunLoop* run_loop) {
|
||||
// The ScopedKeepAlive instance triggers shutdown logic when released on the
|
||||
|
@@ -33,6 +33,7 @@ class ChromeMainRunnerDelegate : public CefMainRunnerDelegate {
|
||||
// CefMainRunnerDelegate overrides.
|
||||
content::ContentMainDelegate* GetContentMainDelegate() override;
|
||||
void BeforeMainThreadInitialize(const CefMainArgs& args) override;
|
||||
void BeforeMainThreadRun(bool multi_threaded_message_loop) override;
|
||||
void BeforeMainMessageLoopRun(base::RunLoop* run_loop) override;
|
||||
bool HandleMainMessageLoopQuit() override;
|
||||
void BeforeUIThreadInitialize() override;
|
||||
|
@@ -21,7 +21,7 @@ class CefMainRunnerDelegate {
|
||||
virtual content::ContentMainDelegate* GetContentMainDelegate() = 0;
|
||||
|
||||
virtual void BeforeMainThreadInitialize(const CefMainArgs& args) {}
|
||||
virtual void BeforeMainThreadRun() {}
|
||||
virtual void BeforeMainThreadRun(bool multi_threaded_message_loop) {}
|
||||
virtual void BeforeMainMessageLoopRun(base::RunLoop* run_loop) {}
|
||||
virtual bool HandleMainMessageLoopQuit() { return false; }
|
||||
virtual void BeforeUIThreadInitialize() {}
|
||||
|
@@ -34,10 +34,11 @@
|
||||
#include "libcef/renderer/render_frame_util.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
|
||||
#include "base/auto_reset.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/threading/thread_local.h"
|
||||
#include "third_party/abseil-cpp/absl/base/attributes.h"
|
||||
#include "third_party/blink/public/web/blink.h"
|
||||
#include "third_party/blink/public/web/web_frame.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
@@ -83,20 +84,34 @@ bool GetPrivate(v8::Local<v8::Context> context,
|
||||
.ToLocal(result);
|
||||
}
|
||||
|
||||
// Chromium uses the default Isolate for the main render process thread and a
|
||||
// new Isolate for each WebWorker thread. Continue this pattern by tracking
|
||||
// Isolate information on a per-thread basis. This implementation will need to
|
||||
// be re-worked (perhaps using a map keyed on v8::Isolate::GetCurrent()) if
|
||||
// in the future Chromium begins using the same Isolate across multiple threads.
|
||||
class CefV8IsolateManager;
|
||||
ABSL_CONST_INIT thread_local CefV8IsolateManager* g_isolate_manager = nullptr;
|
||||
|
||||
// Manages memory and state information associated with a single Isolate.
|
||||
class CefV8IsolateManager {
|
||||
public:
|
||||
CefV8IsolateManager()
|
||||
: isolate_(v8::Isolate::GetCurrent()),
|
||||
: resetter_(&g_isolate_manager, this),
|
||||
isolate_(v8::Isolate::GetCurrent()),
|
||||
task_runner_(CEF_RENDER_TASK_RUNNER()),
|
||||
message_listener_registered_(false),
|
||||
worker_id_(0) {
|
||||
DCHECK(isolate_);
|
||||
DCHECK(task_runner_.get());
|
||||
}
|
||||
~CefV8IsolateManager() {
|
||||
~CefV8IsolateManager() = default;
|
||||
|
||||
static CefV8IsolateManager* Get() { return g_isolate_manager; }
|
||||
|
||||
void Destroy() {
|
||||
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
||||
DCHECK(context_map_.empty());
|
||||
delete this;
|
||||
}
|
||||
|
||||
scoped_refptr<CefV8ContextState> GetContextState(
|
||||
@@ -175,6 +190,8 @@ class CefV8IsolateManager {
|
||||
const GURL& worker_url() const { return worker_url_; }
|
||||
|
||||
private:
|
||||
const base::AutoReset<CefV8IsolateManager*> resetter_;
|
||||
|
||||
v8::Isolate* isolate_;
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
||||
|
||||
@@ -193,43 +210,6 @@ class CefV8IsolateManager {
|
||||
GURL worker_url_;
|
||||
};
|
||||
|
||||
// Chromium uses the default Isolate for the main render process thread and a
|
||||
// new Isolate for each WebWorker thread. Continue this pattern by tracking
|
||||
// Isolate information on a per-thread basis. This implementation will need to
|
||||
// be re-worked (perhaps using a map keyed on v8::Isolate::GetCurrent()) if
|
||||
// in the future Chromium begins using the same Isolate across multiple threads.
|
||||
class CefV8StateManager {
|
||||
public:
|
||||
CefV8StateManager() {}
|
||||
|
||||
void CreateIsolateManager() {
|
||||
DCHECK(!current_tls_.Get());
|
||||
current_tls_.Set(new CefV8IsolateManager());
|
||||
}
|
||||
|
||||
void DestroyIsolateManager() {
|
||||
DCHECK(current_tls_.Get());
|
||||
delete current_tls_.Get();
|
||||
current_tls_.Set(nullptr);
|
||||
}
|
||||
|
||||
CefV8IsolateManager* GetIsolateManager() {
|
||||
CefV8IsolateManager* manager = current_tls_.Get();
|
||||
DCHECK(manager);
|
||||
return manager;
|
||||
}
|
||||
|
||||
private:
|
||||
base::ThreadLocalPointer<CefV8IsolateManager> current_tls_;
|
||||
};
|
||||
|
||||
base::LazyInstance<CefV8StateManager>::Leaky g_v8_state =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
CefV8IsolateManager* GetIsolateManager() {
|
||||
return g_v8_state.Pointer()->GetIsolateManager();
|
||||
}
|
||||
|
||||
class V8TrackObject : public CefTrackNode {
|
||||
public:
|
||||
explicit V8TrackObject(v8::Isolate* isolate)
|
||||
@@ -810,7 +790,7 @@ void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||
v8::Local<v8::StackTrace> v8Stack = message->GetStackTrace();
|
||||
CefRefPtr<CefV8StackTrace> stackTrace =
|
||||
@@ -831,23 +811,24 @@ void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
|
||||
// Global functions.
|
||||
|
||||
void CefV8IsolateCreated() {
|
||||
g_v8_state.Pointer()->CreateIsolateManager();
|
||||
new CefV8IsolateManager();
|
||||
}
|
||||
|
||||
void CefV8IsolateDestroyed() {
|
||||
g_v8_state.Pointer()->DestroyIsolateManager();
|
||||
auto* isolate_manager = CefV8IsolateManager::Get();
|
||||
isolate_manager->Destroy();
|
||||
}
|
||||
|
||||
void CefV8ReleaseContext(v8::Local<v8::Context> context) {
|
||||
GetIsolateManager()->ReleaseContext(context);
|
||||
CefV8IsolateManager::Get()->ReleaseContext(context);
|
||||
}
|
||||
|
||||
void CefV8SetUncaughtExceptionStackSize(int stack_size) {
|
||||
GetIsolateManager()->SetUncaughtExceptionStackSize(stack_size);
|
||||
CefV8IsolateManager::Get()->SetUncaughtExceptionStackSize(stack_size);
|
||||
}
|
||||
|
||||
void CefV8SetWorkerAttributes(int worker_id, const GURL& worker_url) {
|
||||
GetIsolateManager()->SetWorkerAttributes(worker_id, worker_url);
|
||||
CefV8IsolateManager::Get()->SetWorkerAttributes(worker_id, worker_url);
|
||||
}
|
||||
|
||||
bool CefRegisterExtension(const CefString& extension_name,
|
||||
@@ -856,7 +837,7 @@ bool CefRegisterExtension(const CefString& extension_name,
|
||||
// Verify that this method was called on the correct thread.
|
||||
CEF_REQUIRE_RT_RETURN(false);
|
||||
|
||||
CefV8IsolateManager* isolate_manager = GetIsolateManager();
|
||||
auto* isolate_manager = CefV8IsolateManager::Get();
|
||||
|
||||
V8TrackString* name = new V8TrackString(extension_name);
|
||||
isolate_manager->AddGlobalTrackObject(name);
|
||||
@@ -879,7 +860,7 @@ bool CefRegisterExtension(const CefString& extension_name,
|
||||
|
||||
// Helper macros
|
||||
|
||||
#define CEF_V8_HAS_ISOLATE() (!!GetIsolateManager())
|
||||
#define CEF_V8_HAS_ISOLATE() (!!CefV8IsolateManager::Get())
|
||||
#define CEF_V8_REQUIRE_ISOLATE_RETURN(var) \
|
||||
if (!CEF_V8_HAS_ISOLATE()) { \
|
||||
NOTREACHED() << "V8 isolate is not valid"; \
|
||||
@@ -929,7 +910,7 @@ CefV8HandleBase::CefV8HandleBase(v8::Isolate* isolate,
|
||||
: isolate_(isolate) {
|
||||
DCHECK(isolate_);
|
||||
|
||||
CefV8IsolateManager* manager = GetIsolateManager();
|
||||
CefV8IsolateManager* manager = CefV8IsolateManager::Get();
|
||||
DCHECK(manager);
|
||||
DCHECK_EQ(isolate_, manager->isolate());
|
||||
|
||||
@@ -943,7 +924,7 @@ CefV8HandleBase::CefV8HandleBase(v8::Isolate* isolate,
|
||||
CefRefPtr<CefV8Context> CefV8Context::GetCurrentContext() {
|
||||
CefRefPtr<CefV8Context> context;
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(context);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
if (isolate->InContext()) {
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
context = new CefV8ContextImpl(isolate, isolate->GetCurrentContext());
|
||||
@@ -955,7 +936,7 @@ CefRefPtr<CefV8Context> CefV8Context::GetCurrentContext() {
|
||||
CefRefPtr<CefV8Context> CefV8Context::GetEnteredContext() {
|
||||
CefRefPtr<CefV8Context> context;
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(context);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
if (isolate->InContext()) {
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
context =
|
||||
@@ -967,7 +948,7 @@ CefRefPtr<CefV8Context> CefV8Context::GetEnteredContext() {
|
||||
// static
|
||||
bool CefV8Context::InContext() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(false);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
return isolate->InContext();
|
||||
}
|
||||
|
||||
@@ -1179,7 +1160,7 @@ CefV8ValueImpl::Handle::~Handle() {
|
||||
context_state_->DeleteTrackObject(tracker_);
|
||||
}
|
||||
} else {
|
||||
GetIsolateManager()->DeleteGlobalTrackObject(tracker_);
|
||||
CefV8IsolateManager::Get()->DeleteGlobalTrackObject(tracker_);
|
||||
}
|
||||
} else {
|
||||
delete tracker_;
|
||||
@@ -1235,7 +1216,7 @@ void CefV8ValueImpl::Handle::SetWeakIfNecessary() {
|
||||
// |tracker_| will be deleted when:
|
||||
// A. The process shuts down, or
|
||||
// B. SecondWeakCallback is called for the weak handle.
|
||||
GetIsolateManager()->AddGlobalTrackObject(tracker_);
|
||||
CefV8IsolateManager::Get()->AddGlobalTrackObject(tracker_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1268,7 +1249,7 @@ void CefV8ValueImpl::Handle::SecondWeakCallback(
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateUndefined() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitUndefined();
|
||||
return impl.get();
|
||||
@@ -1277,7 +1258,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateUndefined() {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateNull() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitNull();
|
||||
return impl.get();
|
||||
@@ -1286,7 +1267,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateNull() {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateBool(bool value) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitBool(value);
|
||||
return impl.get();
|
||||
@@ -1295,7 +1276,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateBool(bool value) {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateInt(int32 value) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitInt(value);
|
||||
return impl.get();
|
||||
@@ -1304,7 +1285,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateInt(int32 value) {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateUInt(uint32 value) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitUInt(value);
|
||||
return impl.get();
|
||||
@@ -1313,7 +1294,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateUInt(uint32 value) {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitDouble(value);
|
||||
return impl.get();
|
||||
@@ -1322,7 +1303,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value) {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateDate(CefBaseTime value) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
impl->InitDate(value);
|
||||
return impl.get();
|
||||
@@ -1331,7 +1312,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDate(CefBaseTime value) {
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateString(const CefString& value) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
|
||||
CefString str(value);
|
||||
impl->InitString(str);
|
||||
@@ -1344,7 +1325,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateObject(
|
||||
CefRefPtr<CefV8Interceptor> interceptor) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@@ -1395,7 +1376,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateObject(
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreateArray(int length) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@@ -1426,7 +1407,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateArrayBuffer(
|
||||
CefRefPtr<CefV8ArrayBufferReleaseCallback> release_callback) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
if (context.IsEmpty()) {
|
||||
@@ -1476,7 +1457,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateFunction(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@@ -1520,7 +1501,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateFunction(
|
||||
// static
|
||||
CefRefPtr<CefV8Value> CefV8Value::CreatePromise() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
@@ -2626,7 +2607,7 @@ bool CefV8ValueImpl::HasCaught(v8::Local<v8::Context> context,
|
||||
CefRefPtr<CefV8StackTrace> CefV8StackTrace::GetCurrent(int frame_limit) {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
|
||||
isolate, frame_limit, v8::StackTrace::kDetailed);
|
||||
|
Reference in New Issue
Block a user