diff options
Diffstat (limited to 'chromium/content/public')
122 files changed, 1717 insertions, 873 deletions
diff --git a/chromium/content/public/DEPS b/chromium/content/public/DEPS index 63b613bb2ae..37cb1e47fbf 100644 --- a/chromium/content/public/DEPS +++ b/chromium/content/public/DEPS @@ -1,6 +1,7 @@ include_rules = [ "-content", + "+services/cert_verifier/public/mojom", "+services/network/public/mojom", "+services/service_manager/public", "+services/service_manager/sandbox", diff --git a/chromium/content/public/android/BUILD.gn b/chromium/content/public/android/BUILD.gn index fedef329f1c..acc6c3cb82d 100644 --- a/chromium/content/public/android/BUILD.gn +++ b/chromium/content/public/android/BUILD.gn @@ -56,16 +56,13 @@ android_resources("content_java_resources") { ] } -action("generate_sandboxed_service_srcjar") { +action_with_pydeps("generate_sandboxed_service_srcjar") { script = "//content/public/android/generate_child_service.py" - depfile = "$target_gen_dir/$target_name.d" _srcjar_path = "${target_gen_dir}/${target_name}.srcjar" _rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir) args = [ - "--depfile", - rebase_path(depfile, root_build_dir), "40", _rebased_srcjar_path, ] @@ -282,6 +279,7 @@ android_library("content_java") { "java/src/org/chromium/content_public/browser/DeviceUtils.java", "java/src/org/chromium/content_public/browser/GestureListenerManager.java", "java/src/org/chromium/content_public/browser/GestureStateListener.java", + "java/src/org/chromium/content_public/browser/GestureStateListenerWithScroll.java", "java/src/org/chromium/content_public/browser/ImageDownloadCallback.java", "java/src/org/chromium/content_public/browser/ImeAdapter.java", "java/src/org/chromium/content_public/browser/ImeEventObserver.java", @@ -347,7 +345,6 @@ java_cpp_enum("content_public_android_java_enums_srcjar") { "//content/public/browser/invalidate_type.h", "//content/public/browser/navigation_controller.h", "//content/public/browser/visibility.h", - "//content/public/browser/xr_consent_prompt_level.h", "//content/public/common/browser_controls_state.h", "//content/public/common/console_message_level.h", "//content/public/common/screen_orientation_values.h", @@ -486,6 +483,7 @@ android_library("content_javatests") { "javatests/src/org/chromium/content/browser/ContentViewScrollingTest.java", "javatests/src/org/chromium/content/browser/EncodeHtmlDataUriTest.java", "javatests/src/org/chromium/content/browser/GestureDetectorResetTest.java", + "javatests/src/org/chromium/content/browser/GestureListenerManagerTest.java", "javatests/src/org/chromium/content/browser/ImportantFileWriterAndroidTest.java", "javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java", "javatests/src/org/chromium/content/browser/JavaBridgeArrayCoercionTest.java", @@ -571,7 +569,10 @@ junit_binary("content_junit_tests") { "//content/public/test/android:content_java_test_support", "//media/mojo/mojom:mojom_java", "//mojo/public/java:bindings_java", + "//mojo/public/mojom/base:base_java", + "//third_party/android_deps:androidx_test_core_java", "//third_party/blink/public/mojom:android_mojo_bindings_java", + "//third_party/hamcrest:hamcrest_java", "//ui/android:ui_java", "//ui/gfx/geometry/mojom:mojom_java", ] diff --git a/chromium/content/public/android/generate_child_service.py b/chromium/content/public/android/generate_child_service.py index ebe07f2d8f1..8c28dd6242c 100755 --- a/chromium/content/public/android/generate_child_service.py +++ b/chromium/content/public/android/generate_child_service.py @@ -35,7 +35,6 @@ public class SandboxedProcessService{0} extends SandboxedProcessService {{ def DoMain(argv): usage = 'usage: %prog [number] [output]' parser = optparse.OptionParser(usage=usage) - build_utils.AddDepfileOption(parser) options, args = parser.parse_args(argv) @@ -52,8 +51,5 @@ def DoMain(argv): path_template.format(i), data=GenerateService(i)) - if options.depfile: - build_utils.WriteDepfile(options.depfile, output) - if __name__ == '__main__': DoMain(sys.argv[1:]) diff --git a/chromium/content/public/android/generate_child_service.pydeps b/chromium/content/public/android/generate_child_service.pydeps new file mode 100644 index 00000000000..0d6c910a650 --- /dev/null +++ b/chromium/content/public/android/generate_child_service.pydeps @@ -0,0 +1,6 @@ +# Generated by running: +# build/print_python_deps.py --root content/public/android --output content/public/android/generate_child_service.pydeps content/public/android/generate_child_service.py +../../../build/android/gyp/util/__init__.py +../../../build/android/gyp/util/build_utils.py +../../../build/gn_helpers.py +generate_child_service.py diff --git a/chromium/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java b/chromium/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java index 1f2062983dd..40522b0b744 100644 --- a/chromium/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java +++ b/chromium/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java @@ -23,8 +23,8 @@ import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowLooper; import org.chromium.base.process_launcher.ChildProcessConnection; +import org.chromium.base.process_launcher.TestChildProcessConnection; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.base.test.TestChildProcessConnection; import org.chromium.base.test.util.Feature; import java.util.ArrayList; diff --git a/chromium/content/public/android/junit/src/org/chromium/content/browser/ChildProcessRankingTest.java b/chromium/content/public/android/junit/src/org/chromium/content/browser/ChildProcessRankingTest.java index 5175b7032f4..823891d0f66 100644 --- a/chromium/content/public/android/junit/src/org/chromium/content/browser/ChildProcessRankingTest.java +++ b/chromium/content/public/android/junit/src/org/chromium/content/browser/ChildProcessRankingTest.java @@ -13,8 +13,8 @@ import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowLooper; import org.chromium.base.process_launcher.ChildProcessConnection; +import org.chromium.base.process_launcher.TestChildProcessConnection; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.base.test.TestChildProcessConnection; import org.chromium.content_public.browser.ChildProcessImportance; /** Unit tests for ChildProessRanking */ diff --git a/chromium/content/public/android/junit/src/org/chromium/content/browser/CriteriaHelperTest.java b/chromium/content/public/android/junit/src/org/chromium/content/browser/CriteriaHelperTest.java index fa65ca16c01..f4fea4d63fe 100644 --- a/chromium/content/public/android/junit/src/org/chromium/content/browser/CriteriaHelperTest.java +++ b/chromium/content/public/android/junit/src/org/chromium/content/browser/CriteriaHelperTest.java @@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue; import static org.chromium.base.task.TaskTraits.THREAD_POOL; import static org.chromium.content_public.browser.test.util.CriteriaHelper.DEFAULT_POLLING_INTERVAL; -import android.support.test.filters.MediumTest; +import androidx.test.filters.MediumTest; import org.junit.Assert; import org.junit.Rule; @@ -25,6 +25,7 @@ import org.chromium.base.task.PostTask; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.CriteriaHelper; +import org.chromium.content_public.browser.test.util.CriteriaNotSatisfiedException; import java.io.PrintWriter; import java.io.StringWriter; @@ -245,7 +246,7 @@ public class CriteriaHelperTest { }, 0, DEFAULT_POLLING_INTERVAL); } - private String getStackTrace(AssertionError e) { + private String getStackTrace(Throwable e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); return sw.toString(); @@ -255,7 +256,9 @@ public class CriteriaHelperTest { @MediumTest public void testStack_Runnable_UiThread() { try { - CriteriaHelper.pollUiThread((Runnable) Assert::fail, 0, DEFAULT_POLLING_INTERVAL); + CriteriaHelper.pollUiThread(() -> { + throw new CriteriaNotSatisfiedException("test"); + }, 0, DEFAULT_POLLING_INTERVAL); } catch (AssertionError e) { assertThat(getStackTrace(e), containsString("CriteriaHelperTest.testStack_Runnable_UiThread(")); @@ -268,8 +271,9 @@ public class CriteriaHelperTest { @MediumTest public void testStack_Runnable_InstrumentationThread() { try { - CriteriaHelper.pollInstrumentationThread( - (Runnable) Assert::fail, 0, DEFAULT_POLLING_INTERVAL); + CriteriaHelper.pollInstrumentationThread(() -> { + throw new CriteriaNotSatisfiedException("test"); + }, 0, DEFAULT_POLLING_INTERVAL); } catch (AssertionError e) { assertThat(getStackTrace(e), containsString("CriteriaHelperTest.testStack_Runnable_InstrumentationThread(")); diff --git a/chromium/content/public/android/junit/src/org/chromium/content/browser/SpareChildConnectionTest.java b/chromium/content/public/android/junit/src/org/chromium/content/browser/SpareChildConnectionTest.java index f2ba7649bc2..79a99c84750 100644 --- a/chromium/content/public/android/junit/src/org/chromium/content/browser/SpareChildConnectionTest.java +++ b/chromium/content/public/android/junit/src/org/chromium/content/browser/SpareChildConnectionTest.java @@ -27,8 +27,8 @@ import org.robolectric.shadows.ShadowLooper; import org.chromium.base.process_launcher.ChildConnectionAllocator; import org.chromium.base.process_launcher.ChildProcessConnection; +import org.chromium.base.process_launcher.TestChildProcessConnection; import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.base.test.TestChildProcessConnection; import org.chromium.base.test.util.Feature; /** Unit tests for the SpareChildConnection class. */ @@ -53,8 +53,8 @@ public class SpareChildConnectionTest { @Override public ChildProcessConnection createConnection(Context context, ComponentName serviceName, - boolean bindToCaller, boolean bindAsExternalService, Bundle serviceBundle, - String instanceName) { + ComponentName fallbackServiceName, boolean bindToCaller, + boolean bindAsExternalService, Bundle serviceBundle, String instanceName) { // We expect to create only one connection in these tests. assert mConnection == null; mConnection = new TestChildProcessConnection( diff --git a/chromium/content/public/android/junit/src/org/chromium/content/browser/UiThreadTaskTraitsImplTest.java b/chromium/content/public/android/junit/src/org/chromium/content/browser/UiThreadTaskTraitsImplTest.java index 17090971211..8e2140d5f0b 100644 --- a/chromium/content/public/android/junit/src/org/chromium/content/browser/UiThreadTaskTraitsImplTest.java +++ b/chromium/content/public/android/junit/src/org/chromium/content/browser/UiThreadTaskTraitsImplTest.java @@ -7,7 +7,7 @@ package org.chromium.content.browser; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import android.support.test.filters.SmallTest; +import androidx.test.filters.SmallTest; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/chromium/content/public/app/content_main_delegate.cc b/chromium/content/public/app/content_main_delegate.cc index ed5b0e2c0b4..02985a525c9 100644 --- a/chromium/content/public/app/content_main_delegate.cc +++ b/chromium/content/public/app/content_main_delegate.cc @@ -27,8 +27,7 @@ int ContentMainDelegate::RunProcess( #if defined(OS_LINUX) void ContentMainDelegate::ZygoteStarting( - std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>* - delegates) {} + std::vector<std::unique_ptr<ZygoteForkDelegate>>* delegates) {} #endif // defined(OS_LINUX) diff --git a/chromium/content/public/app/content_main_delegate.h b/chromium/content/public/app/content_main_delegate.h index 2d9ee9fa20a..0ca924769b9 100644 --- a/chromium/content/public/app/content_main_delegate.h +++ b/chromium/content/public/app/content_main_delegate.h @@ -21,7 +21,6 @@ class CommandLine; namespace service_manager { class BackgroundServiceManager; class Identity; -class ZygoteForkDelegate; } // namespace service_manager namespace content { @@ -31,6 +30,7 @@ class ContentClient; class ContentGpuClient; class ContentRendererClient; class ContentUtilityClient; +class ZygoteForkDelegate; struct MainFunctionParams; class CONTENT_EXPORT ContentMainDelegate { @@ -65,8 +65,7 @@ class CONTENT_EXPORT ContentMainDelegate { // specify one or more zygote delegates if it wishes by storing them in // |*delegates|. virtual void ZygoteStarting( - std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>* - delegates); + std::vector<std::unique_ptr<ZygoteForkDelegate>>* delegates); // Called every time the zygote process forks. virtual void ZygoteForked() {} diff --git a/chromium/content/public/browser/BUILD.gn b/chromium/content/public/browser/BUILD.gn index fa2aeab0a4a..17d0782de13 100644 --- a/chromium/content/public/browser/BUILD.gn +++ b/chromium/content/public/browser/BUILD.gn @@ -6,6 +6,7 @@ import("//build/config/jumbo.gni") import("//build/config/ui.gni") import("//device/vr/buildflags/buildflags.gni") import("//ppapi/buildflags/buildflags.gni") +import("//third_party/protobuf/proto_library.gni") import("//third_party/webrtc/webrtc.gni") if (is_android) { @@ -50,8 +51,6 @@ jumbo_source_set("browser_sources") { "audio_service_info.cc", "audio_service_info.h", "authenticator_environment.h", - "authenticator_request_client_delegate.cc", - "authenticator_request_client_delegate.h", "ax_event_notification_details.cc", "ax_event_notification_details.h", "back_forward_cache.h", @@ -130,8 +129,6 @@ jumbo_source_set("browser_sources") { "cookie_access_details.cc", "cookie_access_details.h", "cookie_store_factory.h", - "cors_exempt_headers.cc", - "cors_exempt_headers.h", "cors_origin_pattern_setter.cc", "cors_origin_pattern_setter.h", "dedicated_worker_id.h", @@ -238,6 +235,7 @@ jumbo_source_set("browser_sources") { "navigation_entry.h", "navigation_handle.cc", "navigation_handle.h", + "navigation_handle_timing.h", "navigation_throttle.cc", "navigation_throttle.h", "navigation_type.h", @@ -320,6 +318,8 @@ jumbo_source_set("browser_sources") { "service_process_host.h", "service_process_info.cc", "service_process_info.h", + "service_worker_client_info.cc", + "service_worker_client_info.h", "service_worker_context.h", "service_worker_context_observer.h", "service_worker_external_request_result.h", @@ -351,6 +351,8 @@ jumbo_source_set("browser_sources") { "startup_data.h", "storage_notification_service.h", "storage_partition.h", + "storage_partition_config.cc", + "storage_partition_config.h", "storage_usage_info.h", "stored_payment_app.cc", "stored_payment_app.h", @@ -365,12 +367,12 @@ jumbo_source_set("browser_sources") { "tracing_delegate.h", "tracing_service.h", "tts_controller.h", - "tts_controller_delegate.h", "tts_platform.h", "tts_utterance.h", "url_data_source.cc", "url_data_source.h", "url_loader_request_interceptor.h", + "url_loader_throttles.h", "video_capture_device_launcher.cc", "video_capture_device_launcher.h", "video_capture_service.h", @@ -434,6 +436,7 @@ jumbo_source_set("browser_sources") { "//mojo/public/cpp/bindings", "//mojo/public/cpp/system", "//services/audio/public/mojom", + "//services/cert_verifier/public/mojom", "//services/content/public/mojom", "//services/data_decoder/public/mojom", "//services/device/public/mojom:device_service", @@ -504,23 +507,30 @@ jumbo_source_set("browser_sources") { sources += [ "remote_cocoa.h" ] } + if (is_linux) { + sources += [ "zygote_host/zygote_host_linux.h" ] + } + if (!is_android) { sources += [ + "authenticator_request_client_delegate.cc", + "authenticator_request_client_delegate.h", "host_zoom_map.h", "zoom_level_delegate.h", ] } if (is_chromeos) { - sources += - [ "chromeos/delegate_to_browser_gpu_service_accelerator_factory.h" ] + sources += [ + "chromeos/delegate_to_browser_gpu_service_accelerator_factory.h", + "tts_controller_delegate.cc", + "tts_controller_delegate.h", + ] } if (enable_vr) { sources += [ "browser_xr_runtime.h", - "xr_consent_helper.h", - "xr_consent_prompt_level.h", "xr_install_helper.h", "xr_integration_client.cc", "xr_integration_client.h", @@ -539,3 +549,7 @@ if (is_android) { sources = [ "contacts_picker_properties_requested.h" ] } } + +proto_library("proto") { + sources = [ "google_streaming_api.proto" ] +} diff --git a/chromium/content/public/browser/accessibility_tree_formatter.h b/chromium/content/public/browser/accessibility_tree_formatter.h index cecbbe42921..b954cce0aca 100644 --- a/chromium/content/public/browser/accessibility_tree_formatter.h +++ b/chromium/content/public/browser/accessibility_tree_formatter.h @@ -56,15 +56,31 @@ class AccessibilityTestExpectationsLocator { class CONTENT_EXPORT AccessibilityTreeFormatter : public AccessibilityTestExpectationsLocator { public: - // A single property filter specification. See GetAllowString() and - // GetDenyString() for more information. - struct PropertyFilter { + // A single property filter specification. Represents a parsed string of the + // filter_str;match_str format, where `filter_str` has + // :line_num_0,...:line_num_N format, `match_str` has format of + // property_str=value_str. For example, :1,:3;AXDOMClassList=*. + // + // Longer version: `filter_str` is a comma separated list of the line + // indexes from the output accessible tree, and serves to narrow down the + // property calls to the accessible object placed on those line indexes only; + // `match_str` is used to match properties by property name and value. + // For example, :1,:3;AXDOMClassList=* + // will query a AXDOMClassList attribute on accessible objects placed at 1st + // and 3rd lines in the output accessible tree. + // Also see + // DumpAccessibilityTestBase::ParseHtmlForExtraDirectives() for more + // information. + struct CONTENT_EXPORT PropertyFilter { enum Type { ALLOW, ALLOW_EMPTY, DENY }; + base::string16 match_str; + base::string16 property_str; + base::string16 filter_str; Type type; - PropertyFilter(base::string16 match_str, Type type) - : match_str(match_str), type(type) {} + PropertyFilter(const base::string16& str, Type type); + PropertyFilter(const PropertyFilter&); }; // A single node filter specification which will exclude any node where the diff --git a/chromium/content/public/browser/android/compositor.h b/chromium/content/public/browser/android/compositor.h index fd0018b2703..babee38df15 100644 --- a/chromium/content/public/browser/android/compositor.h +++ b/chromium/content/public/browser/android/compositor.h @@ -68,6 +68,9 @@ class CONTENT_EXPORT Compositor { // Set the output surface bounds. virtual void SetWindowBounds(const gfx::Size& size) = 0; + // Return the last size set with |SetWindowBounds|. + virtual const gfx::Size& GetWindowBounds() = 0; + // Set the output surface which the compositor renders into. virtual void SetSurface(jobject surface, bool can_be_used_with_surface_control) = 0; diff --git a/chromium/content/public/browser/authenticator_request_client_delegate.h b/chromium/content/public/browser/authenticator_request_client_delegate.h index e184e0f6fb9..f90abf0419a 100644 --- a/chromium/content/public/browser/authenticator_request_client_delegate.h +++ b/chromium/content/public/browser/authenticator_request_client_delegate.h @@ -50,6 +50,7 @@ class CONTENT_EXPORT AuthenticatorRequestClientDelegate kAuthenticatorRemovedDuringPINEntry, kAuthenticatorMissingResidentKeys, kAuthenticatorMissingUserVerification, + kNoCommonAlgorithms, // kStorageFull indicates that a resident credential could not be created // because the authenticator has insufficient storage. kStorageFull, diff --git a/chromium/content/public/browser/browser_context.h b/chromium/content/public/browser/browser_context.h index 8140c9b0468..429b7d0188e 100644 --- a/chromium/content/public/browser/browser_context.h +++ b/chromium/content/public/browser/browser_context.h @@ -92,6 +92,7 @@ class SharedCorsOriginAccessList; class SiteInstance; class StorageNotificationService; class StoragePartition; +class StoragePartitionConfig; class SSLHostStateDelegate; // A mapping from the scheme name to the protocol handler that services its @@ -130,10 +131,25 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { static StoragePartition* GetStoragePartition(BrowserContext* browser_context, SiteInstance* site_instance, bool can_create = true); + + // Returns a StoragePartition for the given StoragePartitionConfig. By + // default this will create a new StoragePartition if it doesn't exist, + // unless |can_create| is false. + static StoragePartition* GetStoragePartition( + BrowserContext* browser_context, + const StoragePartitionConfig& storage_partition_config, + bool can_create = true); + + // Deprecated. Do not add new callers. Use the SiteInstance or + // StoragePartitionConfig methods above instead. + // Returns a StoragePartition for the given site URL. By default this will + // create a new StoragePartition if it doesn't exist, unless |can_create| is + // false. static StoragePartition* GetStoragePartitionForSite( BrowserContext* browser_context, const GURL& site, bool can_create = true); + using StoragePartitionCallback = base::RepeatingCallback<void(StoragePartition*)>; static void ForEachStoragePartition(BrowserContext* browser_context, diff --git a/chromium/content/public/browser/browser_or_resource_context.h b/chromium/content/public/browser/browser_or_resource_context.h index 48a2f568d5a..62906464ad4 100644 --- a/chromium/content/public/browser/browser_or_resource_context.h +++ b/chromium/content/public/browser/browser_or_resource_context.h @@ -8,7 +8,7 @@ #include <cstddef> #include <type_traits> -#include "base/logging.h" +#include "base/check_op.h" #include "content/public/browser/browser_thread.h" namespace content { diff --git a/chromium/content/public/browser/browser_task_traits.h b/chromium/content/public/browser/browser_task_traits.h index df30a2ebbdc..281a791e13e 100644 --- a/chromium/content/public/browser/browser_task_traits.h +++ b/chromium/content/public/browser/browser_task_traits.h @@ -49,10 +49,10 @@ enum class BrowserTaskType { // to a BrowserThread. // // To post a task to the UI thread (analogous for IO thread): -// base::PostTask(FROM_HERE, {BrowserThread::UI}, task); +// GetUIThreadTaskRunner({})->PostTask(FROM_HERE, task); // // To obtain a TaskRunner for the UI thread (analogous for the IO thread): -// base::CreateSingleThreadTaskRunner({BrowserThread::UI}); +// GetUIThreadTaskRunner({}); // // Tasks posted to the same BrowserThread with the same traits will be executed // in the order they were posted, regardless of the TaskRunners they were @@ -152,6 +152,12 @@ class CONTENT_EXPORT BrowserTaskTraits : public base::TaskTraits { // TODO(1026641): Reconsider whether BrowserTaskTraits should really be // supporting base::TaskPriority. ValidTrait(base::TaskPriority); + + // TODO(1026641): These traits are meaningless on BrowserThreads but some + // callers of post_task.h had been using them in conjunction with + // BrowserThread::ID traits. Remove such usage post-migration. + ValidTrait(base::MayBlock); + ValidTrait(base::TaskShutdownBehavior); }; // TODO(1026641): Get rid of BrowserTaskTraitsExtension and store its members diff --git a/chromium/content/public/browser/browsing_data_remover.h b/chromium/content/public/browser/browsing_data_remover.h index 586ecaa5d32..3d474a7675a 100644 --- a/chromium/content/public/browser/browsing_data_remover.h +++ b/chromium/content/public/browser/browsing_data_remover.h @@ -63,7 +63,7 @@ class BrowsingDataRemoverDelegate; class BrowsingDataRemover { public: // Mask used for Remove. - enum DataType { + enum DataType : uint64_t { // Storage datatypes. DATA_TYPE_APP_CACHE = 1 << 0, DATA_TYPE_FILE_SYSTEMS = 1 << 1, @@ -115,7 +115,7 @@ class BrowsingDataRemover { DATA_TYPE_CONTENT_END = DATA_TYPE_CONVERSIONS, }; - enum OriginType { + enum OriginType : uint64_t { // Web storage origins that StoragePartition recognizes as NOT protected // according to its special storage policy. ORIGIN_TYPE_UNPROTECTED_WEB = 1 << 0, @@ -159,7 +159,7 @@ class BrowsingDataRemover { // Determines whether |origin| matches the |origin_type_mask| according to // the |special_storage_policy|. virtual bool DoesOriginMatchMaskForTesting( - int origin_type_mask, + uint64_t origin_type_mask, const url::Origin& origin, storage::SpecialStoragePolicy* special_storage_policy) = 0; @@ -167,15 +167,15 @@ class BrowsingDataRemover { // specified by |remove_mask| and origin types by |origin_type_mask|. virtual void Remove(const base::Time& delete_begin, const base::Time& delete_end, - int remove_mask, - int origin_type_mask) = 0; + uint64_t remove_mask, + uint64_t origin_type_mask) = 0; // A version of the above that in addition informs the |observer| when the // removal task is finished. virtual void RemoveAndReply(const base::Time& delete_begin, const base::Time& delete_end, - int remove_mask, - int origin_type_mask, + uint64_t remove_mask, + uint64_t origin_type_mask, Observer* observer) = 0; // A version of the above that in addition informs the |observer| when the @@ -183,8 +183,8 @@ class BrowsingDataRemover { virtual void RemoveWithFilterAndReply( const base::Time& delete_begin, const base::Time& delete_end, - int remove_mask, - int origin_type_mask, + uint64_t remove_mask, + uint64_t origin_type_mask, std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, Observer* observer) = 0; @@ -207,8 +207,8 @@ class BrowsingDataRemover { // consider simplifying this interface by removing these methods and changing // the tests to record the parameters using GMock instead. virtual const base::Time& GetLastUsedBeginTimeForTesting() = 0; - virtual int GetLastUsedRemovalMaskForTesting() = 0; - virtual int GetLastUsedOriginTypeMaskForTesting() = 0; + virtual uint64_t GetLastUsedRemovalMaskForTesting() = 0; + virtual uint64_t GetLastUsedOriginTypeMaskForTesting() = 0; }; } // namespace content diff --git a/chromium/content/public/browser/browsing_data_remover_delegate.h b/chromium/content/public/browser/browsing_data_remover_delegate.h index 4774cb1b099..b06d2399deb 100644 --- a/chromium/content/public/browser/browsing_data_remover_delegate.h +++ b/chromium/content/public/browser/browsing_data_remover_delegate.h @@ -5,6 +5,8 @@ #ifndef CONTENT_PUBLIC_BROWSER_BROWSING_DATA_REMOVER_DELEGATE_H_ #define CONTENT_PUBLIC_BROWSER_BROWSING_DATA_REMOVER_DELEGATE_H_ +#include <string> +#include <vector> #include "base/callback_forward.h" namespace base { @@ -28,12 +30,17 @@ class BrowsingDataRemoverDelegate { // Determines whether |origin| matches |origin_type_mask| given // the |special_storage_policy|. using EmbedderOriginTypeMatcher = - base::RepeatingCallback<bool(int origin_type_mask, + base::RepeatingCallback<bool(uint64_t origin_type_mask, const url::Origin& origin, storage::SpecialStoragePolicy* policy)>; virtual ~BrowsingDataRemoverDelegate() {} + // The embedder can define domains, for which cookies are only deleted + // after all other deletions are finished. + virtual std::vector<std::string> GetDomainsForDeferredCookieDeletion( + uint64_t remove_mask) = 0; + // Returns a MaskMatcherFunction to match embedder's origin types. // This MaskMatcherFunction will be called with an |origin_type_mask| // parameter containing ONLY embedder-defined origin types, and must be able @@ -47,9 +54,9 @@ class BrowsingDataRemoverDelegate { // Removes embedder-specific data. virtual void RemoveEmbedderData(const base::Time& delete_begin, const base::Time& delete_end, - int remove_mask, + uint64_t remove_mask, BrowsingDataFilterBuilder* filter_builder, - int origin_type_mask, + uint64_t origin_type_mask, base::OnceClosure callback) = 0; }; diff --git a/chromium/content/public/browser/child_process_termination_info.h b/chromium/content/public/browser/child_process_termination_info.h index 1edb82c008c..deb21d02650 100644 --- a/chromium/content/public/browser/child_process_termination_info.h +++ b/chromium/content/public/browser/child_process_termination_info.h @@ -46,6 +46,9 @@ struct CONTENT_EXPORT ChildProcessTerminationInfo { // True if child service was explicitly killed by browser. bool was_killed_intentionally_by_browser = false; + // True if child process threw an exception before calling into main. + bool threw_exception_during_init = false; + // True if the child shut itself down cleanly by quitting the main runloop. bool clean_exit = false; diff --git a/chromium/content/public/browser/content_browser_client.cc b/chromium/content/public/browser/content_browser_client.cc index c8c1e668d08..87375b2ef10 100644 --- a/chromium/content/public/browser/content_browser_client.cc +++ b/chromium/content/public/browser/content_browser_client.cc @@ -9,7 +9,7 @@ // declarations instead of including more headers. If that is infeasible, adjust // the limit. For more info, see // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md -#pragma clang max_tokens_here 840000 +#pragma clang max_tokens_here 860000 #include <utility> @@ -165,6 +165,12 @@ bool ContentBrowserClient::ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel( return false; } +std::string ContentBrowserClient::GetSiteDisplayNameForCdmProcess( + BrowserContext* browser_context, + const GURL& site_url) { + return site_url.spec(); +} + void ContentBrowserClient::OverrideURLLoaderFactoryParams( BrowserContext* browser_context, const url::Origin& origin, @@ -406,6 +412,11 @@ std::string ContentBrowserClient::GetWebBluetoothBlocklist() { return std::string(); } +bool ContentBrowserClient::AllowConversionMeasurement( + content::BrowserContext* browser_context) { + return true; +} + scoped_refptr<QuotaPermissionContext> ContentBrowserClient::CreateQuotaPermissionContext() { return nullptr; @@ -485,18 +496,12 @@ bool ContentBrowserClient::IsValidStoragePartitionId( return partition_id.empty(); } -void ContentBrowserClient::GetStoragePartitionConfigForSite( +StoragePartitionConfig ContentBrowserClient::GetStoragePartitionConfigForSite( BrowserContext* browser_context, - const GURL& site, - bool can_be_default, - std::string* partition_domain, - std::string* partition_name, - bool* in_memory) { + const GURL& site) { DCHECK(browser_context); - partition_domain->clear(); - partition_name->clear(); - *in_memory = false; + return StoragePartitionConfig::CreateDefault(); } MediaObserver* ContentBrowserClient::GetMediaObserver() { @@ -536,9 +541,11 @@ ContentBrowserClient::CreateSpeechRecognitionManagerDelegate() { return nullptr; } +#if defined(OS_CHROMEOS) TtsControllerDelegate* ContentBrowserClient::GetTtsControllerDelegate() { return nullptr; } +#endif TtsPlatform* ContentBrowserClient::GetTtsPlatform() { return nullptr; @@ -663,10 +670,6 @@ void ContentBrowserClient::OpenURL( std::move(callback).Run(nullptr); } -std::string ContentBrowserClient::GetMetricSuffixForURL(const GURL& url) { - return std::string(); -} - std::vector<std::unique_ptr<NavigationThrottle>> ContentBrowserClient::CreateThrottlesForNavigation( NavigationHandle* navigation_handle) { @@ -723,10 +726,6 @@ std::vector<std::string> ContentBrowserClient::GetStartupServices() { return std::vector<std::string>(); } -::rappor::RapporService* ContentBrowserClient::GetRapporService() { - return nullptr; -} - std::vector<std::unique_ptr<blink::URLLoaderThrottle>> ContentBrowserClient::CreateURLLoaderThrottles( const network::ResourceRequest& request, @@ -889,11 +888,13 @@ bool ContentBrowserClient::ShouldCreateThreadPool() { return true; } +#if !defined(OS_ANDROID) std::unique_ptr<AuthenticatorRequestClientDelegate> ContentBrowserClient::GetWebAuthenticationRequestDelegate( RenderFrameHost* render_frame_host) { return std::make_unique<AuthenticatorRequestClientDelegate>(); } +#endif std::unique_ptr<net::ClientCertStore> ContentBrowserClient::CreateClientCertStore(BrowserContext* browser_context) { @@ -1089,9 +1090,16 @@ bool ContentBrowserClient::IsOriginTrialRequiredForAppCache( blink::features::kAppCacheRequireOriginTrial); } +void ContentBrowserClient::BindBrowserControlInterface( + mojo::GenericPendingReceiver receiver) {} + bool ContentBrowserClient::ShouldInheritCrossOriginEmbedderPolicyImplicitly( const GURL& url) { return false; } +ukm::UkmService* ContentBrowserClient::GetUkmService() { + return nullptr; +} + } // namespace content diff --git a/chromium/content/public/browser/content_browser_client.h b/chromium/content/public/browser/content_browser_client.h index b211fea9879..edf60410ba5 100644 --- a/chromium/content/public/browser/content_browser_client.h +++ b/chromium/content/public/browser/content_browser_client.h @@ -28,6 +28,7 @@ #include "content/public/browser/allow_service_worker_result.h" #include "content/public/browser/certificate_request_result_type.h" #include "content/public/browser/generated_code_cache_settings.h" +#include "content/public/browser/storage_partition_config.h" #include "content/public/common/page_visibility_state.h" #include "content/public/common/previews_state.h" #include "content/public/common/window_container_type.mojom-forward.h" @@ -148,10 +149,6 @@ class TrustedURLLoaderHeaderClient; struct ResourceRequest; } // namespace network -namespace rappor { -class RapporService; -} // namespace rappor - namespace sandbox { class TargetPolicy; } // namespace sandbox @@ -161,6 +158,10 @@ class SelectFilePolicy; class ClipboardFormatType; } // namespace ui +namespace ukm { +class UkmService; +} // namespace ukm + namespace url { class Origin; } // namespace url @@ -202,7 +203,6 @@ class SiteInstance; class SpeechRecognitionManagerDelegate; class StoragePartition; class TracingDelegate; -class TtsControllerDelegate; class TtsPlatform; class URLLoaderRequestInterceptor; class VpnServiceProxy; @@ -219,6 +219,10 @@ struct Referrer; struct SocketPermissionRequest; struct WebPreferences; +#if defined(OS_CHROMEOS) +class TtsControllerDelegate; +#endif + // Embedder API (or SPI) for participating in browser logic, to be implemented // by the client of the content browser. See ChromeContentBrowserClient for the // principal implementation. The methods are assumed to be called on the UI @@ -396,6 +400,12 @@ class CONTENT_EXPORT ContentBrowserClient { base::StringPiece scheme, bool is_embedded_origin_secure); + // Gets a user friendly display name for a given |site_url| to be used in the + // CDM process name. + virtual std::string GetSiteDisplayNameForCdmProcess( + BrowserContext* browser_context, + const GURL& site_url); + // This method allows the //content embedder to override |factory_params| with // |origin|-specific properties (e.g. with relaxed Cross-Origin Read Blocking // enforcement as needed by some extensions, or with extension-specific CORS @@ -706,6 +716,14 @@ class CONTENT_EXPORT ContentBrowserClient { // "1812:e, 00001800-0000-1000-8000-00805f9b34fb:w, ignored:1, alsoignored." virtual std::string GetWebBluetoothBlocklist(); + // Allows the embedder to control the conversion measurement API. + // This gates the following behaviors: + // - Impression registration + // - Conversion registration + // - Conversion reports + virtual bool AllowConversionMeasurement( + content::BrowserContext* browser_context); + #if defined(OS_CHROMEOS) // Notification that a trust anchor was used by the given user. virtual void OnTrustAnchorUsed(BrowserContext* browser_context) {} @@ -751,27 +769,13 @@ class CONTENT_EXPORT ContentBrowserClient { virtual bool IsValidStoragePartitionId(BrowserContext* browser_context, const std::string& partition_id); - // Allows the embedder to provide a storage parititon configuration for a + // Allows the embedder to provide a storage partition configuration for a // site. A storage partition configuration includes a domain of the embedder's // choice, an optional name within that domain, and whether the partition is // in-memory only. - // - // If |can_be_default| is false, the caller is telling the embedder that the - // |site| is known to not be in the default partition. This is useful in - // some shutdown situations where the bookkeeping logic that maps sites to - // their partition configuration are no longer valid. - // - // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in - // which partitions live (similar to namespace). Within a domain, partitions - // can be uniquely identified by the combination of |partition_name| and - // |in_memory| values. When a partition is not to be persisted, the - // |in_memory| value must be set to true. - virtual void GetStoragePartitionConfigForSite(BrowserContext* browser_context, - const GURL& site, - bool can_be_default, - std::string* partition_domain, - std::string* partition_name, - bool* in_memory); + virtual StoragePartitionConfig GetStoragePartitionConfigForSite( + BrowserContext* browser_context, + const GURL& site); // Create and return a new quota permission context. virtual scoped_refptr<QuotaPermissionContext> CreateQuotaPermissionContext(); @@ -854,8 +858,10 @@ class CONTENT_EXPORT ContentBrowserClient { virtual SpeechRecognitionManagerDelegate* CreateSpeechRecognitionManagerDelegate(); +#if defined(OS_CHROMEOS) // Allows the embedder to return a delegate for the TtsController. virtual TtsControllerDelegate* GetTtsControllerDelegate(); +#endif // Allows the embedder to return a TTS platform implementation. virtual TtsPlatform* GetTtsPlatform(); @@ -928,10 +934,10 @@ class CONTENT_EXPORT ContentBrowserClient { virtual void GetAdditionalAllowedSchemesForFileSystem( std::vector<std::string>* additional_schemes) {} - // |schemes| is a return value parameter that gets a whitelist of schemes that - // should bypass the Is Privileged Context check. + // |schemes| is a return value parameter that gets an allowlist of schemes + // that should bypass the Is Privileged Context check. // See http://www.w3.org/TR/powerful-features/#settings-privileged - virtual void GetSchemesBypassingSecureContextCheckWhitelist( + virtual void GetSchemesBypassingSecureContextCheckAllowlist( std::set<std::string>* schemes) {} // Returns auto mount handlers for URL requests for FileSystem APIs. @@ -995,12 +1001,6 @@ class CONTENT_EXPORT ContentBrowserClient { mojo::GenericPendingReceiver receiver) { } - // Called when RenderFrameHostImpl connects to the Media service. Expose - // interfaces to the service using |registry|. - virtual void ExposeInterfacesToMediaService( - service_manager::BinderRegistry* registry, - RenderFrameHost* render_frame_host) {} - // The Media Service can run in many different types of configurations // (typically in the GPU process or its own isolated process), but some // clients want an additional dedicated instance to use for specific @@ -1039,6 +1039,10 @@ class CONTENT_EXPORT ContentBrowserClient { // process. Called on the IO thread. virtual void BindGpuHostReceiver(mojo::GenericPendingReceiver receiver) {} + // Handles an unhandled incoming interface binding request from a Utility + // process. Called on the IO thread. + virtual void BindUtilityHostReceiver(mojo::GenericPendingReceiver receiver) {} + // Called on the main thread to handle an unhandled interface receiver binding // request from a render process. See |RenderThread::BindHostReceiver()|. virtual void BindHostReceiverForRenderer( @@ -1109,16 +1113,6 @@ class CONTENT_EXPORT ContentBrowserClient { const OpenURLParams& params, base::OnceCallback<void(WebContents*)> callback); - // Allows the embedder to record |metric| for a specific |url|. - virtual void RecordURLMetric(const std::string& metric, const GURL& url) {} - - // Allows the embedder to map URLs to strings, intended to be used as suffixes - // for metric names. For example, the embedder can map - // "my-special-site-with-a-complicated-name.example.com/and-complicated-path" - // to the string "MySpecialSite", which will cause some UMA involving that URL - // to be logged as "UmaName.MySpecialSite". - virtual std::string GetMetricSuffixForURL(const GURL& url); - // Allows the embedder to register one or more NavigationThrottles for the // navigation indicated by |navigation_handle|. A NavigationThrottle is used // to control the flow of a navigation on the UI thread. The embedder is @@ -1192,19 +1186,18 @@ class CONTENT_EXPORT ContentBrowserClient { mojo::PendingRemote<media::mojom::RemotingSource> source, mojo::PendingReceiver<media::mojom::Remoter> receiver) {} - // Returns the RapporService from the browser process. - virtual ::rappor::RapporService* GetRapporService(); - - // Allows the embedder to register one or more URLLoaderThrottles for one of - // the following requests: - // 1) A navigation request. - // 2) A request for a dedicated worker's main script (when PlzDedicatedWorker - // is enabled). - // 3) A request for a shared worker's main script. + // Allows the embedder to register one or more URLLoaderThrottles for a + // browser-initiated request. These include navigation requests and requests + // for web worker scripts. // - // For a request for worker's main script, |wc_getter|, |navigation_ui_data|, - // and |frame_tree_node_id| take a callback returning a nullptr, nullptr, and - // RenderFrameHost::kNoFrameTreeNodeId respectively. + // |wc_getter| returns the WebContents of the context of the |request| when + // available. It can return nullptr for requests for which it there are no + // WebContents (e.g., requests for web workers). + // + // |navigation_ui_data| is only valid if this is a navigation request. + // + // |frame_tree_node_id| is also invalid (kNoFrameTreeNodeId) in some cases + // (e.g., requests for web workers). // // This is called on the UI thread. virtual std::vector<std::unique_ptr<blink::URLLoaderThrottle>> @@ -1466,6 +1459,12 @@ class CONTENT_EXPORT ContentBrowserClient { // BrowserContext's StoragePartition. StoragePartition will use the // NetworkService to create a new NetworkContext using these params. // + // If the CertVerifierService is enabled, the CertVerifierCreationParams will + // be used to create a new CertVerifierService, which will be passed to the + // network service in NetworkContextParams. Otherwise, the + // CertVerifierCreationParams will be placed in the NetworkContextParams and + // sent directly to the NetworkService for in-process CertVerifier creation. + // // If |in_memory| is true, |relative_partition_path| is still a path that // uniquely identifies the storage partition, though nothing should be written // to it. @@ -1558,8 +1557,10 @@ class CONTENT_EXPORT ContentBrowserClient { // destroyed before the RenderFrame goes out of scope. The embedder may choose // to return nullptr to indicate that the request cannot be serviced right // now. +#if !defined(OS_ANDROID) virtual std::unique_ptr<AuthenticatorRequestClientDelegate> GetWebAuthenticationRequestDelegate(RenderFrameHost* render_frame_host); +#endif // Get platform ClientCertStore. May return nullptr. Called on the UI thread. virtual std::unique_ptr<net::ClientCertStore> CreateClientCertStore( @@ -1831,10 +1832,19 @@ class CONTENT_EXPORT ContentBrowserClient { virtual bool IsOriginTrialRequiredForAppCache( content::BrowserContext* browser_text); + // External applications and services may launch the browser in a mode which + // exposes browser control interfaces via Mojo. Any such interface binding + // request received from an external client is passed to this method. + virtual void BindBrowserControlInterface( + mojo::GenericPendingReceiver receiver); + // Returns true when a context (e.g., iframe) whose URL is |url| should // inherit the parent COEP value implicitly, similar to "blob:" virtual bool ShouldInheritCrossOriginEmbedderPolicyImplicitly( const GURL& url); + + // Returns the URL-Keyed Metrics service for chrome:ukm. + virtual ukm::UkmService* GetUkmService(); }; } // namespace content diff --git a/chromium/content/public/browser/context_menu_params.h b/chromium/content/public/browser/context_menu_params.h index 5d54099d2a6..2e4d14eb2dd 100644 --- a/chromium/content/public/browser/context_menu_params.h +++ b/chromium/content/public/browser/context_menu_params.h @@ -37,6 +37,9 @@ struct CONTENT_EXPORT ContextMenuParams // This is the URL of the subframe that the context menu was invoked on. GURL frame_url; + // Extra properties for the context menu. + std::map<std::string, std::string> properties; + private: // RenderFrameHostImpl is responsible for validating and sanitizing // UntrustworthyContextMenuParams into ContextMenuParams and therefore is a diff --git a/chromium/content/public/browser/cors_exempt_headers.cc b/chromium/content/public/browser/cors_exempt_headers.cc deleted file mode 100644 index 6faee524304..00000000000 --- a/chromium/content/public/browser/cors_exempt_headers.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2019 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/public/browser/cors_exempt_headers.h" - -#include "content/public/common/content_constants.h" - -namespace content { - -void UpdateCorsExemptHeader(network::mojom::NetworkContextParams* params) { - // Note: This mechanism will be deprecated in the near future. You can find - // a recommended alternative approach on URLRequest::cors_exempt_headers at - // services/network/public/mojom/url_loader.mojom. - params->cors_exempt_header_list.push_back(kCorsExemptPurposeHeaderName); - params->cors_exempt_header_list.push_back(kCorsExemptRequestedWithHeaderName); -} - -} // namespace content diff --git a/chromium/content/public/browser/cors_exempt_headers.h b/chromium/content/public/browser/cors_exempt_headers.h deleted file mode 100644 index c9b5cf13f04..00000000000 --- a/chromium/content/public/browser/cors_exempt_headers.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 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_PUBLIC_BROWSER_CORS_EXEMPT_HEADERS_H_ -#define CONTENT_PUBLIC_BROWSER_CORS_EXEMPT_HEADERS_H_ - -#include "content/common/content_export.h" -#include "services/network/public/mojom/network_context.mojom.h" - -namespace content { - -// Updates |cors_exempt_header_list| field of the given |param| to register -// headers that are used in content for special purpose and should not be -// blocked by CORS checks. -CONTENT_EXPORT void UpdateCorsExemptHeader( - network::mojom::NetworkContextParams* params); - -} // namespace content - -#endif // CONTENT_PUBLIC_BROWSER_CORS_EXEMPT_HEADERS_H_ diff --git a/chromium/content/public/browser/dedicated_worker_service.h b/chromium/content/public/browser/dedicated_worker_service.h index 4c5dae9e6df..b062f04825f 100644 --- a/chromium/content/public/browser/dedicated_worker_service.h +++ b/chromium/content/public/browser/dedicated_worker_service.h @@ -20,12 +20,14 @@ class CONTENT_EXPORT DedicatedWorkerService { public: class Observer : public base::CheckedObserver { public: - // Called when a dedicated worker has started/stopped. - virtual void OnWorkerStarted( + // Called when a dedicated worker is created/destroyed. Note that it is not + // yet started in the renderer since its script still has to be downloaded + // and evaluated. + virtual void OnWorkerCreated( DedicatedWorkerId dedicated_worker_id, int worker_process_id, GlobalFrameRoutingId ancestor_render_frame_host_id) = 0; - virtual void OnBeforeWorkerTerminated( + virtual void OnBeforeWorkerDestroyed( DedicatedWorkerId dedicated_worker_id, GlobalFrameRoutingId ancestor_render_frame_host_id) = 0; @@ -42,13 +44,13 @@ class CONTENT_EXPORT DedicatedWorkerService { virtual void AddObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0; - // Invokes OnWorkerStarted() on |observer| for all existing dedicated workers. + // Invokes OnWorkerCreated() on |observer| for all existing dedicated workers. // // This function must be invoked in conjunction with AddObserver(). It is // meant to be used by an observer that dynamically subscribes to the // DedicatedWorkerService while some workers are already running. It avoids - // receiving a OnBeforeWorkerTerminated() event without having received the - // corresponding OnWorkerStart() event. + // receiving a OnBeforeWorkerDestroyed() event without having received the + // corresponding OnWorkerCreated() event. virtual void EnumerateDedicatedWorkers(Observer* observer) = 0; protected: diff --git a/chromium/content/public/browser/download_manager_delegate.cc b/chromium/content/public/browser/download_manager_delegate.cc index bea2e24ba8e..3d9cfe542f0 100644 --- a/chromium/content/public/browser/download_manager_delegate.cc +++ b/chromium/content/public/browser/download_manager_delegate.cc @@ -8,6 +8,7 @@ #include "base/bind_helpers.h" #include "base/threading/thread_task_runner_handle.h" #include "components/download/public/common/download_item.h" +#include "content/public/browser/web_contents_delegate.h" namespace content { @@ -69,11 +70,33 @@ void DownloadManagerDelegate::CheckDownloadAllowed( bool from_download_cross_origin_redirect, bool content_initiated, CheckDownloadAllowedCallback check_download_allowed_cb) { - // TODO: once hook up delegate callback, make sure sync run of it doesn't - // crash and test it + // TODO: Do this directly, if it doesn't crash. base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(std::move(check_download_allowed_cb), true)); + FROM_HERE, + base::BindOnce( + [](const WebContents::Getter& web_contents_getter, const GURL& url, + const std::string& request_method, + CheckDownloadAllowedCallback check_download_allowed_cb) { + WebContents* contents = web_contents_getter.Run(); + if (!contents) { + // The contents was closed. + std::move(check_download_allowed_cb).Run(false); + return; + } + + WebContentsDelegate* delegate = contents->GetDelegate(); + if (!delegate) { + // The default behavior is to allow it. + std::move(check_download_allowed_cb).Run(true); + return; + } + + delegate->CanDownload(url, request_method, + std::move(check_download_allowed_cb)); + }, + web_contents_getter, url, request_method, + std::move(check_download_allowed_cb))); } download::QuarantineConnectionCallback diff --git a/chromium/content/public/browser/download_manager_delegate.h b/chromium/content/public/browser/download_manager_delegate.h index 5105f4c80c8..100a2e498bc 100644 --- a/chromium/content/public/browser/download_manager_delegate.h +++ b/chromium/content/public/browser/download_manager_delegate.h @@ -9,11 +9,11 @@ #include "base/callback.h" #include "base/files/file_path.h" -#include "base/logging.h" #include "base/optional.h" #include "base/time/time.h" #include "components/download/public/common/download_danger_type.h" #include "components/download/public/common/download_item.h" +#include "components/download/public/common/download_schedule.h" #include "components/download/public/common/download_url_parameters.h" #include "components/download/public/common/quarantine_connection.h" #include "content/common/content_export.h" @@ -67,6 +67,7 @@ using DownloadTargetCallback = base::OnceCallback<void( download::DownloadDangerType danger_type, download::DownloadItem::MixedContentStatus mixed_content_status, const base::FilePath& intermediate_path, + base::Optional<download::DownloadSchedule> download_schedule, download::DownloadInterruptReason interrupt_reason)>; // Called when a download delayed by the delegate has completed. diff --git a/chromium/content/public/browser/google_streaming_api.proto b/chromium/content/public/browser/google_streaming_api.proto new file mode 100644 index 00000000000..ce1b8d98a49 --- /dev/null +++ b/chromium/content/public/browser/google_streaming_api.proto @@ -0,0 +1,76 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +syntax = "proto2"; +option optimize_for = LITE_RUNTIME; + +// TODO(hans): Commented out due to compilation errors. +// option cc_api_version = 2; + +package content.proto; + +// SpeechRecognitionEvent is the only message type sent to client. +// +// The first SpeechRecognitionEvent is an empty (default) message to indicate +// as early as possible that the stream connection has been established. +message SpeechRecognitionEvent { + enum StatusCode { + // Note: in JavaScript API SpeechRecognitionError 0 is "OTHER" error. + STATUS_SUCCESS = 0; + STATUS_NO_SPEECH = 1; + STATUS_ABORTED = 2; + STATUS_AUDIO_CAPTURE = 3; + STATUS_NETWORK = 4; + STATUS_NOT_ALLOWED = 5; + STATUS_SERVICE_NOT_ALLOWED = 6; + STATUS_BAD_GRAMMAR = 7; + STATUS_LANGUAGE_NOT_SUPPORTED = 8; + } + optional StatusCode status = 1 [default = STATUS_SUCCESS]; + + // May contain zero or one final=true result (the newly settled portion). + // May also contain zero or more final=false results. + // (Note that this differs from JavaScript API resultHistory in that no more + // than one final=true result is returned, so client must accumulate + // resultHistory by concatenating the final=true results.) + repeated SpeechRecognitionResult result = 2; + + enum EndpointerEventType { + START_OF_SPEECH = 0; + END_OF_SPEECH = 1; + END_OF_AUDIO = 2; // End of audio stream has been reached. + // End of utterance indicates that no more speech segments are expected. + END_OF_UTTERANCE = 3; + } + + optional EndpointerEventType endpoint = 4; +}; + +message SpeechRecognitionResult { + repeated SpeechRecognitionAlternative alternative = 1; + + // True if this is the final time the speech service will return this + // particular SpeechRecognitionResult. If false, then this represents an + // interim result that could still be changed. + optional bool final = 2 [default = false]; + + // An estimate of the probability that the recognizer will not change its + // guess about this interim result. Values range from 0.0 (completely + // unstable) to 1.0 (completely stable). Note that this is not the same as + // "confidence", which estimate the probability that a recognition result + // is correct. This field is only provided for interim (final=false) results. + optional float stability = 3; +}; + +// Item in N-best list. +message SpeechRecognitionAlternative { + // Spoken text. + optional string transcript = 1; + + // The confidence estimate between 0.0 and 1.0. A higher number means the + // system is more confident that the recognition is correct. + // This field is typically provided only for the top hypothesis and only for + // final results. + optional float confidence = 2; +} diff --git a/chromium/content/public/browser/gpu_data_manager.h b/chromium/content/public/browser/gpu_data_manager.h index d9207f2b050..a54dab6ca68 100644 --- a/chromium/content/public/browser/gpu_data_manager.h +++ b/chromium/content/public/browser/gpu_data_manager.h @@ -32,8 +32,11 @@ enum GpuProcessKind { enum GpuInfoRequest { kGpuInfoRequestDxDiag = 1 << 0, - kGpuInfoRequestDx12Vulkan = 1 << 1, - kGpuInfoRequestAll = kGpuInfoRequestDxDiag | kGpuInfoRequestDx12Vulkan, + kGpuInfoRequestDx12 = 1 << 1, + kGpuInfoRequestVulkan = 1 << 2, + kGpuInfoRequestDx12Vulkan = kGpuInfoRequestVulkan | kGpuInfoRequestDx12, + kGpuInfoRequestAll = + kGpuInfoRequestDxDiag | kGpuInfoRequestDx12 | kGpuInfoRequestVulkan, }; class GpuDataManagerObserver; diff --git a/chromium/content/public/browser/gpu_utils.cc b/chromium/content/public/browser/gpu_utils.cc index 438d5f19ace..89f1ebcd559 100644 --- a/chromium/content/public/browser/gpu_utils.cc +++ b/chromium/content/public/browser/gpu_utils.cc @@ -41,6 +41,12 @@ void StopGpuProcessImpl(base::OnceClosure callback, std::move(callback).Run(); } +void KillGpuProcessImpl(content::GpuProcessHost* host) { + if (host) { + host->ForceShutdown(); + } +} + } // namespace namespace content { @@ -131,6 +137,11 @@ void StopGpuProcess(base::OnceClosure callback) { std::move(callback)))); } +void KillGpuProcess() { + GpuProcessHost::CallOnIO(GPU_PROCESS_KIND_SANDBOXED, false /* force_create */, + base::BindOnce(&KillGpuProcessImpl)); +} + gpu::GpuChannelEstablishFactory* GetGpuChannelEstablishFactory() { return BrowserMainLoop::GetInstance()->gpu_channel_establish_factory(); } diff --git a/chromium/content/public/browser/gpu_utils.h b/chromium/content/public/browser/gpu_utils.h index b35ec8ea2c5..31d96e83d9b 100644 --- a/chromium/content/public/browser/gpu_utils.h +++ b/chromium/content/public/browser/gpu_utils.h @@ -20,6 +20,10 @@ CONTENT_EXPORT const gpu::GpuPreferences GetGpuPreferencesFromCommandLine(); CONTENT_EXPORT void StopGpuProcess(base::OnceClosure callback); +// Kills the GPU process with a normal termination status. +// TODO(crbug.com/1095977): Combine with StopGpuProcess +CONTENT_EXPORT void KillGpuProcess(); + CONTENT_EXPORT gpu::GpuChannelEstablishFactory* GetGpuChannelEstablishFactory(); #if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) diff --git a/chromium/content/public/browser/hid_delegate.h b/chromium/content/public/browser/hid_delegate.h index e4cc2905082..758fdbf3a8d 100644 --- a/chromium/content/public/browser/hid_delegate.h +++ b/chromium/content/public/browser/hid_delegate.h @@ -8,6 +8,7 @@ #include <memory> #include <vector> +#include "base/observer_list_types.h" #include "content/common/content_export.h" #include "content/public/browser/hid_chooser.h" #include "services/device/public/mojom/hid.mojom-forward.h" @@ -26,6 +27,18 @@ class CONTENT_EXPORT HidDelegate { public: virtual ~HidDelegate() = default; + class Observer : public base::CheckedObserver { + public: + // Events forwarded from HidChooserContext::DeviceObserver: + virtual void OnDeviceAdded(const device::mojom::HidDeviceInfo&) = 0; + virtual void OnDeviceRemoved(const device::mojom::HidDeviceInfo&) = 0; + virtual void OnHidManagerConnectionError() = 0; + + // Event forwarded from permissions::ChooserContextBase::PermissionObserver: + virtual void OnPermissionRevoked(const url::Origin& requesting_origin, + const url::Origin& embedding_origin) = 0; + }; + // Shows a chooser for the user to select a HID device. |callback| will be // run when the prompt is closed. Deleting the returned object will cancel the // prompt. @@ -58,6 +71,11 @@ class CONTENT_EXPORT HidDelegate { // possible. virtual device::mojom::HidManager* GetHidManager( WebContents* web_contents) = 0; + + // Functions to manage the set of Observer instances registered to this + // object. + virtual void AddObserver(RenderFrameHost* frame, Observer* observer) = 0; + virtual void RemoveObserver(RenderFrameHost* frame, Observer* observer) = 0; }; } // namespace content diff --git a/chromium/content/public/browser/mhtml_generation_result.h b/chromium/content/public/browser/mhtml_generation_result.h index a6cc0748029..fc2e706c2d0 100644 --- a/chromium/content/public/browser/mhtml_generation_result.h +++ b/chromium/content/public/browser/mhtml_generation_result.h @@ -5,6 +5,8 @@ #ifndef CONTENT_PUBLIC_BROWSER_MHTML_GENERATION_RESULT_H_ #define CONTENT_PUBLIC_BROWSER_MHTML_GENERATION_RESULT_H_ +#include <string> + #include "base/callback_forward.h" #include "base/optional.h" #include "content/common/content_export.h" diff --git a/chromium/content/public/browser/native_file_system_entry_factory.h b/chromium/content/public/browser/native_file_system_entry_factory.h index d7c42af8122..a61442e0388 100644 --- a/chromium/content/public/browser/native_file_system_entry_factory.h +++ b/chromium/content/public/browser/native_file_system_entry_factory.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "content/common/content_export.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/global_routing_id.h" #include "ipc/ipc_message.h" #include "third_party/blink/public/mojom/native_file_system/native_file_system_directory_handle.mojom-forward.h" #include "url/gurl.h" @@ -23,25 +24,24 @@ class CONTENT_EXPORT NativeFileSystemEntryFactory BrowserThread::DeleteOnUIThread> { public: // Context from which a created handle is going to be used. This is used for - // security and permission checks. Pass in MSG_ROUTING_NONE as frame_id if - // the context is a worker, otherwise use the routing id of the relevant - // RenderFrameHost. Pass in the URL most relevant as the url parameter. - // This url will be used for verifications later for SafeBrowsing and - // Quarantine Service if used for writes. + // security and permission checks. Pass in the URL most relevant as the url + // parameter. This url will be used for verifications later for SafeBrowsing + // and Quarantine Service if used for writes. struct CONTENT_EXPORT BindingContext { BindingContext(const url::Origin& origin, const GURL& url, - int process_id, - int frame_id) + GlobalFrameRoutingId frame_id) + : origin(origin), url(url), frame_id(frame_id) {} + BindingContext(const url::Origin& origin, + const GURL& url, + int worker_process_id) : origin(origin), url(url), - process_id(process_id), - frame_id(frame_id) {} + frame_id(worker_process_id, MSG_ROUTING_NONE) {} url::Origin origin; GURL url; - int process_id; - int frame_id; - bool is_worker() const { return frame_id == MSG_ROUTING_NONE; } + GlobalFrameRoutingId frame_id; + bool is_worker() const { return !frame_id; } }; // Creates a new NativeFileSystemEntryPtr from the path to a file. Assumes the diff --git a/chromium/content/public/browser/native_file_system_permission_context.h b/chromium/content/public/browser/native_file_system_permission_context.h index 558801ab48f..ebad6b1d994 100644 --- a/chromium/content/public/browser/native_file_system_permission_context.h +++ b/chromium/content/public/browser/native_file_system_permission_context.h @@ -6,6 +6,7 @@ #define CONTENT_PUBLIC_BROWSER_NATIVE_FILE_SYSTEM_PERMISSION_CONTEXT_H_ #include "base/files/file_path.h" +#include "content/public/browser/global_routing_id.h" #include "content/public/browser/native_file_system_permission_grant.h" #include "content/public/browser/native_file_system_write_item.h" #include "url/origin.h" @@ -37,17 +38,10 @@ class NativeFileSystemPermissionContext { }; // Returns the read permission grant to use for a particular path. - // |process_id| and |frame_id| are the frame in which the handle is used. Once - // postMessage is implemented this isn't meaningful anymore and should be - // removed, but until then they can be used for more accurate usage tracking. - // TODO(https://crbug.com/984769): Eliminate process_id and frame_id from - // this method when grants stop being scoped to a frame. virtual scoped_refptr<NativeFileSystemPermissionGrant> GetReadPermissionGrant( const url::Origin& origin, const base::FilePath& path, bool is_directory, - int process_id, - int frame_id, UserAction user_action) = 0; // Returns the permission grant to use for a particular path. This could be a @@ -55,17 +49,10 @@ class NativeFileSystemPermissionContext { // user has already granted write access to a directory, this method could // return that existing grant when figuring the grant to use for a file in // that directory. - // |process_id| and |frame_id| are the frame in which the handle is used. Once - // postMessage is implemented this isn't meaningful anymore and should be - // removed, but until then they can be used for more accurate usage tracking. - // TODO(https://crbug.com/984769): Eliminate process_id and frame_id from - // this method when grants stop being scoped to a frame. virtual scoped_refptr<NativeFileSystemPermissionGrant> GetWritePermissionGrant(const url::Origin& origin, const base::FilePath& path, bool is_directory, - int process_id, - int frame_id, UserAction user_action) = 0; // Displays a dialog to confirm that the user intended to give read access to @@ -74,8 +61,7 @@ class NativeFileSystemPermissionContext { virtual void ConfirmDirectoryReadAccess( const url::Origin& origin, const base::FilePath& path, - int process_id, - int frame_id, + GlobalFrameRoutingId frame_id, base::OnceCallback<void(PermissionStatus)> callback) = 0; // These values are persisted to logs. Entries should not be renumbered and @@ -95,8 +81,7 @@ class NativeFileSystemPermissionContext { const url::Origin& origin, const std::vector<base::FilePath>& paths, bool is_directory, - int process_id, - int frame_id, + GlobalFrameRoutingId frame_id, base::OnceCallback<void(SensitiveDirectoryResult)> callback) = 0; enum class AfterWriteCheckResult { kAllow, kBlock }; @@ -104,8 +89,7 @@ class NativeFileSystemPermissionContext { // or other security checks to determine if the write should be allowed. virtual void PerformAfterWriteChecks( std::unique_ptr<NativeFileSystemWriteItem> item, - int process_id, - int frame_id, + GlobalFrameRoutingId frame_id, base::OnceCallback<void(AfterWriteCheckResult)> callback) = 0; // Returns whether the give |origin| already allows write permission, or it is diff --git a/chromium/content/public/browser/native_file_system_permission_grant.h b/chromium/content/public/browser/native_file_system_permission_grant.h index 0f8e51057eb..70c54f2faa5 100644 --- a/chromium/content/public/browser/native_file_system_permission_grant.h +++ b/chromium/content/public/browser/native_file_system_permission_grant.h @@ -10,6 +10,7 @@ #include "base/observer_list.h" #include "base/observer_list_types.h" #include "content/common/content_export.h" +#include "content/public/browser/global_routing_id.h" #include "third_party/blink/public/mojom/permissions/permission_status.mojom-forward.h" namespace content { @@ -52,8 +53,7 @@ class CONTENT_EXPORT NativeFileSystemPermissionGrant // should be called after the status of this grant has been updated with // the outcome of the request. virtual void RequestPermission( - int process_id, - int frame_id, + GlobalFrameRoutingId frame_id, base::OnceCallback<void(PermissionRequestOutcome)> callback) = 0; // This observer can be used to be notified of changes to the permission diff --git a/chromium/content/public/browser/navigation_controller.h b/chromium/content/public/browser/navigation_controller.h index 754d13e9688..e9c849418a8 100644 --- a/chromium/content/public/browser/navigation_controller.h +++ b/chromium/content/public/browser/navigation_controller.h @@ -294,24 +294,18 @@ class NavigationController { // has not been responded to, the NavigationEntry is pending. Once data is // received for that entry, that NavigationEntry is committed. - // A transient entry is an entry that, when the user navigates away, is - // removed and discarded rather than being added to the back-forward list. - // Transient entries are useful for interstitial pages and the like. - // Active entry -------------------------------------------------------------- // THIS IS DEPRECATED. DO NOT USE. Use GetVisibleEntry instead. // See http://crbug.com/273710. // - // Returns the active entry, which is the transient entry if any, the pending - // entry if a navigation is in progress or the last committed entry otherwise. - // NOTE: This can be nullptr!! + // Returns the active entry, which is the pending entry if a navigation is in + // progress or the last committed entry otherwise. NOTE: This can be nullptr!! virtual NavigationEntry* GetActiveEntry() = 0; // Returns the entry that should be displayed to the user in the address bar. - // This is the transient entry if any, the pending entry if a navigation is - // in progress *and* is safe to display to the user (see below), or the last - // committed entry otherwise. + // This is the pending entry if a navigation is in progress *and* is safe to + // display to the user (see below), or the last committed entry otherwise. // NOTE: This can be nullptr if no entry has committed! // // A pending entry is safe to display if it started in the browser process or @@ -329,8 +323,7 @@ class NavigationController { virtual NavigationEntry* GetLastCommittedEntry() = 0; // Returns the index of the last committed entry. It will be -1 if there are - // no entries, or if there is a transient entry before the first entry - // commits. + // no entries. virtual int GetLastCommittedEntryIndex() = 0; // Returns true if the source for the current entry can be viewed. @@ -339,8 +332,7 @@ class NavigationController { // Navigation list ----------------------------------------------------------- // Returns the number of entries in the NavigationController, excluding - // the pending entry if there is one, but including the transient entry if - // any. + // the pending entry if there is one. virtual int GetEntryCount() = 0; virtual NavigationEntry* GetEntryAtIndex(int index) = 0; @@ -351,7 +343,7 @@ class NavigationController { // Pending entry ------------------------------------------------------------- - // Discards the pending and transient entries if any. + // Discards the pending entry if any. virtual void DiscardNonCommittedEntries() = 0; // Returns the pending entry corresponding to the navigation that is @@ -362,22 +354,6 @@ class NavigationController { // corresponds to a new navigation (created via LoadURL). virtual int GetPendingEntryIndex() = 0; - // Transient entry ----------------------------------------------------------- - - // Returns the transient entry if any. This is an entry which is removed and - // discarded if any navigation occurs. Note that the returned entry is owned - // by the navigation controller and may be deleted at any time. - virtual NavigationEntry* GetTransientEntry() = 0; - - // Adds an entry that is returned by GetActiveEntry(). The entry is - // transient: any navigation causes it to be removed and discarded. The - // NavigationController becomes the owner of |entry| and deletes it when - // it discards it. This is useful with interstitial pages that need to be - // represented as an entry, but should go away when the user navigates away - // from them. - // Note that adding a transient entry does not change the active contents. - virtual void SetTransientEntry(std::unique_ptr<NavigationEntry> entry) = 0; - // New navigations ----------------------------------------------------------- // Loads the specified URL, specifying extra http headers to add to the @@ -428,8 +404,7 @@ class NavigationController { // |check_for_repost| is true and the current entry has POST data the user is // prompted to see if they really want to reload the page. In nearly all // cases pass in true in production code, but would do false for testing, or - // in cases where no user interface is available for prompting. If a - // transient entry is showing, initiates a new navigation to its URL. + // in cases where no user interface is available for prompting. // NOTE: |reload_type| should never be NONE. virtual void Reload(ReloadType reload_type, bool check_for_repost) = 0; @@ -437,11 +412,11 @@ class NavigationController { // Removes the entry at the specified |index|. If the index is the last // committed index or the pending entry, this does nothing and returns false. - // Otherwise this call discards any transient or pending entries. + // Otherwise this call discards any pending entry. virtual bool RemoveEntryAtIndex(int index) = 0; - // Discards any transient or pending entries, then discards all entries after - // the current entry index. + // Discards any pending entry, then discards all entries after the current + // entry index. virtual void PruneForwardEntries() = 0; // Random -------------------------------------------------------------------- @@ -500,23 +475,20 @@ class NavigationController { // If there is a pending entry after *G* in |this|, it is also preserved. // If |replace_entry| is true, the current entry in |source| is replaced. So // the result above would be A B *G*. - // This ignores any pending or transient entries in |source|. Callers must - // ensure that |CanPruneAllButLastCommitted| returns true before calling this, - // or it will crash. + // This ignores any pending entry in |source|. Callers must ensure that + // |CanPruneAllButLastCommitted| returns true before calling this, or it will + // crash. virtual void CopyStateFromAndPrune(NavigationController* source, bool replace_entry) = 0; // Returns whether it is safe to call PruneAllButLastCommitted or - // CopyStateFromAndPrune. There must be a last committed entry, no transient - // entry, and if there is a pending entry, it must be new and not an existing - // entry. + // CopyStateFromAndPrune. There must be a last committed entry, and if there + // is a pending entry, it must be new and not an existing entry. // // If there were no last committed entry, the pending entry might not commit, // leaving us with a blank page. This is unsafe when used with // |CopyStateFromAndPrune|, which would show an existing entry above the blank // page. - // If there were a transient entry, we would not want to prune the other - // entries, which the transient entry could be referring to. // If there were an existing pending entry, we could not prune the last // committed entry, in case it did not commit. That would leave us with no // sensible place to put the pending entry when it did commit, after all other diff --git a/chromium/content/public/browser/navigation_handle.h b/chromium/content/public/browser/navigation_handle.h index b9accb65fe4..d3907d288e0 100644 --- a/chromium/content/public/browser/navigation_handle.h +++ b/chromium/content/public/browser/navigation_handle.h @@ -9,6 +9,7 @@ #include <string> #include "content/common/content_export.h" +#include "content/public/browser/navigation_handle_timing.h" #include "content/public/browser/navigation_throttle.h" #include "content/public/browser/reload_type.h" #include "content/public/browser/restore_type.h" @@ -22,6 +23,7 @@ #include "net/dns/public/resolve_error_info.h" #include "net/http/http_response_info.h" #include "services/network/public/cpp/resource_request_body.h" +#include "third_party/blink/public/mojom/referrer.mojom.h" #include "ui/base/page_transition_types.h" class GURL; @@ -124,13 +126,8 @@ class CONTENT_EXPORT NavigationHandle { // set if unknown. virtual base::TimeTicks NavigationInputStart() = 0; - // The time the first HTTP request is sent. - // See comments on |NavigationRequest::first_request_start_| for details. - virtual base::TimeTicks FirstRequestStart() = 0; - - // The time the headers of the first HTTP response is received. - // See comments on |NavigationRequest::first_response_start_| for details. - virtual base::TimeTicks FirstResponseStart() = 0; + // The timing information of loading for the navigation. + virtual const NavigationHandleTiming& GetNavigationHandleTiming() = 0; // Whether or not the navigation was started within a context menu. virtual bool WasStartedFromContextMenu() = 0; @@ -164,6 +161,12 @@ class CONTENT_EXPORT NavigationHandle { // Returns a sanitized version of the referrer for this request. virtual const blink::mojom::Referrer& GetReferrer() = 0; + // Sets the referrer. The referrer may only be set during start and redirect + // phases. If the referer is set in navigation start, it is reset during the + // redirect. In other words, if you need to set a referer that applies to + // redirects, then this must be called during DidRedirectNavigation(). + virtual void SetReferrer(blink::mojom::ReferrerPtr referrer) = 0; + // Whether the navigation was initiated by a user gesture. Note that this // will return false for browser-initiated navigations. // TODO(clamy): This should return true for browser-initiated navigations. @@ -227,7 +230,11 @@ class CONTENT_EXPORT NavigationHandle { // errors that leave the user on the previous page. virtual bool HasCommitted() = 0; - // Whether the navigation resulted in an error page. + // Whether the navigation committed an error page. + // + // DO NOT use this before the navigation commit. It would always return false. + // You can use it from WebContentsObserver::DidFinishNavigation(). + // // Note that if an error page reloads, this will return true even though // GetNetErrorCode will be net::OK. virtual bool IsErrorPage() = 0; diff --git a/chromium/content/public/browser/navigation_handle_timing.h b/chromium/content/public/browser/navigation_handle_timing.h new file mode 100644 index 00000000000..84042db93b3 --- /dev/null +++ b/chromium/content/public/browser/navigation_handle_timing.h @@ -0,0 +1,91 @@ +// Copyright 2020 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_PUBLIC_BROWSER_NAVIGATION_HANDLE_TIMING_H_ +#define CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_TIMING_H_ + +#include "base/time/time.h" +#include "content/common/content_export.h" + +namespace content { + +// NavigationHandleTiming contains timing information of loading for navigation +// recorded in NavigationHandle. This is used for UMAs, not exposed to +// JavaScript via Navigation Timing API etc unlike mojom::NavigationTiming. See +// the design doc for details. +// https://docs.google.com/document/d/16oqu9lyPbfgZIjQsRaCfaKE8r1Cdlb3d4GVSdth4AN8/edit?usp=sharing +struct CONTENT_EXPORT NavigationHandleTiming { + // The time the first HTTP request was sent. This is filled with + // net::LoadTimingInfo::send_start during navigation. + // + // In some cases, this can be the time an internal request started that did + // not go to the networking layer. For example, + // - Service Worker: the time the fetch event was ready to be dispatched, see + // content::ServiceWorkerMainResourceLoader::DidPrepareFetchEvent()). + // - HSTS: the time the internal redirect was handled. + // - Signed Exchange: the time the SXG was handled. + base::TimeTicks first_request_start_time; + + // The time the headers of the first HTTP response were received. This is + // filled with net::LoadTimingInfo::receive_headers_start on the first HTTP + // response during navigation. + // + // In some cases, this can be the time an internal response was received that + // did not come from the networking layer. For example, + // - Service Worker: the time the response from the service worker was + // received, see content::ServiceWorkerMainResourceLoader::StartResponse(). + // - HSTS: the time the internal redirect was handled. + // - Signed Exchange: the time the SXG was handled. + base::TimeTicks first_response_start_time; + + // The time a callback for the navigation loader was first invoked. The time + // between this and |first_response_start_time| includes any throttling or + // process/thread hopping between the network stack receiving the response and + // the navigation loader receiving it. + base::TimeTicks first_loader_callback_time; + + // The time the final HTTP request was sent. This is filled with + // net::LoadTimingInfo::send_start during navigation. + // + // In some cases, this can be the time an internal request started that did + // not go to the networking layer. See the comment for + // |first_request_start_time|. + // + // This is equal to |first_request_start_time| if there is no redirection. + base::TimeTicks final_request_start_time; + + // The time the headers of the final HTTP response were received. This is + // filled with net::LoadTimingInfo::receive_headers_start on the final HTTP + // response during navigation. + // + // In some cases, this can be the time an internal response was received that + // did not come from the networking layer. See the comment for + // |first_response_start_time|. + // + // This is equal to |first_response_start_time| if there is no redirection. + base::TimeTicks final_response_start_time; + + // The time a callback for the navigation loader was last invoked. The time + // between this and |final_response_start_time| includes any throttling or + // process/thread hopping between the network stack receiving the response and + // the navigation loader receiving it. + // + // This is equal to |first_loader_callback_time| if there is no redirection. + base::TimeTicks final_loader_callback_time; + + // The time the navigation commit message was sent to a renderer process. + base::TimeTicks navigation_commit_sent_time; + + // The time the headers of the first HTTP response whose status code is + // 103 was received for the first/final request. This is filled with + // net::LoadTimingInfo::first_early_hints_time during navigation. + // These must only be used for 103 Early Hints experiment + // (https://crbug.com/1093693). + base::TimeTicks early_hints_for_first_request_time; + base::TimeTicks early_hints_for_final_request_time; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_TIMING_H_ diff --git a/chromium/content/public/browser/network_service_instance.h b/chromium/content/public/browser/network_service_instance.h index 90d1f8d4970..3ca5329affa 100644 --- a/chromium/content/public/browser/network_service_instance.h +++ b/chromium/content/public/browser/network_service_instance.h @@ -11,7 +11,9 @@ #include "base/callback_list.h" #include "build/build_config.h" #include "content/common/content_export.h" +#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom-forward.h" #include "services/network/public/cpp/network_connection_tracker.h" +#include "services/network/public/mojom/network_context.mojom-forward.h" namespace base { class SequencedTaskRunner; @@ -77,6 +79,25 @@ CONTENT_EXPORT void SetNetworkConnectionTrackerForTesting( CONTENT_EXPORT const scoped_refptr<base::SequencedTaskRunner>& GetNetworkTaskRunner(); +// Returns a CertVerifierParams that can be placed into a new +// network::mojom::NetworkContextParams. +// +// If the CertVerifierService feature is enabled, the +// |cert_verifier_creation_params| will be used to configure a new +// CertVerifierService, and a pipe to the new CertVerifierService will be placed +// in the CertVerifierParams. +// +// Otherwise, |cert_verifier_creation_params| will just be placed directly into +// the CertVerifierParams to configure an in-network-service CertVerifier. +CONTENT_EXPORT network::mojom::CertVerifierParamsPtr GetCertVerifierParams( + network::mojom::CertVerifierCreationParamsPtr + cert_verifier_creation_params); + +// Sets the CertVerifierServiceFactory used to instantiate +// CertVerifierServices. +CONTENT_EXPORT void SetCertVerifierServiceFactoryForTesting( + cert_verifier::mojom::CertVerifierServiceFactory* service_factory); + } // namespace content #endif // CONTENT_PUBLIC_BROWSER_NETWORK_SERVICE_INSTANCE_H_ diff --git a/chromium/content/public/browser/overlay_window.h b/chromium/content/public/browser/overlay_window.h index 361f8e10162..644e5a4d42e 100644 --- a/chromium/content/public/browser/overlay_window.h +++ b/chromium/content/public/browser/overlay_window.h @@ -56,7 +56,7 @@ class OverlayWindow { virtual gfx::Rect GetBounds() = 0; virtual void UpdateVideoSize(const gfx::Size& natural_size) = 0; virtual void SetPlaybackState(PlaybackState playback_state) = 0; - virtual void SetAlwaysHidePlayPauseButton(bool is_visible) = 0; + virtual void SetPlayPauseButtonVisibility(bool is_visible) = 0; virtual void SetSkipAdButtonVisibility(bool is_visible) = 0; virtual void SetNextTrackButtonVisibility(bool is_visible) = 0; virtual void SetPreviousTrackButtonVisibility(bool is_visible) = 0; diff --git a/chromium/content/public/browser/payment_app_provider.h b/chromium/content/public/browser/payment_app_provider.h index 2489ae9a82e..a31725765e9 100644 --- a/chromium/content/public/browser/payment_app_provider.h +++ b/chromium/content/public/browser/payment_app_provider.h @@ -49,12 +49,14 @@ class CONTENT_EXPORT PaymentAppProvider { using CanMakePaymentCallback = base::OnceCallback<void(payments::mojom::CanMakePaymentResponsePtr)>; using AbortCallback = base::OnceCallback<void(bool)>; + using UpdatePaymentAppIconCallback = + base::OnceCallback<void(payments::mojom::PaymentHandlerStatus status)>; // Should be accessed only on the UI thread. virtual void GetAllPaymentApps(BrowserContext* browser_context, GetAllPaymentAppsCallback callback) = 0; virtual void InvokePaymentApp( - BrowserContext* browser_context, + WebContents* web_contents, int64_t registration_id, const url::Origin& sw_origin, payments::mojom::PaymentRequestEventDataPtr event_data, @@ -71,14 +73,23 @@ class CONTENT_EXPORT PaymentAppProvider { const SupportedDelegations& supported_delegations, RegistrationIdCallback registration_id_callback, InvokePaymentAppCallback callback) = 0; - virtual void CanMakePayment( + virtual void UpdatePaymentAppIcon( BrowserContext* browser_context, int64_t registration_id, + const std::string& instrument_key, + const std::string& name, + const std::string& string_encoded_icon, + const std::string& method_name, + const SupportedDelegations& supported_delegations, + UpdatePaymentAppIconCallback callback) = 0; + virtual void CanMakePayment( + WebContents* web_contents, + int64_t registration_id, const url::Origin& sw_origin, const std::string& payment_request_id, payments::mojom::CanMakePaymentEventDataPtr event_data, CanMakePaymentCallback callback) = 0; - virtual void AbortPayment(BrowserContext* browser_context, + virtual void AbortPayment(WebContents* web_contents, int64_t registration_id, const url::Origin& sw_origin, const std::string& payment_request_id, @@ -89,12 +100,12 @@ class CONTENT_EXPORT PaymentAppProvider { // previously opened window in the same browser context will be closed after // calling this interface. virtual void SetOpenedWindow(WebContents* web_contents) = 0; - virtual void CloseOpenedWindow(BrowserContext* browser_context) = 0; + virtual void CloseOpenedWindow() = 0; // Notify the opened payment handler window is closing or closed by user so as // to abort payment request. virtual void OnClosingOpenedWindow( - BrowserContext* browser_context, + WebContents* web_contents, payments::mojom::PaymentEventResponseType reason) = 0; // Check whether given |sw_js_url| from |manifest_url| is allowed to register diff --git a/chromium/content/public/browser/picture_in_picture_window_controller.h b/chromium/content/public/browser/picture_in_picture_window_controller.h index f7c80a3f2e2..1a54e5ad5de 100644 --- a/chromium/content/public/browser/picture_in_picture_window_controller.h +++ b/chromium/content/public/browser/picture_in_picture_window_controller.h @@ -12,16 +12,16 @@ class OverlayWindow; class WebContents; // Interface for Picture in Picture window controllers. This is currently tied -// to a WebContents |initiator| and created when a Picture in Picture window is -// to be shown. This allows creation of a single window for the initiator +// to a WebContents |web_contents| and created when a Picture in Picture window +// is to be shown. This allows creation of a single window for the WebContents // WebContents. class PictureInPictureWindowController { public: - // Gets a reference to the controller associated with |initiator| and creates - // one if it does not exist. The returned pointer is guaranteed to be + // Gets a reference to the controller associated with |web_contents| and + // creates one if it does not exist. The returned pointer is guaranteed to be // non-null. CONTENT_EXPORT static PictureInPictureWindowController* - GetOrCreateForWebContents(WebContents* initiator); + GetOrCreateForWebContents(WebContents* web_contents); virtual ~PictureInPictureWindowController() = default; @@ -43,10 +43,9 @@ class PictureInPictureWindowController { virtual OverlayWindow* GetWindowForTesting() = 0; virtual void UpdateLayerBounds() = 0; virtual bool IsPlayerActive() = 0; - virtual WebContents* GetInitiatorWebContents() = 0; + virtual WebContents* GetWebContents() = 0; virtual void UpdatePlaybackState(bool is_playing, bool reached_end_of_stream) = 0; - virtual void SetAlwaysHidePlayPauseButton(bool is_visible) = 0; // Called when the user interacts with the "Skip Ad" control. virtual void SkipAd() = 0; diff --git a/chromium/content/public/browser/render_document_host_user_data.h b/chromium/content/public/browser/render_document_host_user_data.h index a138fd60aa2..4bdb1e77097 100644 --- a/chromium/content/public/browser/render_document_host_user_data.h +++ b/chromium/content/public/browser/render_document_host_user_data.h @@ -85,6 +85,14 @@ class RenderDocumentHostUserData : public base::SupportsUserData::Data { return static_cast<T*>(GetRenderDocumentHostUserData(rfh, UserDataKey())); } + static T* GetOrCreateForCurrentDocument(RenderFrameHost* rfh) { + DCHECK(rfh); + if (!GetForCurrentDocument(rfh)) { + CreateForCurrentDocument(rfh); + } + return GetForCurrentDocument(rfh); + } + static void DeleteForCurrentDocument(RenderFrameHost* rfh) { DCHECK(rfh); DCHECK(GetForCurrentDocument(rfh)); diff --git a/chromium/content/public/browser/render_frame_host.h b/chromium/content/public/browser/render_frame_host.h index 94ba0f61dec..a45f1208331 100644 --- a/chromium/content/public/browser/render_frame_host.h +++ b/chromium/content/public/browser/render_frame_host.h @@ -50,7 +50,7 @@ enum class FeaturePolicyFeature; namespace base { class UnguessableToken; class Value; -} +} // namespace base namespace features { CONTENT_EXPORT extern const base::Feature kCrashReporting; @@ -123,6 +123,9 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // Returns the route id for this frame. virtual int GetRoutingID() = 0; + // Returns the frame token for this frame. + virtual const base::UnguessableToken& GetFrameToken() = 0; + // Returns the accessibility tree ID for this RenderFrameHost. virtual ui::AXTreeID GetAXTreeID() = 0; @@ -197,12 +200,16 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // never used to look up the FrameTreeNode instance. virtual base::UnguessableToken GetDevToolsFrameToken() = 0; - // Returns the embedding token for the current document in this - // RenderFrameHost. This token is used by a remote parent to uniquely identify - // it. The token will be changed when a new document commits in this - // RenderFrameHost. This will be null if the document is: - // - not embedded by a parent - // - a local child + // This token is present on all frames. For frames with parents, it allows + // identification of embedding relationships between parent and child. For + // main frames, it also allows generalization of the embedding relationship + // when the WebContents itself is embedded in another context such as the rest + // of the browser UI. This will be nullopt prior to the RenderFrameHost + // committing a navigation. After the first navigation commits this + // will return the token for the last committed document. + // + // TODO(crbug/1098283): Remove the nullopt scenario by creating the token in + // CreateChildFrame() or similar. virtual base::Optional<base::UnguessableToken> GetEmbeddingToken() = 0; // Returns the assigned name of the frame, the name of the iframe tag @@ -430,13 +437,6 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // RenderFrameHost. virtual void ViewSource() = 0; - // Starts pausing subresource loading on this frame and returns - // PauseSubresourceLoadingHandle that controls the pausing behavior. As long - // as this handle is live, pausing will continue until an internal - // navigation happens in the frame. - virtual mojo::Remote<blink::mojom::PauseSubresourceLoadingHandle> - PauseSubresourceLoading() = 0; - // Run the given action on the media player location at the given point. virtual void ExecuteMediaPlayerActionAtLocation( const gfx::Point& location, @@ -572,6 +572,14 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // same as the id for the main frame. virtual ukm::SourceId GetPageUkmSourceId() = 0; + // Report an inspector issue to devtools due the frame using an excessive + // amount of resources (cpu or network). Invoked only for ad frames. + // TODO(crbug.com/1091720): This reporting should be done directly in the + // chrome layer in the future. + virtual void ReportHeavyAdIssue( + blink::mojom::HeavyAdResolutionStatus resolution, + blink::mojom::HeavyAdReason reason) = 0; + private: // This interface should only be implemented inside content. friend class RenderFrameHostImpl; diff --git a/chromium/content/public/browser/render_frame_metadata_provider.h b/chromium/content/public/browser/render_frame_metadata_provider.h index 1b372e58a2b..139e9c268cb 100644 --- a/chromium/content/public/browser/render_frame_metadata_provider.h +++ b/chromium/content/public/browser/render_frame_metadata_provider.h @@ -6,6 +6,7 @@ #define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_METADATA_PROVIDER_H_ #include "base/macros.h" +#include "build/build_config.h" #include "cc/trees/render_frame_metadata.h" #include "content/common/content_export.h" @@ -40,6 +41,10 @@ class CONTENT_EXPORT RenderFrameMetadataProvider { // to pass in Viz. virtual void OnLocalSurfaceIdChanged( const cc::RenderFrameMetadata& metadata) = 0; +#if defined(OS_ANDROID) + virtual void OnRootScrollOffsetChanged( + const gfx::Vector2dF& root_scroll_offset) {} +#endif }; RenderFrameMetadataProvider() = default; diff --git a/chromium/content/public/browser/render_process_host.h b/chromium/content/public/browser/render_process_host.h index 675f9251fea..99cd8e9d8a5 100644 --- a/chromium/content/public/browser/render_process_host.h +++ b/chromium/content/public/browser/render_process_host.h @@ -468,6 +468,10 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, virtual void LockToOrigin(const IsolationContext& isolation_context, const GURL& lock_url) = 0; + // Returns true if this process is locked to a particular 'origin'. See the + // LockToOrigin() call above. + virtual bool IsLockedToOriginForTesting() = 0; + // The following several methods are for internal use only, and are only // exposed here to support MockRenderProcessHost usage in tests. virtual void BindCacheStorage( @@ -572,6 +576,16 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, // globally-used spare RenderProcessHost at any time. static RenderProcessHost* GetSpareRenderProcessHostForTesting(); + // Registers a callback to be notified when the spare RenderProcessHost is + // changed. If a new spare RenderProcessHost is created, the callback is made + // when the host is ready (RenderProcessHostObserver::RenderProcessReady). If + // the spare RenderProcessHost is promoted to be a "real" RenderProcessHost or + // discarded for any reason, the callback is made with a null pointer. + static std::unique_ptr< + base::CallbackList<void(RenderProcessHost*)>::Subscription> + RegisterSpareRenderProcessHostChangedCallback( + const base::RepeatingCallback<void(RenderProcessHost*)>& cb); + // Flag to run the renderer in process. This is primarily // for debugging purposes. When running "in process", the // browser maintains a single RenderProcessHost which communicates @@ -598,12 +612,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, static RenderProcessHost* FromRendererInstanceId( const base::Token& instance_id); - // Returns whether the process-per-site model is in use (globally or just for - // the current site), in which case we should ensure there is only one - // RenderProcessHost per site for the entire browser context. - static bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, - const GURL& site_url); - // Returns true if the caller should attempt to use an existing // RenderProcessHost rather than creating a new one. static bool ShouldTryToUseExistingProcessHost( diff --git a/chromium/content/public/browser/render_view_host.h b/chromium/content/public/browser/render_view_host.h index 893c45a5c71..dfd856eb481 100644 --- a/chromium/content/public/browser/render_view_host.h +++ b/chromium/content/public/browser/render_view_host.h @@ -12,8 +12,8 @@ #include "content/public/common/page_zoom.h" #include "ipc/ipc_sender.h" #include "mojo/public/cpp/system/core.h" +#include "third_party/blink/public/common/page/web_drag_operation.h" #include "third_party/blink/public/mojom/frame/frame.mojom-forward.h" -#include "third_party/blink/public/platform/web_drag_operation.h" namespace gfx { class Point; diff --git a/chromium/content/public/browser/render_widget_host.h b/chromium/content/public/browser/render_widget_host.h index 435461c0953..d930028fe53 100644 --- a/chromium/content/public/browser/render_widget_host.h +++ b/chromium/content/public/browser/render_widget_host.h @@ -21,8 +21,8 @@ #include "ipc/ipc_sender.h" #include "third_party/blink/public/common/input/web_gesture_event.h" #include "third_party/blink/public/common/input/web_input_event.h" +#include "third_party/blink/public/common/page/web_drag_operation.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" -#include "third_party/blink/public/platform/web_drag_operation.h" #include "ui/base/ui_base_types.h" #include "ui/surface/transport_dib.h" diff --git a/chromium/content/public/browser/render_widget_host_view.h b/chromium/content/public/browser/render_widget_host_view.h index 3e5bf09f1cf..4810a45aa4b 100644 --- a/chromium/content/public/browser/render_widget_host_view.h +++ b/chromium/content/public/browser/render_widget_host_view.h @@ -267,9 +267,6 @@ class CONTENT_EXPORT RenderWidgetHostView { // |destination_is_loaded| is true when // ResourceCoordinatorTabHelper::IsLoaded() is true for the new tab // contents. - // |destination_is_frozen| is true when - // ResourceCoordinatorTabHelper::IsFrozen() is true for the new tab - // contents. // |show_reason_tab_switching| is true when tab switch event should be // reported. // |show_reason_unoccluded| is true when "unoccluded" event should be @@ -279,7 +276,6 @@ class CONTENT_EXPORT RenderWidgetHostView { virtual void SetRecordContentToVisibleTimeRequest( base::TimeTicks start_time, base::Optional<bool> destination_is_loaded, - base::Optional<bool> destination_is_frozen, bool show_reason_tab_switching, bool show_reason_unoccluded, bool show_reason_bfcache_restore) = 0; diff --git a/chromium/content/public/browser/service_process_host.cc b/chromium/content/public/browser/service_process_host.cc index e03e0f4dc17..842b7afc4f5 100644 --- a/chromium/content/public/browser/service_process_host.cc +++ b/chromium/content/public/browser/service_process_host.cc @@ -15,12 +15,6 @@ ServiceProcessHost::Options::~Options() = default; ServiceProcessHost::Options::Options(Options&&) = default; -ServiceProcessHost::Options& ServiceProcessHost::Options::WithSandboxType( - SandboxType type) { - sandbox_type = type; - return *this; -} - ServiceProcessHost::Options& ServiceProcessHost::Options::WithDisplayName( const std::string& name) { display_name = base::UTF8ToUTF16(name); diff --git a/chromium/content/public/browser/service_process_host.h b/chromium/content/public/browser/service_process_host.h index 5bf31c75cf6..2cd87b2da28 100644 --- a/chromium/content/public/browser/service_process_host.h +++ b/chromium/content/public/browser/service_process_host.h @@ -60,11 +60,6 @@ class CONTENT_EXPORT ServiceProcessHost { Options(Options&&); - // Specifies the sandbox type with which to launch the service process. - // Defaults to a generic, restrictive utility process sandbox. - // TODO(1065087) Deprecate. - Options& WithSandboxType(SandboxType type); - // Specifies the display name of the service process. This should generally // be a human readable and meaningful application or service name and will // appear in places like the system task viewer. @@ -126,9 +121,7 @@ class CONTENT_EXPORT ServiceProcessHost { template <typename Interface> static void Launch(mojo::PendingReceiver<Interface> receiver, Options options = {}) { - // TODO(1065087) remove this test once all services are migrated. - if (options.sandbox_type == SandboxType::kUtility) - options.sandbox_type = content::GetServiceSandboxType<Interface>(); + options.sandbox_type = content::GetServiceSandboxType<Interface>(); Launch(mojo::GenericPendingReceiver(std::move(receiver)), std::move(options)); } @@ -139,9 +132,7 @@ class CONTENT_EXPORT ServiceProcessHost { // May be called from any thread. template <typename Interface> static mojo::Remote<Interface> Launch(Options options = {}) { - // TODO(1065087) remove this test once all services are migrated. - if (options.sandbox_type == SandboxType::kUtility) - options.sandbox_type = content::GetServiceSandboxType<Interface>(); + options.sandbox_type = content::GetServiceSandboxType<Interface>(); mojo::Remote<Interface> remote; Launch(remote.BindNewPipeAndPassReceiver(), std::move(options)); return remote; diff --git a/chromium/content/public/browser/service_worker_client_info.cc b/chromium/content/public/browser/service_worker_client_info.cc new file mode 100644 index 00000000000..d38de92e232 --- /dev/null +++ b/chromium/content/public/browser/service_worker_client_info.cc @@ -0,0 +1,44 @@ +// Copyright 2018 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/public/browser/service_worker_client_info.h" + +namespace content { + +ServiceWorkerClientInfo::ServiceWorkerClientInfo(int frame_tree_node_id) + : type_(blink::mojom::ServiceWorkerClientType::kWindow), + frame_tree_node_id_(frame_tree_node_id) {} +ServiceWorkerClientInfo::ServiceWorkerClientInfo( + DedicatedWorkerId dedicated_worker_id) + : type_(blink::mojom::ServiceWorkerClientType::kDedicatedWorker), + dedicated_worker_id_(dedicated_worker_id) {} +ServiceWorkerClientInfo::ServiceWorkerClientInfo( + SharedWorkerId shared_worker_id) + : type_(blink::mojom::ServiceWorkerClientType::kSharedWorker), + shared_worker_id_(shared_worker_id) {} + +ServiceWorkerClientInfo::ServiceWorkerClientInfo( + const ServiceWorkerClientInfo& other) = default; + +ServiceWorkerClientInfo& ServiceWorkerClientInfo::operator=( + const ServiceWorkerClientInfo& other) = default; + +ServiceWorkerClientInfo::~ServiceWorkerClientInfo() = default; + +int ServiceWorkerClientInfo::GetFrameTreeNodeId() const { + DCHECK_EQ(type_, blink::mojom::ServiceWorkerClientType::kWindow); + return frame_tree_node_id_; +} + +DedicatedWorkerId ServiceWorkerClientInfo::GetDedicatedWorkerId() const { + DCHECK_EQ(type_, blink::mojom::ServiceWorkerClientType::kDedicatedWorker); + return dedicated_worker_id_; +} + +SharedWorkerId ServiceWorkerClientInfo::GetSharedWorkerId() const { + DCHECK_EQ(type_, blink::mojom::ServiceWorkerClientType::kSharedWorker); + return shared_worker_id_; +} + +} // namespace content diff --git a/chromium/content/public/browser/service_worker_client_info.h b/chromium/content/public/browser/service_worker_client_info.h new file mode 100644 index 00000000000..2a5f02e0042 --- /dev/null +++ b/chromium/content/public/browser/service_worker_client_info.h @@ -0,0 +1,52 @@ +// Copyright 2018 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_PUBLIC_BROWSER_SERVICE_WORKER_CLIENT_INFO_H_ +#define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CLIENT_INFO_H_ + +#include "content/common/content_export.h" +#include "content/public/browser/dedicated_worker_id.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/shared_worker_id.h" +#include "third_party/blink/public/mojom/service_worker/service_worker_client.mojom.h" + +namespace content { + +// Holds information about a single service worker client: +// https://w3c.github.io/ServiceWorker/#client +class CONTENT_EXPORT ServiceWorkerClientInfo { + public: + explicit ServiceWorkerClientInfo(int frame_tree_node_id); + explicit ServiceWorkerClientInfo(DedicatedWorkerId dedicated_worker_id); + explicit ServiceWorkerClientInfo(SharedWorkerId shared_worker_id); + + ServiceWorkerClientInfo(const ServiceWorkerClientInfo& other); + ServiceWorkerClientInfo& operator=(const ServiceWorkerClientInfo& other); + + ~ServiceWorkerClientInfo(); + + // Returns the type of this client. + blink::mojom::ServiceWorkerClientType type() const { return type_; } + + int GetFrameTreeNodeId() const; + DedicatedWorkerId GetDedicatedWorkerId() const; + SharedWorkerId GetSharedWorkerId() const; + + private: + // The client type. + blink::mojom::ServiceWorkerClientType type_; + + // The frame tree node ID, if this is a window client. + int frame_tree_node_id_ = content::RenderFrameHost::kNoFrameTreeNodeId; + + // The ID of the client, if this is a dedicated worker client. + DedicatedWorkerId dedicated_worker_id_; + + // The ID of the client, if this is a shared worker client. + SharedWorkerId shared_worker_id_; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CLIENT_INFO_H_ diff --git a/chromium/content/public/browser/service_worker_context.h b/chromium/content/public/browser/service_worker_context.h index 7dd43ecf735..6022b2b75ee 100644 --- a/chromium/content/public/browser/service_worker_context.h +++ b/chromium/content/public/browser/service_worker_context.h @@ -157,6 +157,21 @@ class CONTENT_EXPORT ServiceWorkerContext { const GURL& origin, CountExternalRequestsCallback callback) = 0; + // Whether |origin| has any registrations. Uninstalling and uninstalled + // registrations do not cause this to return true, that is, only registrations + // with status ServiceWorkerRegistration::Status::kIntact are considered, such + // as even if the corresponding live registrations may still exist. Also, + // returns true if it doesn't know (registrations are not yet initialized). + // Must be called on the UI thread. + virtual bool MaybeHasRegistrationForOrigin(const url::Origin& origin) = 0; + + // TODO(nidhijaju): Remove the ForTest() functions here and the tests that + // need it (e.g. in IsolatedPrerender) should use FakeServiceWorkerContext + // instead. + virtual void WaitForRegistrationsInitializedForTest() = 0; + virtual void AddRegistrationToRegisteredOriginsForTest( + const url::Origin& origin) = 0; + // May be called from any thread, and the callback is called on that thread. virtual void GetAllOriginsInfo(GetUsageInfoCallback callback) = 0; diff --git a/chromium/content/public/browser/service_worker_context_observer.h b/chromium/content/public/browser/service_worker_context_observer.h index dd930c28bcb..bdc6acf5b62 100644 --- a/chromium/content/public/browser/service_worker_context_observer.h +++ b/chromium/content/public/browser/service_worker_context_observer.h @@ -5,6 +5,10 @@ #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ +#include <string> + +#include "content/public/browser/global_routing_id.h" +#include "content/public/browser/service_worker_client_info.h" #include "url/gurl.h" namespace content { @@ -52,10 +56,27 @@ class ServiceWorkerContextObserver { const ServiceWorkerRunningInfo& running_info) {} virtual void OnVersionStoppedRunning(int64_t version_id) {} + // Called when a controllee is added/removed for the service worker with id + // |version_id|. + virtual void OnControlleeAdded(int64_t version_id, + const std::string& client_uuid, + const ServiceWorkerClientInfo& client_info) {} + virtual void OnControlleeRemoved(int64_t version_id, + const std::string& client_uuid) {} + // Called when there are no more controllees for the service worker with id // |version_id|. virtual void OnNoControllees(int64_t version_id, const GURL& scope) {} + // Called when the navigation for a window client commits to a render frame + // host. At this point, if there was a previous controllee attached to that + // render frame host, it has already been removed and OnControlleeRemoved() + // has been called. + virtual void OnControlleeNavigationCommitted( + int64_t version_id, + const std::string& client_uuid, + GlobalFrameRoutingId render_frame_host_id) {} + // Called when a console message is reported for the service worker with id // |version_id|. virtual void OnReportConsoleMessage(int64_t version_id, diff --git a/chromium/content/public/browser/shared_worker_service.h b/chromium/content/public/browser/shared_worker_service.h index f4fe6dbfe21..807d4f28a98 100644 --- a/chromium/content/public/browser/shared_worker_service.h +++ b/chromium/content/public/browser/shared_worker_service.h @@ -31,16 +31,14 @@ class CONTENT_EXPORT SharedWorkerService { public: class Observer : public base::CheckedObserver { public: - // Called when a shared worker has started/stopped. This means that Start() - // was called for that worker and it got assigned its DevTools token. Note - // that it may still be evaluating the script and thus it could not be yet - // running in the renderer. This differs a bit from the "started" state of - // the embedded worker. - virtual void OnWorkerStarted( + // Called when a shared worker is created/destroyed. Note that it is not yet + // started in the renderer since its script still has to be downloaded and + // evaluated. + virtual void OnWorkerCreated( SharedWorkerId shared_worker_id, int worker_process_id, const base::UnguessableToken& dev_tools_token) = 0; - virtual void OnBeforeWorkerTerminated(SharedWorkerId shared_worker_id) = 0; + virtual void OnBeforeWorkerDestroyed(SharedWorkerId shared_worker_id) = 0; // Called when the final response URL (the URL after redirects) was // determined when fetching the worker's script. @@ -50,7 +48,7 @@ class CONTENT_EXPORT SharedWorkerService { const GURL& url) {} // Called when a frame starts/stop being a client of a shared worker. It is - // guaranteed that OnWorkerStarted() is called before receiving these + // guaranteed that OnWorkerCreated() is called before receiving these // notifications. virtual void OnClientAdded( SharedWorkerId shared_worker_id, @@ -64,13 +62,13 @@ class CONTENT_EXPORT SharedWorkerService { virtual void AddObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0; - // Invokes OnWorkerStarted() on |observer| for all existing shared workers. + // Invokes OnWorkerCreated() on |observer| for all existing shared workers. // // This function must be invoked in conjunction with AddObserver(). It is // meant to be used by an observer that dynamically subscribe to the - // SharedWorkerService while some workers are already running. It avoids - // receiving a OnBeforeWorkerTerminated() event without having received the - // corresponding OnWorkerStart() event. + // SharedWorkerService while some workers already exist. It avoids + // receiving a OnBeforeWorkerDestroyed() event without having received the + // corresponding OnWorkerCreated() event. // // Note: Due to current callers not needing it, this function does NOT call // OnClientAdded() for each worker's clients. diff --git a/chromium/content/public/browser/site_instance.h b/chromium/content/public/browser/site_instance.h index 0a5aec6455a..82b5d4c25ad 100644 --- a/chromium/content/public/browser/site_instance.h +++ b/chromium/content/public/browser/site_instance.h @@ -157,8 +157,8 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance> { virtual bool IsGuest() = 0; // Factory method to create a new SiteInstance. This will create a new - // new BrowsingInstance, so it should only be used when creating a new tab - // from scratch (or similar circumstances). + // BrowsingInstance, so it should only be used when creating a new tab from + // scratch (or similar circumstances). // // The render process host factory may be nullptr. See SiteInstance // constructor. diff --git a/chromium/content/public/browser/storage_partition_config.cc b/chromium/content/public/browser/storage_partition_config.cc new file mode 100644 index 00000000000..b33b589e877 --- /dev/null +++ b/chromium/content/public/browser/storage_partition_config.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2020 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/public/browser/storage_partition_config.h" + +#include "base/check.h" + +namespace content { + +StoragePartitionConfig::StoragePartitionConfig(const StoragePartitionConfig&) = + default; +StoragePartitionConfig& StoragePartitionConfig::operator=( + const StoragePartitionConfig&) = default; + +// static +StoragePartitionConfig StoragePartitionConfig::CreateDefault() { + return StoragePartitionConfig("", "", false); +} + +// static +StoragePartitionConfig StoragePartitionConfig::Create( + const std::string& partition_domain, + const std::string& partition_name, + bool in_memory) { + // If a caller tries to pass an empty partition_domain something is seriously + // wrong or the calling code is not explicitly signalling its desire to create + // a default partition by calling CreateDefault(). + CHECK(!partition_domain.empty()); + return StoragePartitionConfig(partition_domain, partition_name, in_memory); +} + +StoragePartitionConfig::StoragePartitionConfig( + const std::string& partition_domain, + const std::string& partition_name, + bool in_memory) + : partition_domain_(partition_domain), + partition_name_(partition_name), + in_memory_(in_memory) {} + +StoragePartitionConfig StoragePartitionConfig::CopyWithInMemorySet() const { + if (in_memory_) + return *this; + + return StoragePartitionConfig(partition_domain_, partition_name_, + true /* in_memory */); +} + +bool StoragePartitionConfig::operator<( + const StoragePartitionConfig& rhs) const { + if (partition_domain_ != rhs.partition_domain_) + return partition_domain_ < rhs.partition_domain_; + + if (partition_name_ != rhs.partition_name_) + return partition_name_ < rhs.partition_name_; + + if (in_memory_ != rhs.in_memory_) + return in_memory_ < rhs.in_memory_; + + return false; +} + +bool StoragePartitionConfig::operator==( + const StoragePartitionConfig& rhs) const { + return partition_domain_ == rhs.partition_domain_ && + partition_name_ == rhs.partition_name_ && in_memory_ == rhs.in_memory_; +} + +bool StoragePartitionConfig::operator!=( + const StoragePartitionConfig& rhs) const { + return !(*this == rhs); +} + +} // namespace content diff --git a/chromium/content/public/browser/storage_partition_config.h b/chromium/content/public/browser/storage_partition_config.h new file mode 100644 index 00000000000..c19719d815f --- /dev/null +++ b/chromium/content/public/browser/storage_partition_config.h @@ -0,0 +1,68 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_CONFIG_H_ +#define CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_CONFIG_H_ + +#include <string> + +#include "base/gtest_prod_util.h" +#include "content/common/content_export.h" + +namespace content { + +// Each StoragePartition is uniquely identified by which partition domain +// it belongs to (such as an app or the browser itself), the user supplied +// partition name and the bit indicating whether it should be persisted on +// disk or not. This structure contains those elements and is used as +// uniqueness key to lookup StoragePartition objects in the global map. +class CONTENT_EXPORT StoragePartitionConfig { + public: + StoragePartitionConfig(const StoragePartitionConfig&); + StoragePartitionConfig& operator=(const StoragePartitionConfig&); + + static StoragePartitionConfig CreateDefault(); + + // Creates a config tied to a specific domain. + // The |partition_domain| is [a-z]* UTF-8 string, specifying the domain in + // which partitions live (similar to namespace). |partition_domain| must NOT + // be an empty string. Within a domain, partitions can be uniquely identified + // by the combination of |partition_name| and |in_memory| values. When a + // partition is not to be persisted, the |in_memory| value must be set to + // true. + static StoragePartitionConfig Create(const std::string& partition_domain, + const std::string& partition_name, + bool in_memory); + + std::string partition_domain() const { return partition_domain_; } + std::string partition_name() const { return partition_name_; } + bool in_memory() const { return in_memory_; } + + // Returns true if this config was created by CreateDefault() or is + // a copy of a config created with that method. + bool is_default() const { return partition_domain_.empty(); } + + // Returns a copy of this config that has the same partition_domain + // and partition_name, but the in_memeory field is always set to true. + StoragePartitionConfig CopyWithInMemorySet() const; + + bool operator<(const StoragePartitionConfig& rhs) const; + bool operator==(const StoragePartitionConfig& rhs) const; + bool operator!=(const StoragePartitionConfig& rhs) const; + + private: + FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); + + StoragePartitionConfig(const std::string& partition_domain, + const std::string& partition_name, + bool in_memory); + + std::string partition_domain_; + std::string partition_name_; + bool in_memory_ = false; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_CONFIG_H_ diff --git a/chromium/content/public/browser/storage_partition_config_unittest.cc b/chromium/content/public/browser/storage_partition_config_unittest.cc new file mode 100644 index 00000000000..1805097c8f6 --- /dev/null +++ b/chromium/content/public/browser/storage_partition_config_unittest.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2020 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/public/browser/storage_partition_config.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace content { + +// Test that the Less comparison function is implemented properly to uniquely +// identify storage partitions used as keys in a std::map. +TEST(StoragePartitionConfigTest, OperatorLess) { + StoragePartitionConfig c1(std::string(), std::string(), false); + StoragePartitionConfig c2(std::string(), std::string(), false); + StoragePartitionConfig c3(std::string(), std::string(), true); + StoragePartitionConfig c4("a", std::string(), true); + StoragePartitionConfig c5("b", std::string(), true); + StoragePartitionConfig c6(std::string(), "abc", false); + StoragePartitionConfig c7(std::string(), "abc", true); + StoragePartitionConfig c8("a", "abc", false); + StoragePartitionConfig c9("a", "abc", true); + + // Let's ensure basic comparison works. + EXPECT_TRUE(c1 < c3); + EXPECT_TRUE(c1 < c4); + EXPECT_TRUE(c3 < c4); + EXPECT_TRUE(c4 < c5); + EXPECT_TRUE(c4 < c8); + EXPECT_TRUE(c6 < c4); + EXPECT_TRUE(c6 < c7); + EXPECT_TRUE(c8 < c9); + + // Now, ensure antisymmetry for each pair we've tested. + EXPECT_FALSE(c3 < c1); + EXPECT_FALSE(c4 < c1); + EXPECT_FALSE(c4 < c3); + EXPECT_FALSE(c5 < c4); + EXPECT_FALSE(c8 < c4); + EXPECT_FALSE(c4 < c6); + EXPECT_FALSE(c7 < c6); + EXPECT_FALSE(c9 < c8); + + // Check for irreflexivity. + EXPECT_FALSE(c1 < c1); + EXPECT_TRUE(c8 == c8); + EXPECT_FALSE(c8 != c8); + + // Check for transitivity. + EXPECT_TRUE(c1 < c4); + + // Let's enforce that two identical elements obey strict weak ordering. + EXPECT_TRUE(!(c1 < c2) && !(c2 < c1)); +} + +} // namespace content diff --git a/chromium/content/public/browser/tts_controller.h b/chromium/content/public/browser/tts_controller.h index ced4805ea76..66f4b443d4b 100644 --- a/chromium/content/public/browser/tts_controller.h +++ b/chromium/content/public/browser/tts_controller.h @@ -147,6 +147,10 @@ class CONTENT_EXPORT TtsController { // embedder. virtual TtsEngineDelegate* GetTtsEngineDelegate() = 0; + // Sets whether speech should stop if the WebContents the utterance + // originated from is hidden. The default is false. + virtual void SetStopSpeakingWhenHidden(bool value) = 0; + // Visible for testing. virtual void SetTtsPlatform(TtsPlatform* tts_platform) = 0; virtual int QueueSize() = 0; diff --git a/chromium/content/public/browser/tts_controller_delegate.cc b/chromium/content/public/browser/tts_controller_delegate.cc new file mode 100644 index 00000000000..996b2704517 --- /dev/null +++ b/chromium/content/public/browser/tts_controller_delegate.cc @@ -0,0 +1,29 @@ +// Copyright 2020 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/public/browser/tts_controller_delegate.h" + +namespace content { + +TtsControllerDelegate::PreferredVoiceId::PreferredVoiceId( + const std::string& name, + const std::string& id) + : name(name), id(id) {} + +TtsControllerDelegate::PreferredVoiceId::PreferredVoiceId() = default; + +TtsControllerDelegate::PreferredVoiceId::~PreferredVoiceId() = default; + +TtsControllerDelegate::PreferredVoiceIds::PreferredVoiceIds() = default; + +TtsControllerDelegate::PreferredVoiceIds::PreferredVoiceIds( + const PreferredVoiceIds&) = default; + +TtsControllerDelegate::PreferredVoiceIds& +TtsControllerDelegate::PreferredVoiceIds::operator=(const PreferredVoiceIds&) = + default; + +TtsControllerDelegate::PreferredVoiceIds::~PreferredVoiceIds() = default; + +} // namespace content diff --git a/chromium/content/public/browser/tts_controller_delegate.h b/chromium/content/public/browser/tts_controller_delegate.h index 57b1c3200b2..d5c73556267 100644 --- a/chromium/content/public/browser/tts_controller_delegate.h +++ b/chromium/content/public/browser/tts_controller_delegate.h @@ -5,18 +5,55 @@ #ifndef CONTENT_PUBLIC_BROWSER_TTS_CONTROLLER_DELEGATE_H_ #define CONTENT_PUBLIC_BROWSER_TTS_CONTROLLER_DELEGATE_H_ -#include "content/public/browser/tts_controller.h" -#include "content/public/browser/tts_utterance.h" +#include <memory> +#include <string> + +#include "base/optional.h" +#include "content/common/content_export.h" namespace content { -// Allows embedders to access the current state of text-to-speech. -class TtsControllerDelegate { +class TtsUtterance; + +// Allows embedders to control certain aspects of tts. This is only used on +// ChromeOS. +class CONTENT_EXPORT TtsControllerDelegate { public: - // Given an utterance and a vector of voices, return the - // index of the voice that best matches the utterance. - virtual int GetMatchingVoice(TtsUtterance* utterance, - std::vector<VoiceData>& voices) = 0; + // Used in picking the best Voice for an Utterance. + struct CONTENT_EXPORT PreferredVoiceId { + PreferredVoiceId(const std::string& name, const std::string& id); + PreferredVoiceId(); + ~PreferredVoiceId(); + + // Matches against Voice::name. + std::string name; + // Matches against Voice::engine_id. + std::string id; + }; + + struct CONTENT_EXPORT PreferredVoiceIds { + PreferredVoiceIds(); + PreferredVoiceIds(const PreferredVoiceIds&); + PreferredVoiceIds& operator=(const PreferredVoiceIds&); + ~PreferredVoiceIds(); + + // The voice ID that matches the language of the utterance, if the user + // has picked a preferred voice for that language. + base::Optional<PreferredVoiceId> lang_voice_id; + + // The voice ID that matches the language of the system locale, if the user + // has picked a preferred voice for that locale. + base::Optional<PreferredVoiceId> locale_voice_id; + + // The voice ID that the user has chosen to use when no language code is + // specified, which can be used to match against any locale. + base::Optional<PreferredVoiceId> any_locale_voice_id; + }; + + // Returns the PreferredVoiceIds for an utterance. PreferredVoiceIds are used + // in determining which Voice is used for an Utterance. + virtual std::unique_ptr<PreferredVoiceIds> GetPreferredVoiceIdsForUtterance( + TtsUtterance* utterance) = 0; // Uses the user preferences to update the |rate|, |pitch| and |volume| for // a given |utterance|. @@ -24,15 +61,6 @@ class TtsControllerDelegate { double* rate, double* pitch, double* volume) = 0; - - // Set the delegate that processes TTS requests with user-installed - // extensions. - virtual void SetTtsEngineDelegate(TtsEngineDelegate* delegate) = 0; - - // Get the delegate that processes TTS requests with user-installed - // extensions. - virtual TtsEngineDelegate* GetTtsEngineDelegate() = 0; - protected: virtual ~TtsControllerDelegate() {} }; diff --git a/chromium/content/public/browser/url_data_source.cc b/chromium/content/public/browser/url_data_source.cc index e5b60a8179e..16b1b50842a 100644 --- a/chromium/content/public/browser/url_data_source.cc +++ b/chromium/content/public/browser/url_data_source.cc @@ -7,6 +7,9 @@ #include <utility> #include "base/memory/ptr_util.h" +#include "base/no_destructor.h" +#include "base/strings/strcat.h" +#include "base/strings/string_util.h" #include "base/task_runner_util.h" #include "content/browser/webui/url_data_manager.h" #include "content/browser/webui/url_data_manager_backend.h" @@ -16,6 +19,20 @@ #include "content/public/browser/browser_thread.h" #include "content/public/common/url_constants.h" #include "net/url_request/url_request.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" + +namespace { +// A chrome-untrusted data source's name starts with chrome-untrusted://. +bool IsChromeUntrustedDataSource(content::URLDataSource* source) { + static const base::NoDestructor<std::string> kChromeUntrustedSourceNamePrefix( + base::StrCat( + {content::kChromeUIUntrustedScheme, url::kStandardSchemeSeparator})); + + return base::StartsWith(source->GetSource(), + *kChromeUntrustedSourceNamePrefix, + base::CompareCase::SENSITIVE); +} +} // namespace namespace content { @@ -58,38 +75,33 @@ bool URLDataSource::ShouldAddContentSecurityPolicy() { return true; } -std::string URLDataSource::GetContentSecurityPolicyChildSrc() { - return "child-src 'none';"; -} - -std::string URLDataSource::GetContentSecurityPolicyDefaultSrc() { - return std::string(); -} - -std::string URLDataSource::GetContentSecurityPolicyImgSrc() { - return std::string(); -} - -std::string URLDataSource::GetContentSecurityPolicyObjectSrc() { - return "object-src 'none';"; -} - -std::string URLDataSource::GetContentSecurityPolicyScriptSrc() { - // Note: Do not add 'unsafe-eval' here. Instead override CSP for the - // specific pages that need it, see context http://crbug.com/525224. - return "script-src chrome://resources 'self';"; -} - -std::string URLDataSource::GetContentSecurityPolicyStyleSrc() { - return std::string(); -} - -std::string URLDataSource::GetContentSecurityPolicyWorkerSrc() { - return std::string(); -} - -std::string URLDataSource::GetContentSecurityPolicyFrameAncestors() { - return "frame-ancestors 'none';"; +std::string URLDataSource::GetContentSecurityPolicy( + network::mojom::CSPDirectiveName directive) { + switch (directive) { + case network::mojom::CSPDirectiveName::ChildSrc: + return "child-src 'none';"; + case network::mojom::CSPDirectiveName::DefaultSrc: + return IsChromeUntrustedDataSource(this) ? "default-src 'self';" + : std::string(); + case network::mojom::CSPDirectiveName::ObjectSrc: + return "object-src 'none';"; + case network::mojom::CSPDirectiveName::ScriptSrc: + // Note: Do not add 'unsafe-eval' here. Instead override CSP for the + // specific pages that need it, see context http://crbug.com/525224. + return "script-src chrome://resources 'self';"; + case network::mojom::CSPDirectiveName::FrameAncestors: + return "frame-ancestors 'none';"; + case network::mojom::CSPDirectiveName::ConnectSrc: + case network::mojom::CSPDirectiveName::FormAction: + case network::mojom::CSPDirectiveName::FrameSrc: + case network::mojom::CSPDirectiveName::ImgSrc: + case network::mojom::CSPDirectiveName::MediaSrc: + case network::mojom::CSPDirectiveName::NavigateTo: + case network::mojom::CSPDirectiveName::StyleSrc: + case network::mojom::CSPDirectiveName::WorkerSrc: + case network::mojom::CSPDirectiveName::Unknown: + return std::string(); + } } bool URLDataSource::ShouldDenyXFrameOptions() { diff --git a/chromium/content/public/browser/url_data_source.h b/chromium/content/public/browser/url_data_source.h index b386897a5ff..cf4df700f44 100644 --- a/chromium/content/public/browser/url_data_source.h +++ b/chromium/content/public/browser/url_data_source.h @@ -13,6 +13,7 @@ #include "base/single_thread_task_runner.h" #include "content/common/content_export.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui_data_source.h" #include "ui/base/template_expressions.h" class GURL; @@ -94,32 +95,15 @@ class CONTENT_EXPORT URLDataSource { // is delivered through the data manager backend. Do not disable CSP on your // page without first contacting the chrome security team. virtual bool ShouldAddContentSecurityPolicy(); - // For pre-existing code, enabling CSP with relaxed script-src attributes - // may be marginally better than disabling CSP outright. - // Do not override this method without first contacting the chrome security - // team. - // By default, "script-src chrome://resources 'self';" is added to CSP. - // Override to change this. - virtual std::string GetContentSecurityPolicyScriptSrc(); - - // It is OK to override the following methods to a custom CSP directive - // thereby slightly reducing the protection applied to the page. - - // By default, "child-src 'none';" is added to CSP. Override to change this. - virtual std::string GetContentSecurityPolicyChildSrc(); - // By default empty. Override to change this. - virtual std::string GetContentSecurityPolicyDefaultSrc(); - // By default empty. Override to change this. - virtual std::string GetContentSecurityPolicyImgSrc(); - // By default, "object-src 'none';" is added to CSP. Override to change this. - virtual std::string GetContentSecurityPolicyObjectSrc(); - // By default empty. Override to change this. - virtual std::string GetContentSecurityPolicyStyleSrc(); - // By default empty. Override to change this. - virtual std::string GetContentSecurityPolicyWorkerSrc(); - // By default, "frame ancestors: 'none'" is added to the CSP unless - // ShouldDenyXFrameOptions() returns false. - virtual std::string GetContentSecurityPolicyFrameAncestors(); + + // By default, the following CSPs are added. Override to change this. + // - "child-src 'none';" + // - "object-src 'none';" + // - "frame ancestors: 'none'" is added to the CSP unless + // ShouldDenyXFrameOptions() returns false + // - "script-src chrome://resources 'self';" + virtual std::string GetContentSecurityPolicy( + network::mojom::CSPDirectiveName directive); // By default, the "X-Frame-Options: DENY" header is sent. To stop this from // happening, return false. It is OK to return false as needed. diff --git a/chromium/content/public/browser/url_loader_throttles.h b/chromium/content/public/browser/url_loader_throttles.h new file mode 100644 index 00000000000..0e67d38f73a --- /dev/null +++ b/chromium/content/public/browser/url_loader_throttles.h @@ -0,0 +1,38 @@ +// Copyright 2020 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_PUBLIC_BROWSER_URL_LOADER_THROTTLES_H_ +#define CONTENT_PUBLIC_BROWSER_URL_LOADER_THROTTLES_H_ + +#include "base/callback.h" +#include "content/common/content_export.h" + +namespace blink { +class URLLoaderThrottle; +} // namespace blink + +namespace network { +struct ResourceRequest; +} // namespace network + +namespace content { + +class BrowserContext; +class NavigationUIData; +class WebContents; + +// Wrapper around ContentBrowserClient::CreateURLLoaderThrottles which inserts +// additional content specific throttles. +CONTENT_EXPORT +std::vector<std::unique_ptr<blink::URLLoaderThrottle>> +CreateContentBrowserURLLoaderThrottles( + const network::ResourceRequest& request, + BrowserContext* browser_context, + const base::RepeatingCallback<WebContents*()>& wc_getter, + NavigationUIData* navigation_ui_data, + int frame_tree_node_id); + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_URL_LOADER_THROTTLES_H_ diff --git a/chromium/content/public/browser/web_contents.h b/chromium/content/public/browser/web_contents.h index 039f001f129..c5d3d6a2004 100644 --- a/chromium/content/public/browser/web_contents.h +++ b/chromium/content/public/browser/web_contents.h @@ -82,7 +82,6 @@ class BrowserContext; class BrowserPluginGuestDelegate; class RenderFrameHost; class RenderViewHost; -class RenderWidgetHost; class RenderWidgetHostView; class WebContentsDelegate; class WebUI; @@ -291,10 +290,7 @@ class WebContents : public PageNavigator, // Gets the virtual URL currently being displayed in the URL bar, if there is // one. This URL might be a pending navigation that hasn't committed yet, so - // it is not guaranteed to match the current page in this WebContents. A - // typical example of this is interstitials, which show the URL of the - // new/loading page (active) but the security context is of the old page (last - // committed). + // it is not guaranteed to match the current page in this WebContents. virtual const GURL& GetVisibleURL() = 0; // Gets the virtual URL of the last committed page in this WebContents. @@ -428,12 +424,15 @@ class WebContents : public PageNavigator, using AccessibilityEventCallback = base::RepeatingCallback<void(const std::string&)>; - // Starts or stops recording accessibility events. While accessibility events - // are being recorded, the callback will be called when an accessibility - // event is received. The start paramater says whether the recording is - // starting or stopping. - virtual void RecordAccessibilityEvents(AccessibilityEventCallback callback, - bool start) = 0; + // Starts or stops recording accessibility events. |start_recording| is true + // when recording should start and false when recording should stop. + // |callback| is an optional function which is called when an accessibility + // event is received while accessibility events are being recorded. When + // |start_recording| is true, it is expected that |callback| has a value; when + // |start_recording| is false, it is expected that |callback| does not. + virtual void RecordAccessibilityEvents( + bool start_recording, + base::Optional<AccessibilityEventCallback> callback) = 0; // Tab navigation state ------------------------------------------------------ @@ -509,6 +508,9 @@ class WebContents : public PageNavigator, bool stay_hidden) = 0; virtual void DecrementCapturerCount(bool stay_hidden) = 0; virtual bool IsBeingCaptured() = 0; + // Returns true if there is any active capturer that called + // IncrementCaptureCount() with |stay_hidden|==false. + virtual bool IsBeingVisiblyCaptured() = 0; // Indicates/Sets whether all audio output from this WebContents is muted. virtual bool IsAudioMuted() = 0; @@ -533,18 +535,6 @@ class WebContents : public PageNavigator, // handles. virtual bool HasNativeFileSystemHandles() = 0; - // Indicates whether any frame in the WebContents has native file system - // directory handles. - virtual bool HasNativeFileSystemDirectoryHandles() = 0; - - // Returns the paths of all the native file system directory handles frames in - // this WebContents have access to. - virtual std::vector<base::FilePath> GetNativeFileSystemDirectoryHandles() = 0; - - // Indicates whether any frame in the WebContents has writable native file - // system handles. - virtual bool HasWritableNativeFileSystemHandles() = 0; - // Indicates whether a video is in Picture-in-Picture for |this|. virtual bool HasPictureInPictureVideo() = 0; @@ -628,6 +618,10 @@ class WebContents : public PageNavigator, // This value may change over time due to portal activation and adoption. virtual bool IsPortal() = 0; + // If |IsPortal()| is true, returns this WebContents' portal host's + // WebContents. Otherwise, returns nullptr. + virtual WebContents* GetPortalHostWebContents() = 0; + // Returns the outer WebContents frame, the same frame that this WebContents // was attached in AttachToOuterWebContentsFrame(). virtual RenderFrameHost* GetOuterWebContentsFrame() = 0; @@ -684,13 +678,6 @@ class WebContents : public PageNavigator, // Reloads the focused frame. virtual void ReloadFocusedFrame() = 0; - // Attains PauseSubresourceLoadingHandles for each frame in the web contents. - // As long as these handles are not deleted, subresources will continue to be - // deferred until an internal navigation happens in the frame. Holding handles - // for deleted or re-navigated frames has no effect. - virtual std::vector<mojo::Remote<blink::mojom::PauseSubresourceLoadingHandle>> - PauseSubresourceLoading() = 0; - // Editing commands ---------------------------------------------------------- virtual void Undo() = 0; @@ -769,11 +756,6 @@ class WebContents : public PageNavigator, // is true when using Shift-Tab). virtual void FocusThroughTabTraversal(bool reverse) = 0; - // Interstitials ------------------------------------------------------------- - - // Various other systems need to know about our interstitials. - virtual bool ShowingInterstitialPage() = 0; - // Misc state & callbacks ---------------------------------------------------- // Check whether we can do the saving page operation this page given its MIME @@ -832,9 +814,6 @@ class WebContents : public PageNavigator, // Returns the contents MIME type after a navigation. virtual const std::string& GetContentsMimeType() = 0; - // Returns true if this WebContents will notify about disconnection. - virtual bool WillNotifyDisconnection() = 0; - // Returns the settings which get passed to the renderer. virtual blink::mojom::RendererPreferences* GetMutableRendererPrefs() = 0; @@ -842,10 +821,6 @@ class WebContents : public PageNavigator, // out of nested run loops. virtual void Close() = 0; - // A render view-originated drag has ended. Informs the render view host and - // WebContentsDelegate. - virtual void SystemDragEnded(RenderWidgetHost* source_rwh) = 0; - // Indicates if this tab was explicitly closed by the user (control-w, close // tab menu item...). This is false for actions that indirectly close the tab, // such as closing the window. The setter is maintained by TabStripModel, and diff --git a/chromium/content/public/browser/web_contents_delegate.cc b/chromium/content/public/browser/web_contents_delegate.cc index 6017278cc0f..50936cd961b 100644 --- a/chromium/content/public/browser/web_contents_delegate.cc +++ b/chromium/content/public/browser/web_contents_delegate.cc @@ -353,6 +353,11 @@ WebContents* WebContentsDelegate::GetResponsibleWebContents( return web_contents; } +device::mojom::GeolocationContext* +WebContentsDelegate::GetInstalledWebappGeolocationContext() { + return nullptr; +} + base::WeakPtr<WebContentsDelegate> WebContentsDelegate::GetDelegateWeakPtr() { return nullptr; } diff --git a/chromium/content/public/browser/web_contents_delegate.h b/chromium/content/public/browser/web_contents_delegate.h index 7757c772040..e545ff70c61 100644 --- a/chromium/content/public/browser/web_contents_delegate.h +++ b/chromium/content/public/browser/web_contents_delegate.h @@ -26,12 +26,12 @@ #include "content/public/common/previews_state.h" #include "content/public/common/window_container_type.mojom-forward.h" #include "third_party/blink/public/common/mediastream/media_stream_request.h" +#include "third_party/blink/public/common/page/web_drag_operation.h" #include "third_party/blink/public/common/security/security_style.h" #include "third_party/blink/public/mojom/choosers/color_chooser.mojom-forward.h" #include "third_party/blink/public/mojom/frame/blocked_navigation_types.mojom.h" #include "third_party/blink/public/mojom/frame/fullscreen.mojom-forward.h" #include "third_party/blink/public/mojom/manifest/display_mode.mojom.h" -#include "third_party/blink/public/platform/web_drag_operation.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/window_open_disposition.h" #include "ui/gfx/geometry/rect_f.h" @@ -73,6 +73,12 @@ struct Referrer; struct SecurityStyleExplanations; } // namespace content +namespace device { +namespace mojom { +class GeolocationContext; +} +} // namespace device + namespace gfx { class Rect; class Size; @@ -448,12 +454,9 @@ class CONTENT_EXPORT WebContentsDelegate { virtual bool EmbedsFullscreenWidget(); // Called when the renderer puts a tab into fullscreen mode. - // |origin| is the origin of the initiating frame inside the |web_contents|. - // |origin| can be empty in which case the |web_contents| last committed - // URL's origin should be used. + // |requesting_frame| is the specific content frame requesting fullscreen. virtual void EnterFullscreenModeForTab( - WebContents* web_contents, - const GURL& origin, + RenderFrameHost* requesting_frame, const blink::mojom::FullscreenOptions& options) {} // Called when the renderer puts a tab out of fullscreen mode. @@ -732,6 +735,12 @@ class CONTENT_EXPORT WebContentsDelegate { // Invoked when media playback is interrupted or completed. virtual void MediaWatchTimeChanged(const MediaPlayerWatchTime& watch_time) {} + // Returns a InstalledWebappGeolocationContext if this web content is running + // in a installed webapp and geolocation should be deleagted from the + // installed webapp; otherwise returns nullptr. + virtual device::mojom::GeolocationContext* + GetInstalledWebappGeolocationContext(); + // Returns a weak ptr to the web contents delegate. virtual base::WeakPtr<WebContentsDelegate> GetDelegateWeakPtr(); diff --git a/chromium/content/public/browser/web_contents_observer.h b/chromium/content/public/browser/web_contents_observer.h index f0f6c11f599..231047ad1fe 100644 --- a/chromium/content/public/browser/web_contents_observer.h +++ b/chromium/content/public/browser/web_contents_observer.h @@ -214,6 +214,14 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { // so do not keep a reference to it afterward. virtual void DidFinishNavigation(NavigationHandle* navigation_handle) {} + // Called after the contents replaces the |predecessor_contents| in its + // container due to portal activation. The |predecessor_contents| is now a + // portal pending adoption. |predecessor_contents| is non-null, but may + // subsequently be destroyed if it is not adopted. + // |activation_time| is the time the activation happened. + virtual void DidActivatePortal(WebContents* predecessor_web_contents, + base::TimeTicks activation_time) {} + // Document load events ------------------------------------------------------ // These three methods correspond to the points in time when a document starts @@ -419,6 +427,20 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { // added to the WebContents tree at this point, but can be observed safely. virtual void InnerWebContentsCreated(WebContents* inner_web_contents) {} + // Notifies that an |inner_web_contents| instance has been attached to the + // provided |render_frame_host|. By the time this is called the + // |inner_web_contents| will have been added to the WebContents tree. + virtual void InnerWebContentsAttached(WebContents* inner_web_contents, + RenderFrameHost* render_frame_host, + bool is_full_page) {} + + // Notifies that an |inner_web_contents| instance has been detached from this + // WebContents. InnerWebContentsAttached() will already have been called for + // the |inner_web_contents|. By the time this is called the + // |inner_web_contents| will have been removed from the WebContents tree, but + // will still be alive and is safe to observe. + virtual void InnerWebContentsDetached(WebContents* inner_web_contents) {} + // Invoked when WebContents::Clone() was used to clone a WebContents. virtual void DidCloneToNewWebContents(WebContents* old_web_contents, WebContents* new_web_contents) {} @@ -436,12 +458,20 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { // the renderer process. If the instance is created after the page is loaded, // it is recommended to call WebContents::GetFaviconURLs() to get the current // list as this callback will not be executed unless there is an update. + // |render_frame_host| is the main render frame host. virtual void DidUpdateFaviconURL( + RenderFrameHost* render_frame_host, const std::vector<blink::mojom::FaviconURLPtr>& candidates) {} - // Called when an audio change occurs. + // Called when an audio change occurs to this WebContents. If |audible| is + // true then one or more frames or child contents are emitting audio; if + // false, then no frames or child contents are emitting audio. See + // OnFrameAudioStateChanged for per-frame information. virtual void OnAudioStateChanged(bool audible) {} + // Called when the audio state of an individual frame changes. + virtual void OnFrameAudioStateChanged(RenderFrameHost* rfh, bool audible) {} + // Called when the connected to Bluetooth device state changes. virtual void OnIsConnectedToBluetoothDeviceChanged( bool is_connected_to_bluetooth_device) {} @@ -466,10 +496,6 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { // this frame own the current fullscreen element again. virtual void DidAcquireFullscreen(RenderFrameHost* rfh) {} - // Invoked when an interstitial page is attached or detached. - virtual void DidAttachInterstitialPage() {} - virtual void DidDetachInterstitialPage() {} - // Invoked when the vertical scroll direction of the root layer is changed. // Note that if a scroll in a given direction occurs, the scroll is completed, // and then another scroll in the *same* direction occurs, we will not @@ -546,6 +572,7 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { virtual void MediaEffectivelyFullscreenChanged(bool is_fullscreen) {} virtual void MediaPictureInPictureChanged(bool is_picture_in_picture) {} virtual void MediaMutedStatusChanged(const MediaPlayerId& id, bool muted) {} + virtual void MediaBufferUnderflow(const MediaPlayerId& id) {} // Invoked when the renderer process changes the page scale factor. virtual void OnPageScaleFactorChanged(float page_scale_factor) {} @@ -580,6 +607,7 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { // document has both a manifest and a favicon, DidUpdateWebManifestURL() will // be invoked before DidUpdateFaviconURL(). virtual void DidUpdateWebManifestURL( + RenderFrameHost* target_frame, const base::Optional<GURL>& manifest_url) {} // DEPRECATED. Please register interface binders with BrowserInterfaceBroker @@ -598,12 +626,6 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { virtual void AudioContextPlaybackStopped( const AudioContextId& audio_context_id) {} - // Called after the contents replaces the |predecessor_contents| in its - // container due to portal activation. The |predecessor_contents| is now a - // portal pending adoption. |predecessor_contents| is non-null, but may - // subsequently be destroyed if it is not adopted. - virtual void DidActivatePortal(WebContents* predecessor_contents) {} - // Called when the RenderFrameHost tries to use a ServiceWorker // (e.g. via navigation.serviceWorker API). virtual void OnServiceWorkerAccessed(RenderFrameHost* render_frame_host, diff --git a/chromium/content/public/browser/web_contents_user_data.h b/chromium/content/public/browser/web_contents_user_data.h index 28996e5253e..6f5718e5d4b 100644 --- a/chromium/content/public/browser/web_contents_user_data.h +++ b/chromium/content/public/browser/web_contents_user_data.h @@ -5,7 +5,7 @@ #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_USER_DATA_H_ #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_USER_DATA_H_ -#include "base/logging.h" +#include "base/check.h" #include "base/memory/ptr_util.h" #include "base/supports_user_data.h" #include "content/public/browser/web_contents.h" diff --git a/chromium/content/public/browser/web_ui.h b/chromium/content/public/browser/web_ui.h index 4e6aa0e28d9..fa6f10c1bff 100644 --- a/chromium/content/public/browser/web_ui.h +++ b/chromium/content/public/browser/web_ui.h @@ -138,22 +138,6 @@ class CONTENT_EXPORT WebUI { template <typename T> static T GetValue(const base::Value& value); - template <> - inline bool GetValue<bool>(const base::Value& value) { - return value.GetBool(); - } - - template <> - inline int GetValue<int>(const base::Value& value) { - return value.GetInt(); - } - - template <> - inline const std::string& GetValue<const std::string&>( - const base::Value& value) { - return value.GetString(); - } - template <typename Is, typename... Args> struct Call; @@ -169,6 +153,22 @@ class CONTENT_EXPORT WebUI { }; }; +template <> +inline bool WebUI::GetValue<bool>(const base::Value& value) { + return value.GetBool(); +} + +template <> +inline int WebUI::GetValue<int>(const base::Value& value) { + return value.GetInt(); +} + +template <> +inline const std::string& WebUI::GetValue<const std::string&>( + const base::Value& value) { + return value.GetString(); +} + } // namespace content #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_H_ diff --git a/chromium/content/public/browser/web_ui_controller.h b/chromium/content/public/browser/web_ui_controller.h index bf308f1bb32..1c7d8216217 100644 --- a/chromium/content/public/browser/web_ui_controller.h +++ b/chromium/content/public/browser/web_ui_controller.h @@ -5,7 +5,9 @@ #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_ #define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_ -#include "base/logging.h" +#include <ostream> + +#include "base/check.h" #include "base/strings/string16.h" #include "content/common/content_export.h" diff --git a/chromium/content/public/browser/web_ui_data_source.h b/chromium/content/public/browser/web_ui_data_source.h index e963d50a0ff..0c97a5c422d 100644 --- a/chromium/content/public/browser/web_ui_data_source.h +++ b/chromium/content/public/browser/web_ui_data_source.h @@ -15,6 +15,7 @@ #include "base/strings/string16.h" #include "base/strings/string_piece.h" #include "content/common/content_export.h" +#include "services/network/public/mojom/content_security_policy.mojom-forward.h" #include "url/gurl.h" namespace base { @@ -111,19 +112,12 @@ class WebUIDataSource { // Currently only used by embedders for WebUIs with multiple instances. virtual void DisableReplaceExistingSource() = 0; virtual void DisableContentSecurityPolicy() = 0; - virtual void OverrideContentSecurityPolicyChildSrc( - const std::string& data) = 0; - virtual void OverrideContentSecurityPolicyDefaultSrc( - const std::string& data) = 0; - virtual void OverrideContentSecurityPolicyImgSrc(const std::string& data) = 0; - virtual void OverrideContentSecurityPolicyObjectSrc( - const std::string& data) = 0; - virtual void OverrideContentSecurityPolicyScriptSrc( - const std::string& data) = 0; - virtual void OverrideContentSecurityPolicyStyleSrc( - const std::string& data) = 0; - virtual void OverrideContentSecurityPolicyWorkerSrc( - const std::string& data) = 0; + + // Overrides the content security policy for a certain directive. + virtual void OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName directive, + const std::string& value) = 0; + // This method is deprecated and AddFrameAncestors should be used instead. virtual void DisableDenyXFrameOptions() = 0; virtual void AddFrameAncestor(const GURL& frame_ancestor) = 0; diff --git a/chromium/content/public/browser/web_ui_message_handler.h b/chromium/content/public/browser/web_ui_message_handler.h index e75b710f04b..f1be7363b66 100644 --- a/chromium/content/public/browser/web_ui_message_handler.h +++ b/chromium/content/public/browser/web_ui_message_handler.h @@ -7,8 +7,8 @@ #include <vector> +#include "base/check.h" #include "base/gtest_prod_util.h" -#include "base/logging.h" #include "base/strings/string16.h" #include "base/values.h" #include "content/common/content_export.h" diff --git a/chromium/content/public/browser/xr_consent_helper.h b/chromium/content/public/browser/xr_consent_helper.h deleted file mode 100644 index 1af0df38c68..00000000000 --- a/chromium/content/public/browser/xr_consent_helper.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2019 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_PUBLIC_BROWSER_XR_CONSENT_HELPER_H_ -#define CONTENT_PUBLIC_BROWSER_XR_CONSENT_HELPER_H_ - -#include "base/callback_forward.h" -#include "content/common/content_export.h" -#include "content/public/browser/xr_consent_prompt_level.h" - -namespace content { - -using OnXrUserConsentCallback = - base::OnceCallback<void(XrConsentPromptLevel, bool)>; - -// Interface class to provide the opportunity for runtimes to ensure that any -// necessary UI is shown to request the appropriate level of user consent -// for the requested session. This is acquired via the |XrInstallHelperFactory|. -// Generally, these steps are specific per runtime, so likely this should be -// implemented for each runtime that has browser-specific installation steps. -// This should be implemented by embedders. -class CONTENT_EXPORT XrConsentHelper { - public: - virtual ~XrConsentHelper() = default; - - XrConsentHelper(const XrConsentHelper&) = delete; - XrConsentHelper& operator=(const XrConsentHelper&) = delete; - - // Shows UI necessary to prompt the user for the given level of consent. - // render_process_id and render_frame_id are passed in order to ensure that - // any tab specific UI can be shown. - // The callback should be guaranteed to run in the event that the object is - // destroyed, and the object should handle being destroyed as an indication - // that any displayed UI should be cleaned up. - // The Callback should return either the highest level of consent that was - // granted and true (if e.g. the user only granted consent to a lower level - // than was initially requested), or the requested level of consent and false, - // if the user denied consent. - virtual void ShowConsentPrompt(int render_process_id, - int render_frame_id, - XrConsentPromptLevel consent_level, - OnXrUserConsentCallback) = 0; - - protected: - XrConsentHelper() = default; -}; - -} // namespace content - -#endif // CONTENT_PUBLIC_BROWSER_XR_CONSENT_HELPER_H_ diff --git a/chromium/content/public/browser/xr_consent_prompt_level.h b/chromium/content/public/browser/xr_consent_prompt_level.h deleted file mode 100644 index 1bce74d4e25..00000000000 --- a/chromium/content/public/browser/xr_consent_prompt_level.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2019 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_PUBLIC_BROWSER_XR_CONSENT_PROMPT_LEVEL_H_ -#define CONTENT_PUBLIC_BROWSER_XR_CONSENT_PROMPT_LEVEL_H_ -namespace content { - -// Consent levels are incremental, granting consent for a higher level -// automatically grants consent for all levels below it. For that reason, -// these levels should not be used in histograms so that new levels can be -// added in between the existing levels. -// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content_public.browser -enum class XrConsentPromptLevel : int { - // No consent is needed, typically this is due to the fact that no sensitive - // information is exposed (all sensitive information is emulated, or not - // available, such as in the "viewer" reference space). - kNone = 0, - // A default level of consent is needed, with no special features that need to - // be explicitly called out. This is typically used for entering an immersive - // session, where there may not be an easy way out, and we want to ensure the - // user is aware that they are doing so. - kDefault = 1, - // At this level of consent, the user is warned that their physical features - // (such as height) could be exposed to the site. This is the case when a - // site requests a "local-floor" reference space for example, where the site - // can detect the height of the headset from the ground. - kVRFeatures = 2, - // At this level of consent, the user is warned that the site may be able to - // determine the layout of their room, due to specific geometries being given - // to the site. All methods of exposing these geometries inherently also can - // expose the user's height, and thus this supersedes/includes features - // being potentially exposed. - kVRFloorPlan = 3 -}; - -} // namespace content -#endif // CONTENT_PUBLIC_BROWSER_XR_CONSENT_PROMPT_LEVEL_H_ diff --git a/chromium/content/public/browser/xr_integration_client.cc b/chromium/content/public/browser/xr_integration_client.cc index 4b617dcc7a1..14a74340197 100644 --- a/chromium/content/public/browser/xr_integration_client.cc +++ b/chromium/content/public/browser/xr_integration_client.cc @@ -4,7 +4,6 @@ #include "content/public/browser/xr_integration_client.h" -#include "content/public/browser/xr_consent_helper.h" #include "content/public/browser/xr_install_helper.h" #include "device/vr/public/cpp/vr_device_provider.h" #include "device/vr/public/mojom/vr_service.mojom-shared.h" @@ -16,11 +15,6 @@ std::unique_ptr<XrInstallHelper> XrIntegrationClient::GetInstallHelper( return nullptr; } -std::unique_ptr<XrConsentHelper> XrIntegrationClient::GetConsentHelper( - device::mojom::XRDeviceId device_id) { - return nullptr; -} - XRProviderList XrIntegrationClient::GetAdditionalProviders() { return {}; } diff --git a/chromium/content/public/browser/xr_integration_client.h b/chromium/content/public/browser/xr_integration_client.h index bfdf231cd50..7da3f0af7f7 100644 --- a/chromium/content/public/browser/xr_integration_client.h +++ b/chromium/content/public/browser/xr_integration_client.h @@ -21,7 +21,6 @@ class VRDeviceProvider; } namespace content { -class XrConsentHelper; class XrInstallHelper; using XRProviderList = std::vector<std::unique_ptr<device::VRDeviceProvider>>; @@ -56,12 +55,6 @@ class CONTENT_EXPORT XrIntegrationClient { virtual std::unique_ptr<XrInstallHelper> GetInstallHelper( device::mojom::XRDeviceId device_id); - // Returns the |XrConsentHelper| for the corresponding |XRDeviceId|, or - // nullptr if the requested |XRDeviceId| cannot prompt for consent. - // In this case, consent is assumed to have been denied. - virtual std::unique_ptr<XrConsentHelper> GetConsentHelper( - device::mojom::XRDeviceId device_id); - // Returns a vector of device providers that should be used in addition to // any default providers built-in to //content. virtual XRProviderList GetAdditionalProviders(); diff --git a/chromium/content/public/browser/zygote_host/OWNERS b/chromium/content/public/browser/zygote_host/OWNERS new file mode 100644 index 00000000000..eb4b322bdf5 --- /dev/null +++ b/chromium/content/public/browser/zygote_host/OWNERS @@ -0,0 +1,4 @@ +file://content/zygote/OWNERS + +# TEAM: security-dev@chromium.org +# COMPONENT: Internals>Sandbox diff --git a/chromium/content/public/browser/zygote_host/zygote_host_linux.h b/chromium/content/public/browser/zygote_host/zygote_host_linux.h new file mode 100644 index 00000000000..449ccf7b3ce --- /dev/null +++ b/chromium/content/public/browser/zygote_host/zygote_host_linux.h @@ -0,0 +1,42 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_LINUX_H_ +#define CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_LINUX_H_ + +#include <unistd.h> + +#include "base/process/process.h" +#include "content/common/content_export.h" + +namespace content { + +// https://chromium.googlesource.com/chromium/src/+/master/docs/linux/zygote.md + +// The zygote host is an interface, in the browser process, to the zygote +// process. +class ZygoteHost { + public: + // Returns the singleton instance. + static CONTENT_EXPORT ZygoteHost* GetInstance(); + + virtual ~ZygoteHost() {} + + // Returns the pid of the Zygote process. + virtual bool IsZygotePid(pid_t pid) = 0; + + // Returns an int which is a bitmask of kSandboxLinux* values. Only valid + // after the first render has been forked. + virtual int GetRendererSandboxStatus() = 0; + + // Adjust the OOM score of the given renderer's PID. The allowed + // range for the score is [0, 1000], where higher values are more + // likely to be killed by the OOM killer. + virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle, + int score) = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_LINUX_H_ diff --git a/chromium/content/public/common/BUILD.gn b/chromium/content/public/common/BUILD.gn index 47b93531c4b..a85f429a0d1 100644 --- a/chromium/content/public/common/BUILD.gn +++ b/chromium/content/public/common/BUILD.gn @@ -7,6 +7,7 @@ import("//build/config/chromecast_build.gni") import("//build/config/features.gni") import("//build/config/jumbo.gni") import("//build/config/ui.gni") +import("//content/public/common/zygote/features.gni") import("//media/media_options.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//ppapi/buildflags/buildflags.gni") @@ -202,6 +203,7 @@ jumbo_source_set("common_sources") { ":renderer_type", ":service_names", "//content/common", + "//content/public/common/zygote:buildflags", "//ipc", "//media/capture:capture_base", "//mojo/public/cpp/bindings", @@ -232,14 +234,13 @@ jumbo_source_set("common_sources") { "//services/network/public/cpp", "//services/service_manager/embedder:embedder_result_codes", "//services/service_manager/public/cpp", - "//services/service_manager/zygote:zygote_buildflags", "//skia", "//storage/common", "//third_party/blink/public/common", "//third_party/icu", "//ui/accessibility", "//ui/base", - "//ui/base/cursor", + "//ui/base/cursor:cursor_base", "//ui/gfx", "//ui/gfx/ipc", "//ui/gfx/ipc/color", @@ -255,12 +256,20 @@ jumbo_source_set("common_sources") { deps += [ "//content/public/android:jni" ] } + if (is_chromeos) { + public_deps += [ "//media/capture/video/chromeos/public" ] + } + if (is_linux) { - deps += [ "//services/service_manager/zygote" ] + sources += [ + "zygote/sandbox_support_linux.h", + "zygote/send_zygote_child_ping_linux.h", + "zygote/zygote_fork_delegate_linux.h", + ] } - if (is_chromeos) { - public_deps += [ "//media/capture/video/chromeos/public" ] + if (use_zygote_handle) { + sources += [ "zygote/zygote_handle.h" ] } if (rtc_use_pipewire) { @@ -305,6 +314,7 @@ mojom("interfaces") { "browser_controls_state.mojom", "drop_data.mojom", "fullscreen_video_element.mojom", + "performance_manager/v8_per_frame_memory.mojom", "resource_usage_reporter.mojom", "transferrable_url_loader.mojom", "was_activated_option.mojom", diff --git a/chromium/content/public/common/DEPS b/chromium/content/public/common/DEPS index 93053069e40..91e7360dbb7 100644 --- a/chromium/content/public/common/DEPS +++ b/chromium/content/public/common/DEPS @@ -9,7 +9,7 @@ specific_include_rules = { "+content/common", ], "simple_url_loader\.cc": [ - "-content/", + "-content", "+content/public/common/simple_url_loader\.h", "+content/public/common/resource_request\.h", "+content/public/common/resource_response\.h", diff --git a/chromium/content/public/common/common_param_traits_macros.h b/chromium/content/public/common/common_param_traits_macros.h index c7a871602f5..d67aa115c4e 100644 --- a/chromium/content/public/common/common_param_traits_macros.h +++ b/chromium/content/public/common/common_param_traits_macros.h @@ -17,12 +17,12 @@ #include "ipc/ipc_message_macros.h" #include "services/network/public/cpp/network_ipc_param_traits.h" #include "services/network/public/mojom/referrer_policy.mojom.h" +#include "third_party/blink/public/common/page/web_drag_operation.h" #include "third_party/blink/public/common/security/security_style.h" #include "third_party/blink/public/mojom/devtools/console_message.mojom.h" #include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" #include "third_party/blink/public/mojom/renderer_preferences.mojom.h" #include "third_party/blink/public/mojom/window_features/window_features.mojom.h" -#include "third_party/blink/public/platform/web_drag_operation.h" #include "third_party/blink/public/platform/web_history_scroll_restoration_type.h" #include "third_party/blink/public/platform/web_rect.h" #include "third_party/blink/public/platform/web_url_request.h" @@ -77,7 +77,7 @@ IPC_ENUM_TRAITS_MIN_MAX_VALUE( content::AutoplayPolicy::kNoUserGestureRequired, content::AutoplayPolicy::kDocumentUserActivationRequired) IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::PreferredColorScheme, - blink::PreferredColorScheme::kNoPreference, + blink::PreferredColorScheme::kDark, blink::PreferredColorScheme::kMaxValue) IPC_STRUCT_TRAITS_BEGIN(blink::WebRect) @@ -142,7 +142,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(new_canvas_2d_api_enabled) IPC_STRUCT_TRAITS_MEMBER(antialiased_2d_canvas_disabled) IPC_STRUCT_TRAITS_MEMBER(antialiased_clips_2d_canvas_enabled) - IPC_STRUCT_TRAITS_MEMBER(accelerated_2d_canvas_msaa_sample_count) IPC_STRUCT_TRAITS_MEMBER(accelerated_filters_enabled) IPC_STRUCT_TRAITS_MEMBER(deferred_filters_enabled) IPC_STRUCT_TRAITS_MEMBER(container_culling_enabled) @@ -166,7 +165,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(primary_hover_type) IPC_STRUCT_TRAITS_MEMBER(barrel_button_for_drag_enabled) IPC_STRUCT_TRAITS_MEMBER(sync_xhr_in_documents_enabled) - IPC_STRUCT_TRAITS_MEMBER(should_respect_image_orientation) IPC_STRUCT_TRAITS_MEMBER(number_of_cpu_cores) IPC_STRUCT_TRAITS_MEMBER(editing_behavior) IPC_STRUCT_TRAITS_MEMBER(supports_multiple_windows) @@ -244,7 +242,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(picture_in_picture_enabled) IPC_STRUCT_TRAITS_MEMBER(translate_service_available) IPC_STRUCT_TRAITS_MEMBER(network_quality_estimator_web_holdback) - IPC_STRUCT_TRAITS_MEMBER(lazy_load_enabled) IPC_STRUCT_TRAITS_MEMBER(lazy_frame_loading_distance_thresholds_px) IPC_STRUCT_TRAITS_MEMBER(lazy_image_loading_distance_thresholds_px) IPC_STRUCT_TRAITS_MEMBER(lazy_image_first_k_fully_load) diff --git a/chromium/content/public/common/content_features.cc b/chromium/content/public/common/content_features.cc index cbe291d39b8..87b1ee17b48 100644 --- a/chromium/content/public/common/content_features.cc +++ b/chromium/content/public/common/content_features.cc @@ -110,11 +110,6 @@ const base::Feature kCacheStorageParallelOps{"CacheStorageParallelOps", const base::Feature kCacheStorageEagerReading{ "CacheStorageEagerReading", base::FEATURE_DISABLED_BY_DEFAULT}; -// Enables scheduling the operation at high priority when a cache.match() is -// initiated from a FetchEvent handler with a matching request URL. -const base::Feature kCacheStorageHighPriorityMatch{ - "CacheStorageHighPriorityMatch", base::FEATURE_ENABLED_BY_DEFAULT}; - // If Canvas2D Image Chromium is allowed, this feature controls whether it is // enabled. const base::Feature kCanvas2DImageChromium { @@ -130,6 +125,9 @@ const base::Feature kCanvas2DImageChromium { const base::Feature kCanvasOopRasterization{"CanvasOopRasterization", base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kClickPointerEvent{"ClickPointerEvent", + base::FEATURE_DISABLED_BY_DEFAULT}; + // When enabled, code cache does not use a browsing_data filter for deletions. extern const base::Feature kCodeCacheDeletionWithoutFilter{ "CodeCacheDeletionWithoutFilter", base::FEATURE_DISABLED_BY_DEFAULT}; @@ -265,21 +263,13 @@ const base::Feature kHistoryPreventSandboxedNavigation{ const base::Feature kIdleDetection{"IdleDetection", base::FEATURE_ENABLED_BY_DEFAULT}; -// This flag is used to set field parameters to choose predictor we use when -// kResamplingInputEvents is disabled. It's used for gatherig accuracy metrics -// on finch and also for choosing predictor type for predictedEvents API without -// enabling resampling. It does not have any effect when the resampling flag is -// enabled. -const base::Feature kInputPredictorTypeChoice{ - "InputPredictorTypeChoice", base::FEATURE_DISABLED_BY_DEFAULT}; - // Kill switch for the GetInstalledRelatedApps API. const base::Feature kInstalledApp{"InstalledApp", base::FEATURE_ENABLED_BY_DEFAULT}; // Allow Windows specific implementation for the GetInstalledRelatedApps API. const base::Feature kInstalledAppProvider{"InstalledAppProvider", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_ENABLED_BY_DEFAULT}; // Show warning about clearing data from installed apps in the clear browsing // data flow. The warning will be shown in a second dialog. @@ -324,8 +314,14 @@ const base::Feature kLazyInitializeMediaControls{ const base::Feature kLegacyWindowsDWriteFontFallback{ "LegacyWindowsDWriteFontFallback", base::FEATURE_DISABLED_BY_DEFAULT}; -const base::Feature kLogJsConsoleMessages{"LogJsConsoleMessages", - base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kLogJsConsoleMessages { + "LogJsConsoleMessages", +#if defined(OS_ANDROID) + base::FEATURE_DISABLED_BY_DEFAULT +#else + base::FEATURE_ENABLED_BY_DEFAULT +#endif +}; // Enables lowering the priority of the resources in iframes. const base::Feature kLowPriorityIframes{"LowPriorityIframes", @@ -404,10 +400,6 @@ const base::Feature kOverscrollHistoryNavigation { #endif }; -// Whether ParkableStrings in blink can be written out to disk. -const base::Feature kParkableStringsToDisk{"ParkableStringsToDisk", - base::FEATURE_DISABLED_BY_DEFAULT}; - // Whether web apps can run periodic tasks upon network connectivity. const base::Feature kPeriodicBackgroundSync{"PeriodicBackgroundSync", base::FEATURE_DISABLED_BY_DEFAULT}; @@ -506,9 +498,10 @@ const base::Feature kRenderDocument{"RenderDocument", const base::Feature kRequestUnbufferedDispatch{ "RequestUnbufferedDispatch", base::FEATURE_ENABLED_BY_DEFAULT}; -// Enables resampling input events on main thread. -const base::Feature kResamplingInputEvents{"ResamplingInputEvents", - base::FEATURE_DISABLED_BY_DEFAULT}; +// Respect the MacOS system setting for subpixel text anti-aliasing. +// https://crbug.com/1079418. +const base::Feature kRespectMacLCDTextSetting{ + "RespectMacLCDTextSetting", base::FEATURE_DISABLED_BY_DEFAULT}; // Run video capture service in the Browser process as opposed to a dedicated // utility process @@ -609,9 +602,19 @@ const base::Feature kSiteIsolationEnforcementForFileSystemApi{ const base::Feature kSpareRendererForSitePerProcess{ "SpareRendererForSitePerProcess", base::FEATURE_ENABLED_BY_DEFAULT}; +// Enables Storage Pressure Event. +const base::Feature kStoragePressureEvent{"StoragePressureEvent", + base::FEATURE_DISABLED_BY_DEFAULT}; + // Enables Storage Pressure notifications and settings pages. -const base::Feature kStoragePressureUI{"StoragePressureUI", - base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kStoragePressureUI { + "StoragePressureUI", +#if defined(OS_ANDROID) + base::FEATURE_DISABLED_BY_DEFAULT +#else + base::FEATURE_ENABLED_BY_DEFAULT +#endif +}; // Enables the out-of-process Storage Service. const base::Feature kStorageServiceOutOfProcess{ @@ -627,6 +630,10 @@ const base::Feature kStorageServiceSandbox{"StorageServiceSandbox", const base::Feature kStrictOriginIsolation{"StrictOriginIsolation", base::FEATURE_DISABLED_BY_DEFAULT}; +// Enables subresource loading with Web Bundles. +const base::Feature kSubresourceWebBundles{"SubresourceWebBundles", + base::FEATURE_DISABLED_BY_DEFAULT}; + // Dispatch touch events to "SyntheticGestureController" for events from // Devtool Protocol Input.dispatchTouchEvent to simulate touch events close to // real OS events. @@ -687,23 +694,13 @@ const base::Feature kUserAgentClientHint{"UserAgentClientHint", const base::Feature kVideoPlaybackQuality{"VideoPlaybackQuality", base::FEATURE_ENABLED_BY_DEFAULT}; -// Enables V8's low memory mode for subframes. This is used only -// in conjunction with the --site-per-process feature. -const base::Feature kV8LowMemoryModeForSubframes{ - "V8LowMemoryModeForSubframes", base::FEATURE_DISABLED_BY_DEFAULT}; - // Enables future V8 VM features const base::Feature kV8VmFuture{"V8VmFuture", base::FEATURE_DISABLED_BY_DEFAULT}; -// Enable WebAssembly baseline compilation and tier up. +// Enable WebAssembly baseline compilation (Liftoff). const base::Feature kWebAssemblyBaseline{"WebAssemblyBaseline", -#ifdef ARCH_CPU_X86_FAMILY - base::FEATURE_ENABLED_BY_DEFAULT -#else - base::FEATURE_DISABLED_BY_DEFAULT -#endif -}; + base::FEATURE_ENABLED_BY_DEFAULT}; // Enable WebAssembly lazy compilation (JIT on first call). const base::Feature kWebAssemblyLazyCompilation{ diff --git a/chromium/content/public/common/content_features.h b/chromium/content/public/common/content_features.h index 93139ce799c..5f69a8fb406 100644 --- a/chromium/content/public/common/content_features.h +++ b/chromium/content/public/common/content_features.h @@ -35,9 +35,9 @@ CONTENT_EXPORT extern const base::Feature kBrowserVerifiedUserActivationMouse; CONTENT_EXPORT extern const base::Feature kCacheInlineScriptCode; CONTENT_EXPORT extern const base::Feature kCacheStorageParallelOps; CONTENT_EXPORT extern const base::Feature kCacheStorageEagerReading; -CONTENT_EXPORT extern const base::Feature kCacheStorageHighPriorityMatch; CONTENT_EXPORT extern const base::Feature kCanvas2DImageChromium; CONTENT_EXPORT extern const base::Feature kCanvasOopRasterization; +CONTENT_EXPORT extern const base::Feature kClickPointerEvent; CONTENT_EXPORT extern const base::Feature kCodeCacheDeletionWithoutFilter; CONTENT_EXPORT extern const base::Feature kConsolidatedMovementXY; CONTENT_EXPORT extern const base::Feature kConversionMeasurement; @@ -66,7 +66,6 @@ CONTENT_EXPORT extern const base::Feature kFtpProtocol; CONTENT_EXPORT extern const base::Feature kHistoryManipulationIntervention; CONTENT_EXPORT extern const base::Feature kHistoryPreventSandboxedNavigation; CONTENT_EXPORT extern const base::Feature kIdleDetection; -CONTENT_EXPORT extern const base::Feature kInputPredictorTypeChoice; CONTENT_EXPORT extern const base::Feature kInstalledApp; CONTENT_EXPORT extern const base::Feature kInstalledAppProvider; CONTENT_EXPORT extern const base::Feature kInstalledAppsInCbd; @@ -93,7 +92,6 @@ CONTENT_EXPORT extern const base::Feature kNotificationTriggers; CONTENT_EXPORT extern const base::Feature kOriginIsolationHeader; CONTENT_EXPORT extern const base::Feature kOriginPolicy; CONTENT_EXPORT extern const base::Feature kOverscrollHistoryNavigation; -CONTENT_EXPORT extern const base::Feature kParkableStringsToDisk; CONTENT_EXPORT extern const base::Feature kPeriodicBackgroundSync; CONTENT_EXPORT extern const base::Feature kPepper3DImageChromium; CONTENT_EXPORT extern const base::Feature kPepperCrossOriginRedirectRestriction; @@ -110,7 +108,7 @@ CONTENT_EXPORT extern const base::Feature CONTENT_EXPORT extern const base::Feature kReloadHiddenTabsWithCrashedSubframes; CONTENT_EXPORT extern const base::Feature kRenderDocument; CONTENT_EXPORT extern const base::Feature kRequestUnbufferedDispatch; -CONTENT_EXPORT extern const base::Feature kResamplingInputEvents; +CONTENT_EXPORT extern const base::Feature kRespectMacLCDTextSetting; CONTENT_EXPORT extern const base::Feature kRunVideoCaptureServiceInBrowserProcess; CONTENT_EXPORT extern const base::Feature kSavePageAsWebBundle; @@ -133,10 +131,12 @@ CONTENT_EXPORT extern const base::Feature kSiteIsolationEnforcementForFileSystemApi; CONTENT_EXPORT extern const base::Feature kSmsReceiver; CONTENT_EXPORT extern const base::Feature kSpareRendererForSitePerProcess; +CONTENT_EXPORT extern const base::Feature kStoragePressureEvent; CONTENT_EXPORT extern const base::Feature kStoragePressureUI; CONTENT_EXPORT extern const base::Feature kStorageServiceOutOfProcess; CONTENT_EXPORT extern const base::Feature kStorageServiceSandbox; CONTENT_EXPORT extern const base::Feature kStrictOriginIsolation; +CONTENT_EXPORT extern const base::Feature kSubresourceWebBundles; CONTENT_EXPORT extern const base::Feature kSyntheticPointerActions; CONTENT_EXPORT extern const base::Feature kTimerThrottlingForHiddenFrames; CONTENT_EXPORT extern const base::Feature kTopLevelAwait; @@ -148,7 +148,6 @@ CONTENT_EXPORT extern const base::Feature kUserActivationPostMessageTransfer; CONTENT_EXPORT extern const base::Feature kUserActivationSameOriginVisibility; CONTENT_EXPORT extern const base::Feature kUserAgentClientHint; CONTENT_EXPORT extern const base::Feature kVideoPlaybackQuality; -CONTENT_EXPORT extern const base::Feature kV8LowMemoryModeForSubframes; CONTENT_EXPORT extern const base::Feature kV8VmFuture; CONTENT_EXPORT extern const base::Feature kWebAssemblyBaseline; CONTENT_EXPORT extern const base::Feature kWebAssemblyLazyCompilation; diff --git a/chromium/content/public/common/content_switch_dependent_feature_overrides.cc b/chromium/content/public/common/content_switch_dependent_feature_overrides.cc index c3f1d1658f3..61f09762672 100644 --- a/chromium/content/public/common/content_switch_dependent_feature_overrides.cc +++ b/chromium/content/public/common/content_switch_dependent_feature_overrides.cc @@ -9,7 +9,6 @@ #include "net/base/features.h" #include "services/network/public/cpp/features.h" #include "third_party/blink/public/common/features.h" -#include "ui/base/ui_base_features.h" namespace content { @@ -39,6 +38,9 @@ GetSwitchDependentFeatureOverrides(const base::CommandLine& command_line) { std::cref(network::features::kCrossOriginOpenerPolicyReporting), base::FeatureList::OVERRIDE_ENABLE_FEATURE}, {switches::kEnableExperimentalWebPlatformFeatures, + std::cref(network::features::kCrossOriginOpenerPolicyAccessReporting), + base::FeatureList::OVERRIDE_ENABLE_FEATURE}, + {switches::kEnableExperimentalWebPlatformFeatures, std::cref(network::features::kCrossOriginEmbedderPolicy), base::FeatureList::OVERRIDE_ENABLE_FEATURE}, {switches::kEnableExperimentalWebPlatformFeatures, @@ -57,11 +59,6 @@ GetSwitchDependentFeatureOverrides(const base::CommandLine& command_line) { std::cref(features::kOriginIsolationHeader), base::FeatureList::OVERRIDE_ENABLE_FEATURE}, - // Overrides for --use-legacy-form-controls. - {switches::kUseLegacyFormControls, - std::cref(features::kFormControlsRefresh), - base::FeatureList::OVERRIDE_DISABLE_FEATURE}, - // Overrides for --enable-experimental-cookie-features. {switches::kEnableExperimentalCookieFeatures, std::cref(features::kCookieDeprecationMessages), diff --git a/chromium/content/public/common/content_switches.cc b/chromium/content/public/common/content_switches.cc index 8e9eb3625f0..f24ff2313d2 100644 --- a/chromium/content/public/common/content_switches.cc +++ b/chromium/content/public/common/content_switches.cc @@ -9,10 +9,6 @@ namespace switches { -// The number of MSAA samples for canvas2D. Requires MSAA support by GPU to -// have an effect. 0 disables MSAA. -const char kAcceleratedCanvas2dMSAASampleCount[] = "canvas-msaa-sample-count"; - // Allows processing of input before a frame has been committed. // TODO(schenney): crbug.com/987626. Used by headless. Look for a way not // involving a command line switch. @@ -70,13 +66,6 @@ const char kBrowserTest[] = "browser-test"; // Causes the Conversion Measurement API to run without delays or noise. const char kConversionsDebugMode[] = "conversions-debug-mode"; -// Sets the tile size used by composited layers. -const char kDefaultTileWidth[] = "default-tile-width"; -const char kDefaultTileHeight[] = "default-tile-height"; - -// Sets the min tile height for GPU raster. -const char kMinHeightForGpuRasterTile[] = "min-height-for-gpu-raster-tile"; - // Disable antialiasing on 2d canvas. const char kDisable2dCanvasAntialiasing[] = "disable-canvas-aa"; @@ -176,19 +165,10 @@ const char kDisableGpuProcessCrashLimit[] = "disable-gpu-process-crash-limit"; const char kDisableSoftwareCompositingFallback[] = "disable-software-compositing-fallback"; -// When using CPU rasterizing disable low resolution tiling. This uses -// less power, particularly during animations, but more white may be seen -// during fast scrolling especially on slower devices. -const char kDisableLowResTiling[] = "disable-low-res-tiling"; - // Disable the thread that crashes the GPU process if it stops responding to // messages. const char kDisableGpuWatchdog[] = "disable-gpu-watchdog"; -// Disallow image animations to be reset to the beginning to avoid skipping -// many frames. Only effective if compositor image animations are enabled. -const char kDisableImageAnimationResync[] = "disable-image-animation-resync"; - // Disables the IPC flooding protection. // It is activated by default. Some javascript functions can be used to flood // the browser process with IPC. This protection limits the rate at which they @@ -229,10 +209,6 @@ const char kDisableNewContentRenderingTimeout[] = // Disables the Web Notification and the Push APIs. const char kDisableNotifications[] = "disable-notifications"; -// Disable partial raster in the renderer. Disabling this switch also disables -// the use of persistent gpu memory buffers. -const char kDisablePartialRaster[] = "disable-partial-raster"; - // Disable Pepper3D. const char kDisablePepper3d[] = "disable-pepper-3d"; @@ -255,9 +231,6 @@ const char kDisablePresentationAPI[] = "disable-presentation-api"; // Disables throttling of history.pushState/replaceState calls. const char kDisablePushStateThrottle[] = "disable-pushstate-throttle"; -// Disables RGBA_4444 textures. -const char kDisableRGBA4444Textures[] = "disable-rgba-4444-textures"; - // Taints all <canvas> elements, regardless of origin. const char kDisableReadingFromCanvas[] = "disable-reading-from-canvas"; @@ -315,9 +288,6 @@ const char kDisableWebGLImageChromium[] = "disable-webgl-image-chromium"; // Don't enforce the same-origin policy. (Used by people testing their sites.) const char kDisableWebSecurity[] = "disable-web-security"; -// Disable rasterizer that writes directly to GPU memory associated with tiles. -const char kDisableZeroCopy[] = "disable-zero-copy"; - // Disable the video decoder from drawing directly to a texture. const char kDisableZeroCopyDxgiVideo[] = "disable-zero-copy-dxgi-video"; @@ -389,18 +359,10 @@ const char kEnableFtp[] = "enable-ftp"; const char kDisableOriginTrialControlledBlinkFeatures[] = "disable-origin-trial-controlled-blink-features"; -// Specify that all compositor resources should be backed by GPU memory buffers. -const char kEnableGpuMemoryBufferCompositorResources[] = - "enable-gpu-memory-buffer-compositor-resources"; - // Enable GpuMemoryBuffer backed VideoFrames. const char kEnableGpuMemoryBufferVideoFrames[] = "enable-gpu-memory-buffer-video-frames"; -// When using CPU rasterizing generate low resolution tiling. Low res -// tiles may be displayed during fast scrolls especially on slower devices. -const char kEnableLowResTiling[] = "enable-low-res-tiling"; - // Force logging to be enabled. Logging is disabled by default in release // builds. const char kEnableLogging[] = "enable-logging"; @@ -424,9 +386,6 @@ const char kEnablePluginPlaceholderTesting[] = // also applys to workers. const char kEnablePreciseMemoryInfo[] = "enable-precise-memory-info"; -// Enables RGBA_4444 textures. -const char kEnableRGBA4444Textures[] = "enable-rgba-4444-textures"; - // Set options to cache V8 data. (off, preparse data, or code) const char kV8CacheOptions[] = "v8-cache-options"; @@ -478,6 +437,13 @@ const char kEnableViewport[] = "enable-viewport"; // Enable the Vtune profiler support. const char kEnableVtune[] = "enable-vtune-support"; +// Enable the WebAuthn Mojo Testing API. This is a way to interact with the +// virtual authenticator environment through a mojo interface and is supported +// only to run web-platform-tests on content shell. +// Removal of this deprecated API is blocked on crbug.com/937369. +const char kEnableWebAuthDeprecatedMojoTestingApi[] = + "enable-web-auth-deprecated-mojo-testing-api"; + // Enable WebGL2 Compute context. const char kEnableWebGL2ComputeContext[] = "enable-webgl2-compute-context"; @@ -487,9 +453,6 @@ const char kEnableWebGLDraftExtensions[] = "enable-webgl-draft-extensions"; // Enables WebGL rendering into a scanout buffer for overlay support. const char kEnableWebGLImageChromium[] = "enable-webgl-image-chromium"; -// Enable rasterizer that writes directly to GPU memory associated with tiles. -const char kEnableZeroCopy[] = "enable-zero-copy"; - // Handle to the shared memory segment containing field trial state that is to // be shared between processes. The argument to this switch is the handle id // (pointer on Windows) as a string, followed by a comma, then the size of the @@ -515,11 +478,6 @@ const char kEnableOopRasterization[] = "enable-oop-rasterization"; const char kForceLegacyDefaultReferrerPolicy[] = "force-legacy-default-referrer-policy"; -// The number of multisample antialiasing samples for GPU rasterization. -// Requires MSAA support on GPU to have an effect. 0 disables MSAA. -const char kGpuRasterizationMSAASampleCount[] = - "gpu-rasterization-msaa-sample-count"; - // Forces use of hardware overlay for fullscreen video playback. Useful for // testing the Android overlay fullscreen functionality on other platforms. const char kForceOverlayFullscreenVideo[] = "force-overlay-fullscreen-video"; @@ -606,10 +564,6 @@ const char kMaxActiveWebGLContexts[] = "max-active-webgl-contexts"; // Sets the maximium decoded image size limitation. const char kMaxDecodedImageSizeMb[] = "max-decoded-image-size-mb"; -// Sets the width and height above which a composited layer will get tiled. -const char kMaxUntiledLayerHeight[] = "max-untiled-layer-height"; -const char kMaxUntiledLayerWidth[] = "max-untiled-layer-width"; - // Indicates the utility process should run with a message loop type of UI. const char kMessageLoopTypeUi[] = "message-loop-type-ui"; @@ -617,6 +571,10 @@ const char kMessageLoopTypeUi[] = "message-loop-type-ui"; const char kMockCertVerifierDefaultResultForTesting[] = "mock-cert-verifier-default-result-for-testing"; +// Initializes Mojo Core from a shared library at the specified path, rather +// than using the version of Mojo Core embedded within the Content executable. +const char kMojoCoreLibraryPath[] = "mojo-core-library-path"; + // Use a Mojo-based LocalStorage implementation. const char kMojoLocalStorage[] = "mojo-local-storage"; @@ -752,14 +710,6 @@ const char kRunManualTestsFlag[] = "run-manual"; // Causes the process to run as a sandbox IPC subprocess. const char kSandboxIPCProcess[] = "sandbox-ipc"; -// Visibly render a border around layout shift rects in the web page to help -// debug and study layout shifts. -const char kShowLayoutShiftRegions[] = "show-layout-shift-regions"; - -// Visibly render a border around paint rects in the web page to help debug -// and study painting behavior. -const char kShowPaintRects[] = "show-paint-rects"; - // Runs the renderer and plugins in the same process as the browser const char kSingleProcess[] = "single-process"; @@ -887,6 +837,9 @@ const char kWebglAntialiasingMode[] = "webgl-antialiasing-mode"; // Set a default sample count for webgl if msaa is enabled. const char kWebglMSAASampleCount[] = "webgl-msaa-sample-count"; +// The prefix used when starting the zygote process. (i.e. 'gdb --args') +const char kZygoteCmdPrefix[] = "zygote-cmd-prefix"; + // Enables specified backend for the Web OTP API. const char kWebOtpBackend[] = "web-otp-backend"; @@ -967,16 +920,6 @@ const char kWebXrRuntimeOpenVr[] = "openvr"; const char kWebXrRuntimeOpenXr[] = "openxr"; const char kWebXrRuntimeWMR[] = "windows-mixed-reality"; -// This switch allows the Web Components v0 APIs to be re-enabled temporarily -// from M80 through M84. -// TODO(937746): Remove this after M84. -const char kWebComponentsV0Enabled[] = "web-components-v0-enabled"; - -// This switch allows the FormControlsRefresh feature to be disabled temporarily -// from M81 through M84. -// TODO(1034611): Remove this after M84. -const char kUseLegacyFormControls[] = "use-legacy-form-controls"; - // This switch disables the ScrollToTextFragment feature. const char kDisableScrollToTextFragment[] = "disable-scroll-to-text-fragment"; diff --git a/chromium/content/public/common/content_switches.h b/chromium/content/public/common/content_switches.h index 81c110d18ad..be727273b85 100644 --- a/chromium/content/public/common/content_switches.h +++ b/chromium/content/public/common/content_switches.h @@ -15,7 +15,6 @@ namespace switches { // All switches in alphabetical order. The switches should be documented // alongside the definition of their values in the .cc file. -CONTENT_EXPORT extern const char kAcceleratedCanvas2dMSAASampleCount[]; CONTENT_EXPORT extern const char kAllowPreCommitInput[]; CONTENT_EXPORT extern const char kAllowFileAccessFromFiles[]; CONTENT_EXPORT extern const char kAllowInsecureLocalhost[]; @@ -30,9 +29,6 @@ CONTENT_EXPORT extern const char kBrowserStartupDialog[]; CONTENT_EXPORT extern const char kBrowserSubprocessPath[]; CONTENT_EXPORT extern const char kBrowserTest[]; CONTENT_EXPORT extern const char kConversionsDebugMode[]; -CONTENT_EXPORT extern const char kDefaultTileWidth[]; -CONTENT_EXPORT extern const char kDefaultTileHeight[]; -CONTENT_EXPORT extern const char kMinHeightForGpuRasterTile[]; CONTENT_EXPORT extern const char kDisable2dCanvasAntialiasing[]; CONTENT_EXPORT extern const char kDisable2dCanvasImageChromium[]; CONTENT_EXPORT extern const char kDisable3DAPIs[]; @@ -62,11 +58,9 @@ CONTENT_EXPORT extern const char kDisableGpuMemoryBufferVideoFrames[]; extern const char kDisableGpuProcessCrashLimit[]; CONTENT_EXPORT extern const char kDisableSoftwareCompositingFallback[]; CONTENT_EXPORT extern const char kDisableGpuWatchdog[]; -CONTENT_EXPORT extern const char kDisableImageAnimationResync[]; CONTENT_EXPORT extern const char kDisableIpcFloodingProtection[]; CONTENT_EXPORT extern const char kDisableJavaScriptHarmonyShipping[]; CONTENT_EXPORT extern const char kDisableLowLatencyDxva[]; -CONTENT_EXPORT extern const char kDisableLowResTiling[]; CONTENT_EXPORT extern const char kDisableHangMonitor[]; extern const char kDisableHistogramCustomizer[]; CONTENT_EXPORT extern const char kDisableLCDText[]; @@ -77,14 +71,12 @@ CONTENT_EXPORT extern const char kDisableLogging[]; CONTENT_EXPORT extern const char kDisableNewContentRenderingTimeout[]; CONTENT_EXPORT extern const char kDisableNotifications[]; CONTENT_EXPORT extern const char kDisableOriginTrialControlledBlinkFeatures[]; -CONTENT_EXPORT extern const char kDisablePartialRaster[]; extern const char kDisablePepper3d[]; CONTENT_EXPORT extern const char kDisablePepper3DImageChromium[]; CONTENT_EXPORT extern const char kDisablePermissionsAPI[]; CONTENT_EXPORT extern const char kDisablePinch[]; CONTENT_EXPORT extern const char kDisablePresentationAPI[]; CONTENT_EXPORT extern const char kDisablePushStateThrottle[]; -CONTENT_EXPORT extern const char kDisableRGBA4444Textures[]; CONTENT_EXPORT extern const char kDisableReadingFromCanvas[]; extern const char kDisableRemoteFonts[]; CONTENT_EXPORT extern const char kDisableRemotePlaybackAPI[]; @@ -103,7 +95,6 @@ CONTENT_EXPORT extern const char kDisableThreadedScrolling[]; extern const char kDisableV8IdleTasks[]; CONTENT_EXPORT extern const char kDisableWebGLImageChromium[]; CONTENT_EXPORT extern const char kDisableWebSecurity[]; -CONTENT_EXPORT extern const char kDisableZeroCopy[]; CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[]; CONTENT_EXPORT extern const char kDomAutomationController[]; extern const char kDisable2dCanvasClipAntialiasing[]; @@ -119,10 +110,7 @@ CONTENT_EXPORT extern const char kEnableExperimentalCookieFeatures[]; CONTENT_EXPORT extern const char kEnableExperimentalWebAssemblyFeatures[]; CONTENT_EXPORT extern const char kEnableExperimentalWebPlatformFeatures[]; CONTENT_EXPORT extern const char kEnableFtp[]; -CONTENT_EXPORT extern const char kEnableGpuMemoryBufferCompositorResources[]; CONTENT_EXPORT extern const char kEnableGpuMemoryBufferVideoFrames[]; -CONTENT_EXPORT extern const char kGpuRasterizationMSAASampleCount[]; -CONTENT_EXPORT extern const char kEnableLowResTiling[]; CONTENT_EXPORT extern const char kEnableLCDText[]; CONTENT_EXPORT extern const char kEnableLogging[]; CONTENT_EXPORT extern const char kEnableNetworkInformationDownlinkMax[]; @@ -130,7 +118,6 @@ CONTENT_EXPORT extern const char kEnableNewCanvas2DAPI[]; CONTENT_EXPORT extern const char kDisableNv12DxgiVideo[]; CONTENT_EXPORT extern const char kEnablePluginPlaceholderTesting[]; CONTENT_EXPORT extern const char kEnablePreciseMemoryInfo[]; -CONTENT_EXPORT extern const char kEnableRGBA4444Textures[]; CONTENT_EXPORT extern const char kEnableServiceBinaryLauncher[]; extern const char kEnableSkiaBenchmarking[]; CONTENT_EXPORT extern const char kEnableSmoothScrolling[]; @@ -144,11 +131,11 @@ CONTENT_EXPORT extern const char kEnableUserMediaScreenCapturing[]; CONTENT_EXPORT extern const char kEnableUseZoomForDSF[]; CONTENT_EXPORT extern const char kEnableViewport[]; CONTENT_EXPORT extern const char kEnableVtune[]; +CONTENT_EXPORT extern const char kEnableWebAuthDeprecatedMojoTestingApi[]; CONTENT_EXPORT extern const char kEnableWebGL2ComputeContext[]; CONTENT_EXPORT extern const char kEnableWebGLDraftExtensions[]; CONTENT_EXPORT extern const char kEnableWebGLImageChromium[]; CONTENT_EXPORT extern const char kEnableWebVR[]; -CONTENT_EXPORT extern const char kEnableZeroCopy[]; CONTENT_EXPORT extern const char kFieldTrialHandle[]; CONTENT_EXPORT extern const char kFileUrlPathAlias[]; CONTENT_EXPORT extern const char kForceDisplayList2dCanvas[]; @@ -175,14 +162,13 @@ CONTENT_EXPORT extern const char kLoggingLevel[]; CONTENT_EXPORT extern const char kLogFile[]; CONTENT_EXPORT extern const char kMainFrameResizesAreOrientationChanges[]; extern const char kMaxActiveWebGLContexts[]; -extern const char kMaxDecodedImageSizeMb[]; -extern const char kMaxUntiledLayerHeight[]; -extern const char kMaxUntiledLayerWidth[]; +CONTENT_EXPORT extern const char kMaxDecodedImageSizeMb[]; CONTENT_EXPORT extern const char kMessageLoopTypeUi[]; CONTENT_EXPORT extern const char kMHTMLGeneratorOption[]; CONTENT_EXPORT extern const char kMHTMLSkipNostoreMain[]; CONTENT_EXPORT extern const char kMHTMLSkipNostoreAll[]; CONTENT_EXPORT extern const char kMockCertVerifierDefaultResultForTesting[]; +CONTENT_EXPORT extern const char kMojoCoreLibraryPath[]; CONTENT_EXPORT extern const char kMojoLocalStorage[]; CONTENT_EXPORT extern const char kNetworkQuietTimeout[]; CONTENT_EXPORT extern const char kNoZygote[]; @@ -211,8 +197,6 @@ CONTENT_EXPORT extern const char kRendererProcessLimit[]; CONTENT_EXPORT extern const char kRendererStartupDialog[]; CONTENT_EXPORT extern const char kRunManualTestsFlag[]; extern const char kSandboxIPCProcess[]; -extern const char kShowLayoutShiftRegions[]; -extern const char kShowPaintRects[]; CONTENT_EXPORT extern const char kSingleProcess[]; CONTENT_EXPORT extern const char kSitePerProcess[]; CONTENT_EXPORT extern const char kDisableSiteIsolation[]; @@ -239,8 +223,9 @@ CONTENT_EXPORT extern const char kUtilitySubType[]; CONTENT_EXPORT extern const char kV8CacheOptions[]; CONTENT_EXPORT extern const char kValidateInputEventStream[]; CONTENT_EXPORT extern const char kWaitForDebuggerChildren[]; -extern const char kWebglAntialiasingMode[]; -extern const char kWebglMSAASampleCount[]; +CONTENT_EXPORT extern const char kWebglAntialiasingMode[]; +CONTENT_EXPORT extern const char kWebglMSAASampleCount[]; +CONTENT_EXPORT extern const char kZygoteCmdPrefix[]; CONTENT_EXPORT extern const char kWebOtpBackend[]; CONTENT_EXPORT extern const char kWebOtpBackendSmsVerification[]; @@ -258,8 +243,6 @@ extern const char kWebRtcMaxCaptureFramerate[]; extern const char kWebRtcMaxCpuConsumptionPercentage[]; CONTENT_EXPORT extern const char kWebRtcStunProbeTrialParameter[]; CONTENT_EXPORT extern const char kWebRtcLocalEventLogging[]; -CONTENT_EXPORT extern const char kWebComponentsV0Enabled[]; -CONTENT_EXPORT extern const char kUseLegacyFormControls[]; CONTENT_EXPORT extern const char kDisableScrollToTextFragment[]; CONTENT_EXPORT extern const char kWebXrForceRuntime[]; diff --git a/chromium/content/public/common/drop_data.h b/chromium/content/public/common/drop_data.h index bbd24fa2ae9..e4a2cadfbc6 100644 --- a/chromium/content/public/common/drop_data.h +++ b/chromium/content/public/common/drop_data.h @@ -17,7 +17,7 @@ #include "base/files/file_path.h" #include "base/optional.h" -#include "base/strings/nullable_string16.h" +#include "base/strings/string16.h" #include "content/common/content_export.h" #include "ipc/ipc_message.h" #include "services/network/public/mojom/referrer_policy.mojom.h" @@ -103,12 +103,12 @@ struct CONTENT_EXPORT DropData { std::vector<FileSystemFileInfo> file_system_files; // User is dragging plain text into the webview. - base::NullableString16 text; + base::Optional<base::string16> text; // User is dragging text/html into the webview (e.g., out of Firefox). // |html_base_url| is the URL that the html fragment is taken from (used to // resolve relative links). It's ok for |html_base_url| to be empty. - base::NullableString16 html; + base::Optional<base::string16> html; GURL html_base_url; // User is dragging an image out of the WebView. diff --git a/chromium/content/public/common/performance_manager/OWNERS b/chromium/content/public/common/performance_manager/OWNERS new file mode 100644 index 00000000000..7e4c8d7e6b4 --- /dev/null +++ b/chromium/content/public/common/performance_manager/OWNERS @@ -0,0 +1,5 @@ +file://components/performance_manager/OWNERS + +# For IPC security review +per-file *.mojom=set noparent +per-file *.mojom=file://ipc/SECURITY_OWNERS diff --git a/chromium/content/public/common/performance_manager/v8_per_frame_memory.mojom b/chromium/content/public/common/performance_manager/v8_per_frame_memory.mojom new file mode 100644 index 00000000000..6e0d5a3e95a --- /dev/null +++ b/chromium/content/public/common/performance_manager/v8_per_frame_memory.mojom @@ -0,0 +1,62 @@ +// Copyright 2020 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. + +module performance_manager.mojom; + +import "mojo/public/mojom/base/unguessable_token.mojom"; + +// The amount of heap memory used by V8 in the context of a frame. +struct V8IsolatedWorldMemoryUsage { + // The number of v8 heap bytes used by a V8 isolated world. + uint64 bytes_used = 0; + + // An optional tag for this world that does not vary between browser sessions + // or between renderers, unlike the world ID which can be randomly assigned. + // + // The exact meaning depends on the embedder and the type of isolated world. + // For example Chrome extensions use the host ID, as per + // extensions::ScriptInjection::GetHostIdForIsolatedWorld. Some types of + // isolated world will not have a suitable tag so will leave this empty. + string stable_id; + + // An optional human readable name for the world, for debugging. Unlike + // stable_id this might not be unique. + string human_readable_name; +}; + +// Returns the number of bytes used by the v8 heap per frame. +struct PerFrameV8MemoryUsageData { + // The frame-unique token. + mojo_base.mojom.UnguessableToken frame_token; + + // The resources used by this frame, mapped on the isolated world ID. + // World ID 0 is the main world. + map<int64, V8IsolatedWorldMemoryUsage> associated_bytes; +}; + +// Returns the number of bytes used by the v8 heap in a process. +struct PerProcessV8MemoryUsageData { + // The number of v8 heap bytes that were not associated with a specific + // v8 context, most likely because they're shared objects. + uint64 unassociated_bytes_used; + + // The number of v8 contexts not associated with a frame, likely web + // application leaks, and their associated byte usage. At the present time + // (April 2020), it's expected and normal to see one unassociated context per + // renderer process accounting for ~70kB. + uint64 num_unassociated_contexts; + uint64 unassociated_context_bytes_used; + + // The V8 memory usage by individual frames in this process. + array<PerFrameV8MemoryUsageData> associated_memory; +}; + +// Allows a browser to query the resource usage of sub-processes. +interface V8PerFrameMemoryReporter { + // Requests a per-frame estimate of v8 heap byte usage on the next garbage + // collection. Note that this causes extra cost for the next garbage + // collection, which can be on the order of 10-20%. + GetPerFrameV8MemoryUsageData() => (PerProcessV8MemoryUsageData data); +}; + diff --git a/chromium/content/public/common/profiling.cc b/chromium/content/public/common/profiling.cc index d0835889baf..b304b3a136f 100644 --- a/chromium/content/public/common/profiling.cc +++ b/chromium/content/public/common/profiling.cc @@ -71,7 +71,7 @@ void FlushProfilingData(base::Thread* thread) { class ProfilingThreadControl { public: - ProfilingThreadControl() : thread_(NULL) {} + ProfilingThreadControl() : thread_(nullptr) {} void Start() { base::AutoLock locked(lock_); @@ -91,7 +91,7 @@ class ProfilingThreadControl { return; thread_->Stop(); delete thread_; - thread_ = NULL; + thread_ = nullptr; } private: diff --git a/chromium/content/public/common/referrer.cc b/chromium/content/public/common/referrer.cc index b73b4573fd9..d7221ea4718 100644 --- a/chromium/content/public/common/referrer.cc +++ b/chromium/content/public/common/referrer.cc @@ -12,8 +12,10 @@ #include "content/public/common/content_switches.h" #include "mojo/public/cpp/bindings/enum_utils.h" #include "net/base/features.h" +#include "net/url_request/url_request_job.h" #include "services/network/public/cpp/features.h" #include "services/network/public/cpp/resource_request.h" +#include "services/network/public/mojom/referrer_policy.mojom-shared.h" #include "third_party/blink/public/mojom/referrer.mojom.h" namespace content { @@ -55,81 +57,18 @@ Referrer Referrer::SanitizeForRequest(const GURL& request, blink::mojom::ReferrerPtr Referrer::SanitizeForRequest( const GURL& request, const blink::mojom::Referrer& referrer) { - blink::mojom::ReferrerPtr sanitized_referrer = blink::mojom::Referrer::New( - referrer.url.GetAsReferrer(), referrer.policy); - if (sanitized_referrer->policy == network::mojom::ReferrerPolicy::kDefault) { - sanitized_referrer->policy = - Referrer::NetReferrerPolicyToBlinkReferrerPolicy( - Referrer::GetDefaultReferrerPolicy()); + network::mojom::ReferrerPolicy effective_policy = referrer.policy; + if (effective_policy == network::mojom::ReferrerPolicy::kDefault) { + effective_policy = + NetReferrerPolicyToBlinkReferrerPolicy(GetDefaultReferrerPolicy()); } + DCHECK_NE(effective_policy, network::mojom::ReferrerPolicy::kDefault); - if (sanitized_referrer->policy < network::mojom::ReferrerPolicy::kMinValue || - sanitized_referrer->policy > network::mojom::ReferrerPolicy::kMaxValue) { - NOTREACHED(); - sanitized_referrer->policy = network::mojom::ReferrerPolicy::kNever; - } - - bool is_web_scheme = request.SchemeIsHTTPOrHTTPS() || request.IsAboutBlank(); - if (!is_web_scheme || !sanitized_referrer->url.SchemeIsValidForReferrer()) { - sanitized_referrer->url = GURL(); - return sanitized_referrer; - } - - bool is_downgrade = sanitized_referrer->url.SchemeIsCryptographic() && - !request.SchemeIsCryptographic(); - - switch (sanitized_referrer->policy) { - case network::mojom::ReferrerPolicy::kDefault: - NOTREACHED(); - break; - case network::mojom::ReferrerPolicy::kNoReferrerWhenDowngrade: - if (is_downgrade) - sanitized_referrer->url = GURL(); - break; - case network::mojom::ReferrerPolicy::kAlways: - break; - case network::mojom::ReferrerPolicy::kNever: - sanitized_referrer->url = GURL(); - break; - case network::mojom::ReferrerPolicy::kOrigin: - sanitized_referrer->url = sanitized_referrer->url.GetOrigin(); - break; - case network::mojom::ReferrerPolicy::kOriginWhenCrossOrigin: - if (request.GetOrigin() != sanitized_referrer->url.GetOrigin()) - sanitized_referrer->url = sanitized_referrer->url.GetOrigin(); - break; - case network::mojom::ReferrerPolicy::kStrictOrigin: - if (is_downgrade) { - sanitized_referrer->url = GURL(); - } else { - sanitized_referrer->url = sanitized_referrer->url.GetOrigin(); - } - break; - case network::mojom::ReferrerPolicy::kSameOrigin: - if (request.GetOrigin() != sanitized_referrer->url.GetOrigin()) - sanitized_referrer->url = GURL(); - break; - case network::mojom::ReferrerPolicy::kStrictOriginWhenCrossOrigin: - if (is_downgrade) { - sanitized_referrer->url = GURL(); - } else if (request.GetOrigin() != sanitized_referrer->url.GetOrigin()) { - sanitized_referrer->url = sanitized_referrer->url.GetOrigin(); - } - break; - } - - // We limit the `referer` header to 4k: see step of - // https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer - // and https://github.com/whatwg/fetch/issues/903. - if (sanitized_referrer->url.spec().length() > 4096 || - (base::FeatureList::IsEnabled( - network::features::kCapReferrerToOriginOnCrossOrigin) && - !url::Origin::Create(sanitized_referrer->url) - .IsSameOriginWith(url::Origin::Create(request)))) { - sanitized_referrer->url = sanitized_referrer->url.GetOrigin(); - } - - return sanitized_referrer; + return blink::mojom::Referrer::New( + net::URLRequestJob::ComputeReferrerForPolicy( + ReferrerPolicyForUrlRequest(effective_policy), + referrer.url /* original_referrer */, request /* destination */), + effective_policy); } // static @@ -138,8 +77,8 @@ url::Origin Referrer::SanitizeOriginForRequest( const url::Origin& initiator, network::mojom::ReferrerPolicy policy) { Referrer fake_referrer(initiator.GetURL(), policy); - Referrer sanitizied_referrer = SanitizeForRequest(request, fake_referrer); - return url::Origin::Create(sanitizied_referrer.url); + Referrer sanitized_referrer = SanitizeForRequest(request, fake_referrer); + return url::Origin::Create(sanitized_referrer.url); } // static diff --git a/chromium/content/public/common/referrer.h b/chromium/content/public/common/referrer.h index e90313e5f9a..91dcc51508e 100644 --- a/chromium/content/public/common/referrer.h +++ b/chromium/content/public/common/referrer.h @@ -5,7 +5,6 @@ #ifndef CONTENT_PUBLIC_COMMON_REFERRER_H_ #define CONTENT_PUBLIC_COMMON_REFERRER_H_ -#include "base/logging.h" #include "content/common/content_export.h" #include "net/url_request/url_request.h" #include "services/network/public/mojom/referrer_policy.mojom-shared.h" diff --git a/chromium/content/public/common/sandboxed_process_launcher_delegate.cc b/chromium/content/public/common/sandboxed_process_launcher_delegate.cc index ee8e819d6da..f28909f5eb1 100644 --- a/chromium/content/public/common/sandboxed_process_launcher_delegate.cc +++ b/chromium/content/public/common/sandboxed_process_launcher_delegate.cc @@ -5,7 +5,7 @@ #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "build/build_config.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" +#include "content/public/common/zygote/zygote_buildflags.h" namespace content { @@ -33,10 +33,10 @@ bool SandboxedProcessLauncherDelegate::ShouldLaunchElevated() { #endif // defined(OS_WIN) #if BUILDFLAG(USE_ZYGOTE_HANDLE) -service_manager::ZygoteHandle SandboxedProcessLauncherDelegate::GetZygote() { +ZygoteHandle SandboxedProcessLauncherDelegate::GetZygote() { // Default to the sandboxed zygote. If a more lax sandbox is needed, then the // child class should override this method and use the unsandboxed zygote. - return service_manager::GetGenericZygote(); + return GetGenericZygote(); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) diff --git a/chromium/content/public/common/sandboxed_process_launcher_delegate.h b/chromium/content/public/common/sandboxed_process_launcher_delegate.h index 9d7fd9cf229..03336bc1708 100644 --- a/chromium/content/public/common/sandboxed_process_launcher_delegate.h +++ b/chromium/content/public/common/sandboxed_process_launcher_delegate.h @@ -10,12 +10,12 @@ #include "base/process/process.h" #include "build/build_config.h" #include "content/common/content_export.h" +#include "content/public/common/zygote/zygote_buildflags.h" #include "services/service_manager/sandbox/sandbox_delegate.h" #include "services/service_manager/sandbox/sandbox_type.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote/zygote_handle.h" // nogncheck #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) namespace content { @@ -43,7 +43,7 @@ class CONTENT_EXPORT SandboxedProcessLauncherDelegate #if BUILDFLAG(USE_ZYGOTE_HANDLE) // Returns the zygote used to launch the process. - virtual service_manager::ZygoteHandle GetZygote(); + virtual ZygoteHandle GetZygote(); #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) #if defined(OS_POSIX) diff --git a/chromium/content/public/common/untrustworthy_context_menu_params.h b/chromium/content/public/common/untrustworthy_context_menu_params.h index dc333a40a91..0940ef2a3f6 100644 --- a/chromium/content/public/common/untrustworthy_context_menu_params.h +++ b/chromium/content/public/common/untrustworthy_context_menu_params.h @@ -137,9 +137,6 @@ struct CONTENT_EXPORT UntrustworthyContextMenuParams { ui::MenuSourceType source_type; - // Extra properties for the context menu. - std::map<std::string, std::string> properties; - // If this node is an input field, the type of that field. blink::ContextMenuDataInputFieldType input_field_type; diff --git a/chromium/content/public/common/url_constants.cc b/chromium/content/public/common/url_constants.cc index d954b9e581b..db7ce218c43 100644 --- a/chromium/content/public/common/url_constants.cc +++ b/chromium/content/public/common/url_constants.cc @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "build/build_config.h" #include "content/public/common/url_constants.h" +#include "build/build_config.h" + namespace content { // Before adding new chrome schemes please check with security@chromium.org. @@ -36,6 +37,7 @@ const char kChromeUIProcessInternalsHost[] = "process-internals"; const char kChromeUIResourcesHost[] = "resources"; const char kChromeUIServiceWorkerInternalsHost[] = "serviceworker-internals"; const char kChromeUITracingHost[] = "tracing"; +const char kChromeUIUkmHost[] = "ukm"; const char kChromeUIWebRTCInternalsHost[] = "webrtc-internals"; const char kChromeUIBadCastCrashURL[] = "chrome://badcastcrash/"; @@ -60,6 +62,7 @@ const char kChromeUINetworkErrorsListingURL[] = "chrome://network-errors/"; const char kChromeUIPpapiFlashCrashURL[] = "chrome://ppapiflashcrash/"; const char kChromeUIPpapiFlashHangURL[] = "chrome://ppapiflashhang/"; const char kChromeUIProcessInternalsURL[] = "chrome://process-internals"; +const char kChromeUIUntrustedResourcesURL[] = "chrome-untrusted://resources/"; #if defined(OS_ANDROID) const char kChromeUIGpuJavaCrashURL[] = "chrome://gpu-java-crash/"; #endif diff --git a/chromium/content/public/common/url_constants.h b/chromium/content/public/common/url_constants.h index e09016439f5..e554270649d 100644 --- a/chromium/content/public/common/url_constants.h +++ b/chromium/content/public/common/url_constants.h @@ -5,7 +5,7 @@ #ifndef CONTENT_PUBLIC_COMMON_URL_CONSTANTS_H_ #define CONTENT_PUBLIC_COMMON_URL_CONSTANTS_H_ -#include "base/logging.h" +#include "base/check_op.h" #include "build/build_config.h" #include "content/common/content_export.h" #include "url/url_constants.h" @@ -48,6 +48,7 @@ CONTENT_EXPORT extern const char kChromeUIProcessInternalsHost[]; CONTENT_EXPORT extern const char kChromeUIResourcesHost[]; CONTENT_EXPORT extern const char kChromeUIServiceWorkerInternalsHost[]; CONTENT_EXPORT extern const char kChromeUITracingHost[]; +CONTENT_EXPORT extern const char kChromeUIUkmHost[]; CONTENT_EXPORT extern const char kChromeUIWebRTCInternalsHost[]; // Full about URLs (including schemes). @@ -71,6 +72,7 @@ CONTENT_EXPORT extern const char kChromeUINetworkErrorURL[]; CONTENT_EXPORT extern const char kChromeUIPpapiFlashCrashURL[]; CONTENT_EXPORT extern const char kChromeUIPpapiFlashHangURL[]; CONTENT_EXPORT extern const char kChromeUIProcessInternalsURL[]; +CONTENT_EXPORT extern const char kChromeUIUntrustedResourcesURL[]; #if defined(OS_ANDROID) CONTENT_EXPORT extern const char kChromeUIGpuJavaCrashURL[]; #endif diff --git a/chromium/content/public/common/url_utils.cc b/chromium/content/public/common/url_utils.cc index 16c6b998ad4..db318b6740f 100644 --- a/chromium/content/public/common/url_utils.cc +++ b/chromium/content/public/common/url_utils.cc @@ -23,8 +23,8 @@ namespace content { bool HasWebUIScheme(const GURL& url) { - return url.SchemeIs(kChromeDevToolsScheme) || - url.SchemeIs(kChromeUIScheme); + return url.SchemeIs(kChromeDevToolsScheme) || url.SchemeIs(kChromeUIScheme) || + url.SchemeIs(kChromeUIUntrustedScheme); } bool IsSavableURL(const GURL& url) { diff --git a/chromium/content/public/common/url_utils_unittest.cc b/chromium/content/public/common/url_utils_unittest.cc index f09740586a9..5efdae44661 100644 --- a/chromium/content/public/common/url_utils_unittest.cc +++ b/chromium/content/public/common/url_utils_unittest.cc @@ -17,6 +17,21 @@ GURL CreateValidURL(const std::string& str) { return url; } +TEST(UrlUtilsTest, HasWebUIScheme) { + EXPECT_TRUE(HasWebUIScheme(CreateValidURL("chrome://test"))); + EXPECT_TRUE(HasWebUIScheme(CreateValidURL("chrome-untrusted://test"))); + EXPECT_TRUE(HasWebUIScheme(CreateValidURL("devtools://test"))); + + // Other chromium schemes not considered WebUI schemes. + EXPECT_FALSE(HasWebUIScheme(CreateValidURL("chrome-error://test"))); + EXPECT_FALSE(HasWebUIScheme(CreateValidURL("chrome-guest://test"))); + EXPECT_FALSE(HasWebUIScheme(CreateValidURL("googlechrome://test"))); + + EXPECT_FALSE(HasWebUIScheme(CreateValidURL("http://foo/bar.html"))); + EXPECT_FALSE(HasWebUIScheme(CreateValidURL("https://foo/bar.html"))); + EXPECT_FALSE(HasWebUIScheme(CreateValidURL("data://foo"))); +} + TEST(UrlUtilsTest, IsURLHandledByNetworkStack) { EXPECT_TRUE( IsURLHandledByNetworkStack(CreateValidURL("http://foo/bar.html"))); @@ -24,6 +39,10 @@ TEST(UrlUtilsTest, IsURLHandledByNetworkStack) { IsURLHandledByNetworkStack(CreateValidURL("https://foo/bar.html"))); EXPECT_TRUE(IsURLHandledByNetworkStack(CreateValidURL("data://foo"))); EXPECT_TRUE(IsURLHandledByNetworkStack(CreateValidURL("cid:foo@bar"))); + EXPECT_TRUE(IsURLHandledByNetworkStack(CreateValidURL("chrome://test"))); + EXPECT_TRUE(IsURLHandledByNetworkStack(CreateValidURL("devtools://test"))); + EXPECT_TRUE( + IsURLHandledByNetworkStack(CreateValidURL("chrome-untrusted://test"))); EXPECT_FALSE(IsURLHandledByNetworkStack(CreateValidURL("about:blank"))); EXPECT_FALSE(IsURLHandledByNetworkStack(CreateValidURL("about:srcdoc"))); @@ -66,6 +85,12 @@ TEST(UrlUtilsTest, IsSafeRedirectTarget) { EXPECT_TRUE(IsSafeRedirectTarget(CreateValidURL("file:///foo/bar/"), CreateValidURL("http://foo/bar.html"))); + // WebUI schemes + EXPECT_FALSE(IsSafeRedirectTarget(GURL(), CreateValidURL("chrome://test"))); + EXPECT_FALSE(IsSafeRedirectTarget(GURL(), CreateValidURL("devtools://test"))); + EXPECT_FALSE( + IsSafeRedirectTarget(GURL(), CreateValidURL("chrome-untrusted://test"))); + // TODO(cmumford): Capturing current behavior, but should probably prevent // redirect to invalid URL. EXPECT_TRUE(IsSafeRedirectTarget(GURL(), GURL())); diff --git a/chromium/content/public/common/web_preferences.cc b/chromium/content/public/common/web_preferences.cc index eac2562c779..f85ad51fb34 100644 --- a/chromium/content/public/common/web_preferences.cc +++ b/chromium/content/public/common/web_preferences.cc @@ -102,7 +102,6 @@ WebPreferences::WebPreferences() accelerated_2d_canvas_enabled(false), antialiased_2d_canvas_disabled(false), antialiased_clips_2d_canvas_enabled(true), - accelerated_2d_canvas_msaa_sample_count(0), accelerated_filters_enabled(false), deferred_filters_enabled(false), container_culling_enabled(false), @@ -127,7 +126,6 @@ WebPreferences::WebPreferences() primary_hover_type(ui::HOVER_TYPE_NONE), dont_send_key_events_to_javascript(false), sync_xhr_in_documents_enabled(true), - should_respect_image_orientation(false), number_of_cpu_cores(1), #if defined(OS_MACOSX) editing_behavior(EDITING_BEHAVIOR_MAC), @@ -224,7 +222,6 @@ WebPreferences::WebPreferences() media_controls_enabled(true), do_not_update_selection_on_mutating_selection_range(false), autoplay_policy(AutoplayPolicy::kDocumentUserActivationRequired), - preferred_color_scheme(blink::PreferredColorScheme::kNoPreference), low_priority_iframes_threshold(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN), picture_in_picture_enabled(true), translate_service_available(false), diff --git a/chromium/content/public/common/web_preferences.h b/chromium/content/public/common/web_preferences.h index 4ba03d3a621..bf98747b7b3 100644 --- a/chromium/content/public/common/web_preferences.h +++ b/chromium/content/public/common/web_preferences.h @@ -126,7 +126,6 @@ struct CONTENT_EXPORT WebPreferences { bool new_canvas_2d_api_enabled; bool antialiased_2d_canvas_disabled; bool antialiased_clips_2d_canvas_enabled; - int accelerated_2d_canvas_msaa_sample_count; bool accelerated_filters_enabled; bool deferred_filters_enabled; bool container_culling_enabled; @@ -161,7 +160,6 @@ struct CONTENT_EXPORT WebPreferences { bool dont_send_key_events_to_javascript; bool barrel_button_for_drag_enabled = false; bool sync_xhr_in_documents_enabled; - bool should_respect_image_orientation; int number_of_cpu_cores; EditingBehavior editing_behavior; bool supports_multiple_windows; @@ -320,7 +318,7 @@ struct CONTENT_EXPORT WebPreferences { // evaluate the prefers-color-scheme media query and resolve UA color scheme // to be used based on the supported-color-schemes META tag and CSS property. blink::PreferredColorScheme preferred_color_scheme = - blink::PreferredColorScheme::kNoPreference; + blink::PreferredColorScheme::kLight; // Network quality threshold below which resources from iframes are assigned // either kVeryLow or kVeryLow Blink priority. diff --git a/chromium/content/public/common/zygote/BUILD.gn b/chromium/content/public/common/zygote/BUILD.gn new file mode 100644 index 00000000000..cb8c2f8197c --- /dev/null +++ b/chromium/content/public/common/zygote/BUILD.gn @@ -0,0 +1,11 @@ +# Copyright 2020 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. + +import("//build/buildflag_header.gni") +import("//content/public/common/zygote/features.gni") + +buildflag_header("buildflags") { + header = "zygote_buildflags.h" + flags = [ "USE_ZYGOTE_HANDLE=$use_zygote_handle" ] +} diff --git a/chromium/content/public/common/zygote/OWNERS b/chromium/content/public/common/zygote/OWNERS new file mode 100644 index 00000000000..eb4b322bdf5 --- /dev/null +++ b/chromium/content/public/common/zygote/OWNERS @@ -0,0 +1,4 @@ +file://content/zygote/OWNERS + +# TEAM: security-dev@chromium.org +# COMPONENT: Internals>Sandbox diff --git a/chromium/content/public/common/zygote/features.gni b/chromium/content/public/common/zygote/features.gni new file mode 100644 index 00000000000..c7580b35ff3 --- /dev/null +++ b/chromium/content/public/common/zygote/features.gni @@ -0,0 +1,5 @@ +# Copyright 2018 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. + +use_zygote_handle = is_posix && !is_android && !is_mac diff --git a/chromium/content/public/common/zygote/sandbox_support_linux.h b/chromium/content/public/common/zygote/sandbox_support_linux.h new file mode 100644 index 00000000000..279f983f3f8 --- /dev/null +++ b/chromium/content/public/common/zygote/sandbox_support_linux.h @@ -0,0 +1,42 @@ +// Copyright 2017 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_PUBLIC_COMMON_ZYGOTE_SANDBOX_SUPPORT_LINUX_H_ +#define CONTENT_PUBLIC_COMMON_ZYGOTE_SANDBOX_SUPPORT_LINUX_H_ + +#include <stddef.h> + +#include "build/build_config.h" +#include "content/common/content_export.h" + +class NaClListener; + +namespace content { + +#if !defined(OS_NACL_NONSFI) +// TODO(crbug.com/982879): Remove this when NaCl is unshipped. +class CONTENT_EXPORT SharedMemoryIPCSupport { + private: + friend class ::NaClListener; + + // Returns a file descriptor for a shared memory segment. The + // executable flag indicates that the caller intends to use mprotect + // with PROT_EXEC after making a mapping, but not that it intends to + // mmap with PROT_EXEC in the first place. (Some systems, such as + // ChromeOS, disallow PROT_EXEC in mmap on /dev/shm files but do allow + // PROT_EXEC in mprotect on mappings from such files. This function + // can yield an object that has that constraint.) + static int MakeSharedMemorySegment(size_t length, bool executable); + + SharedMemoryIPCSupport() = delete; +}; +#endif + +// Gets the well-known file descriptor on which we expect to find the +// sandbox IPC channel. +CONTENT_EXPORT int GetSandboxFD(); + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_ZYGOTE_SANDBOX_SUPPORT_LINUX_H_ diff --git a/chromium/content/public/common/zygote/send_zygote_child_ping_linux.h b/chromium/content/public/common/zygote/send_zygote_child_ping_linux.h new file mode 100644 index 00000000000..cc08f264e07 --- /dev/null +++ b/chromium/content/public/common/zygote/send_zygote_child_ping_linux.h @@ -0,0 +1,18 @@ +// Copyright 2014 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_PUBLIC_COMMON_ZYGOTE_SEND_ZYGOTE_CHILD_PING_LINUX_H_ +#define CONTENT_PUBLIC_COMMON_ZYGOTE_SEND_ZYGOTE_CHILD_PING_LINUX_H_ + +#include "content/common/content_export.h" + +namespace content { + +// Sends a zygote child "ping" message to browser process via socket |fd|. +// Returns true on success. +CONTENT_EXPORT bool SendZygoteChildPing(int fd); + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_ZYGOTE_SEND_ZYGOTE_CHILD_PING_LINUX_H_ diff --git a/chromium/content/public/common/zygote/zygote_fork_delegate_linux.h b/chromium/content/public/common/zygote/zygote_fork_delegate_linux.h new file mode 100644 index 00000000000..12f784b0f85 --- /dev/null +++ b/chromium/content/public/common/zygote/zygote_fork_delegate_linux.h @@ -0,0 +1,90 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_ZYGOTE_FORK_DELEGATE_LINUX_H_ +#define CONTENT_PUBLIC_COMMON_ZYGOTE_ZYGOTE_FORK_DELEGATE_LINUX_H_ + +#include <unistd.h> + +#include <string> +#include <vector> + +// TODO(jln) base::TerminationStatus should be forward declared when switching +// to C++11. +#include "base/process/kill.h" + +namespace content { + +// The ZygoteForkDelegate allows the Chrome Linux zygote to delegate +// fork operations to another class that knows how to do some +// specialized version of fork. +class ZygoteForkDelegate { + public: + // A ZygoteForkDelegate is created during Chrome linux zygote + // initialization, and provides "fork()" functionality as an + // alternative to forking the zygote. A new delegate is passed in + // as an argument to ZygoteMain(). + virtual ~ZygoteForkDelegate() {} + + // Initialization happens in the zygote after it has been + // started by ZygoteMain. + // If |enable_layer1_sandbox| is true, the delegate must enable a + // layer-1 sandbox such as the setuid sandbox. + virtual void Init(int sandboxdesc, bool enable_layer1_sandbox) = 0; + + // After Init, supply a UMA_HISTOGRAM_ENUMERATION the delegate would like + // reported to the browser process. (Note: Because these reports are + // piggy-backed onto fork responses that don't otherwise contain UMA reports, + // this method may not be called until much later.) + virtual void InitialUMA(std::string* uma_name, + int* uma_sample, + int* uma_boundary_value) = 0; + + // Returns 'true' if the delegate would like to handle a given fork + // request. Otherwise returns false. Optionally, fills in uma_name et al + // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. + virtual bool CanHelp(const std::string& process_type, + std::string* uma_name, + int* uma_sample, + int* uma_boundary_value) = 0; + + // Indexes of FDs in the vector passed to Fork(). + enum { + // Used to pass in the descriptor for talking to the Browser. + // Because the children use ChannelMojo, this is actually the Mojo fd. + kBrowserFDIndex, + // The PID oracle is used in the protocol for discovering the + // child process's real PID from within the SUID sandbox. + // The child process is required to write to the socket after + // successfully forking. + kPIDOracleFDIndex, + kNumPassedFDs // Number of FDs in the vector passed to Fork(). + }; + + // Delegate forks, returning a -1 on failure. Outside the + // suid sandbox, Fork() returns the Linux process ID. + // This method is not aware of any potential pid namespaces, so it'll + // return a raw pid just like fork() would. + // Delegate is responsible for communicating the channel ID to the + // newly created child process. + virtual pid_t Fork(const std::string& process_type, + const std::vector<int>& fds, + const std::string& channel_id) = 0; + + // The fork delegate must also assume the role of waiting for its children + // since the caller will not be their parents and cannot do it. |pid| here + // should be a pid that has been returned by the Fork() method. i.e. This + // method is completely unaware of eventual PID namespaces due to sandboxing. + // |known_dead| indicates that the process is already dead and that a + // blocking wait() should be performed. In this case, GetTerminationStatus() + // will send a SIGKILL to the target process first. + virtual bool GetTerminationStatus(pid_t pid, + bool known_dead, + base::TerminationStatus* status, + int* exit_code) = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_ZYGOTE_ZYGOTE_FORK_DELEGATE_LINUX_H_ diff --git a/chromium/content/public/common/zygote/zygote_handle.h b/chromium/content/public/common/zygote/zygote_handle.h new file mode 100644 index 00000000000..95a6e6113ec --- /dev/null +++ b/chromium/content/public/common/zygote/zygote_handle.h @@ -0,0 +1,34 @@ +// Copyright 2016 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_PUBLIC_COMMON_ZYGOTE_ZYGOTE_HANDLE_H_ +#define CONTENT_PUBLIC_COMMON_ZYGOTE_ZYGOTE_HANDLE_H_ + +#include "base/callback.h" +#include "base/command_line.h" +#include "base/files/scoped_file.h" +#include "build/build_config.h" +#include "content/common/content_export.h" +#include "content/public/common/zygote/zygote_buildflags.h" + +#if !BUILDFLAG(USE_ZYGOTE_HANDLE) +#error "Can not use zygote handles without USE_ZYGOTE_HANDLE" +#endif + +namespace content { + +#if defined(OS_POSIX) +class ZygoteCommunication; +using ZygoteHandle = ZygoteCommunication*; +#else +// Perhaps other ports may USE_ZYGOTE_HANDLE here somdeday. +#error "Can not use zygote handles on this platform" +#endif // defined(OS_POSIX) + +// Gets the generic global zygote used to launch sandboxed children. +CONTENT_EXPORT ZygoteHandle GetGenericZygote(); + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_ZYGOTE_ZYGOTE_HANDLE_H_ diff --git a/chromium/content/public/renderer/content_renderer_client.cc b/chromium/content/public/renderer/content_renderer_client.cc index ea6d8e63572..064d0a433db 100644 --- a/chromium/content/public/renderer/content_renderer_client.cc +++ b/chromium/content/public/renderer/content_renderer_client.cc @@ -189,7 +189,8 @@ ContentRendererClient::CreateWorkerContentSettingsClient( #if !defined(OS_ANDROID) std::unique_ptr<media::SpeechRecognitionClient> ContentRendererClient::CreateSpeechRecognitionClient( - RenderFrame* render_frame) { + RenderFrame* render_frame, + media::SpeechRecognitionClient::OnReadyCallback callback) { return nullptr; } #endif diff --git a/chromium/content/public/renderer/content_renderer_client.h b/chromium/content/public/renderer/content_renderer_client.h index 7da02ee5414..f6d2f50e8d6 100644 --- a/chromium/content/public/renderer/content_renderer_client.h +++ b/chromium/content/public/renderer/content_renderer_client.h @@ -150,9 +150,10 @@ class CONTENT_EXPORT ContentRendererClient { virtual bool ShouldTrackUseCounter(const GURL& url); // Returns the information to display when a navigation error occurs. - // If |error_html| is not null then it may be set to a HTML page - // containing the details of the error and maybe links to more info. - // Note that |error_html| may be not written to in certain cases + // |error_html| should be set to null if this is a custom error page that will + // set its own html content, otherwise if |error_html| is not null then it may + // be set to a HTML page containing the details of the error and maybe links + // to more info. Note that |error_html| may be not written to in certain cases // (lack of information on the error code) so the caller should take care to // initialize it with a safe default before the call. virtual void PrepareErrorPage(content::RenderFrame* render_frame, @@ -304,7 +305,9 @@ class CONTENT_EXPORT ContentRendererClient { #if !defined(OS_ANDROID) // Creates a speech recognition client used to transcribe audio into captions. virtual std::unique_ptr<media::SpeechRecognitionClient> - CreateSpeechRecognitionClient(RenderFrame* render_frame); + CreateSpeechRecognitionClient( + RenderFrame* render_frame, + media::SpeechRecognitionClient::OnReadyCallback callback); #endif // Returns true if the page at |url| can use Pepper CameraDevice APIs. diff --git a/chromium/content/public/renderer/document_state.h b/chromium/content/public/renderer/document_state.h index c78fba87644..7a0bd60e30d 100644 --- a/chromium/content/public/renderer/document_state.h +++ b/chromium/content/public/renderer/document_state.h @@ -8,7 +8,6 @@ #include <memory> #include <string> -#include "base/logging.h" #include "base/supports_user_data.h" #include "base/time/time.h" #include "content/common/content_export.h" diff --git a/chromium/content/public/renderer/render_accessibility.h b/chromium/content/public/renderer/render_accessibility.h index eea7c3ae5c2..254f3b3283f 100644 --- a/chromium/content/public/renderer/render_accessibility.h +++ b/chromium/content/public/renderer/render_accessibility.h @@ -22,6 +22,7 @@ class CONTENT_EXPORT RenderAccessibility { // PluginAXTreeSource, into the page's accessibility tree. virtual void SetPluginTreeSource(PluginAXTreeSource* source) = 0; virtual void OnPluginRootNodeUpdated() = 0; + virtual void ShowPluginContextMenu() = 0; protected: ~RenderAccessibility() {} diff --git a/chromium/content/public/renderer/render_frame.h b/chromium/content/public/renderer/render_frame.h index 77b499ea74f..568a0a8c9bc 100644 --- a/chromium/content/public/renderer/render_frame.h +++ b/chromium/content/public/renderer/render_frame.h @@ -304,12 +304,6 @@ class CONTENT_EXPORT RenderFrame : public IPC::Listener, virtual void SetRenderFrameMediaPlaybackOptions( const RenderFrameMediaPlaybackOptions& opts) = 0; - // Synchronously performs the complete set of document lifecycle phases, - // including updates to the compositor state and rasterization, then sending - // a frame to the viz display compositor. Does nothing if RenderFrame is not - // a local root. - virtual void UpdateAllLifecyclePhasesAndCompositeForTesting() = 0; - // Sets that cross browsing instance frame lookup is allowed. virtual void SetAllowsCrossBrowsingInstanceFrameLookup() = 0; diff --git a/chromium/content/public/renderer/render_frame_observer.h b/chromium/content/public/renderer/render_frame_observer.h index 831a3574055..4e195f960d7 100644 --- a/chromium/content/public/renderer/render_frame_observer.h +++ b/chromium/content/public/renderer/render_frame_observer.h @@ -106,8 +106,9 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, virtual void DidCreateNewDocument() {} virtual void DidCreateDocumentElement() {} // TODO(dgozman): replace next two methods with DidFinishNavigation. - virtual void DidCommitProvisionalLoad(bool is_same_document_navigation, - ui::PageTransition transition) {} + // DidCommitProvisionalLoad is only called for new-document navigations. + // Use DidFinishSameDocumentNavigation for same-document navigations. + virtual void DidCommitProvisionalLoad(ui::PageTransition transition) {} virtual void DidFailProvisionalLoad() {} virtual void DidFinishLoad() {} virtual void DidFinishDocumentLoad() {} @@ -124,6 +125,19 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, const blink::WebVector<blink::WebString>& newly_matching_selectors, const blink::WebVector<blink::WebString>& stopped_matching_selectors) {} + // Called when same-document navigation finishes. + // This is the only callback for same-document navigations, + // DidStartNavigation and ReadyToCommitNavigation are not called. + // + // Same-document navigation is typically initiated by an anchor click + // (that usually results in the page scrolling to the anchor) or a + // history web API manipulation. + // + // However, it could be some rare case like user changing #hash in the url + // bar or history restore for subframe or anything else that was classified + // as same-document. + virtual void DidFinishSameDocumentNavigation() {} + // Called when this frame has been detached from the view. This *will* be // called for child frames when a parent frame is detached. Since the frame is // already detached from the DOM at this time, it should not be inspected. @@ -154,6 +168,9 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, // Notifications When an input delay data becomes available. virtual void DidObserveInputDelay(base::TimeDelta input_delay) {} + // Notification When the First Scroll Delay becomes available. + virtual void DidObserveFirstScrollDelay(base::TimeDelta first_scroll_delay) {} + // Notifications when a cpu timing update becomes available, when a frame // has performed at least 100ms of tasks. virtual void DidChangeCpuTiming(base::TimeDelta time) {} @@ -257,6 +274,12 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle* handle); + // Submit throughput data to the browser process. Only called for local roots. + virtual void OnThroughputDataAvailable(ukm::SourceId source_id, + int aggregated_percent, + int impl_percent, + base::Optional<int> main_percent) {} + // IPC::Listener implementation. bool OnMessageReceived(const IPC::Message& message) override; diff --git a/chromium/content/public/test/android/BUILD.gn b/chromium/content/public/test/android/BUILD.gn index bbe969b2e3f..0be1666b536 100644 --- a/chromium/content/public/test/android/BUILD.gn +++ b/chromium/content/public/test/android/BUILD.gn @@ -29,7 +29,7 @@ android_library("content_java_test_support") { "javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettings.java", "javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettingsHook.java", "javatests/src/org/chromium/content_public/browser/test/ContentJUnit4ClassRunner.java", - "javatests/src/org/chromium/content_public/browser/test/NativeLibraryTestRule.java", + "javatests/src/org/chromium/content_public/browser/test/NativeLibraryTestUtils.java", "javatests/src/org/chromium/content_public/browser/test/RenderFrameHostTestExt.java", "javatests/src/org/chromium/content_public/browser/test/mock/MockNavigationController.java", "javatests/src/org/chromium/content_public/browser/test/mock/MockRenderFrameHost.java", @@ -39,13 +39,13 @@ android_library("content_java_test_support") { "javatests/src/org/chromium/content_public/browser/test/util/Coordinates.java", "javatests/src/org/chromium/content_public/browser/test/util/Criteria.java", "javatests/src/org/chromium/content_public/browser/test/util/CriteriaHelper.java", + "javatests/src/org/chromium/content_public/browser/test/util/CriteriaNotSatisfiedException.java", "javatests/src/org/chromium/content_public/browser/test/util/DOMUtils.java", "javatests/src/org/chromium/content_public/browser/test/util/DomAutomationController.java", "javatests/src/org/chromium/content_public/browser/test/util/HistoryUtils.java", "javatests/src/org/chromium/content_public/browser/test/util/JavaScriptUtils.java", "javatests/src/org/chromium/content_public/browser/test/util/KeyUtils.java", "javatests/src/org/chromium/content_public/browser/test/util/MatcherCriteria.java", - "javatests/src/org/chromium/content_public/browser/test/util/RenderProcessLimit.java", "javatests/src/org/chromium/content_public/browser/test/util/TestCallbackHelperContainer.java", "javatests/src/org/chromium/content_public/browser/test/util/TestInputMethodManagerWrapper.java", "javatests/src/org/chromium/content_public/browser/test/util/TestSelectionPopupController.java", diff --git a/chromium/content/public/utility/content_utility_client.h b/chromium/content/public/utility/content_utility_client.h index 51667228d48..672a774c983 100644 --- a/chromium/content/public/utility/content_utility_client.h +++ b/chromium/content/public/utility/content_utility_client.h @@ -44,6 +44,10 @@ class CONTENT_EXPORT ContentUtilityClient { // corresponding UtilityProcessHost. virtual void ExposeInterfacesToBrowser(mojo::BinderMap* binders) {} + // Called on the main thread immediately after the IO thread is created. + virtual void PostIOThreadCreated( + base::SingleThreadTaskRunner* io_thread_task_runner) {} + // Allows the embedder to handle an incoming service request. If this is // called, this utility process was started for the sole purpose of running // the service identified by |service_name|. |