diff options
Diffstat (limited to 'chromium/content/child')
21 files changed, 262 insertions, 457 deletions
diff --git a/chromium/content/child/BUILD.gn b/chromium/content/child/BUILD.gn index 171cc79c2a3..cdaf2b28aad 100644 --- a/chromium/content/child/BUILD.gn +++ b/chromium/content/child/BUILD.gn @@ -10,6 +10,13 @@ if (is_android) { import("//build/config/android/config.gni") } +# This file depends on the legacy global sources assignment filter. It should +# be converted to check target platform before assigning source files to the +# sources variable. Remove this import and set_sources_assignment_filter call +# when the file has been converted. See https://crbug.com/1018739 for details. +import("//build/config/deprecated_default_sources_assignment_filter.gni") +set_sources_assignment_filter(deprecated_default_sources_assignment_filter) + if (is_component_build) { link_target_type = "source_set" } else { @@ -69,8 +76,6 @@ target(link_target_type, "child") { "runtime_features.h", "scoped_child_process_reference.cc", "scoped_child_process_reference.h", - "thread_safe_sender.cc", - "thread_safe_sender.h", "webthemeengine_impl_android.cc", "webthemeengine_impl_android.h", "webthemeengine_impl_conversions.cc", diff --git a/chromium/content/child/DEPS b/chromium/content/child/DEPS index 1e31f84748d..a9b6a8c618c 100644 --- a/chromium/content/child/DEPS +++ b/chromium/content/child/DEPS @@ -2,7 +2,6 @@ include_rules = [ # Allow inclusion of specific components that we depend on. # See comment in content/DEPS for which components are allowed. "+components/tracing", - "+components/variations/child_process_field_trial_syncer.h", "+components/webcrypto", "+components/services/font/public", diff --git a/chromium/content/child/browser_font_resource_trusted.cc b/chromium/content/child/browser_font_resource_trusted.cc index 3a64779621c..1bafbe03eef 100644 --- a/chromium/content/child/browser_font_resource_trusted.cc +++ b/chromium/content/child/browser_font_resource_trusted.cc @@ -11,7 +11,6 @@ #include "base/strings/utf_string_conversions.h" #include "cc/paint/paint_canvas.h" #include "cc/paint/skia_paint_canvas.h" -#include "content/public/common/web_preferences.h" #include "ppapi/proxy/connection.h" #include "ppapi/shared_impl/ppapi_preferences.h" #include "ppapi/shared_impl/var.h" @@ -19,6 +18,7 @@ #include "ppapi/thunk/ppb_image_data_api.h" #include "ppapi/thunk/thunk.h" #include "skia/ext/platform_canvas.h" +#include "third_party/blink/public/common/web_preferences/web_preferences.h" #include "third_party/blink/public/platform/web_float_rect.h" #include "third_party/blink/public/platform/web_font.h" #include "third_party/blink/public/platform/web_font_description.h" @@ -44,9 +44,9 @@ namespace { // undefined reference linker error. const char kCommonScript[] = "Zyyy"; -base::string16 GetFontFromMap(const ScriptFontFamilyMap& map, +base::string16 GetFontFromMap(const blink::web_pref::ScriptFontFamilyMap& map, const std::string& script) { - ScriptFontFamilyMap::const_iterator it = map.find(script); + blink::web_pref::ScriptFontFamilyMap::const_iterator it = map.find(script); if (it != map.end()) return it->second; return base::string16(); diff --git a/chromium/content/child/child_process.cc b/chromium/content/child/child_process.cc index 1d22ba51f82..dbfebe13f13 100644 --- a/chromium/content/child/child_process.cc +++ b/chromium/content/child/child_process.cc @@ -7,6 +7,7 @@ #include <string.h> #include "base/bind.h" +#include "base/clang_profiling_buildflags.h" #include "base/lazy_instance.h" #include "base/message_loop/message_pump_type.h" #include "base/process/process_handle.h" @@ -23,6 +24,14 @@ #include "services/tracing/public/cpp/trace_startup.h" #include "third_party/blink/public/common/features.h" +#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) +#include "base/test/clang_profiling.h" +#endif + +#if defined(OS_ANDROID) +#include "content/common/android/cpu_affinity.h" +#endif + namespace content { namespace { @@ -78,6 +87,10 @@ ChildProcess::ChildProcess(base::ThreadPriority io_thread_priority, #if defined(OS_ANDROID) SetupCpuTimeMetrics(); + // For child processes, this requires allowing of the sched_setaffinity() + // syscall in the sandbox (baseline_policy_android.cc). When this call is + // removed, the sandbox allowlist should be updated too. + SetupCpuAffinityPollingOnce(); #endif // We can't recover from failing to start the IO thread. @@ -121,6 +134,13 @@ ChildProcess::~ChildProcess() { DCHECK(base::ThreadPoolInstance::Get()); base::ThreadPoolInstance::Get()->Shutdown(); } + +#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) + // Flush the profiling data to disk. Doing this manually (vs relying on this + // being done automatically when the process exits) will ensure that this data + // doesn't get lost if the process is fast killed. + base::WriteClangProfilingProfile(); +#endif } ChildThreadImpl* ChildProcess::main_thread() { diff --git a/chromium/content/child/child_process_sandbox_support_impl_mac.cc b/chromium/content/child/child_process_sandbox_support_impl_mac.cc index 4b1d573f5ea..c5c1fcb9758 100644 --- a/chromium/content/child/child_process_sandbox_support_impl_mac.cc +++ b/chromium/content/child/child_process_sandbox_support_impl_mac.cc @@ -60,9 +60,8 @@ bool WebSandboxSupportMac::LoadFont( out_descriptor); } -SkColor WebSandboxSupportMac::GetSystemColor( - blink::MacSystemColorID color_id, - blink::WebColorScheme color_scheme) { +SkColor WebSandboxSupportMac::GetSystemColor(blink::MacSystemColorID color_id, + blink::ColorScheme color_scheme) { if (!color_map_.IsValid()) { DLOG(ERROR) << "GetSystemColor does not have a valid color_map_"; return SK_ColorMAGENTA; @@ -71,11 +70,10 @@ SkColor WebSandboxSupportMac::GetSystemColor( "Light and dark color scheme system colors loaded."); base::span<const SkColor> color_map = color_map_.GetMemoryAsSpan<SkColor>( blink::kMacSystemColorIDCount * blink::kMacSystemColorSchemeCount); - base::span<const SkColor> color_map_for_scheme = - color_map.subspan(color_scheme == blink::WebColorScheme::kDark - ? blink::kMacSystemColorIDCount - : 0, - blink::kMacSystemColorIDCount); + base::span<const SkColor> color_map_for_scheme = color_map.subspan( + color_scheme == blink::ColorScheme::kDark ? blink::kMacSystemColorIDCount + : 0, + blink::kMacSystemColorIDCount); return color_map_for_scheme[static_cast<size_t>(color_id)]; } diff --git a/chromium/content/child/child_process_sandbox_support_impl_mac.h b/chromium/content/child/child_process_sandbox_support_impl_mac.h index b12e6238f07..1456f4600d6 100644 --- a/chromium/content/child/child_process_sandbox_support_impl_mac.h +++ b/chromium/content/child/child_process_sandbox_support_impl_mac.h @@ -29,7 +29,7 @@ class WebSandboxSupportMac : public blink::WebSandboxSupport { base::ScopedCFTypeRef<CTFontDescriptorRef>* out_descriptor, uint32_t* font_id) override; SkColor GetSystemColor(blink::MacSystemColorID color_id, - blink::WebColorScheme color_scheme) override; + blink::ColorScheme color_scheme) override; private: void OnGotSystemColors(base::ReadOnlySharedMemoryRegion region); diff --git a/chromium/content/child/child_thread_impl.cc b/chromium/content/child/child_thread_impl.cc index 93d09b83ffd..2a5eaf61305 100644 --- a/chromium/content/child/child_thread_impl.cc +++ b/chromium/content/child/child_thread_impl.cc @@ -45,8 +45,8 @@ #include "build/build_config.h" #include "content/child/browser_exposed_child_interfaces.h" #include "content/child/child_process.h" -#include "content/child/thread_safe_sender.h" #include "content/common/child_process.mojom.h" +#include "content/common/content_constants_internal.h" #include "content/common/field_trial_recorder.mojom.h" #include "content/common/in_process_child_thread_params.h" #include "content/common/mojo_core_library_support.h" @@ -74,7 +74,6 @@ #include "services/device/public/cpp/power_monitor/power_monitor_broadcast_source.h" #include "services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" -#include "services/service_manager/embedder/switches.h" #include "services/tracing/public/cpp/background_tracing/background_tracing_agent_impl.h" #include "services/tracing/public/cpp/background_tracing/background_tracing_agent_provider_impl.h" @@ -226,9 +225,8 @@ mojo::IncomingInvitation InitializeMojoIPCChannel() { endpoint = mojo::PlatformChannelEndpoint(mojo::PlatformHandle(std::move(receive))); #elif defined(OS_POSIX) - endpoint = mojo::PlatformChannelEndpoint(mojo::PlatformHandle( - base::ScopedFD(base::GlobalDescriptors::GetInstance()->Get( - service_manager::kMojoIPCChannel)))); + endpoint = mojo::PlatformChannelEndpoint(mojo::PlatformHandle(base::ScopedFD( + base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel)))); #endif return mojo::IncomingInvitation::Accept( @@ -246,13 +244,11 @@ class ChildThreadImpl::IOThreadState scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner, base::WeakPtr<ChildThreadImpl> weak_main_thread, base::RepeatingClosure quit_closure, - ChildThreadImpl::Options::ServiceBinder service_binder, - mojo::PendingReceiver<mojom::ChildProcessHost> host_receiver) + ChildThreadImpl::Options::ServiceBinder service_binder) : main_thread_task_runner_(std::move(main_thread_task_runner)), weak_main_thread_(std::move(weak_main_thread)), quit_closure_(std::move(quit_closure)), - service_binder_(std::move(service_binder)), - host_receiver_(std::move(host_receiver)) {} + service_binder_(std::move(service_binder)) {} // Used only in the deprecated Service Manager IPC mode. void BindChildProcessReceiver( @@ -284,14 +280,6 @@ class ChildThreadImpl::IOThreadState ~IOThreadState() override = default; // mojom::ChildProcess: - void Initialize(mojo::PendingRemote<mojom::ChildProcessHostBootstrap> - bootstrap) override { - // The browser only calls this method once. - DCHECK(host_receiver_); - mojo::Remote<mojom::ChildProcessHostBootstrap>(std::move(bootstrap)) - ->BindProcessHost(std::move(host_receiver_)); - } - void ProcessShutdown() override { main_thread_task_runner_->PostTask(FROM_HERE, base::BindOnce(quit_closure_)); @@ -407,7 +395,6 @@ class ChildThreadImpl::IOThreadState mojo::BinderMap interface_binders_; bool wait_for_interface_binders_ = true; mojo::Receiver<mojom::ChildProcess> receiver_{this}; - mojo::PendingReceiver<mojom::ChildProcessHost> host_receiver_; // The pending legacy IPC channel endpoint to fuse with one we will eventually // receiver on the ChildProcess interface. Only used when not in the @@ -513,14 +500,9 @@ ChildThreadImpl::ChildThreadImpl(base::RepeatingClosure quit_closure, channel_connected_factory_( new base::WeakPtrFactory<ChildThreadImpl>(this)), ipc_task_runner_(options.ipc_task_runner) { - mojo::PendingRemote<mojom::ChildProcessHost> remote_host; - auto host_receiver = remote_host.InitWithNewPipeAndPassReceiver(); - child_process_host_ = mojo::SharedRemote<mojom::ChildProcessHost>( - std::move(remote_host), GetIOTaskRunner()); io_thread_state_ = base::MakeRefCounted<IOThreadState>( base::ThreadTaskRunnerHandle::Get(), weak_factory_.GetWeakPtr(), - quit_closure_, std::move(options.service_binder), - std::move(host_receiver)); + quit_closure_, std::move(options.service_binder)); // |ExposeInterfacesToBrowser()| must be called exactly once. Subclasses which // set |exposes_interfaces_to_browser| in Options signify that they take @@ -575,10 +557,8 @@ void ChildThreadImpl::Init(const Options& options) { IPC::Logging::GetInstance()->SetIPCSender(this); #endif - // Only one of these will be made valid by the block below. This determines - // whether we were launched in normal IPC mode or deprecated Service Manager - // IPC mode. - mojo::ScopedMessagePipeHandle child_process_pipe; + mojo::ScopedMessagePipeHandle child_process_pipe_for_receiver; + mojo::ScopedMessagePipeHandle child_process_host_pipe_for_remote; if (!IsInBrowserProcess()) { // If using a shared Mojo Core library, IPC support is already initialized. if (!IsMojoCoreSharedLibraryEnabled()) { @@ -594,14 +574,27 @@ void ChildThreadImpl::Init(const Options& options) { mojo::core::ScopedIPCSupport::ShutdownPolicy::FAST); } mojo::IncomingInvitation invitation = InitializeMojoIPCChannel(); - child_process_pipe = invitation.ExtractMessagePipe(0); + child_process_pipe_for_receiver = + invitation.ExtractMessagePipe(kChildProcessReceiverAttachmentName); + child_process_host_pipe_for_remote = + invitation.ExtractMessagePipe(kChildProcessHostRemoteAttachmentName); } else { - child_process_pipe = options.mojo_invitation->ExtractMessagePipe(0); + child_process_pipe_for_receiver = + options.mojo_invitation->ExtractMessagePipe( + kChildProcessReceiverAttachmentName); + child_process_host_pipe_for_remote = + options.mojo_invitation->ExtractMessagePipe( + kChildProcessHostRemoteAttachmentName); } + // Now that we've recovered the message pipe for the ChildProcessHost, build + // our |child_process_host_| with it. + mojo::PendingRemote<mojom::ChildProcessHost> remote_host( + std::move(child_process_host_pipe_for_remote), /*version=*/0u); + child_process_host_ = mojo::SharedRemote<mojom::ChildProcessHost>( + std::move(remote_host), GetIOTaskRunner()); + sync_message_filter_ = channel_->CreateSyncMessageFilter(); - thread_safe_sender_ = - new ThreadSafeSender(main_thread_runner_, sync_message_filter_.get()); // In single process mode, browser-side tracing and memory will cover the // whole process including renderers. @@ -645,7 +638,7 @@ void ChildThreadImpl::Init(const Options& options) { channel_->AddFilter(startup_filter); } - DCHECK(child_process_pipe.is_valid()); + DCHECK(child_process_pipe_for_receiver.is_valid()); mojo::PendingRemote<IPC::mojom::ChannelBootstrap> legacy_ipc_bootstrap; mojo::ScopedMessagePipeHandle legacy_ipc_channel_handle = legacy_ipc_bootstrap.InitWithNewPipeAndPassReceiver().PassPipe(); @@ -661,7 +654,7 @@ void ChildThreadImpl::Init(const Options& options) { base::BindOnce(&IOThreadState::BindChildProcessReceiverAndLegacyIpc, io_thread_state_, mojo::PendingReceiver<mojom::ChildProcess>( - std::move(child_process_pipe)), + std::move(child_process_pipe_for_receiver)), std::move(legacy_ipc_bootstrap))); int connection_timeout = kConnectionTimeoutS; @@ -775,14 +768,6 @@ IPC::MessageRouter* ChildThreadImpl::GetRouter() { return &router_; } -mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() { - if (!remote_route_provider_) { - DCHECK(channel_); - channel_->GetRemoteAssociatedInterface(&remote_route_provider_); - } - return remote_route_provider_.get(); -} - bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { if (msg.routing_id() == MSG_ROUTING_CONTROL) return OnControlMessageReceived(msg); @@ -793,17 +778,10 @@ bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { void ChildThreadImpl::OnAssociatedInterfaceRequest( const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle handle) { - if (interface_name == mojom::RouteProvider::Name_) { - DCHECK(!route_provider_receiver_.is_bound()); - route_provider_receiver_.Bind( - mojo::PendingAssociatedReceiver<mojom::RouteProvider>( - std::move(handle)), - ipc_task_runner_ ? ipc_task_runner_ - : base::ThreadTaskRunnerHandle::Get()); - } else { - LOG(ERROR) << "Receiver for unknown Channel-associated interface: " - << interface_name; - } + // All associated interfaces are requested through RenderThreadImpl. + LOG(ERROR) << "Receiver for unknown Channel-associated interface: " + << interface_name; + NOTREACHED(); } void ChildThreadImpl::ExposeInterfacesToBrowser(mojo::BinderMap binders) { @@ -861,27 +839,18 @@ void ChildThreadImpl::EnsureConnected() { base::Process::TerminateCurrentProcessImmediately(0); } -void ChildThreadImpl::GetRoute( - int32_t routing_id, - mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider> - receiver) { - associated_interface_provider_receivers_.Add(this, std::move(receiver), - routing_id); +bool ChildThreadImpl::IsInBrowserProcess() const { + return static_cast<bool>(browser_process_io_runner_); } void ChildThreadImpl::GetAssociatedInterface( + int32_t routing_id, const std::string& name, mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterface> receiver) { - int32_t routing_id = - associated_interface_provider_receivers_.current_context(); Listener* route = router_.GetRoute(routing_id); if (route) route->OnAssociatedInterfaceRequest(name, receiver.PassHandle()); } -bool ChildThreadImpl::IsInBrowserProcess() const { - return static_cast<bool>(browser_process_io_runner_); -} - } // namespace content diff --git a/chromium/content/child/child_thread_impl.h b/chromium/content/child/child_thread_impl.h index 090be911261..bd07f46554d 100644 --- a/chromium/content/child/child_thread_impl.h +++ b/chromium/content/child/child_thread_impl.h @@ -62,15 +62,11 @@ class BackgroundTracingAgentProviderImpl; namespace content { class InProcessChildThreadParams; -class ThreadSafeSender; // The main thread of a child process derives from this class. -class CONTENT_EXPORT ChildThreadImpl - : public IPC::Listener, - virtual public ChildThread, - private base::FieldTrialList::Observer, - public mojom::RouteProvider, - public blink::mojom::AssociatedInterfaceProvider { +class CONTENT_EXPORT ChildThreadImpl : public IPC::Listener, + virtual public ChildThread, + private base::FieldTrialList::Observer { public: struct CONTENT_EXPORT Options; @@ -112,19 +108,10 @@ class CONTENT_EXPORT ChildThreadImpl IPC::MessageRouter* GetRouter(); - mojom::RouteProvider* GetRemoteRouteProvider(); - IPC::SyncMessageFilter* sync_message_filter() const { return sync_message_filter_.get(); } - // The getter should only be called on the main thread, however the - // IPC::Sender it returns may be safely called on any thread including - // the main thread. - ThreadSafeSender* thread_safe_sender() const { - return thread_safe_sender_.get(); - } - scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner() const { return main_thread_runner_; } @@ -174,7 +161,20 @@ class CONTENT_EXPORT ChildThreadImpl bool IsInBrowserProcess() const; + void GetAssociatedInterface( + int32_t routing_id, + const std::string& name, + mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterface> + receiver); + private: + // TODO(crbug.com/1111231): This class is a friend so that it can call our + // private mojo implementation methods, acting as a pass-through. This is only + // necessary during the associated interface migration, after which, + // AgentSchedulingGroup will not act as a pass-through to the private methods + // here. At that point we'll remove this friend class. + friend class AgentSchedulingGroup; + class IOThreadState; class ChildThreadMessageRouter : public IPC::MessageRouter { @@ -196,30 +196,12 @@ class CONTENT_EXPORT ChildThreadImpl void EnsureConnected(); - // mojom::RouteProvider: - void GetRoute( - int32_t routing_id, - mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider> - receiver) override; - - // blink::mojom::AssociatedInterfaceProvider: - void GetAssociatedInterface( - const std::string& name, - mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterface> - receiver) override; - #if defined(OS_WIN) const mojo::Remote<mojom::FontCacheWin>& GetFontCacheWin(); #endif base::Thread mojo_ipc_thread_{"Mojo IPC"}; std::unique_ptr<mojo::core::ScopedIPCSupport> mojo_ipc_support_; - - mojo::AssociatedReceiver<mojom::RouteProvider> route_provider_receiver_{this}; - mojo::AssociatedReceiverSet<blink::mojom::AssociatedInterfaceProvider, - int32_t> - associated_interface_provider_receivers_; - mojo::AssociatedRemote<mojom::RouteProvider> remote_route_provider_; #if defined(OS_WIN) mutable mojo::Remote<mojom::FontCacheWin> font_cache_win_; #endif @@ -229,8 +211,6 @@ class CONTENT_EXPORT ChildThreadImpl // Allows threads other than the main thread to send sync messages. scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; - scoped_refptr<ThreadSafeSender> thread_safe_sender_; - // Implements message routing functionality to the consumers of // ChildThreadImpl. ChildThreadMessageRouter router_; @@ -260,7 +240,7 @@ class CONTENT_EXPORT ChildThreadImpl // An interface to the browser's process host object. mojo::SharedRemote<mojom::ChildProcessHost> child_process_host_; - // ChlidThreadImpl state which lives on the IO thread, including its + // ChildThreadImpl state which lives on the IO thread, including its // implementation of the mojom ChildProcess interface. scoped_refptr<IOThreadState> io_thread_state_; diff --git a/chromium/content/child/field_trial.cc b/chromium/content/child/field_trial.cc index 48a202e95c2..737f452d295 100644 --- a/chromium/content/child/field_trial.cc +++ b/chromium/content/child/field_trial.cc @@ -10,9 +10,9 @@ #include "base/macros.h" #include "base/metrics/field_trial.h" #include "build/build_config.h" +#include "content/public/common/content_descriptors.h" #include "content/public/common/content_switch_dependent_feature_overrides.h" #include "content/public/common/content_switches.h" -#include "services/service_manager/embedder/descriptors.h" namespace content { @@ -41,8 +41,7 @@ void InitializeFieldTrialAndFeatureList() { // On POSIX systems that use the zygote, we get the trials from a shared // memory segment backed by an fd instead of the command line. base::FieldTrialList::CreateTrialsFromCommandLine( - command_line, switches::kFieldTrialHandle, - service_manager::kFieldTrialDescriptor); + command_line, switches::kFieldTrialHandle, kFieldTrialDescriptor); #endif std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); diff --git a/chromium/content/child/runtime_features.cc b/chromium/content/child/runtime_features.cc index e5c0d9cb89d..5772c39cdc5 100644 --- a/chromium/content/child/runtime_features.cc +++ b/chromium/content/child/runtime_features.cc @@ -18,7 +18,6 @@ #include "content/common/content_switches_internal.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" -#include "content/public/common/referrer.h" #include "device/fido/features.h" #include "device/gamepad/public/cpp/gamepad_features.h" #include "gpu/config/gpu_switches.h" @@ -26,8 +25,8 @@ #include "net/base/features.h" #include "services/device/public/cpp/device_features.h" #include "services/network/public/cpp/features.h" -#include "services/network/public/cpp/network_switches.h" #include "third_party/blink/public/common/features.h" +#include "third_party/blink/public/common/loader/referrer_utils.h" #include "third_party/blink/public/common/switches.h" #include "third_party/blink/public/platform/web_runtime_features.h" #include "ui/accessibility/accessibility_features.h" @@ -137,19 +136,23 @@ void SetRuntimeFeatureDefaultsForPlatform( } enum RuntimeFeatureEnableOptions { - // Always set the Blink feature to the enabled state of the base::Feature. - // Example: A run time feature that is completely controlled - // by base::Feature. - kUseFeatureState, - // Enables the Blink feature when the base::Feature is enabled, - // otherwise no change. - kEnableOnly, - // Enables the Blink feature when the base::Feature is enabled - // via an override on the command-line, otherwise no change. - kEnableOnlyIfOverriddenFromCommandLine, - // Disables the Blink feature when the base::Feature is *disabled*, - // otherwise no change. - kDisableOnly, + // - If the base::Feature default is overridden by field trial or command + // line, set Blink feature to the state of the base::Feature; + // - Otherwise if the base::Feature is enabled, enable the Blink feature. + // - Otherwise no change. + kDefault, + // Enables the Blink feature when the base::Feature is overridden by field + // trial or command line. Otherwise no change. Its difference from kDefault is + // that the Blink feature isn't affected by the default state of the + // base::Feature. This is useful for Blink origin trial features especially + // those implemented in both Chromium and Blink. As origin trial only controls + // the Blink features, for now we require the base::Feature to be enabled by + // default, but we don't want the default enabled status affect the Blink + // feature. See also https://crbug.com/1048656#c10. + // This can also be used for features that are enabled by default in Chromium + // but not in Blink on all platforms and we want to use the Blink status. + // However, we would prefer consistent Chromium and Blink status to this. + kSetOnlyIfOverridden, }; template <typename T> @@ -161,7 +164,7 @@ struct RuntimeFeatureToChromiumFeatureMap { T feature_enabler; // The chromium base::Feature to check. const base::Feature& chromium_feature; - const RuntimeFeatureEnableOptions option; + const RuntimeFeatureEnableOptions option = kDefault; }; template <typename Enabler> @@ -170,25 +173,19 @@ void SetRuntimeFeatureFromChromiumFeature(const base::Feature& chromium_feature, const Enabler& enabler) { using FeatureList = base::FeatureList; const bool feature_enabled = FeatureList::IsEnabled(chromium_feature); + const bool is_overridden = + FeatureList::GetInstance()->IsFeatureOverridden(chromium_feature.name); switch (option) { - case kEnableOnly: - if (feature_enabled) - enabler(true); + case kSetOnlyIfOverridden: + if (is_overridden) + enabler(feature_enabled); break; - case kEnableOnlyIfOverriddenFromCommandLine: - if (FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine( - chromium_feature.name, FeatureList::OVERRIDE_ENABLE_FEATURE)) { - DCHECK(feature_enabled); - enabler(true); - } - break; - case kDisableOnly: - if (!feature_enabled) - enabler(false); - break; - case kUseFeatureState: - enabler(feature_enabled); + case kDefault: + if (feature_enabled || is_overridden) + enabler(feature_enabled); break; + default: + NOTREACHED(); } } @@ -205,148 +202,120 @@ void SetRuntimeFeaturesFromChromiumFeatures() { blinkFeatureToBaseFeatureMapping[] = { // TODO(rodneyding): Sort features in alphabetical order - {wf::EnableWebUsb, features::kWebUsb, kDisableOnly}, + {wf::EnableWebUsb, features::kWebUsb}, {wf::EnableBlockingFocusWithoutUserActivation, - blink::features::kBlockingFocusWithoutUserActivation, kEnableOnly}, + blink::features::kBlockingFocusWithoutUserActivation}, {wf::EnableNotificationContentImage, features::kNotificationContentImage, - kDisableOnly}, - {wf::EnablePeriodicBackgroundSync, features::kPeriodicBackgroundSync, - kEnableOnly}, - {wf::EnableWebXR, features::kWebXr, kUseFeatureState}, - {wf::EnableWebXRARModule, features::kWebXrArModule, kUseFeatureState}, - {wf::EnableWebXRHitTest, features::kWebXrHitTest, kUseFeatureState}, - {wf::EnableWebXRAnchors, features::kWebXrIncubations, kEnableOnly}, - {wf::EnableWebXRCameraAccess, features::kWebXrIncubations, kEnableOnly}, - {wf::EnableWebXRLightEstimation, features::kWebXrIncubations, kEnableOnly}, - {wf::EnableWebXRPlaneDetection, features::kWebXrIncubations, kEnableOnly}, - {wf::EnableWebXRReflectionEstimation, features::kWebXrIncubations, - kEnableOnly}, + kSetOnlyIfOverridden}, + {wf::EnablePeriodicBackgroundSync, features::kPeriodicBackgroundSync}, + {wf::EnableWebXR, features::kWebXr}, + {wf::EnableWebXRARModule, features::kWebXrArModule}, + {wf::EnableWebXRHitTest, features::kWebXrHitTest}, + {wf::EnableWebXRAnchors, features::kWebXrIncubations}, + {wf::EnableWebXRCameraAccess, features::kWebXrIncubations}, + {wf::EnableWebXRDepth, features::kWebXrIncubations}, + {wf::EnableWebXRLightEstimation, features::kWebXrIncubations}, + {wf::EnableWebXRPlaneDetection, features::kWebXrIncubations}, + {wf::EnableWebXRReflectionEstimation, features::kWebXrIncubations}, {wf::EnableUserActivationSameOriginVisibility, - features::kUserActivationSameOriginVisibility, kUseFeatureState}, + features::kUserActivationSameOriginVisibility}, {wf::EnableExpensiveBackgroundTimerThrottling, - features::kExpensiveBackgroundTimerThrottling, kUseFeatureState}, + features::kExpensiveBackgroundTimerThrottling}, {wf::EnableTimerThrottlingForHiddenFrames, - features::kTimerThrottlingForHiddenFrames, kUseFeatureState}, + features::kTimerThrottlingForHiddenFrames}, {wf::EnableSendBeaconThrowForBlobWithNonSimpleType, - features::kSendBeaconThrowForBlobWithNonSimpleType, kEnableOnly}, - {wf::EnablePaymentRequest, features::kWebPayments, kUseFeatureState}, + features::kSendBeaconThrowForBlobWithNonSimpleType}, + {wf::EnablePaymentRequest, features::kWebPayments}, {wf::EnableSecurePaymentConfirmationDebug, - features::kSecurePaymentConfirmationDebug, kUseFeatureState}, - {wf::EnablePaymentHandlerMinimalUI, features::kWebPaymentsMinimalUI, - kEnableOnly}, - {wf::EnablePaymentApp, features::kServiceWorkerPaymentApps, kEnableOnly}, + features::kSecurePaymentConfirmationDebug}, + {wf::EnablePaymentHandlerMinimalUI, features::kWebPaymentsMinimalUI}, + {wf::EnablePaymentApp, features::kServiceWorkerPaymentApps}, {wf::EnablePushSubscriptionChangeEvent, - features::kPushSubscriptionChangeEvent, kEnableOnly}, - {wf::EnableGenericSensorExtraClasses, features::kGenericSensorExtraClasses, - kEnableOnly}, - {wf::EnableMediaCastOverlayButton, media::kMediaCastOverlayButton, - kUseFeatureState}, + features::kPushSubscriptionChangeEvent}, + {wf::EnableGenericSensorExtraClasses, features::kGenericSensorExtraClasses}, + {wf::EnableMediaCastOverlayButton, media::kMediaCastOverlayButton}, {wf::EnableLazyInitializeMediaControls, - features::kLazyInitializeMediaControls, kUseFeatureState}, + features::kLazyInitializeMediaControls}, {wf::EnableMediaEngagementBypassAutoplayPolicies, - media::kMediaEngagementBypassAutoplayPolicies, kUseFeatureState}, - {wf::EnableOverflowIconsForMediaControls, - media::kOverflowIconsForMediaControls, kUseFeatureState}, + media::kMediaEngagementBypassAutoplayPolicies}, {wf::EnableAllowActivationDelegationAttr, - features::kAllowActivationDelegationAttr, kUseFeatureState}, - {wf::EnableLazyFrameLoading, features::kLazyFrameLoading, kUseFeatureState}, + features::kAllowActivationDelegationAttr}, + {wf::EnableLazyFrameLoading, features::kLazyFrameLoading}, {wf::EnableLazyFrameVisibleLoadTimeMetrics, - features::kLazyFrameVisibleLoadTimeMetrics, kUseFeatureState}, - {wf::EnableLazyImageLoading, features::kLazyImageLoading, kUseFeatureState}, + features::kLazyFrameVisibleLoadTimeMetrics}, + {wf::EnableLazyImageLoading, features::kLazyImageLoading}, {wf::EnableLazyImageVisibleLoadTimeMetrics, - features::kLazyImageVisibleLoadTimeMetrics, kUseFeatureState}, - {wf::EnablePictureInPicture, media::kPictureInPicture, kUseFeatureState}, - {wf::EnableCacheInlineScriptCode, features::kCacheInlineScriptCode, - kUseFeatureState}, + features::kLazyImageVisibleLoadTimeMetrics}, + {wf::EnablePictureInPicture, media::kPictureInPicture}, + {wf::EnableCacheInlineScriptCode, features::kCacheInlineScriptCode}, {wf::EnableExperimentalProductivityFeatures, - features::kExperimentalProductivityFeatures, kEnableOnly}, - {wf::EnableFeaturePolicyForSandbox, features::kFeaturePolicyForSandbox, - kEnableOnly}, - {wf::EnableAccessibilityExposeARIAAnnotations, - features::kEnableAccessibilityExposeARIAAnnotations, kEnableOnly}, + features::kExperimentalProductivityFeatures}, + {wf::EnableFeaturePolicyForSandbox, features::kFeaturePolicyForSandbox}, {wf::EnableAccessibilityExposeDisplayNone, - features::kEnableAccessibilityExposeDisplayNone, kEnableOnly}, + features::kEnableAccessibilityExposeDisplayNone}, {wf::EnableAccessibilityExposeHTMLElement, - features::kEnableAccessibilityExposeHTMLElement, kUseFeatureState}, + features::kEnableAccessibilityExposeHTMLElement}, + {wf::EnableAccessibilityUseAXPositionForDocumentMarkers, + features::kUseAXPositionForDocumentMarkers}, {wf::EnableAllowSyncXHRInPageDismissal, - blink::features::kAllowSyncXHRInPageDismissal, kEnableOnly}, - {wf::EnableAutoplayIgnoresWebAudio, media::kAutoplayIgnoreWebAudio, - kUseFeatureState}, - {wf::EnablePortals, blink::features::kPortals, - kEnableOnlyIfOverriddenFromCommandLine}, - {wf::EnableImplicitRootScroller, blink::features::kImplicitRootScroller, - kUseFeatureState}, + blink::features::kAllowSyncXHRInPageDismissal}, + {wf::EnableAutoplayIgnoresWebAudio, media::kAutoplayIgnoreWebAudio}, + {wf::EnablePortals, blink::features::kPortals, kSetOnlyIfOverridden}, + {wf::EnableImplicitRootScroller, blink::features::kImplicitRootScroller}, {wf::EnableCSSOMViewScrollCoordinates, - blink::features::kCSSOMViewScrollCoordinates, kEnableOnly}, - {wf::EnableTextFragmentAnchor, blink::features::kTextFragmentAnchor, - kUseFeatureState}, - {wf::EnableBackgroundFetch, features::kBackgroundFetch, kDisableOnly}, - {wf::EnableForcedColors, features::kForcedColors, kUseFeatureState}, - {wf::EnableFractionalScrollOffsets, features::kFractionalScrollOffsets, - kUseFeatureState}, - {wf::EnableGetDisplayMedia, blink::features::kRTCGetDisplayMedia, - kUseFeatureState}, + blink::features::kCSSOMViewScrollCoordinates}, + {wf::EnableTextFragmentAnchor, blink::features::kTextFragmentAnchor}, + {wf::EnableBackgroundFetch, features::kBackgroundFetch}, + {wf::EnableForcedColors, features::kForcedColors}, + {wf::EnableFractionalScrollOffsets, features::kFractionalScrollOffsets}, + {wf::EnableGetDisplayMedia, blink::features::kRTCGetDisplayMedia}, {wf::EnableSignedExchangePrefetchCacheForNavigations, - features::kSignedExchangePrefetchCacheForNavigations, kUseFeatureState}, + features::kSignedExchangePrefetchCacheForNavigations}, {wf::EnableSignedExchangeSubresourcePrefetch, - features::kSignedExchangeSubresourcePrefetch, kUseFeatureState}, - {wf::EnableIdleDetection, features::kIdleDetection, kDisableOnly}, - {wf::EnableSkipTouchEventFilter, blink::features::kSkipTouchEventFilter, - kUseFeatureState}, - {wf::EnableSmsReceiver, features::kSmsReceiver, kDisableOnly}, - {wf::EnableClickPointerEvent, features::kClickPointerEvent, kEnableOnly}, - {wf::EnableConsolidatedMovementXY, features::kConsolidatedMovementXY, - kUseFeatureState}, - {wf::EnableCooperativeScheduling, features::kCooperativeScheduling, - kUseFeatureState}, + features::kSignedExchangeSubresourcePrefetch}, + {wf::EnableIdleDetection, features::kIdleDetection, kSetOnlyIfOverridden}, + {wf::EnableSkipTouchEventFilter, blink::features::kSkipTouchEventFilter}, + {wf::EnableSmsReceiver, features::kSmsReceiver, kSetOnlyIfOverridden}, + {wf::EnableClickPointerEvent, features::kClickPointerEvent}, + {wf::EnableConsolidatedMovementXY, features::kConsolidatedMovementXY}, + {wf::EnableCooperativeScheduling, features::kCooperativeScheduling}, {wf::EnableMouseSubframeNoImplicitCapture, - features::kMouseSubframeNoImplicitCapture, kUseFeatureState}, - {wf::EnableSubresourceWebBundles, features::kSubresourceWebBundles, - kUseFeatureState}, - {wf::EnableCookieDeprecationMessages, features::kCookieDeprecationMessages, - kEnableOnly}, + features::kMouseSubframeNoImplicitCapture}, + {wf::EnableSubresourceWebBundles, features::kSubresourceWebBundles}, + {wf::EnableCookieDeprecationMessages, features::kCookieDeprecationMessages}, {wf::EnableSameSiteByDefaultCookies, - net::features::kSameSiteByDefaultCookies, kEnableOnly}, + net::features::kSameSiteByDefaultCookies}, {wf::EnableCookiesWithoutSameSiteMustBeSecure, - net::features::kCookiesWithoutSameSiteMustBeSecure, kEnableOnly}, - {wf::EnablePointerLockOptions, features::kPointerLockOptions, kEnableOnly}, - {wf::EnableDocumentPolicy, features::kDocumentPolicy, kUseFeatureState}, - {wf::EnableDocumentPolicyNegotiation, features::kDocumentPolicyNegotiation, - kUseFeatureState}, - {wf::EnableScrollUnification, features::kScrollUnification, - kUseFeatureState}, - {wf::EnableNeverSlowMode, features::kNeverSlowMode, kUseFeatureState}, - {wf::EnableShadowDOMV0, blink::features::kWebComponentsV0, - kUseFeatureState}, - {wf::EnableCustomElementsV0, blink::features::kWebComponentsV0, - kUseFeatureState}, - {wf::EnableHTMLImports, blink::features::kWebComponentsV0, - kUseFeatureState}, - {wf::EnableVideoPlaybackQuality, features::kVideoPlaybackQuality, - kUseFeatureState}, + net::features::kCookiesWithoutSameSiteMustBeSecure}, + {wf::EnablePointerLockOptions, features::kPointerLockOptions}, + {wf::EnableDocumentPolicy, features::kDocumentPolicy}, + {wf::EnableDocumentPolicyNegotiation, features::kDocumentPolicyNegotiation}, + {wf::EnableScrollUnification, features::kScrollUnification}, + {wf::EnableNeverSlowMode, features::kNeverSlowMode}, + {wf::EnableShadowDOMV0, blink::features::kWebComponentsV0}, + {wf::EnableCustomElementsV0, blink::features::kWebComponentsV0}, + {wf::EnableHTMLImports, blink::features::kWebComponentsV0}, + {wf::EnableVideoPlaybackQuality, features::kVideoPlaybackQuality}, {wf::EnableBrowserVerifiedUserActivationKeyboard, - features::kBrowserVerifiedUserActivationKeyboard, kEnableOnly}, + features::kBrowserVerifiedUserActivationKeyboard}, {wf::EnableBrowserVerifiedUserActivationMouse, - features::kBrowserVerifiedUserActivationMouse, kEnableOnly}, - {wf::EnablePercentBasedScrolling, features::kPercentBasedScrolling, - kUseFeatureState}, + features::kBrowserVerifiedUserActivationMouse}, + {wf::EnablePercentBasedScrolling, features::kPercentBasedScrolling}, #if defined(OS_ANDROID) - {wf::EnableWebNfc, features::kWebNfc, kDisableOnly}, + {wf::EnableWebNfc, features::kWebNfc, kSetOnlyIfOverridden}, #endif - {wf::EnableInstalledApp, features::kInstalledApp, kDisableOnly}, + {wf::EnableInstalledApp, features::kInstalledApp}, {wf::EnableWebAuthenticationGetAssertionFeaturePolicy, - device::kWebAuthGetAssertionFeaturePolicy, kUseFeatureState}, - {wf::EnableTransformInterop, blink::features::kTransformInterop, - kUseFeatureState}, + device::kWebAuthGetAssertionFeaturePolicy}, + {wf::EnableTransformInterop, blink::features::kTransformInterop}, {wf::EnableVideoWakeLockOptimisationHiddenMuted, - media::kWakeLockOptimisationHiddenMuted, kUseFeatureState}, - {wf::EnableMediaFeeds, media::kMediaFeeds, kUseFeatureState}, - {wf::EnableRestrictGamepadAccess, features::kRestrictGamepadAccess, - kEnableOnly}, + media::kWakeLockOptimisationHiddenMuted}, + {wf::EnableMediaFeeds, media::kMediaFeeds}, + {wf::EnableRestrictGamepadAccess, features::kRestrictGamepadAccess}, {wf::EnableCompositingOptimizations, - blink::features::kCompositingOptimizations, kUseFeatureState}, + blink::features::kCompositingOptimizations}, {wf::EnableConversionMeasurementInfraSupport, - features::kConversionMeasurement, kUseFeatureState}, + features::kConversionMeasurement}, }; for (const auto& mapping : blinkFeatureToBaseFeatureMapping) { SetRuntimeFeatureFromChromiumFeature( @@ -357,73 +326,55 @@ void SetRuntimeFeaturesFromChromiumFeatures() { // function and using feature string name with EnableFeatureFromString. const RuntimeFeatureToChromiumFeatureMap<const char*> runtimeFeatureNameToChromiumFeatureMapping[] = { - {"AddressSpace", - network::features::kBlockInsecurePrivateNetworkRequests, - kEnableOnly}, + {"AddressSpace", features::kBlockInsecurePrivateNetworkRequests}, {"AllowContentInitiatedDataUrlNavigations", - features::kAllowContentInitiatedDataUrlNavigations, - kUseFeatureState}, + features::kAllowContentInitiatedDataUrlNavigations}, + {"AndroidDownloadableFontsMatching", + features::kAndroidDownloadableFontsMatching}, {"AudioWorkletRealtimeThread", - blink::features::kAudioWorkletRealtimeThread, kEnableOnly}, + blink::features::kAudioWorkletRealtimeThread}, {"BlockCredentialedSubresources", - features::kBlockCredentialedSubresources, kDisableOnly}, - {"BlockFlowHandlesWebkitLineClamp", - blink::features::kBlockFlowHandlesWebkitLineClamp, kUseFeatureState}, + features::kBlockCredentialedSubresources}, {"BlockHTMLParserOnStyleSheets", - blink::features::kBlockHTMLParserOnStyleSheets, kUseFeatureState}, - {"CSSColorSchemeUARendering", features::kCSSColorSchemeUARendering, - kUseFeatureState}, - {"CSSReducedFontLoadingInvalidations", - blink::features::kCSSReducedFontLoadingInvalidations, - kUseFeatureState}, + blink::features::kBlockHTMLParserOnStyleSheets}, + {"CSSColorSchemeUARendering", features::kCSSColorSchemeUARendering}, {"CSSReducedFontLoadingLayoutInvalidations", - blink::features::kCSSReducedFontLoadingLayoutInvalidations, - kUseFeatureState}, + blink::features::kCSSReducedFontLoadingLayoutInvalidations}, {"CSSMatchedPropertiesCacheDependencies", - blink::features::kCSSMatchedPropertiesCacheDependencies, - kUseFeatureState}, - {"CustomElementsV0", blink::features::kWebComponentsV0, - kUseFeatureState}, + blink::features::kCSSMatchedPropertiesCacheDependencies}, + {"CustomElementsV0", blink::features::kWebComponentsV0}, {"FeaturePolicyForClientHints", - features::kFeaturePolicyForClientHints, kUseFeatureState}, - {"FontAccess", blink::features::kFontAccess, kUseFeatureState}, - {"FontSrcLocalMatching", features::kFontSrcLocalMatching, - kUseFeatureState}, + features::kFeaturePolicyForClientHints}, + {"EditingNG", blink::features::kEditingNG}, + {"FlexAspectRatio", blink::features::kFlexAspectRatio}, + {"FontAccess", blink::features::kFontAccess}, + {"FontSrcLocalMatching", features::kFontSrcLocalMatching}, {"ForceSynchronousHTMLParsing", - blink::features::kForceSynchronousHTMLParsing, kUseFeatureState}, - {"HTMLImports", blink::features::kWebComponentsV0, kUseFeatureState}, + blink::features::kForceSynchronousHTMLParsing}, + {"HTMLImports", blink::features::kWebComponentsV0}, {"IgnoreCrossOriginWindowWhenNamedAccessOnWindow", - blink::features::kIgnoreCrossOriginWindowWhenNamedAccessOnWindow, - kEnableOnly}, - {"LangClientHintHeader", features::kLangClientHintHeader, - kUseFeatureState}, - {"LayoutNG", blink::features::kLayoutNG, kUseFeatureState}, - {"LayoutNGFieldset", blink::features::kLayoutNGFieldset, - kUseFeatureState}, - {"LayoutNGFlexBox", blink::features::kFlexNG, kUseFeatureState}, - {"LayoutNGFragmentItem", blink::features::kFragmentItem, - kUseFeatureState}, - {"LayoutNGRuby", blink::features::kLayoutNGRuby, kUseFeatureState}, + blink::features::kIgnoreCrossOriginWindowWhenNamedAccessOnWindow}, + {"LangClientHintHeader", features::kLangClientHintHeader}, + {"LayoutNG", blink::features::kLayoutNG}, + {"LayoutNGFieldset", blink::features::kLayoutNGFieldset}, + {"LayoutNGFragmentItem", blink::features::kFragmentItem}, + {"LayoutNGRuby", blink::features::kLayoutNGRuby}, {"LegacyWindowsDWriteFontFallback", - features::kLegacyWindowsDWriteFontFallback, kUseFeatureState}, + features::kLegacyWindowsDWriteFontFallback}, {"LinkDisabledNewSpecBehavior", - blink::features::kLinkDisabledNewSpecBehavior, kUseFeatureState}, - {"OriginPolicy", features::kOriginPolicy, kUseFeatureState}, - {"OriginIsolationHeader", features::kOriginIsolationHeader, - kUseFeatureState}, + blink::features::kLinkDisabledNewSpecBehavior}, + {"OriginPolicy", features::kOriginPolicy}, + {"OriginIsolationHeader", features::kOriginIsolationHeader}, {"ParentNodeReplaceChildren", - blink::features::kParentNodeReplaceChildren, kUseFeatureState}, - {"RawClipboard", blink::features::kRawClipboard, kEnableOnly}, - {"ShadowDOMV0", blink::features::kWebComponentsV0, kUseFeatureState}, - {"StorageAccessAPI", blink::features::kStorageAccessAPI, kEnableOnly}, - {"TransferableStreams", blink::features::kTransferableStreams, - kEnableOnly}, - {"TrustedDOMTypes", features::kTrustedDOMTypes, kEnableOnly}, - {"UserAgentClientHint", features::kUserAgentClientHint, - kUseFeatureState}, + blink::features::kParentNodeReplaceChildren}, + {"RawClipboard", blink::features::kRawClipboard}, + {"ShadowDOMV0", blink::features::kWebComponentsV0}, + {"StorageAccessAPI", blink::features::kStorageAccessAPI}, + {"TrustedDOMTypes", features::kTrustedDOMTypes}, + {"UserAgentClientHint", features::kUserAgentClientHint}, {"WebAppManifestDisplayOverride", - features::kWebAppManifestDisplayOverride, kUseFeatureState}, - + features::kWebAppManifestDisplayOverride}, + {"WebXRMultiGpu", blink::features::kWebXrMultiGpu}, }; for (const auto& mapping : runtimeFeatureNameToChromiumFeatureMapping) { SetRuntimeFeatureFromChromiumFeature( @@ -558,8 +509,7 @@ void SetRuntimeFeaturesFromFieldTrialParams() { // not covered by other functions. In short, this should be used // as a last resort. void SetCustomizedRuntimeFeaturesFromCombinedArgs( - const base::CommandLine& command_line, - bool enable_experimental_web_platform_features) { + const base::CommandLine& command_line) { // CAUTION: Only add custom enabling logic here if it cannot // be covered by the other functions. @@ -582,13 +532,7 @@ void SetCustomizedRuntimeFeaturesFromCombinedArgs( // They're moved here to distinguish them from actual base checks WebRuntimeFeatures::EnableOverlayScrollbars(ui::IsOverlayScrollbarEnabled()); - if (base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine( - blink::features::kNativeFileSystemAPI.name, - base::FeatureList::OVERRIDE_ENABLE_FEATURE)) { - WebRuntimeFeatures::EnableFeatureFromString("NativeFileSystem", true); - } - if (base::FeatureList::IsEnabled(blink::features::kNativeFileSystemAPI) && - base::FeatureList::IsEnabled(blink::features::kFileHandlingAPI)) { + if (base::FeatureList::IsEnabled(blink::features::kFileHandlingAPI)) { WebRuntimeFeatures::EnableFeatureFromString("FileHandling", true); } @@ -599,36 +543,11 @@ void SetCustomizedRuntimeFeaturesFromCombinedArgs( else WebRuntimeFeatures::EnableV8IdleTasks(true); - // This is a hack to get the tests passing as they require - // these blink features to be enabled while they are disabled - // by base::Feature controls earlier in code. - // TODO(rodneyding): Investigate more on proper treatments of - // these features. - if (enable_experimental_web_platform_features) { - WebRuntimeFeatures::EnableNetInfoDownlinkMax(true); - } - - // Except for stable release mode, web tests still run with Web Components - // v0 features enabled. - // TODO(crbug.com/937746): remove this once the features are deleted. - if (command_line.HasSwitch("run-web-tests") && - !command_line.HasSwitch("stable-release-mode")) { - WebRuntimeFeatures::EnableShadowDOMV0(true); - WebRuntimeFeatures::EnableCustomElementsV0(true); - WebRuntimeFeatures::EnableHTMLImports(true); - } - WebRuntimeFeatures::EnableBackForwardCache( content::IsBackForwardCacheEnabled()); - // Gate the ReducedReferrerGranularity runtime feature depending on whether - // content is configured to force a no-referrer-when-downgrade default policy. - // TODO(crbug.com/1016541): After M82, remove when the corresponding - // enterprise policy has been deleted. - WebRuntimeFeatures::EnableReducedReferrerGranularity( - base::FeatureList::IsEnabled( - blink::features::kReducedReferrerGranularity) && - !content::Referrer::ShouldForceLegacyDefaultReferrerPolicy()); + if (base::FeatureList::IsEnabled(features::kDirectSockets)) + WebRuntimeFeatures::EnableDirectSockets(true); if (base::FeatureList::IsEnabled( blink::features::kAppCacheRequireOriginTrial)) { @@ -684,8 +603,10 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( // Sets experimental features. bool enable_experimental_web_platform_features = command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures); + bool enable_blink_test_features = + command_line.HasSwitch(switches::kEnableBlinkTestFeatures); - if (command_line.HasSwitch(switches::kEnableBlinkTestFeatures)) { + if (enable_blink_test_features) { enable_experimental_web_platform_features = true; WebRuntimeFeatures::EnableTestOnlyFeatures(true); } @@ -701,12 +622,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( WebRuntimeFeatures::EnableOriginTrialControlledFeatures(false); } - if (!command_line.HasSwitch( - network::switches::kForceToDisableOutOfBlinkCors) && - base::FeatureList::IsEnabled(network::features::kOutOfBlinkCors)) { - WebRuntimeFeatures::EnableOutOfBlinkCors(true); - } - // TODO(rodneyding): add doc explaining ways to add new runtime features // controls in the following functions. @@ -716,8 +631,7 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( SetRuntimeFeaturesFromFieldTrialParams(); - SetCustomizedRuntimeFeaturesFromCombinedArgs( - command_line, enable_experimental_web_platform_features); + SetCustomizedRuntimeFeaturesFromCombinedArgs(command_line); // Enable explicitly enabled features, and then disable explicitly disabled // ones. diff --git a/chromium/content/child/thread_safe_sender.cc b/chromium/content/child/thread_safe_sender.cc deleted file mode 100644 index 2542f220299..00000000000 --- a/chromium/content/child/thread_safe_sender.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/child/thread_safe_sender.h" - -#include "base/single_thread_task_runner.h" -#include "content/child/child_thread_impl.h" -#include "ipc/ipc_sync_message_filter.h" - -namespace content { - -ThreadSafeSender::~ThreadSafeSender() { -} - -ThreadSafeSender::ThreadSafeSender( - const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, - const scoped_refptr<IPC::SyncMessageFilter>& sync_filter) - : main_task_runner_(main_task_runner), sync_filter_(sync_filter) { -} - -bool ThreadSafeSender::Send(IPC::Message* msg) { - if (main_task_runner_->BelongsToCurrentThread()) - return ChildThreadImpl::current()->Send(msg); - return sync_filter_->Send(msg); -} - -} // namespace content diff --git a/chromium/content/child/thread_safe_sender.h b/chromium/content/child/thread_safe_sender.h deleted file mode 100644 index bf5253e0418..00000000000 --- a/chromium/content/child/thread_safe_sender.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_CHILD_THREAD_SAFE_SENDER_H_ -#define CONTENT_CHILD_THREAD_SAFE_SENDER_H_ - -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "content/common/content_export.h" -#include "ipc/ipc_sender.h" - -namespace base { -class SingleThreadTaskRunner; -} - -namespace IPC { -class SyncMessageFilter; -} - -namespace content { -class ChildThreadImpl; - -// The class of Sender returned by ChildThreadImpl::thread_safe_sender(). -class CONTENT_EXPORT ThreadSafeSender - : public IPC::Sender, - public base::RefCountedThreadSafe<ThreadSafeSender> { - public: - bool Send(IPC::Message* msg) override; - - protected: - ThreadSafeSender( - const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, - const scoped_refptr<IPC::SyncMessageFilter>& sync_filter); - ~ThreadSafeSender() override; - - private: - friend class ChildThreadImpl; // for construction - friend class IndexedDBDispatcherTest; - friend class WebIDBCursorImplTest; - friend class base::RefCountedThreadSafe<ThreadSafeSender>; - - scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; - scoped_refptr<IPC::SyncMessageFilter> sync_filter_; - - DISALLOW_COPY_AND_ASSIGN(ThreadSafeSender); -}; - -} // namespace content - -#endif // CONTENT_CHILD_THREAD_SAFE_SENDER_H_ diff --git a/chromium/content/child/webthemeengine_impl_android.cc b/chromium/content/child/webthemeengine_impl_android.cc index fe96bd18f74..b35d710f28e 100644 --- a/chromium/content/child/webthemeengine_impl_android.cc +++ b/chromium/content/child/webthemeengine_impl_android.cc @@ -12,7 +12,7 @@ #include "third_party/blink/public/platform/web_size.h" #include "ui/native_theme/native_theme.h" -using blink::WebColorScheme; +using blink::ColorScheme; using blink::WebRect; using blink::WebThemeEngine; @@ -159,7 +159,7 @@ void WebThemeEngineAndroid::Paint( WebThemeEngine::State state, const blink::WebRect& rect, const WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) { + blink::ColorScheme color_scheme) { ui::NativeTheme::ExtraParams native_theme_extra_params; GetNativeThemeExtraParams( part, state, extra_params, &native_theme_extra_params); diff --git a/chromium/content/child/webthemeengine_impl_android.h b/chromium/content/child/webthemeengine_impl_android.h index b8c713e785f..2224bb83730 100644 --- a/chromium/content/child/webthemeengine_impl_android.h +++ b/chromium/content/child/webthemeengine_impl_android.h @@ -21,7 +21,7 @@ class WebThemeEngineAndroid : public blink::WebThemeEngine { blink::WebThemeEngine::State state, const blink::WebRect& rect, const blink::WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) override; + blink::ColorScheme color_scheme) override; blink::ForcedColors GetForcedColors() const override; void SetForcedColors(const blink::ForcedColors forced_colors) override; }; diff --git a/chromium/content/child/webthemeengine_impl_conversions.cc b/chromium/content/child/webthemeengine_impl_conversions.cc index ce5773a6f3f..84509d43d30 100644 --- a/chromium/content/child/webthemeengine_impl_conversions.cc +++ b/chromium/content/child/webthemeengine_impl_conversions.cc @@ -84,11 +84,11 @@ ui::NativeTheme::State NativeThemeState(blink::WebThemeEngine::State state) { } ui::NativeTheme::ColorScheme NativeColorScheme( - blink::WebColorScheme color_scheme) { + blink::ColorScheme color_scheme) { switch (color_scheme) { - case blink::WebColorScheme::kLight: + case blink::ColorScheme::kLight: return ui::NativeTheme::ColorScheme::kLight; - case blink::WebColorScheme::kDark: + case blink::ColorScheme::kDark: return ui::NativeTheme::ColorScheme::kDark; } } diff --git a/chromium/content/child/webthemeengine_impl_conversions.h b/chromium/content/child/webthemeengine_impl_conversions.h index fdd2e5691cc..88858bc882a 100644 --- a/chromium/content/child/webthemeengine_impl_conversions.h +++ b/chromium/content/child/webthemeengine_impl_conversions.h @@ -22,7 +22,7 @@ CONTENT_EXPORT ui::NativeTheme::State NativeThemeState( blink::WebThemeEngine::State state); CONTENT_EXPORT ui::NativeTheme::ColorScheme NativeColorScheme( - blink::WebColorScheme color_scheme); + blink::ColorScheme color_scheme); CONTENT_EXPORT ui::NativeTheme::SystemThemeColor NativeSystemThemeColor( blink::WebThemeEngine::SystemThemeColor theme_color); diff --git a/chromium/content/child/webthemeengine_impl_default.cc b/chromium/content/child/webthemeengine_impl_default.cc index 3b81850a18f..95f765e05ed 100644 --- a/chromium/content/child/webthemeengine_impl_default.cc +++ b/chromium/content/child/webthemeengine_impl_default.cc @@ -12,7 +12,7 @@ #include "ui/native_theme/native_theme.h" #include "ui/native_theme/overlay_scrollbar_constants_aura.h" -using blink::WebColorScheme; +using blink::ColorScheme; using blink::WebRect; using blink::WebScrollbarOverlayColorTheme; using blink::WebThemeEngine; @@ -188,7 +188,7 @@ void WebThemeEngineDefault::Paint( WebThemeEngine::State state, const blink::WebRect& rect, const WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) { + blink::ColorScheme color_scheme) { ui::NativeTheme::ExtraParams native_theme_extra_params; GetNativeThemeExtraParams( part, state, extra_params, &native_theme_extra_params); diff --git a/chromium/content/child/webthemeengine_impl_default.h b/chromium/content/child/webthemeengine_impl_default.h index 755a6d8afe3..cb24854e74f 100644 --- a/chromium/content/child/webthemeengine_impl_default.h +++ b/chromium/content/child/webthemeengine_impl_default.h @@ -22,7 +22,7 @@ class WebThemeEngineDefault : public blink::WebThemeEngine { blink::WebThemeEngine::State state, const blink::WebRect& rect, const blink::WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) override; + blink::ColorScheme color_scheme) override; void GetOverlayScrollbarStyle( blink::WebThemeEngine::ScrollbarStyle*) override; bool SupportsNinePatch(Part part) const override; diff --git a/chromium/content/child/webthemeengine_impl_mac.cc b/chromium/content/child/webthemeengine_impl_mac.cc index f8aa72dbe3c..a7d26ea74a9 100644 --- a/chromium/content/child/webthemeengine_impl_mac.cc +++ b/chromium/content/child/webthemeengine_impl_mac.cc @@ -23,7 +23,7 @@ void WebThemeEngineMac::Paint(cc::PaintCanvas* canvas, WebThemeEngine::State state, const blink::WebRect& rect, const WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) { + blink::ColorScheme color_scheme) { if (IsScrollbarPart(part)) { PaintMacScrollBarParts(canvas, part, state, rect, extra_params, color_scheme); @@ -53,7 +53,7 @@ void WebThemeEngineMac::PaintMacScrollBarParts( WebThemeEngine::State state, const blink::WebRect& rect, const WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) { + blink::ColorScheme color_scheme) { ui::NativeTheme::ExtraParams native_theme_extra_params; native_theme_extra_params.scrollbar_extra.is_hovering = extra_params->scrollbar_extra.is_hovering; diff --git a/chromium/content/child/webthemeengine_impl_mac.h b/chromium/content/child/webthemeengine_impl_mac.h index f2f232388d5..89046514eae 100644 --- a/chromium/content/child/webthemeengine_impl_mac.h +++ b/chromium/content/child/webthemeengine_impl_mac.h @@ -21,7 +21,7 @@ class WebThemeEngineMac : public WebThemeEngineDefault { blink::WebThemeEngine::State state, const blink::WebRect& rect, const blink::WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme) override; + blink::ColorScheme color_scheme) override; static bool IsScrollbarPart(WebThemeEngine::Part part); static void PaintMacScrollBarParts( @@ -30,7 +30,7 @@ class WebThemeEngineMac : public WebThemeEngineDefault { WebThemeEngine::State state, const blink::WebRect& rect, const WebThemeEngine::ExtraParams* extra_params, - blink::WebColorScheme color_scheme); + blink::ColorScheme color_scheme); private: blink::ForcedColors forced_colors_ = blink::ForcedColors::kNone; diff --git a/chromium/content/child/webthemeengine_impl_unittest.cc b/chromium/content/child/webthemeengine_impl_unittest.cc index 755ac9f5aab..45c2598dce9 100644 --- a/chromium/content/child/webthemeengine_impl_unittest.cc +++ b/chromium/content/child/webthemeengine_impl_unittest.cc @@ -97,8 +97,8 @@ TEST(WebThemeEngineTest, NativeSystemThemeState) { } TEST(WebThemeEngineTest, NativeColorScheme) { - std::vector<blink::WebColorScheme> blink_inputs = { - blink::WebColorScheme::kLight, blink::WebColorScheme::kDark}; + std::vector<blink::ColorScheme> blink_inputs = {blink::ColorScheme::kLight, + blink::ColorScheme::kDark}; std::vector<ui::NativeTheme::ColorScheme> native_theme_outputs = { ui::NativeTheme::ColorScheme::kLight, |