diff options
Diffstat (limited to 'chromium/content/public/browser')
71 files changed, 840 insertions, 386 deletions
diff --git a/chromium/content/public/browser/BUILD.gn b/chromium/content/public/browser/BUILD.gn index e07e88cca28..dc2f2f24869 100644 --- a/chromium/content/public/browser/BUILD.gn +++ b/chromium/content/public/browser/BUILD.gn @@ -4,6 +4,7 @@ import("//build/config/jumbo.gni") import("//build/config/ui.gni") +import("//ppapi/buildflags/buildflags.gni") import("//third_party/webrtc/webrtc.gni") # See //content/BUILD.gn for how this works. @@ -107,6 +108,8 @@ jumbo_source_set("browser_sources") { "content_browser_client.cc", "content_browser_client.h", "cookie_store_factory.h", + "cors_exempt_headers.cc", + "cors_exempt_headers.h", "cors_origin_pattern_setter.cc", "cors_origin_pattern_setter.h", "delegate_to_browser_gpu_service_accelerator_factory.h", @@ -175,6 +178,8 @@ jumbo_source_set("browser_sources") { "media_device_id.h", "media_keys_listener_manager.cc", "media_keys_listener_manager.h", + "media_player_id.cc", + "media_player_id.h", "media_request_state.h", "media_session.h", "media_stream_request.cc", @@ -225,9 +230,6 @@ jumbo_source_set("browser_sources") { "picture_in_picture_window_controller.h", "platform_notification_context.h", "platform_notification_service.h", - "plugin_data_remover.h", - "plugin_service.h", - "plugin_service_filter.h", "presentation_request.cc", "presentation_request.h", "presentation_screen_availability_listener.h", @@ -272,6 +274,7 @@ jumbo_source_set("browser_sources") { "serial_delegate.h", "service_worker_context.h", "service_worker_context_observer.h", + "service_worker_running_info.h", "session_storage_namespace.h", "session_storage_usage_info.h", "shared_cors_origin_access_list.h", @@ -351,6 +354,14 @@ jumbo_source_set("browser_sources") { "//content:content_implementation", ] + if (enable_plugins) { + sources += [ + "plugin_data_remover.h", + "plugin_service.h", + "plugin_service_filter.h", + ] + } + if (rtc_use_pipewire) { configs += [ "//third_party/webrtc/modules/desktop_capture:pipewire_config" ] diff --git a/chromium/content/public/browser/DEPS b/chromium/content/public/browser/DEPS index 49fd1ed83c4..805504c5638 100644 --- a/chromium/content/public/browser/DEPS +++ b/chromium/content/public/browser/DEPS @@ -18,6 +18,7 @@ include_rules = [ specific_include_rules = { ".*\.cc": [ "+content/browser", + "+content/common/content_constants_internal.h", "-content/browser/loader", # TODO: content/browser/loader is being separated out of content, and this diff --git a/chromium/content/public/browser/android/child_process_importance.h b/chromium/content/public/browser/android/child_process_importance.h index 45b3afa3abc..4e2baeaf303 100644 --- a/chromium/content/public/browser/android/child_process_importance.h +++ b/chromium/content/public/browser/android/child_process_importance.h @@ -17,8 +17,6 @@ enum class ChildProcessImportance { NORMAL = 0, MODERATE, IMPORTANT, - // Place holder to represent number of values. - COUNT, }; } // namespace content diff --git a/chromium/content/public/browser/android/synchronous_compositor.h b/chromium/content/public/browser/android/synchronous_compositor.h index 7d679567508..4049d9347bd 100644 --- a/chromium/content/public/browser/android/synchronous_compositor.h +++ b/chromium/content/public/browser/android/synchronous_compositor.h @@ -12,6 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/synchronization/waitable_event.h" #include "base/time/time.h" +#include "components/viz/common/presentation_feedback_map.h" #include "components/viz/common/resources/returned_resource.h" #include "content/common/content_export.h" #include "ui/gfx/geometry/rect.h" @@ -90,6 +91,9 @@ class CONTENT_EXPORT SynchronousCompositor { uint32_t layer_tree_frame_sink_id, const std::vector<viz::ReturnedResource>& resources) = 0; + virtual void DidPresentCompositorFrames( + viz::PresentationFeedbackMap feedbacks) = 0; + // "On demand" SW draw, into the supplied canvas (observing the transform // and clip set there-in). virtual bool DemandDrawSw(SkCanvas* canvas) = 0; diff --git a/chromium/content/public/browser/android/synchronous_compositor_client.h b/chromium/content/public/browser/android/synchronous_compositor_client.h index 9763f6206db..3fe5bee356e 100644 --- a/chromium/content/public/browser/android/synchronous_compositor_client.h +++ b/chromium/content/public/browser/android/synchronous_compositor_client.h @@ -5,6 +5,8 @@ #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_CLIENT_H_ #define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_CLIENT_H_ +#include <memory> + #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -16,6 +18,10 @@ namespace ui { class TouchHandleDrawable; } +namespace viz { +class CopyOutputRequest; +} + namespace content { class SynchronousCompositor; @@ -56,6 +62,10 @@ class SynchronousCompositorClient { virtual ui::TouchHandleDrawable* CreateDrawable() = 0; + virtual void CopyOutput( + SynchronousCompositor* compositor, + std::unique_ptr<viz::CopyOutputRequest> copy_request) = 0; + protected: SynchronousCompositorClient() {} virtual ~SynchronousCompositorClient() {} diff --git a/chromium/content/public/browser/appcache_service.h b/chromium/content/public/browser/appcache_service.h index 1ed0d80d147..7aa7020476d 100644 --- a/chromium/content/public/browser/appcache_service.h +++ b/chromium/content/public/browser/appcache_service.h @@ -55,6 +55,12 @@ class CONTENT_EXPORT AppCacheService { virtual void DeleteAppCacheGroup(const GURL& manifest_url, net::CompletionOnceCallback callback) = 0; + // Deletes all appcache groups associated with an origin. + // Always completes asynchronously. + virtual void DeleteAppCachesForOrigin( + const url::Origin& origin, + net::CompletionOnceCallback callback) = 0; + protected: virtual ~AppCacheService() {} }; diff --git a/chromium/content/public/browser/authenticator_request_client_delegate.cc b/chromium/content/public/browser/authenticator_request_client_delegate.cc index 07d3039ca4d..c789d42858f 100644 --- a/chromium/content/public/browser/authenticator_request_client_delegate.cc +++ b/chromium/content/public/browser/authenticator_request_client_delegate.cc @@ -38,10 +38,29 @@ void AuthenticatorRequestClientDelegate::ShouldReturnAttestation( std::move(callback).Run(true); } +bool AuthenticatorRequestClientDelegate::SupportsResidentKeys() { + return false; +} + +void AuthenticatorRequestClientDelegate::SetMightCreateResidentCredential( + bool v) {} + +void AuthenticatorRequestClientDelegate::SelectAccount( + std::vector<device::AuthenticatorGetAssertionResponse> responses, + base::OnceCallback<void(device::AuthenticatorGetAssertionResponse)> + callback) { + // SupportsResidentKeys returned false so this should never be called. + NOTREACHED(); +} + bool AuthenticatorRequestClientDelegate::IsFocused() { return true; } +bool AuthenticatorRequestClientDelegate::ShouldDisablePlatformAuthenticators() { + return false; +} + #if defined(OS_MACOSX) base::Optional<AuthenticatorRequestClientDelegate::TouchIdAuthenticatorConfig> AuthenticatorRequestClientDelegate::GetTouchIdAuthenticatorConfig() const { @@ -83,10 +102,18 @@ void AuthenticatorRequestClientDelegate::FidoAuthenticatorPairingModeChanged( base::StringPiece authenticator_id, bool is_in_pairing_mode) {} +bool AuthenticatorRequestClientDelegate::SupportsPIN() const { + return false; +} + void AuthenticatorRequestClientDelegate::CollectPIN( base::Optional<int> attempts, - base::OnceCallback<void(std::string)> provide_pin_cb) {} + base::OnceCallback<void(std::string)> provide_pin_cb) { + NOTREACHED(); +} -void AuthenticatorRequestClientDelegate::FinishCollectPIN() {} +void AuthenticatorRequestClientDelegate::FinishCollectPIN() { + NOTREACHED(); +} } // namespace content diff --git a/chromium/content/public/browser/authenticator_request_client_delegate.h b/chromium/content/public/browser/authenticator_request_client_delegate.h index 3c6a60095a3..6d34ff72bde 100644 --- a/chromium/content/public/browser/authenticator_request_client_delegate.h +++ b/chromium/content/public/browser/authenticator_request_client_delegate.h @@ -12,6 +12,7 @@ #include "base/optional.h" #include "build/build_config.h" #include "content/common/content_export.h" +#include "device/fido/authenticator_get_assertion_response.h" #include "device/fido/fido_request_handler_base.h" #include "device/fido/fido_transport_protocol.h" @@ -41,6 +42,9 @@ class CONTENT_EXPORT AuthenticatorRequestClientDelegate kKeyAlreadyRegistered, kSoftPINBlock, kHardPINBlock, + kAuthenticatorRemovedDuringPINEntry, + kAuthenticatorMissingResidentKeys, + kAuthenticatorMissingUserVerification, }; AuthenticatorRequestClientDelegate(); @@ -82,6 +86,31 @@ class CONTENT_EXPORT AuthenticatorRequestClientDelegate virtual void ShouldReturnAttestation(const std::string& relying_party_id, base::OnceCallback<void(bool)> callback); + // SupportsResidentKeys returns true if this implementation of + // |AuthenticatorRequestClientDelegate| supports resident keys. If false then + // requests to create or get assertions will be immediately rejected and + // |SelectAccount| will never be called. + virtual bool SupportsResidentKeys(); + + // SetMightCreateResidentCredential indicates whether activating an + // authenticator may cause a resident credential to be created. A resident + // credential may be discovered by someone with physical access to the + // authenticator and thus has privacy implications. + void SetMightCreateResidentCredential(bool v) override; + + // SelectAccount is called to allow the embedder to select between one or more + // accounts. This is triggered when the web page requests an unspecified + // credential (by passing an empty allow-list). In this case, any accounts + // will come from the authenticator's storage and the user should confirm the + // use of any specific account before it is returned. The callback takes the + // selected account, or else |cancel_callback| can be called. + // + // This is only called if |SupportsResidentKeys| returns true. + virtual void SelectAccount( + std::vector<device::AuthenticatorGetAssertionResponse> responses, + base::OnceCallback<void(device::AuthenticatorGetAssertionResponse)> + callback); + // Returns whether the WebContents corresponding to |render_frame_host| is the // active tab in the focused window. We do not want to allow // authenticatorMakeCredential operations to be triggered by background tabs. @@ -91,6 +120,10 @@ class CONTENT_EXPORT AuthenticatorRequestClientDelegate // that testing is possible. virtual bool IsFocused(); + // Returns whether IsUVPAA() should always return false, regardless of + // hardware support or enrollment status. + virtual bool ShouldDisablePlatformAuthenticators(); + #if defined(OS_MACOSX) using TouchIdAuthenticatorConfig = device::fido::mac::AuthenticatorConfig; @@ -133,6 +166,7 @@ class CONTENT_EXPORT AuthenticatorRequestClientDelegate std::string new_authenticator_id) override; void FidoAuthenticatorPairingModeChanged(base::StringPiece authenticator_id, bool is_in_pairing_mode) override; + bool SupportsPIN() const override; void CollectPIN( base::Optional<int> attempts, base::OnceCallback<void(std::string)> provide_pin_cb) override; diff --git a/chromium/content/public/browser/background_sync_context.h b/chromium/content/public/browser/background_sync_context.h index f4ec66a35ca..67a7fa23f37 100644 --- a/chromium/content/public/browser/background_sync_context.h +++ b/chromium/content/public/browser/background_sync_context.h @@ -7,9 +7,17 @@ #include "base/callback_forward.h" #include "base/macros.h" +#include "base/time/time.h" +#include "build/build_config.h" + +#if defined(OS_ANDROID) +#include "base/android/jni_android.h" +#include "base/android/scoped_java_ref.h" +#endif namespace content { +class BrowserContext; class StoragePartition; // One instance of this exists per StoragePartition, and services multiple child @@ -18,15 +26,33 @@ class StoragePartition; // other components. class CONTENT_EXPORT BackgroundSyncContext { public: + // Gets the soonest time delta from now, when the browser should be woken up + // to fire any Background Sync events, across all storage partitions in + // |browser_context|, and invokes |callback| with it. + static void GetSoonestWakeupDeltaAcrossPartitions( + BrowserContext* browser_context, + base::OnceCallback<void(base::TimeDelta)> callback); + +#if defined(OS_ANDROID) + // Processes pending Background Sync registrations for all storage partitions + // in |browser_context|, and then runs the |j_runnable| when done. + static void FireBackgroundSyncEventsAcrossPartitions( + BrowserContext* browser_context, + const base::android::JavaParamRef<jobject>& j_runnable); +#endif + BackgroundSyncContext() = default; - // Process any pending Background Sync registrations for |storage_partition|. + // Process any pending Background Sync registrations. // This involves firing any sync events ready to be fired, and optionally // scheduling a job to wake up the browser when the next event needs to be // fired. - virtual void FireBackgroundSyncEventsForStoragePartition( - StoragePartition* storage_partition, - base::OnceClosure done_closure) = 0; + virtual void FireBackgroundSyncEvents(base::OnceClosure done_closure) = 0; + + // Gets the soonest time delta from now, when the browser should be woken up + // to fire any Background Sync events. Calls |callback| with this value. + virtual void GetSoonestWakeupDelta( + base::OnceCallback<void(base::TimeDelta)> callback) = 0; protected: virtual ~BackgroundSyncContext() = default; diff --git a/chromium/content/public/browser/background_sync_controller.h b/chromium/content/public/browser/background_sync_controller.h index 33ad82d987a..ade65bf0f33 100644 --- a/chromium/content/public/browser/background_sync_controller.h +++ b/chromium/content/public/browser/background_sync_controller.h @@ -7,11 +7,14 @@ #include <stdint.h> +#include "base/time/time.h" #include "content/common/content_export.h" +#include "third_party/blink/public/common/service_worker/service_worker_status_code.h" +#include "third_party/blink/public/mojom/background_sync/background_sync.mojom-shared.h" namespace url { class Origin; -} +} // namespace url namespace content { @@ -21,6 +24,14 @@ struct BackgroundSyncParameters; // embedder. Must only be used on the UI thread. class CONTENT_EXPORT BackgroundSyncController { public: + class BackgroundSyncEventKeepAlive { + public: + virtual ~BackgroundSyncEventKeepAlive() = default; + + protected: + BackgroundSyncEventKeepAlive() = default; + }; + virtual ~BackgroundSyncController() {} // This function allows the controller to alter the parameters used by @@ -30,19 +41,39 @@ class CONTENT_EXPORT BackgroundSyncController { BackgroundSyncParameters* parameters) const {} // Notification that a service worker registration with origin |origin| just - // registered a background sync event. - virtual void NotifyBackgroundSyncRegistered(const url::Origin& origin) {} - - // If |enabled|, ensures that the browser is running when the device next goes - // online after |min_ms| has passed. The behavior is platform dependent: - // * Android: Registers a GCM task which verifies that the browser is running - // the next time the device goes online after |min_ms| has passed. If it's - // not, it starts it. - // - // * Other Platforms: (UNIMPLEMENTED) Keeps the browser alive via - // BackgroundModeManager until called with |enabled| = false. |min_ms| is - // ignored. - virtual void RunInBackground(bool enabled, int64_t min_ms) {} + // registered a background sync event. Also includes information about the + // registration. + virtual void NotifyBackgroundSyncRegistered(const url::Origin& origin, + bool can_fire, + bool is_reregistered) {} + + // Notification that a service worker registration with origin |origin| just + // completed a background sync registration. Also include the |status_code| + // the registration finished with, the number of attempts, and the max + // allowed number of attempts. + virtual void NotifyBackgroundSyncCompleted( + const url::Origin& origin, + blink::ServiceWorkerStatusCode status_code, + int num_attempts, + int max_attempts) {} + + // Calculates the soonest wakeup delta across all storage partitions and + // schedules a background task to wake up the browser. + virtual void RunInBackground() {} + + // Calculates the delay after which the next sync event should be fired + // for a BackgroundSync registration. The delay is based on the |sync_type|. + virtual base::TimeDelta GetNextEventDelay( + const url::Origin& origin, + int64_t min_interval, + int num_attempts, + blink::mojom::BackgroundSyncType sync_type, + BackgroundSyncParameters* parameters) const = 0; + + // Keeps the browser alive to allow a one-shot Background Sync registration + // to finish firing one sync event. + virtual std::unique_ptr<BackgroundSyncEventKeepAlive> + CreateBackgroundSyncEventKeepAlive() = 0; }; } // namespace content diff --git a/chromium/content/public/browser/background_tracing_manager.h b/chromium/content/public/browser/background_tracing_manager.h index dfbd33f3a9a..d3178a3cbf5 100644 --- a/chromium/content/public/browser/background_tracing_manager.h +++ b/chromium/content/public/browser/background_tracing_manager.h @@ -6,7 +6,9 @@ #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ #include <memory> +#include <string> +#include "base/strings/string_piece.h" #include "base/trace_event/trace_event_impl.h" #include "base/values.h" #include "content/common/content_export.h" @@ -90,10 +92,18 @@ class BackgroundTracingManager { virtual bool HasActiveScenario() = 0; + // Returns true whether a trace is ready to be uploaded. + virtual bool HasTraceToUpload() = 0; + + // Returns the latest trace created for uploading in a serialized proto of + // message type perfetto::Trace. + // TODO(ssid): This should also return the trigger for the trace along with + // the serialized trace proto. + virtual std::string GetLatestTraceToUpload() = 0; + // For tests virtual void AbortScenario() = 0; - virtual void InvalidateTriggerHandlesForTesting() = 0; - virtual void FireTimerForTesting() = 0; + virtual void SetTraceToUploadForTesting(base::StringPiece data) = 0; protected: virtual ~BackgroundTracingManager() {} diff --git a/chromium/content/public/browser/browser_accessibility_state.h b/chromium/content/public/browser/browser_accessibility_state.h index 484214bddd9..389acd30dd7 100644 --- a/chromium/content/public/browser/browser_accessibility_state.h +++ b/chromium/content/public/browser/browser_accessibility_state.h @@ -56,7 +56,14 @@ class CONTENT_EXPORT BrowserAccessibilityState { // browser starts up, when accessibility state histograms are updated. // Use this to register a method to update additional accessibility // histograms. - virtual void AddHistogramCallback(base::Closure callback) = 0; + // + // Use this variant for a callback that must be run on the UI thread, + // for example something that needs to access prefs. + virtual void AddUIThreadHistogramCallback(base::OnceClosure callback) = 0; + + // Use this variant for a callback that's better to run on another + // thread, for example something that may block or run slowly. + virtual void AddOtherThreadHistogramCallback(base::OnceClosure callback) = 0; virtual void UpdateHistogramsForTesting() = 0; }; diff --git a/chromium/content/public/browser/browser_child_process_host.h b/chromium/content/public/browser/browser_child_process_host.h index b07bb6aabd7..2a556cf2253 100644 --- a/chromium/content/public/browser/browser_child_process_host.h +++ b/chromium/content/public/browser/browser_child_process_host.h @@ -65,10 +65,10 @@ class CONTENT_EXPORT BrowserChildProcessHost : public IPC::Sender { std::unique_ptr<base::CommandLine> cmd_line, bool terminate_on_shutdown) = 0; - virtual const ChildProcessData& GetData() const = 0; + virtual const ChildProcessData& GetData() = 0; // Returns the ChildProcessHost object used by this object. - virtual ChildProcessHost* GetHost() const = 0; + virtual ChildProcessHost* GetHost() = 0; // Returns the termination info of a child. // |known_dead| indicates that the child is already dead. On Linux, this diff --git a/chromium/content/public/browser/browser_context.h b/chromium/content/public/browser/browser_context.h index 0a6913f2ca5..d2570b23290 100644 --- a/chromium/content/public/browser/browser_context.h +++ b/chromium/content/public/browser/browser_context.h @@ -246,7 +246,9 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { // Returns the path of the directory where this context's data is stored. virtual base::FilePath GetPath() const = 0; - // Return whether this context is incognito. Default is false. + // Return whether this context is off the record. Default is false. + // Note that for Chrome this does not imply Incognito as Guest sessions are + // also off the record. virtual bool IsOffTheRecord() const = 0; // Returns the resource context. diff --git a/chromium/content/public/browser/browser_ppapi_host.h b/chromium/content/public/browser/browser_ppapi_host.h index cf79a508dc0..91754a118e6 100644 --- a/chromium/content/public/browser/browser_ppapi_host.h +++ b/chromium/content/public/browser/browser_ppapi_host.h @@ -50,10 +50,10 @@ class CONTENT_EXPORT BrowserPpapiHost { virtual ppapi::host::PpapiHost* GetPpapiHost() = 0; // Returns a reference to the plugin process. - virtual const base::Process& GetPluginProcess() const = 0; + virtual const base::Process& GetPluginProcess() = 0; // Returns true if the given PP_Instance is valid. - virtual bool IsValidInstance(PP_Instance instance) const = 0; + virtual bool IsValidInstance(PP_Instance instance) = 0; // Retrieves the process/frame Ids associated with the RenderFrame containing // the given instance and returns true on success. If the instance is @@ -66,7 +66,7 @@ class CONTENT_EXPORT BrowserPpapiHost { // IDs to a RenderFrame/ProcessHost on the UI thread. virtual bool GetRenderFrameIDsForInstance(PP_Instance instance, int* render_process_id, - int* render_frame_id) const = 0; + int* render_frame_id) = 0; // Returns the name of the plugin. virtual const std::string& GetPluginName() = 0; diff --git a/chromium/content/public/browser/browser_task_traits.h b/chromium/content/public/browser/browser_task_traits.h index 961dc115b6d..f90334bc627 100644 --- a/chromium/content/public/browser/browser_task_traits.h +++ b/chromium/content/public/browser/browser_task_traits.h @@ -32,6 +32,12 @@ enum class BrowserTaskType { // Critical startup tasks. kBootstrap, + // Navigation related tasks. + kNavigation, + + // A subset of network tasks related to preconnection. + kPreconnect, + // Used to validate values in Java kBrowserTaskType_Last }; diff --git a/chromium/content/public/browser/browser_thread.h b/chromium/content/public/browser/browser_thread.h index c2b7716e003..247c7405cdb 100644 --- a/chromium/content/public/browser/browser_thread.h +++ b/chromium/content/public/browser/browser_thread.h @@ -54,11 +54,11 @@ class CONTENT_EXPORT BrowserThread { UI, // This is the thread that processes non-blocking IO, i.e. IPC and network. - // Blocking I/O should happen in TaskScheduler. + // Blocking I/O should happen in ThreadPool. IO, // NOTE: do not add new threads here. Instead you should just use - // base::Create*TaskRunnerWithTraits to run tasks on the TaskScheduler. + // base::Create*TaskRunnerWithTraits to run tasks on the ThreadPool. // This identifier does not represent a thread. Instead it counts the // number of well-known threads. Insert new well-known threads before this @@ -140,9 +140,9 @@ class CONTENT_EXPORT BrowserThread { // creating thread etc). Note: see base::OnTaskRunnerDeleter and // base::RefCountedDeleteOnSequence to bind to SequencedTaskRunner instead of // specific BrowserThreads. - template<ID thread> + template <ID thread> struct DeleteOnThread { - template<typename T> + template <typename T> static void Destruct(const T* x) { if (CurrentlyOn(thread)) { delete x; @@ -180,12 +180,24 @@ class CONTENT_EXPORT BrowserThread { // // Note: see base::OnTaskRunnerDeleter and base::RefCountedDeleteOnSequence to // bind to SequencedTaskRunner instead of specific BrowserThreads. - struct DeleteOnUIThread : public DeleteOnThread<UI> { }; - struct DeleteOnIOThread : public DeleteOnThread<IO> { }; + struct DeleteOnUIThread : public DeleteOnThread<UI> {}; + struct DeleteOnIOThread : public DeleteOnThread<IO> {}; // Returns an appropriate error message for when DCHECK_CURRENTLY_ON() fails. static std::string GetDCheckCurrentlyOnErrorMessage(ID expected); + // Runs all pending tasks for the given thread. Tasks posted after this method + // is called (in particular any task posted from within any of the pending + // tasks) will be queued but not run. Conceptually this call will disable all + // queues, run any pending tasks, and re-enable all the queues. + // + // If any of the pending tasks posted a task, these could be run by calling + // this method again or running a regular RunLoop. But if that were the case + // you should probably rewrite you tests to wait for a specific event instead. + // + // NOTE: Can only be called from the UI thread. + static void RunAllPendingTasksOnThreadForTesting(ID identifier); + protected: // For DeleteSoon(). Requires that the BrowserThread with the provided // |identifier| was started. diff --git a/chromium/content/public/browser/browsing_data_remover.h b/chromium/content/public/browser/browsing_data_remover.h index 60055a796bb..6708519017e 100644 --- a/chromium/content/public/browser/browsing_data_remover.h +++ b/chromium/content/public/browser/browsing_data_remover.h @@ -12,12 +12,14 @@ #include "base/time/time.h" #include "build/build_config.h" -class GURL; - namespace storage { class SpecialStoragePolicy; } +namespace url { +class Origin; +} + namespace content { class BrowsingDataFilterBuilder; @@ -151,7 +153,7 @@ class BrowsingDataRemover { // the |special_storage_policy|. virtual bool DoesOriginMatchMask( int origin_type_mask, - const GURL& origin, + const url::Origin& origin, storage::SpecialStoragePolicy* special_storage_policy) const = 0; // Removes browsing data within the given |time_range|, with datatypes being diff --git a/chromium/content/public/browser/browsing_data_remover_delegate.h b/chromium/content/public/browser/browsing_data_remover_delegate.h index faf7f83af64..108145717b2 100644 --- a/chromium/content/public/browser/browsing_data_remover_delegate.h +++ b/chromium/content/public/browser/browsing_data_remover_delegate.h @@ -7,8 +7,6 @@ #include "base/callback_forward.h" -class GURL; - namespace base { class Time; } @@ -17,6 +15,10 @@ namespace storage { class SpecialStoragePolicy; } +namespace url { +class Origin; +} + namespace content { class BrowsingDataFilterBuilder; @@ -25,10 +27,10 @@ class BrowsingDataRemoverDelegate { public: // Determines whether |origin| matches |origin_type_mask| given // the |special_storage_policy|. - typedef base::Callback<bool(int origin_type_mask, - const GURL& origin, - storage::SpecialStoragePolicy* policy)> - EmbedderOriginTypeMatcher; + using EmbedderOriginTypeMatcher = + base::Callback<bool(int origin_type_mask, + const url::Origin& origin, + storage::SpecialStoragePolicy* policy)>; virtual ~BrowsingDataRemoverDelegate() {} diff --git a/chromium/content/public/browser/child_process_security_policy.h b/chromium/content/public/browser/child_process_security_policy.h index 0424abc595a..59608e126a0 100644 --- a/chromium/content/public/browser/child_process_security_policy.h +++ b/chromium/content/public/browser/child_process_security_policy.h @@ -6,6 +6,7 @@ #define CONTENT_PUBLIC_BROWSER_CHILD_PROCESS_SECURITY_POLICY_H_ #include <string> +#include <vector> #include "content/common/content_export.h" #include "url/gurl.h" @@ -17,6 +18,8 @@ class FilePath; namespace content { +class BrowserContext; + // The ChildProcessSecurityPolicy class is used to grant and revoke security // capabilities for child processes. For example, it restricts whether a child // process is permitted to load file:// URLs based on whether the process @@ -215,6 +218,58 @@ class ChildProcessSecurityPolicy { // url::Origin instead of GURL (so that CanAccessDataForOrigin can verify // whether precursor of opaque origins also matches the process lock). virtual bool CanAccessDataForOrigin(int child_id, const GURL& url) = 0; + + // Add |origins| to the list of origins that require process isolation. When + // making process model decisions for such origins, the scheme+host tuple + // rather than scheme and eTLD+1 will be used. SiteInstances for these + // origins will also use the full host of the isolated origin as site URL. + // + // Subdomains of an isolated origin are considered to be part of that + // origin's site. For example, if https://isolated.foo.com is added as an + // isolated origin, then https://bar.isolated.foo.com will be considered part + // of the site for https://isolated.foo.com. + // + // Note that origins from |origins| must not be unique - URLs that render with + // unique origins, such as data: URLs, are not supported. Non-standard + // schemes are also not supported. Sandboxed frames (e.g., <iframe sandbox>) + // *are* supported, since process placement decisions will be based on the + // URLs such frames navigate to, and not the origin of committed documents + // (which might be unique). If an isolated origin opens an about:blank + // popup, it will stay in the isolated origin's process. Nested URLs + // (filesystem: and blob:) retain process isolation behavior of their inner + // origin. + // + // Note that it is okay if |origins| contains duplicates - the set of origins + // will be deduplicated inside the method. + // + // The new isolated origins will apply only to BrowsingInstances and renderer + // processes created *after* this call. This is necessary to not break + // scripting relationships between same-origin iframes in existing + // BrowsingInstances. To do this, this function internally determines a + // threshold BrowsingInstance ID that is higher than all existing + // BrowsingInstance IDs but lower than future BrowsingInstance IDs, and + // associates it with each of the |origins|. If an origin had already been + // isolated prior to calling this, it is ignored, and its threshold is not + // updated. + // + // If |browser_context| is non-null, the new isolated origins added via this + // function will apply only within that BrowserContext. If |browser_context| + // is null, the new isolated origins will apply globally in *all* + // BrowserContexts (but still subject to the BrowsingInstance ID cutoff in + // the previous paragraph). + // + // This function may be called again for the same origin but different + // |browser_context|. In that case, the origin will be isolated in all + // BrowserContexts for which this function has been called. However, + // attempts to re-add an origin for the same |browser_context| will be + // ignored. + virtual void AddIsolatedOrigins( + std::vector<url::Origin> origins, + BrowserContext* browser_context = nullptr) = 0; + + // Returns true if |origin| is a globally (not per-profile) isolated origin. + virtual bool IsGloballyIsolatedOriginForTesting( + const url::Origin& origin) = 0; }; } // namespace content diff --git a/chromium/content/public/browser/console_message.h b/chromium/content/public/browser/console_message.h index 2bef8a178c5..265b50afd71 100644 --- a/chromium/content/public/browser/console_message.h +++ b/chromium/content/public/browser/console_message.h @@ -14,20 +14,19 @@ namespace content { // A collection of information about a message that has been added to the // console. struct ConsoleMessage { - ConsoleMessage(int source_identifier, + ConsoleMessage(blink::mojom::ConsoleMessageSource source, blink::mojom::ConsoleMessageLevel message_level, const base::string16& message, int line_number, const GURL& source_url) - : source_identifier(source_identifier), + : source(source), message_level(message_level), message(message), line_number(line_number), source_url(source_url) {} - // The type of source this came from. In practice, this maps to - // blink::MessageSource. - const int source_identifier; + // The type of source this came from. + const blink::mojom::ConsoleMessageSource source; // The severity of the console message. const blink::mojom::ConsoleMessageLevel message_level; // The message that was logged to the console. diff --git a/chromium/content/public/browser/content_browser_client.cc b/chromium/content/public/browser/content_browser_client.cc index 9cd2333fe02..445e1febebe 100644 --- a/chromium/content/public/browser/content_browser_client.cc +++ b/chromium/content/public/browser/content_browser_client.cc @@ -115,9 +115,9 @@ bool ContentBrowserClient::ShouldUseSpareRenderProcessHost( } bool ContentBrowserClient::DoesSiteRequireDedicatedProcess( - BrowserContext* browser_context, + BrowserOrResourceContext browser_or_resource_context, const GURL& effective_site_url) { - DCHECK(browser_context); + DCHECK(browser_or_resource_context); return false; } @@ -315,6 +315,10 @@ bool ContentBrowserClient::AllowSharedWorker( return true; } +bool ContentBrowserClient::AllowSignedExchange(ResourceContext* context) { + return true; +} + bool ContentBrowserClient::IsDataSaverEnabled(BrowserContext* context) { DCHECK(context); return false; @@ -373,6 +377,13 @@ bool ContentBrowserClient::AllowWorkerIndexedDB( return true; } +bool ContentBrowserClient::AllowWorkerCacheStorage( + const GURL& url, + ResourceContext* context, + const std::vector<GlobalFrameRoutingId>& render_frames) { + return true; +} + ContentBrowserClient::AllowWebBluetoothResult ContentBrowserClient::AllowWebBluetooth( content::BrowserContext* browser_context, @@ -386,7 +397,8 @@ std::string ContentBrowserClient::GetWebBluetoothBlocklist() { return std::string(); } -QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() { +scoped_refptr<QuotaPermissionContext> +ContentBrowserClient::CreateQuotaPermissionContext() { return nullptr; } @@ -491,7 +503,8 @@ MediaObserver* ContentBrowserClient::GetMediaObserver() { } PlatformNotificationService* -ContentBrowserClient::GetPlatformNotificationService() { +ContentBrowserClient::GetPlatformNotificationService( + BrowserContext* browser_context) { return nullptr; } @@ -538,6 +551,10 @@ std::string ContentBrowserClient::GetDefaultDownloadName() { return std::string(); } +base::FilePath ContentBrowserClient::GetFontLookupTableCacheDir() { + return base::FilePath(); +} + base::FilePath ContentBrowserClient::GetShaderDiskCacheDirectory() { return base::FilePath(); } @@ -716,8 +733,8 @@ std::vector<std::string> ContentBrowserClient::GetStartupServices() { return nullptr; } -std::unique_ptr<base::TaskScheduler::InitParams> -ContentBrowserClient::GetTaskSchedulerInitParams() { +std::unique_ptr<base::ThreadPool::InitParams> +ContentBrowserClient::GetThreadPoolInitParams() { return nullptr; } @@ -758,7 +775,8 @@ void ContentBrowserClient::WillCreateWebSocket( RenderFrameHost* frame, network::mojom::WebSocketRequest* request, network::mojom::AuthenticationHandlerPtr* auth_handler, - network::mojom::TrustedHeaderClientPtr* header_client) {} + network::mojom::TrustedHeaderClientPtr* header_client, + uint32_t* options) {} std::vector<std::unique_ptr<URLLoaderRequestInterceptor>> ContentBrowserClient::WillCreateURLLoaderRequestInterceptors( @@ -785,7 +803,6 @@ network::mojom::NetworkContextPtr ContentBrowserClient::CreateNetworkContext( network::mojom::NetworkContextParams::New(); context_params->user_agent = GetUserAgent(); context_params->accept_language = "en-us,en"; - context_params->enable_data_url_support = true; GetNetworkService()->CreateNetworkContext(MakeRequest(&network_context), std::move(context_params)); return network_context; @@ -797,10 +814,6 @@ ContentBrowserClient::GetNetworkContextsParentDirectory() { } #if defined(OS_ANDROID) -bool ContentBrowserClient::NeedURLRequestContext() { - return true; -} - bool ContentBrowserClient::ShouldOverrideUrlLoading( int frame_tree_node_id, bool browser_initiated, @@ -844,13 +857,14 @@ bool ContentBrowserClient::ShowPaymentHandlerWindow( return false; } -bool ContentBrowserClient::ShouldCreateTaskScheduler() { +bool ContentBrowserClient::ShouldCreateThreadPool() { return true; } std::unique_ptr<AuthenticatorRequestClientDelegate> ContentBrowserClient::GetWebAuthenticationRequestDelegate( - RenderFrameHost* render_frame_host) { + RenderFrameHost* render_frame_host, + const std::string& relying_party_id) { return std::make_unique<AuthenticatorRequestClientDelegate>(); } @@ -866,7 +880,7 @@ ContentBrowserClient::CreateClientCertStore(ResourceContext* resource_context) { } std::unique_ptr<LoginDelegate> ContentBrowserClient::CreateLoginDelegate( - net::AuthChallengeInfo* auth_info, + const net::AuthChallengeInfo& auth_info, content::WebContents* web_contents, const GlobalRequestID& request_id, bool is_request_for_main_frame, @@ -886,7 +900,9 @@ bool ContentBrowserClient::HandleExternalProtocol( ui::PageTransition page_transition, bool has_user_gesture, const std::string& method, - const net::HttpRequestHeaders& headers) { + const net::HttpRequestHeaders& headers, + network::mojom::URLLoaderFactoryRequest* factory_request, + network::mojom::URLLoaderFactory*& out_factory) { return true; } @@ -971,4 +987,9 @@ ContentBrowserClient::GetWideColorGamutHeuristic() const { } #endif +base::flat_set<std::string> ContentBrowserClient::GetMimeHandlerViewMimeTypes( + ResourceContext* resource_context) { + return base::flat_set<std::string>(); +} + } // namespace content diff --git a/chromium/content/public/browser/content_browser_client.h b/chromium/content/public/browser/content_browser_client.h index 009991aa57e..39174b67d1d 100644 --- a/chromium/content/public/browser/content_browser_client.h +++ b/chromium/content/public/browser/content_browser_client.h @@ -18,10 +18,11 @@ #include "base/containers/flat_map.h" #include "base/containers/flat_set.h" #include "base/optional.h" -#include "base/task/task_scheduler/task_scheduler.h" +#include "base/task/thread_pool/thread_pool.h" #include "base/time/time.h" #include "base/values.h" #include "build/build_config.h" +#include "content/public/browser/browser_or_resource_context.h" #include "content/public/browser/certificate_request_result_type.h" #include "content/public/browser/generated_code_cache_settings.h" #include "content/public/browser/global_request_id.h" @@ -29,6 +30,7 @@ #include "content/public/browser/navigation_throttle.h" #include "content/public/browser/overlay_window.h" #include "content/public/browser/page_visibility_state.h" +#include "content/public/browser/quota_permission_context.h" #include "content/public/browser/resource_request_info.h" #include "content/public/common/content_client.h" #include "content/public/common/previews_state.h" @@ -53,9 +55,10 @@ #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/mediastream/media_stream_request.h" #include "third_party/blink/public/common/user_agent/user_agent_metadata.h" +#include "third_party/blink/public/mojom/credentialmanager/credential_manager.mojom-forward.h" #include "third_party/blink/public/mojom/renderer_preference_watcher.mojom-forward.h" #include "third_party/blink/public/mojom/web_feature/web_feature.mojom-forward.h" -#include "third_party/blink/public/web/window_features.mojom-forward.h" +#include "third_party/blink/public/mojom/window_features/window_features.mojom-forward.h" #include "ui/accessibility/ax_mode.h" #include "ui/base/page_transition_types.h" #include "ui/base/window_open_disposition.h" @@ -307,8 +310,9 @@ class CONTENT_EXPORT ContentBrowserClient { // enforced by the content layer. Will only be called if the content layer // didn't decide to isolate |effective_site_url| according to its internal // policy (e.g. because of --site-per-process). - virtual bool DoesSiteRequireDedicatedProcess(BrowserContext* browser_context, - const GURL& effective_site_url); + virtual bool DoesSiteRequireDedicatedProcess( + BrowserOrResourceContext browser_or_resource_context, + const GURL& effective_site_url); // Returns true unless the effective URL is part of a site that cannot live in // a process restricted to just that site. This is only called if site @@ -484,6 +488,12 @@ class CONTENT_EXPORT ContentBrowserClient { // Retrieves names of any additional site isolation modes from the embedder. virtual std::vector<std::string> GetAdditionalSiteIsolationModes(); + // Called when a new dynamic isolated origin was added in |context|, and the + // origin desires to be persisted across restarts, to give the embedder an + // opportunity to save this isolated origin to disk. + virtual void PersistIsolatedOrigin(BrowserContext* context, + const url::Origin& origin) {} + // Indicates whether a file path should be accessible via file URL given a // request from a browser context which lives within |profile_path|. virtual bool IsFileAccessAllowed(const base::FilePath& path, @@ -551,6 +561,12 @@ class CONTENT_EXPORT ContentBrowserClient { int render_process_id, int render_frame_id); + // Allows the embedder to control whether Signed HTTP Exchanges (SXG) can be + // loaded. This is called on the IO thread. + // Relying on ResourceContext to access preferences on IO thread until we move + // the call sites out of the IO thread. See crbug.com/908955 for more context. + virtual bool AllowSignedExchange(ResourceContext* context); + virtual bool IsDataSaverEnabled(BrowserContext* context); // Updates the given prefs for Service Worker and Shared Worker. The prefs @@ -613,6 +629,14 @@ class CONTENT_EXPORT ContentBrowserClient { ResourceContext* context, const std::vector<GlobalFrameRoutingId>& render_frames); + // Allow the embedder to control if access to CacheStorage by a shared worker + // is allowed. + // This is called on the IO thread. + virtual bool AllowWorkerCacheStorage( + const GURL& url, + ResourceContext* context, + const std::vector<GlobalFrameRoutingId>& render_frames); + // Allow the embedder to control whether we can use Web Bluetooth. // TODO(crbug.com/589228): Replace this with a use of the permission system. enum class AllowWebBluetoothResult { @@ -715,7 +739,7 @@ class CONTENT_EXPORT ContentBrowserClient { bool* in_memory); // Create and return a new quota permission context. - virtual QuotaPermissionContext* CreateQuotaPermissionContext(); + virtual scoped_refptr<QuotaPermissionContext> CreateQuotaPermissionContext(); // Allows the embedder to provide settings that determine the amount // of disk space that may be used by content facing storage apis like @@ -760,8 +784,10 @@ class CONTENT_EXPORT ContentBrowserClient { // Returns the platform notification service, capable of displaying Web // Notifications to the user. The embedder can return a nullptr if they don't - // support this functionality. May be called from any thread. - virtual PlatformNotificationService* GetPlatformNotificationService(); + // support this functionality. Must be called on the UI thread. + // TODO(knollr): move this to the BrowserContext. + virtual PlatformNotificationService* GetPlatformNotificationService( + BrowserContext* browser_context); // Returns true if the given page is allowed to open a window of the given // type. If true is returned, |no_javascript_access| will indicate whether @@ -818,6 +844,11 @@ class CONTENT_EXPORT ContentBrowserClient { // else we should do with the file. virtual std::string GetDefaultDownloadName(); + // Returns the path to the font lookup table cache directory in which - on + // Windows 7 & 8 - we cache font name meta information to perform @font-face { + // src: local() } lookups. + virtual base::FilePath GetFontLookupTableCacheDir(); + // Returns the path to the browser shader disk cache root. virtual base::FilePath GetShaderDiskCacheDirectory(); @@ -939,6 +970,12 @@ class CONTENT_EXPORT ContentBrowserClient { const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe) {} + // Content was unable to bind a CredentialManager request, so the embedder + // should try. + virtual void BindCredentialManagerRequest( + RenderFrameHost* render_frame_host, + blink::mojom::CredentialManagerRequest request) {} + // Content was unable to bind a request for this associated interface, so the // embedder should try. Returns true if the |handle| was actually taken and // bound; false otherwise. @@ -1144,10 +1181,10 @@ class CONTENT_EXPORT ContentBrowserClient { // Returns the RapporService from the browser process. virtual ::rappor::RapporService* GetRapporService(); - // Provides parameters for initializing the global task scheduler. Default + // Provides parameters for initializing the global thread pool. Default // params are used if this returns nullptr. - virtual std::unique_ptr<base::TaskScheduler::InitParams> - GetTaskSchedulerInitParams(); + virtual std::unique_ptr<base::ThreadPool::InitParams> + GetThreadPoolInitParams(); // Allows the embedder to register one or more URLLoaderThrottles for a // navigation request. @@ -1238,7 +1275,8 @@ class CONTENT_EXPORT ContentBrowserClient { RenderFrameHost* frame, network::mojom::WebSocketRequest* request, network::mojom::AuthenticationHandlerPtr* authentication_handler, - network::mojom::TrustedHeaderClientPtr* header_client); + network::mojom::TrustedHeaderClientPtr* header_client, + uint32_t* options); // Allows the embedder to returns a list of request interceptors that can // intercept a navigation request. @@ -1290,10 +1328,6 @@ class CONTENT_EXPORT ContentBrowserClient { virtual std::vector<base::FilePath> GetNetworkContextsParentDirectory(); #if defined(OS_ANDROID) - // Configures whether StoragePartition needs to create a - // net::URLRequestContext in the browser when the network service is enabled. - virtual bool NeedURLRequestContext(); - // Only used by Android WebView. // Returns: // true - The check was successfully performed without throwing a @@ -1346,22 +1380,24 @@ class CONTENT_EXPORT ContentBrowserClient { int /* render_process_id */, int /* render_frame_id */)> callback); - // Returns whether a base::TaskScheduler should be created when + // Returns whether a base::ThreadPool should be created when // BrowserMainLoop starts. - // If false, a task scheduler has been created by the embedder, and + // If false, a thread pool has been created by the embedder, and // BrowserMainLoop should skip creating a second one. - // Note: the embedder should *not* start the TaskScheduler for + // Note: the embedder should *not* start the ThreadPool for // BrowserMainLoop, BrowserMainLoop itself is responsible for that. - virtual bool ShouldCreateTaskScheduler(); + virtual bool ShouldCreateThreadPool(); // Returns an AuthenticatorRequestClientDelegate subclass instance to provide // embedder-specific configuration for a single Web Authentication API request // being serviced in a given RenderFrame. The instance is guaranteed to be // 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. + // now. |relying_party_id| is the RP ID from Webauthn, essentially a domain + // name. virtual std::unique_ptr<AuthenticatorRequestClientDelegate> - GetWebAuthenticationRequestDelegate(RenderFrameHost* render_frame_host); + GetWebAuthenticationRequestDelegate(RenderFrameHost* render_frame_host, + const std::string& relying_party_id); #if defined(OS_MACOSX) // Returns whether WebAuthn supports the built-in Touch ID platform @@ -1401,7 +1437,7 @@ class CONTENT_EXPORT ContentBrowserClient { // WebContentsDelegate, where the lifetime ordering is more // obvious. https://crbug.com/456255 virtual std::unique_ptr<LoginDelegate> CreateLoginDelegate( - net::AuthChallengeInfo* auth_info, + const net::AuthChallengeInfo& auth_info, WebContents* web_contents, const GlobalRequestID& request_id, bool is_request_for_main_frame, @@ -1426,7 +1462,9 @@ class CONTENT_EXPORT ContentBrowserClient { ui::PageTransition page_transition, bool has_user_gesture, const std::string& method, - const net::HttpRequestHeaders& headers); + const net::HttpRequestHeaders& headers, + network::mojom::URLLoaderFactoryRequest* factory_request, + network::mojom::URLLoaderFactory*& out_factory); // Creates an OverlayWindow to be used for Picture-in-Picture. This window // will house the content shown when in Picture-in-Picture mode. This will @@ -1527,6 +1565,10 @@ class CONTENT_EXPORT ContentBrowserClient { // Returns kNone by default. virtual WideColorGamutHeuristic GetWideColorGamutHeuristic() const; #endif + + // Obtains the list of MIME types that are handled by a MimeHandlerView. + virtual base::flat_set<std::string> GetMimeHandlerViewMimeTypes( + ResourceContext* resource_context); }; } // namespace content diff --git a/chromium/content/public/browser/cors_exempt_headers.cc b/chromium/content/public/browser/cors_exempt_headers.cc new file mode 100644 index 00000000000..6faee524304 --- /dev/null +++ b/chromium/content/public/browser/cors_exempt_headers.cc @@ -0,0 +1,19 @@ +// 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 new file mode 100644 index 00000000000..c9b5cf13f04 --- /dev/null +++ b/chromium/content/public/browser/cors_exempt_headers.h @@ -0,0 +1,21 @@ +// 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/delegate_to_browser_gpu_service_accelerator_factory.h b/chromium/content/public/browser/delegate_to_browser_gpu_service_accelerator_factory.h index 0e8b5f84cf2..7dfee02211e 100644 --- a/chromium/content/public/browser/delegate_to_browser_gpu_service_accelerator_factory.h +++ b/chromium/content/public/browser/delegate_to_browser_gpu_service_accelerator_factory.h @@ -17,7 +17,7 @@ class CONTENT_EXPORT DelegateToBrowserGpuServiceAcceleratorFactory : public video_capture::mojom::AcceleratorFactory { public: void CreateJpegDecodeAccelerator( - media::mojom::JpegDecodeAcceleratorRequest jda_request) override; + media::mojom::MjpegDecodeAcceleratorRequest jda_request) override; }; } // namespace content diff --git a/chromium/content/public/browser/desktop_media_id.cc b/chromium/content/public/browser/desktop_media_id.cc index b2d53c94cf6..9330ec65d44 100644 --- a/chromium/content/public/browser/desktop_media_id.cc +++ b/chromium/content/public/browser/desktop_media_id.cc @@ -14,6 +14,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "build/build_config.h" #include "content/browser/media/desktop_media_window_registry.h" namespace content { @@ -26,7 +27,7 @@ const DesktopMediaID::Id DesktopMediaID::kNullId = 0; // static const DesktopMediaID::Id DesktopMediaID::kFakeId = -3; -#if defined(USE_AURA) +#if defined(USE_AURA) || defined(OS_MACOSX) // static DesktopMediaID DesktopMediaID::RegisterNativeWindow(DesktopMediaID::Type type, gfx::NativeWindow window) { diff --git a/chromium/content/public/browser/desktop_media_id.h b/chromium/content/public/browser/desktop_media_id.h index fc84715e209..c9791b4f436 100644 --- a/chromium/content/public/browser/desktop_media_id.h +++ b/chromium/content/public/browser/desktop_media_id.h @@ -8,6 +8,7 @@ #include <string> #include <tuple> +#include "build/build_config.h" #include "content/common/content_export.h" #include "content/public/browser/web_contents_media_capture_id.h" #include "ui/gfx/native_widget_types.h" @@ -27,7 +28,7 @@ struct CONTENT_EXPORT DesktopMediaID { // Represents a fake id to create a dummy capturer for autotests. static const Id kFakeId; -#if defined(USE_AURA) +#if defined(USE_AURA) || defined(OS_MACOSX) // Assigns integer identifier to the |window| and returns its DesktopMediaID. static DesktopMediaID RegisterNativeWindow(Type type, gfx::NativeWindow window); @@ -35,7 +36,7 @@ struct CONTENT_EXPORT DesktopMediaID { // Returns the Window that was previously registered using // RegisterNativeWindow(), else nullptr. static gfx::NativeWindow GetNativeWindowById(const DesktopMediaID& id); -#endif // USE_AURA +#endif // USE_AURA || OS_MACOSX constexpr DesktopMediaID() = default; diff --git a/chromium/content/public/browser/download_manager.h b/chromium/content/public/browser/download_manager.h index 5eae5621719..82474b8cb65 100644 --- a/chromium/content/public/browser/download_manager.h +++ b/chromium/content/public/browser/download_manager.h @@ -41,6 +41,7 @@ #include "components/download/public/common/download_stream.mojom-forward.h" #include "components/download/public/common/download_url_parameters.h" #include "components/download/public/common/input_stream.h" +#include "components/download/public/common/simple_download_manager.h" #include "content/common/content_export.h" #include "net/base/net_errors.h" #include "services/network/public/cpp/shared_url_loader_factory.h" @@ -59,7 +60,8 @@ class BrowserContext; class DownloadManagerDelegate; // Browser's download manager: manages all downloads and destination view. -class CONTENT_EXPORT DownloadManager : public base::SupportsUserData::Data { +class CONTENT_EXPORT DownloadManager : public base::SupportsUserData::Data, + public download::SimpleDownloadManager { public: ~DownloadManager() override {} @@ -110,12 +112,6 @@ class CONTENT_EXPORT DownloadManager : public base::SupportsUserData::Data { virtual ~Observer() {} }; - typedef std::vector<download::DownloadItem*> DownloadVector; - - // Add all download items to |downloads|, no matter the type or state, without - // clearing |downloads| first. - virtual void GetAllDownloads(DownloadVector* downloads) = 0; - // Called by a download source (Currently DownloadResourceHandler) // to initiate the non-source portions of a download. // If the DownloadCreateInfo specifies an id, that id will be used. @@ -137,11 +133,7 @@ class CONTENT_EXPORT DownloadManager : public base::SupportsUserData::Data { base::Time remove_begin, base::Time remove_end) = 0; - // See download::DownloadUrlParameters for details about controlling the - // download. - virtual void DownloadUrl( - std::unique_ptr<download::DownloadUrlParameters> parameters) = 0; - + using SimpleDownloadManager::DownloadUrl; // For downloads of blob URLs, the caller can pass a BlobDataHandle object so // that the blob will remain valid until the download starts. The // BlobDataHandle will be attached to the associated URLRequest. @@ -236,10 +228,6 @@ class CONTENT_EXPORT DownloadManager : public base::SupportsUserData::Data { // (http://crbug.com/593020) virtual download::DownloadItem* GetDownload(uint32_t id) = 0; - // Get the download item for |guid|. - virtual download::DownloadItem* GetDownloadByGuid( - const std::string& guid) = 0; - using GetNextIdCallback = base::OnceCallback<void(uint32_t)>; // Called to get an ID for a new download. |callback| may be called // synchronously. diff --git a/chromium/content/public/browser/global_routing_id.h b/chromium/content/public/browser/global_routing_id.h index bf6a9d847c1..7cb4ea086f3 100644 --- a/chromium/content/public/browser/global_routing_id.h +++ b/chromium/content/public/browser/global_routing_id.h @@ -7,7 +7,7 @@ #include <tuple> -#include "base/hash.h" +#include "base/hash/hash.h" #include "ipc/ipc_message.h" namespace content { diff --git a/chromium/content/public/browser/gpu_utils.cc b/chromium/content/public/browser/gpu_utils.cc index 375118c9178..8502b829ea7 100644 --- a/chromium/content/public/browser/gpu_utils.cc +++ b/chromium/content/public/browser/gpu_utils.cc @@ -111,15 +111,13 @@ const gpu::GpuPreferences GetGpuPreferencesFromCommandLine() { gpu_preferences.enable_oop_rasterization_ddl = command_line->HasSwitch(switches::kEnableOopRasterizationDDL); - gpu_preferences.enable_passthrough_raster_decoder = - command_line->HasSwitch(switches::kEnablePassthroughRasterDecoder); -#if defined(OS_WIN) - gpu_preferences.enable_passthrough_raster_decoder = true; -#endif gpu_preferences.enable_vulkan = command_line->HasSwitch(switches::kEnableVulkan); + gpu_preferences.disable_vulkan_fallback_to_gl_for_testing = + command_line->HasSwitch(switches::kDisableVulkanFallbackToGLForTesting); + gpu_preferences.enable_gpu_benchmarking_extension = command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking); diff --git a/chromium/content/public/browser/manifest_icon_downloader.h b/chromium/content/public/browser/manifest_icon_downloader.h index 5731e96f885..5ddd57d795c 100644 --- a/chromium/content/public/browser/manifest_icon_downloader.h +++ b/chromium/content/public/browser/manifest_icon_downloader.h @@ -22,15 +22,15 @@ namespace content { class WebContents; -// Helper class which downloads the icon located at a specified. If the icon -// file contains multiple icons then it attempts to pick the one closest in size -// bigger than or equal to ideal_icon_size_in_px, taking into account the +// Helper class which downloads the icon located at a specified URL. If the +// icon file contains multiple icons then it attempts to pick the one closest in +// size bigger than or equal to ideal_icon_size_in_px, taking into account the // density of the device. If a bigger icon is chosen then, the icon is scaled // down to be equal to ideal_icon_size_in_px. Smaller icons will be chosen down // to the value specified by |minimum_icon_size_in_px|. class CONTENT_EXPORT ManifestIconDownloader final { public: - using IconFetchCallback = base::Callback<void(const SkBitmap&)>; + using IconFetchCallback = base::OnceCallback<void(const SkBitmap&)>; ManifestIconDownloader() = delete; ~ManifestIconDownloader() = delete; @@ -42,7 +42,12 @@ class CONTENT_EXPORT ManifestIconDownloader final { const GURL& icon_url, int ideal_icon_size_in_px, int minimum_icon_size_in_px, - const IconFetchCallback& callback); + IconFetchCallback callback, + bool square_only = true); + + // This threshold has been chosen arbitrarily and is open to any necessary + // changes in the future. + static const int kMaxWidthToHeightRatio = 5; private: class DevToolsConsoleHelper; @@ -51,20 +56,23 @@ class CONTENT_EXPORT ManifestIconDownloader final { // download failed. static void OnIconFetched(int ideal_icon_size_in_px, int minimum_icon_size_in_px, + bool square_only, DevToolsConsoleHelper* console_helper, - const IconFetchCallback& callback, + IconFetchCallback callback, int id, int http_status_code, const GURL& url, const std::vector<SkBitmap>& bitmaps, const std::vector<gfx::Size>& sizes); - static void ScaleIcon(int ideal_icon_size_in_px, + static void ScaleIcon(int ideal_icon_width_in_px, + int ideal_icon_height_in_px, const SkBitmap& bitmap, - const IconFetchCallback& callback); + IconFetchCallback callback); static int FindClosestBitmapIndex(int ideal_icon_size_in_px, int minimum_icon_size_in_px, + bool square_only, const std::vector<SkBitmap>& bitmaps); friend class ManifestIconDownloaderTest; diff --git a/chromium/content/public/browser/media_device_id.cc b/chromium/content/public/browser/media_device_id.cc index 769af476fd0..8a7651efb27 100644 --- a/chromium/content/public/browser/media_device_id.cc +++ b/chromium/content/public/browser/media_device_id.cc @@ -4,6 +4,7 @@ #include "content/public/browser/media_device_id.h" #include "base/strings/string_util.h" +#include "base/threading/sequenced_task_runner_handle.h" #include "content/browser/browser_main_loop.h" #include "content/browser/renderer_host/media/media_stream_manager.h" #include "media/audio/audio_device_description.h" @@ -38,6 +39,18 @@ bool GetMediaDeviceIDForHMAC(blink::MediaStreamType stream_type, device_id); } +void GetMediaDeviceIDForHMAC( + blink::MediaStreamType stream_type, + std::string salt, + url::Origin security_origin, + std::string hmac_device_id, + base::OnceCallback<void(const base::Optional<std::string>&)> callback) { + MediaStreamManager::GetMediaDeviceIDForHMAC( + stream_type, std::move(salt), std::move(security_origin), + std::move(hmac_device_id), base::SequencedTaskRunnerHandle::Get(), + std::move(callback)); +} + bool IsValidDeviceId(const std::string& device_id) { constexpr int hash_size = 64; // 32 bytes * 2 char/byte hex encoding if (media::AudioDeviceDescription::IsDefaultDevice(device_id) || diff --git a/chromium/content/public/browser/media_device_id.h b/chromium/content/public/browser/media_device_id.h index 5a921f9dcb6..6d3b1ce8ea4 100644 --- a/chromium/content/public/browser/media_device_id.h +++ b/chromium/content/public/browser/media_device_id.h @@ -34,12 +34,24 @@ CONTENT_EXPORT bool DoesMediaDeviceIDMatchHMAC( const std::string& device_guid, const std::string& raw_unique_id); +// This function is deprecated. Use the callback version below instead. CONTENT_EXPORT bool GetMediaDeviceIDForHMAC(blink::MediaStreamType stream_type, const std::string& salt, const url::Origin& security_origin, const std::string& source_id, std::string* device_id); +// Returns the raw device ID for the given HMAC |hmac_device_id| for the given +// |security_origin| and |salt|. The result is passed via |callback| on the +// task runner where this function is called. If |hmac_device_id| is not a +// valid device ID nullopt is returned. +CONTENT_EXPORT void GetMediaDeviceIDForHMAC( + blink::MediaStreamType stream_type, + std::string salt, + url::Origin security_origin, + std::string hmac_device_id, + base::OnceCallback<void(const base::Optional<std::string>&)> callback); + CONTENT_EXPORT bool IsValidDeviceId(const std::string& device_id); } // namespace content diff --git a/chromium/content/public/browser/media_player_id.cc b/chromium/content/public/browser/media_player_id.cc new file mode 100644 index 00000000000..ae6b6e39e79 --- /dev/null +++ b/chromium/content/public/browser/media_player_id.cc @@ -0,0 +1,35 @@ +// 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/media_player_id.h" + +#include "content/public/browser/render_frame_host.h" + +namespace content { + +MediaPlayerId::MediaPlayerId(RenderFrameHost* render_frame_host, + int delegate_id) + : render_frame_host(render_frame_host), delegate_id(delegate_id) {} + +MediaPlayerId MediaPlayerId::CreateMediaPlayerIdForTests() { + return MediaPlayerId(nullptr, 0); +} + +bool MediaPlayerId::operator==(const MediaPlayerId& other) const { + return render_frame_host == other.render_frame_host && + delegate_id == other.delegate_id; +} + +bool MediaPlayerId::operator!=(const MediaPlayerId& other) const { + return render_frame_host != other.render_frame_host || + delegate_id != other.delegate_id; +} + +bool MediaPlayerId::operator<(const MediaPlayerId& other) const { + if (render_frame_host == other.render_frame_host) + return delegate_id < other.delegate_id; + return render_frame_host < other.render_frame_host; +} + +} // namespace content diff --git a/chromium/content/public/browser/media_player_id.h b/chromium/content/public/browser/media_player_id.h new file mode 100644 index 00000000000..68ffe98f403 --- /dev/null +++ b/chromium/content/public/browser/media_player_id.h @@ -0,0 +1,29 @@ +// 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_MEDIA_PLAYER_ID_H_ +#define CONTENT_PUBLIC_BROWSER_MEDIA_PLAYER_ID_H_ + +#include "content/common/content_export.h" + +namespace content { + +class RenderFrameHost; + +struct CONTENT_EXPORT MediaPlayerId { + static MediaPlayerId CreateMediaPlayerIdForTests(); + MediaPlayerId() = delete; + + MediaPlayerId(RenderFrameHost* render_frame_host, int delegate_id); + bool operator==(const MediaPlayerId&) const; + bool operator!=(const MediaPlayerId&) const; + bool operator<(const MediaPlayerId&) const; + + RenderFrameHost* render_frame_host = nullptr; + int delegate_id = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_MEDIA_PLAYER_ID_H_ diff --git a/chromium/content/public/browser/navigation_entry.h b/chromium/content/public/browser/navigation_entry.h index 31f27b8e7f4..e3c6f60fbf0 100644 --- a/chromium/content/public/browser/navigation_entry.h +++ b/chromium/content/public/browser/navigation_entry.h @@ -13,6 +13,7 @@ #include "base/memory/ref_counted_memory.h" #include "base/optional.h" #include "base/strings/string16.h" +#include "base/supports_user_data.h" #include "base/time/time.h" #include "build/build_config.h" #include "content/common/content_export.h" @@ -34,9 +35,9 @@ struct SSLStatus; // required to recreate a browsing state. This includes some opaque binary // state as provided by the WebContents as well as some clear text title and // URL which is used for our user interface. -class NavigationEntry { +class NavigationEntry : public base::SupportsUserData { public: - virtual ~NavigationEntry() {} + ~NavigationEntry() override {} CONTENT_EXPORT static std::unique_ptr<NavigationEntry> Create(); @@ -193,15 +194,6 @@ class NavigationEntry { virtual void SetCanLoadLocalResources(bool allow) = 0; virtual bool GetCanLoadLocalResources() = 0; - // Set extra data on this NavigationEntry according to the specified |key|. - // This data is not persisted by default. - virtual void SetExtraData(const std::string& key, - const base::string16& data) = 0; - // If present, fills the |data| present at the specified |key|. - virtual bool GetExtraData(const std::string& key, base::string16* data) = 0; - // Removes the data at the specified |key|. - virtual void ClearExtraData(const std::string& key) = 0; - // The status code of the last known successful navigation. If // GetHttpStatusCode() returns 0 that means that either: // @@ -231,6 +223,11 @@ class NavigationEntry { // Adds more extra headers (separated by \r\n) to send during the request. virtual void AddExtraHeaders(const std::string& extra_headers) = 0; + + // Returns a unique value identifying the main document for this navigation. + // This persists across same-document navigations and stays the same after + // a history navigation to an already visited document. + virtual int64_t GetMainFrameDocumentSequenceNumber() = 0; }; } // namespace content diff --git a/chromium/content/public/browser/navigation_handle.h b/chromium/content/public/browser/navigation_handle.h index a7a9640eb4e..cb60e28bb10 100644 --- a/chromium/content/public/browser/navigation_handle.h +++ b/chromium/content/public/browser/navigation_handle.h @@ -52,7 +52,7 @@ class CONTENT_EXPORT NavigationHandle { // some may change during navigation (e.g. due to server redirects). // Get a unique ID for this navigation. - virtual int64_t GetNavigationId() const = 0; + virtual int64_t GetNavigationId() = 0; // The URL the frame is navigating to. This may change during the navigation // when encountering a server redirect. @@ -113,7 +113,7 @@ class CONTENT_EXPORT NavigationHandle { virtual base::TimeTicks NavigationInputStart() = 0; // Whether or not the navigation was started within a context menu. - virtual bool WasStartedFromContextMenu() const = 0; + virtual bool WasStartedFromContextMenu() = 0; // Returns the URL and encoding of an INPUT field that corresponds to a // searchable form request. @@ -300,6 +300,24 @@ class CONTENT_EXPORT NavigationHandle { // navigation for this NavigationHandle. virtual const base::Optional<url::Origin>& GetInitiatorOrigin() = 0; + // Whether the new document will be hosted in the same process as the current + // document or not. Set only when the navigation commits. + virtual bool IsSameProcess() = 0; + + // Returns the offset between the indices of the previous last committed and + // the newly committed navigation entries. + // (e.g. -1 for back navigations, 0 for reloads, 1 for forward navigations). + // + // Note that this value is computed when we create the navigation request + // and doesn't fully cover all corner cases. + // We try to approximate them with params.should_replace_entry, but in + // some cases it's inaccurate: + // - Main frame client redirects, + // - History navigation to the page with subframes. The subframe + // navigations will return 1 here although they don't create a new + // navigation entry. + virtual int GetNavigationEntryOffset() = 0; + // Testing methods ---------------------------------------------------------- // // The following methods should be used exclusively for writing unit tests. diff --git a/chromium/content/public/browser/navigation_throttle.cc b/chromium/content/public/browser/navigation_throttle.cc index 45ff97ecf4e..552b1af65a8 100644 --- a/chromium/content/public/browser/navigation_throttle.cc +++ b/chromium/content/public/browser/navigation_throttle.cc @@ -85,7 +85,9 @@ void NavigationThrottle::Resume() { resume_callback_.Run(); return; } - static_cast<NavigationHandleImpl*>(navigation_handle_)->Resume(this); + static_cast<NavigationHandleImpl*>(navigation_handle_) + ->navigation_request() + ->Resume(this); } void NavigationThrottle::CancelDeferredNavigation( @@ -95,6 +97,7 @@ void NavigationThrottle::CancelDeferredNavigation( return; } static_cast<NavigationHandleImpl*>(navigation_handle_) + ->navigation_request() ->CancelDeferredNavigation(this, result); } diff --git a/chromium/content/public/browser/permission_controller.h b/chromium/content/public/browser/permission_controller.h index d42de371ad1..b9b42def49b 100644 --- a/chromium/content/public/browser/permission_controller.h +++ b/chromium/content/public/browser/permission_controller.h @@ -8,7 +8,7 @@ #include "base/supports_user_data.h" #include "content/common/content_export.h" #include "content/public/browser/permission_type.h" -#include "third_party/blink/public/platform/modules/permissions/permission_status.mojom.h" +#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" class GURL; diff --git a/chromium/content/public/browser/permission_controller_delegate.h b/chromium/content/public/browser/permission_controller_delegate.h index 98eb65187d3..2ba6de9deec 100644 --- a/chromium/content/public/browser/permission_controller_delegate.h +++ b/chromium/content/public/browser/permission_controller_delegate.h @@ -6,7 +6,7 @@ #define CONTENT_PUBLIC_BROWSER_PERMISSION_CONTROLLER_DELEGATE_H_ #include "content/common/content_export.h" -#include "third_party/blink/public/platform/modules/permissions/permission_status.mojom.h" +#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" class GURL; diff --git a/chromium/content/public/browser/platform_notification_context.h b/chromium/content/public/browser/platform_notification_context.h index 276ca40cf10..ee0eb8f3eca 100644 --- a/chromium/content/public/browser/platform_notification_context.h +++ b/chromium/content/public/browser/platform_notification_context.h @@ -6,6 +6,8 @@ #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ #include <stdint.h> + +#include <string> #include <vector> #include "base/callback.h" @@ -46,6 +48,9 @@ class PlatformNotificationContext using DeleteResultCallback = base::OnceCallback<void(bool /* success */)>; + using DeleteAllResultCallback = + base::OnceCallback<void(bool /* success */, size_t /* deleted_count */)>; + // Reasons for updating a notification, triggering a read. enum class Interaction { // No interaction was taken with the notification. @@ -88,10 +93,12 @@ class PlatformNotificationContext int64_t service_worker_registration_id, ReadAllResultCallback callback) = 0; - // Writes the data associated with a notification to a database. When this - // action completed, |callback| will be invoked with the success status and - // the notification id when written successfully. The notification ID field - // for |database_data| will be generated, and thus must be empty. + // Writes the data associated with a notification to a database and displays + // it either immediately or at the desired time if the notification has a show + // trigger defined. When this action is completed, |callback| will be invoked + // with the success status and the notification id when written successfully. + // The notification ID field for |database_data| will be generated, and thus + // must be empty. virtual void WriteNotificationData( int64_t persistent_notification_id, int64_t service_worker_registration_id, @@ -106,6 +113,14 @@ class PlatformNotificationContext const GURL& origin, DeleteResultCallback callback) = 0; + // Checks permissions for all notifications in the database and deletes all + // that do not have the permission anymore. + virtual void DeleteAllNotificationDataForBlockedOrigins( + DeleteAllResultCallback callback) = 0; + + // Trigger all pending notifications. + virtual void TriggerNotifications() = 0; + protected: friend class base::DeleteHelper<PlatformNotificationContext>; friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; diff --git a/chromium/content/public/browser/platform_notification_service.h b/chromium/content/public/browser/platform_notification_service.h index c7209a74a84..ca61088079c 100644 --- a/chromium/content/public/browser/platform_notification_service.h +++ b/chromium/content/public/browser/platform_notification_service.h @@ -13,9 +13,10 @@ #include <vector> #include "base/callback_forward.h" +#include "base/time/time.h" #include "content/common/content_export.h" #include "content/public/browser/notification_database_data.h" -#include "third_party/blink/public/platform/modules/permissions/permission_status.mojom.h" +#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" class GURL; @@ -26,8 +27,6 @@ struct PlatformNotificationData; namespace content { -class BrowserContext; - // The service using which notifications can be presented to the user. There // should be a unique instance of the PlatformNotificationService depending // on the browsing context being used. @@ -42,7 +41,6 @@ class CONTENT_EXPORT PlatformNotificationService { // Displays the notification described in |notification_data| to the user. // This method must be called on the UI thread. virtual void DisplayNotification( - BrowserContext* browser_context, const std::string& notification_id, const GURL& origin, const blink::PlatformNotificationData& notification_data, @@ -51,7 +49,6 @@ class CONTENT_EXPORT PlatformNotificationService { // Displays the persistent notification described in |notification_data| to // the user. This method must be called on the UI thread. virtual void DisplayPersistentNotification( - BrowserContext* browser_context, const std::string& notification_id, const GURL& service_worker_origin, const GURL& origin, @@ -60,29 +57,32 @@ class CONTENT_EXPORT PlatformNotificationService { // Closes the notification identified by |notification_id|. This method must // be called on the UI thread. - virtual void CloseNotification(BrowserContext* browser_context, - const std::string& notification_id) = 0; + virtual void CloseNotification(const std::string& notification_id) = 0; // Closes the persistent notification identified by |notification_id|. This // method must be called on the UI thread. virtual void ClosePersistentNotification( - BrowserContext* browser_context, const std::string& notification_id) = 0; // Retrieves the ids of all currently displaying notifications and // posts |callback| with the result. virtual void GetDisplayedNotifications( - BrowserContext* browser_context, DisplayedNotificationsCallback callback) = 0; + // Schedules a job to run at |timestamp| and call TriggerNotifications + // on all PlatformNotificationContext instances. + virtual void ScheduleTrigger(base::Time timestamp) = 0; + + // Reads the value of the next notification trigger time for this profile. + // This will return base::Time::Max if there is no trigger set. + virtual base::Time ReadNextTriggerTimestamp() = 0; + // Reads the value of the next persistent notification ID from the profile and // increments the value, as it is called once per notification write. - virtual int64_t ReadNextPersistentNotificationId( - BrowserContext* browser_context) = 0; + virtual int64_t ReadNextPersistentNotificationId() = 0; // Records a given notification to UKM. virtual void RecordNotificationUkmEvent( - BrowserContext* browser_context, const NotificationDatabaseData& data) = 0; }; diff --git a/chromium/content/public/browser/posix_file_descriptor_info.h b/chromium/content/public/browser/posix_file_descriptor_info.h index 07e61cf85f3..137dae4e50b 100644 --- a/chromium/content/public/browser/posix_file_descriptor_info.h +++ b/chromium/content/public/browser/posix_file_descriptor_info.h @@ -40,21 +40,21 @@ class PosixFileDescriptorInfo { virtual void Transfer(int id, base::ScopedFD fd) = 0; // A vector backed map of registered ID-FD pairs. - virtual const base::FileHandleMappingVector& GetMapping() const = 0; + virtual const base::FileHandleMappingVector& GetMapping() = 0; // A GetMapping() variant that adjusts the ID value by |delta|. // Some environments need this trick. virtual base::FileHandleMappingVector GetMappingWithIDAdjustment( - int delta) const = 0; + int delta) = 0; // API for iterating over the registered ID-FD pairs. - virtual base::PlatformFile GetFDAt(size_t i) const = 0; - virtual int GetIDAt(size_t i) const = 0; - virtual const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const = 0; - virtual size_t GetMappingSize() const = 0; + virtual base::PlatformFile GetFDAt(size_t i) = 0; + virtual int GetIDAt(size_t i) = 0; + virtual const base::MemoryMappedFile::Region& GetRegionAt(size_t i) = 0; + virtual size_t GetMappingSize() = 0; // Returns true if |this| has ownership of |file|. - virtual bool OwnsFD(base::PlatformFile file) const = 0; + virtual bool OwnsFD(base::PlatformFile file) = 0; // Assuming |OwnsFD(file)|, releases the ownership. virtual base::ScopedFD ReleaseFD(base::PlatformFile file) = 0; }; diff --git a/chromium/content/public/browser/render_frame_host.h b/chromium/content/public/browser/render_frame_host.h index 18ae216594e..056aa14bac7 100644 --- a/chromium/content/public/browser/render_frame_host.h +++ b/chromium/content/public/browser/render_frame_host.h @@ -15,12 +15,12 @@ #include "build/build_config.h" #include "content/common/content_export.h" #include "content/public/browser/page_visibility_state.h" -#include "content/public/common/console_message_level.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_sender.h" #include "services/network/public/mojom/url_loader_factory.mojom-forward.h" #include "third_party/blink/public/common/feature_policy/feature_policy.h" #include "third_party/blink/public/common/frame/sandbox_flags.h" +#include "third_party/blink/public/mojom/devtools/console_message.mojom.h" #include "third_party/blink/public/mojom/loader/pause_subresource_loading_handle.mojom-forward.h" #include "third_party/blink/public/platform/web_sudden_termination_disabler_type.h" #include "ui/accessibility/ax_tree_id.h" @@ -172,29 +172,34 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, virtual gfx::NativeView GetNativeView() = 0; // Adds |message| to the DevTools console. - virtual void AddMessageToConsole(ConsoleMessageLevel level, + virtual void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level, const std::string& message) = 0; - // Runs some JavaScript in this frame's context. If a callback is provided, it - // will be used to return the result, when the result is available. - // This API can only be called on chrome:// or chrome-devtools:// URLs. - typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback; - virtual void ExecuteJavaScript(const base::string16& javascript) = 0; + // Functions to run JavaScript in this frame's context. Pass in a callback to + // receive a result when it is available. If there is no need to receive the + // result, pass in a default-constructed callback. If provided, the callback + // will be invoked on the UI thread. + using JavaScriptResultCallback = base::OnceCallback<void(base::Value)>; + + // This is the default API to run JavaScript in this frame. This API can only + // be called on chrome:// or chrome-devtools:// URLs. virtual void ExecuteJavaScript(const base::string16& javascript, - const JavaScriptResultCallback& callback) = 0; + JavaScriptResultCallback callback) = 0; - // Runs some JavaScript in an isolated world of top of this frame's context. + // This runs the JavaScript in an isolated world of the top of this frame's + // context. virtual void ExecuteJavaScriptInIsolatedWorld( const base::string16& javascript, - const JavaScriptResultCallback& callback, + JavaScriptResultCallback callback, int world_id) = 0; - // ONLY FOR TESTS: Same as above but without restrictions. Optionally, adds a - // fake UserGestureIndicator around execution. (crbug.com/408426) - virtual void ExecuteJavaScriptForTests(const base::string16& javascript) = 0; - virtual void ExecuteJavaScriptForTests( - const base::string16& javascript, - const JavaScriptResultCallback& callback) = 0; + // This runs the JavaScript, but without restrictions. THIS IS ONLY FOR TESTS. + virtual void ExecuteJavaScriptForTests(const base::string16& javascript, + JavaScriptResultCallback callback) = 0; + + // This runs the JavaScript, but without restrictions. THIS IS ONLY FOR TESTS. + // This version adds a fake UserGestureIndicator to test functionality that + // requires such a user gesture. https://crbug.com/408426 virtual void ExecuteJavaScriptWithUserGestureForTests( const base::string16& javascript) = 0; @@ -244,6 +249,11 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // of a frame are defined in Blink. virtual PageVisibilityState GetVisibilityState() = 0; + // Returns true if WebContentsObserver::RenderFrameCreate notification has + // been dispatched for this frame, and so a RenderFrameDeleted notification + // will later be dispatched for this frame. + virtual bool IsRenderFrameCreated() = 0; + // Returns whether the RenderFrame in the renderer process has been created // and still has a connection. This is valid for all frames. virtual bool IsRenderFrameLive() = 0; @@ -279,7 +289,7 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // Returns a bitwise OR of bindings types that have been enabled for this // RenderFrame. See BindingsPolicy for details. - virtual int GetEnabledBindings() const = 0; + virtual int GetEnabledBindings() = 0; #if defined(OS_ANDROID) // Returns an InterfaceProvider for Java-implemented interfaces that are @@ -346,7 +356,7 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, // The effective flags include those which have been set by a // Content-Security-Policy header, in addition to those which are set by the // embedding frame. - virtual bool IsSandboxed(blink::WebSandboxFlags flags) const = 0; + virtual bool IsSandboxed(blink::WebSandboxFlags flags) = 0; // Calls |FlushForTesting()| on Network Service and FrameNavigationControl // related interfaces to make sure all in-flight mojo messages have been diff --git a/chromium/content/public/browser/render_process_host.h b/chromium/content/public/browser/render_process_host.h index 7463db06800..3b3eea6859c 100644 --- a/chromium/content/public/browser/render_process_host.h +++ b/chromium/content/public/browser/render_process_host.h @@ -300,18 +300,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, virtual void EnableAudioDebugRecordings(const base::FilePath& file) = 0; virtual void DisableAudioDebugRecordings() = 0; - // Enables or disables WebRTC's echo canceller AEC3. Disabled implies - // selecting the older AEC2. The operation is asynchronous, |callback| is run - // when done with the boolean indicating if successful and an error message. - // The error message is empty if successful. - // TODO(crbug.com/696930): Remove once the AEC3 is fully rolled out and the - // old AEC is deprecated. - virtual void SetEchoCanceller3( - bool enable, - base::OnceCallback<void(bool /* success */, - const std::string& /* error_message */)> - callback) = 0; - using WebRtcRtpPacketCallback = base::Callback<void(std::unique_ptr<uint8_t[]> packet_header, size_t header_length, @@ -401,9 +389,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, // Returns true if DisableKeepAliveRefCount() was called. virtual bool IsKeepAliveRefCountDisabled() = 0; - // Purges and suspends the renderer process. - virtual void PurgeAndSuspend() = 0; - // Resumes the renderer process. virtual void Resume() = 0; diff --git a/chromium/content/public/browser/render_view_host.h b/chromium/content/public/browser/render_view_host.h index 96b851a90c0..832d14711c5 100644 --- a/chromium/content/public/browser/render_view_host.h +++ b/chromium/content/public/browser/render_view_host.h @@ -63,10 +63,10 @@ class CONTENT_EXPORT RenderViewHost : public IPC::Sender { ~RenderViewHost() override {} // Returns the RenderWidgetHost for this RenderViewHost. - virtual RenderWidgetHost* GetWidget() const = 0; + virtual RenderWidgetHost* GetWidget() = 0; // Returns the RenderProcessHost for this RenderViewHost. - virtual RenderProcessHost* GetProcess() const = 0; + virtual RenderProcessHost* GetProcess() = 0; // Returns the routing id for IPC use for this RenderViewHost. // @@ -74,7 +74,7 @@ class CONTENT_EXPORT RenderViewHost : public IPC::Sender { // and shared its IPC channel and its routing ID. Although this inheritance is // no longer so, the IPC channel is currently still shared. Expect this to // change. - virtual int GetRoutingID() const = 0; + virtual int GetRoutingID() = 0; // Returns the main frame for this render view. virtual RenderFrameHost* GetMainFrame() = 0; @@ -87,12 +87,12 @@ class CONTENT_EXPORT RenderViewHost : public IPC::Sender { virtual void ExecutePluginActionAtLocation( const gfx::Point& location, const blink::WebPluginAction& action) = 0; - virtual RenderViewHostDelegate* GetDelegate() const = 0; + virtual RenderViewHostDelegate* GetDelegate() = 0; - virtual SiteInstance* GetSiteInstance() const = 0; + virtual SiteInstance* GetSiteInstance() = 0; // Returns true if the RenderView is active and has not crashed. - virtual bool IsRenderViewLive() const = 0; + virtual bool IsRenderViewLive() = 0; // Notification that a move or resize renderer's containing window has // started. diff --git a/chromium/content/public/browser/render_widget_host.h b/chromium/content/public/browser/render_widget_host.h index 4b98057e09f..cd4be08544a 100644 --- a/chromium/content/public/browser/render_widget_host.h +++ b/chromium/content/public/browser/render_widget_host.h @@ -188,21 +188,18 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Sender { virtual void ForwardGestureEvent( const blink::WebGestureEvent& gesture_event) = 0; - virtual RenderProcessHost* GetProcess() const = 0; + virtual RenderProcessHost* GetProcess() = 0; - virtual int GetRoutingID() const = 0; + virtual int GetRoutingID() = 0; // Gets the View of this RenderWidgetHost. Can be nullptr, e.g. if the // RenderWidget is being destroyed or the render process crashed. You should // never cache this pointer since it can become nullptr if the renderer // crashes, instead you should always ask for it using the accessor. - virtual RenderWidgetHostView* GetView() const = 0; - - // Returns true if the renderer is loading, false if not. - virtual bool IsLoading() const = 0; + virtual RenderWidgetHostView* GetView() = 0; // Returns true if the renderer is considered unresponsive. - virtual bool IsCurrentlyUnresponsive() const = 0; + virtual bool IsCurrentlyUnresponsive() = 0; // Called to propagate updated visual properties to the renderer. Returns // whether the renderer has been informed of updated properties. diff --git a/chromium/content/public/browser/render_widget_host_view.h b/chromium/content/public/browser/render_widget_host_view.h index d02f832a994..ebe6ae74f31 100644 --- a/chromium/content/public/browser/render_widget_host_view.h +++ b/chromium/content/public/browser/render_widget_host_view.h @@ -61,7 +61,7 @@ class CONTENT_EXPORT RenderWidgetHostView { virtual void InitAsChild(gfx::NativeView parent_view) = 0; // Returns the associated RenderWidgetHost. - virtual RenderWidgetHost* GetRenderWidgetHost() const = 0; + virtual RenderWidgetHost* GetRenderWidgetHost() = 0; // Tells the View to size itself to the specified size. virtual void SetSize(const gfx::Size& size) = 0; @@ -79,7 +79,7 @@ class CONTENT_EXPORT RenderWidgetHostView { virtual void SetBounds(const gfx::Rect& rect) = 0; // Indicates whether the scroll offset of the view is at top. - virtual bool IsScrollOffsetAtTop() const = 0; + virtual bool IsScrollOffsetAtTop() = 0; // Sets a flag that indicates if it is in virtual reality mode. virtual void SetIsInVR(bool is_in_vr) = 0; @@ -106,7 +106,7 @@ class CONTENT_EXPORT RenderWidgetHostView { // Retrieves the native view used to contain plugins and identify the // renderer in IPC messages. - virtual gfx::NativeView GetNativeView() const = 0; + virtual gfx::NativeView GetNativeView() = 0; virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; // Returns a ui::TextInputClient to support text input or nullptr if this RWHV @@ -119,7 +119,7 @@ class CONTENT_EXPORT RenderWidgetHostView { // Set focus to the associated View component. virtual void Focus() = 0; // Returns true if the View currently has the focus. - virtual bool HasFocus() const = 0; + virtual bool HasFocus() = 0; // Shows/hides the view. These must always be called together in pairs. // It is not legal to call Hide() multiple times in a row. @@ -136,7 +136,7 @@ class CONTENT_EXPORT RenderWidgetHostView { virtual void WasOccluded() = 0; // Retrieve the bounds of the View, in screen coordinates. - virtual gfx::Rect GetViewBounds() const = 0; + virtual gfx::Rect GetViewBounds() = 0; // Returns the currently selected text in both of editable text fields and // non-editable texts. @@ -155,7 +155,7 @@ class CONTENT_EXPORT RenderWidgetHostView { // which is shown if the background color of the renderer is not available. virtual void SetBackgroundColor(SkColor color) = 0; // GetBackgroundColor returns the current background color of the view. - virtual base::Optional<SkColor> GetBackgroundColor() const = 0; + virtual base::Optional<SkColor> GetBackgroundColor() = 0; // Return value indicates whether the mouse is locked successfully or not. virtual bool LockMouse() = 0; @@ -178,14 +178,14 @@ class CONTENT_EXPORT RenderWidgetHostView { // Retrives the size of the viewport for the visible region. May be smaller // than the view size if a portion of the view is obstructed (e.g. by a // virtual keyboard). - virtual gfx::Size GetVisibleViewportSize() const = 0; + virtual gfx::Size GetVisibleViewportSize() = 0; // Set insets for the visible region of the root window. Used to compute the // visible viewport. virtual void SetInsets(const gfx::Insets& insets) = 0; // Returns true if the current display surface is available. - virtual bool IsSurfaceAvailableForCopy() const = 0; + virtual bool IsSurfaceAvailableForCopy() = 0; // Copies the given subset of the view's surface, optionally scales it, and // returns the result as a bitmap via the provided callback. This is meant for @@ -241,10 +241,10 @@ class CONTENT_EXPORT RenderWidgetHostView { // This method returns the ScreenInfo used by the view to render. If the // information is not knowable (e.g, because the view is not attached to a // screen yet), then a default best-guess will be used. - virtual void GetScreenInfo(ScreenInfo* screen_info) const = 0; + virtual void GetScreenInfo(ScreenInfo* screen_info) = 0; // This must always return the same device scale factor as GetScreenInfo. - virtual float GetDeviceScaleFactor() const = 0; + virtual float GetDeviceScaleFactor() = 0; #if defined(OS_MACOSX) // Set the view's active state (i.e., tint state of controls). @@ -260,6 +260,10 @@ class CONTENT_EXPORT RenderWidgetHostView { // Indicates that this view should show the contents of |view| if it doesn't // have anything to show. virtual void TakeFallbackContentFrom(RenderWidgetHostView* view) = 0; + + // Set the last time a tab change starts to be processed for this + // RenderWidgetHostView. Will overwrite any previously stored value. + virtual void SetLastTabChangeStartTime(base::TimeTicks start_time) = 0; }; } // namespace content diff --git a/chromium/content/public/browser/renderer_preferences_util.cc b/chromium/content/public/browser/renderer_preferences_util.cc index b7de4425dc3..fee03cb7024 100644 --- a/chromium/content/public/browser/renderer_preferences_util.cc +++ b/chromium/content/public/browser/renderer_preferences_util.cc @@ -12,10 +12,6 @@ #include "third_party/blink/public/mojom/renderer_preferences.mojom.h" #include "ui/gfx/font_render_params.h" -#if defined(OS_ANDROID) -#include "content/browser/android/android_ui_constants.h" -#endif - namespace content { void UpdateFontRendererPreferencesFromSystemSettings( @@ -30,22 +26,4 @@ void UpdateFontRendererPreferencesFromSystemSettings( prefs->subpixel_rendering = params->subpixel_rendering; } -void UpdateFocusRingPreferencesFromSystemSettings( - blink::mojom::RendererPreferences* prefs) { -#if defined(OS_ANDROID) - prefs->is_focus_ring_outset = AndroidUiConstants::IsFocusRingOutset(); - - base::Optional<float> stroke_width = - AndroidUiConstants::GetMinimumStrokeWidthForFocusRing(); - if (stroke_width) - prefs->minimum_stroke_width_for_focus_ring = *stroke_width; - - base::Optional<SkColor> color = AndroidUiConstants::GetFocusRingColor(); - if (color) { - prefs->use_custom_colors = true; - prefs->focus_ring_color = *color; - } -#endif -} - } // namespace content diff --git a/chromium/content/public/browser/renderer_preferences_util.h b/chromium/content/public/browser/renderer_preferences_util.h index bfd5be80907..eb81d84f0f6 100644 --- a/chromium/content/public/browser/renderer_preferences_util.h +++ b/chromium/content/public/browser/renderer_preferences_util.h @@ -19,9 +19,6 @@ namespace content { CONTENT_EXPORT void UpdateFontRendererPreferencesFromSystemSettings( blink::mojom::RendererPreferences* prefs); -CONTENT_EXPORT void UpdateFocusRingPreferencesFromSystemSettings( - blink::mojom::RendererPreferences* prefs); - } // namespace content #endif // CONTENT_PUBLIC_BROWSER_RENDERER_PREFERENCES_UTIL_H_ diff --git a/chromium/content/public/browser/security_style_explanations.cc b/chromium/content/public/browser/security_style_explanations.cc index a047830ce6c..b18aeb760df 100644 --- a/chromium/content/public/browser/security_style_explanations.cc +++ b/chromium/content/public/browser/security_style_explanations.cc @@ -7,15 +7,7 @@ namespace content { SecurityStyleExplanations::SecurityStyleExplanations() - : ran_mixed_content(false), - displayed_mixed_content(false), - contained_mixed_form(false), - ran_content_with_cert_errors(false), - displayed_content_with_cert_errors(false), - ran_insecure_content_style(blink::kWebSecurityStyleUnknown), - displayed_insecure_content_style(blink::kWebSecurityStyleUnknown), - scheme_is_cryptographic(false), - pkp_bypassed(false) {} + : scheme_is_cryptographic(false) {} SecurityStyleExplanations::SecurityStyleExplanations( const SecurityStyleExplanations& other) = default; diff --git a/chromium/content/public/browser/security_style_explanations.h b/chromium/content/public/browser/security_style_explanations.h index b3026dd49de..5dd0047737c 100644 --- a/chromium/content/public/browser/security_style_explanations.h +++ b/chromium/content/public/browser/security_style_explanations.h @@ -5,6 +5,7 @@ #ifndef CONTENT_PUBLIC_BROWSER_SECURITY_STYLE_EXPLANATIONS_H_ #define CONTENT_PUBLIC_BROWSER_SECURITY_STYLE_EXPLANATIONS_H_ +#include <string> #include <vector> #include "content/common/content_export.h" @@ -30,43 +31,8 @@ struct CONTENT_EXPORT SecurityStyleExplanations { SecurityStyleExplanations(const SecurityStyleExplanations& other); ~SecurityStyleExplanations(); - // True if the page was loaded over HTTPS and ran mixed (HTTP) content - // such as scripts. - bool ran_mixed_content; - // True if the page was loaded over HTTPS and displayed mixed (HTTP) - // content such as images. - bool displayed_mixed_content; - // True if the page was loaded over HTTPS and contained a form targeting a - // nonsecure url. - bool contained_mixed_form; - // True if the page was loaded over HTTPS without certificate errors, - // but ran subresources, such as scripts, that were loaded over HTTPS - // with certificate errors. - bool ran_content_with_cert_errors; - // True if the page was loaded over HTTPS without certificate errors, - // but displayed subresources, such as images, that were loaded over HTTPS - // with certificate errors. - bool displayed_content_with_cert_errors; - - // The SecurityStyle assigned to a page that runs or displays insecure - // content, respectively. Insecure content can be either HTTP - // subresources loaded on an HTTPS page (mixed content), or HTTPS - // subresources loaded with certificate errors on an HTTPS page. - // - // These values are used to convey the effect - // that insecure content has on the overall SecurityStyle of the page; - // for example, a |displayed_insecure_content_style| value of - // WebSecurityStyleUnauthenticated indicates that the page's overall - // SecurityStyle will be downgraded to Unauthenticated as a result of - // displaying insecure content. - blink::WebSecurityStyle ran_insecure_content_style; - blink::WebSecurityStyle displayed_insecure_content_style; - bool scheme_is_cryptographic; - // True if PKP was bypassed due to a local trust anchor. - bool pkp_bypassed; - // User-visible summary of the security style, set only when // the style cannot be determined from HTTPS status alone. std::string summary; diff --git a/chromium/content/public/browser/service_worker_context.h b/chromium/content/public/browser/service_worker_context.h index a283d436f8e..2e1e9160d8d 100644 --- a/chromium/content/public/browser/service_worker_context.h +++ b/chromium/content/public/browser/service_worker_context.h @@ -11,6 +11,7 @@ #include "base/callback_forward.h" #include "content/common/content_export.h" +#include "content/public/browser/service_worker_running_info.h" #include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom-forward.h" #include "url/gurl.h" @@ -72,6 +73,12 @@ class ServiceWorkerContext { using StartWorkerCallback = base::OnceCallback< void(int64_t version_id, int process_id, int thread_id)>; + using GetAllServiceWorkerRunningInfosCallback = + base::OnceCallback<void(ServiceWorkerContext*, + const std::vector<ServiceWorkerRunningInfo>)>; + using GetServiceWorkerRunningInfoCallback = + base::OnceCallback<void(ServiceWorkerContext*, + const ServiceWorkerRunningInfo&)>; // Returns true if |url| is within the service worker |scope|. CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url); @@ -225,6 +232,20 @@ class ServiceWorkerContext { // The |callback| is called on the caller's thread. virtual void StopAllServiceWorkers(base::OnceClosure callback) = 0; + // Gets info about all running workers. + // + // Must be called on the UI thread. The callback is called on the UI thread. + virtual void GetAllServiceWorkerRunningInfos( + GetAllServiceWorkerRunningInfosCallback callback) = 0; + + // Gets info of the running worker whose version id is + // |service_worker_version_id|. + // + // Must be called on the UI thread. The callback is called on the UI thread. + virtual void GetServiceWorkerRunningInfo( + int64_t service_worker_version_id, + GetServiceWorkerRunningInfoCallback callback) = 0; + protected: ServiceWorkerContext() {} virtual ~ServiceWorkerContext() {} diff --git a/chromium/content/public/browser/service_worker_context_observer.h b/chromium/content/public/browser/service_worker_context_observer.h index 84de4825f5c..4b72a388d59 100644 --- a/chromium/content/public/browser/service_worker_context_observer.h +++ b/chromium/content/public/browser/service_worker_context_observer.h @@ -9,6 +9,7 @@ namespace content { struct ConsoleMessage; +class ServiceWorkerContext; class ServiceWorkerContextObserver { public: @@ -27,6 +28,19 @@ class ServiceWorkerContextObserver { // redundant. virtual void OnVersionRedundant(int64_t version_id, const GURL& scope) {} + // Called when the service worker with id |version_id| starts or stops + // running. + // + // This function is currently only called after a worker finishes + // starting/stopping or the version is destroyed before finishing + // stopping. That is, a worker in the process of starting is not yet + // considered running, even if it's executing JavaScript. See TODO in + // ServiceWorkerContextWrapper::OnRunningStateChanged. + virtual void OnVersionRunningStatusChanged( + content::ServiceWorkerContext* context, + int64_t version_id, + bool is_running) {} + // 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) {} @@ -36,6 +50,9 @@ class ServiceWorkerContextObserver { virtual void OnReportConsoleMessage(int64_t version_id, const ConsoleMessage& message) {} + // Called when |context| is destroyed. Observers must no longer use |context|. + virtual void OnDestruct(content::ServiceWorkerContext* context) {} + protected: virtual ~ServiceWorkerContextObserver() {} }; diff --git a/chromium/content/public/browser/service_worker_running_info.h b/chromium/content/public/browser/service_worker_running_info.h new file mode 100644 index 00000000000..83e2b100949 --- /dev/null +++ b/chromium/content/public/browser/service_worker_running_info.h @@ -0,0 +1,36 @@ +// 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_SERVICE_WORKER_RUNNING_INFO_H_ +#define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_RUNNING_INFO_H_ + +#include "content/common/content_export.h" +#include "content/public/common/child_process_host.h" +#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom.h" +#include "url/gurl.h" + +namespace content { + +// A struct containing information about a running service worker. +struct CONTENT_EXPORT ServiceWorkerRunningInfo { + ServiceWorkerRunningInfo(const GURL& script_url, + int64_t id, + int64_t process_id) + : script_url(script_url), version_id(id), process_id(process_id) {} + + ServiceWorkerRunningInfo() = default; + + // The service worker script URL. + const GURL script_url; + + // The unique identifier for this service worker within the same + // ServiceWorkerContext. + const int64_t version_id = blink::mojom::kInvalidServiceWorkerVersionId; + + const int process_id = content::ChildProcessHost::kInvalidUniqueID; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_RUNNING_INFO_H_ diff --git a/chromium/content/public/browser/site_instance.h b/chromium/content/public/browser/site_instance.h index 050707af9e4..e3b2796e1d5 100644 --- a/chromium/content/public/browser/site_instance.h +++ b/chromium/content/public/browser/site_instance.h @@ -187,6 +187,12 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance> { // Note that this has no effect if site isolation is turned off, such as via // the kDisableSiteIsolation cmdline flag or enterprise policy -- see also // SiteIsolationPolicy::AreDynamicIsolatedOriginsEnabled(). + // + // Currently this function assumes that the site is added *persistently*: it + // will ask the embedder to save the site as part of profile data for + // |context|, so that it survives restarts. The site will be cleared from + // profile data if the user clears browsing data. Future uses of this + // function may want to avoid persistence by passing in a new flag. static void StartIsolatingSite(BrowserContext* context, const GURL& url); protected: diff --git a/chromium/content/public/browser/site_isolation_policy.cc b/chromium/content/public/browser/site_isolation_policy.cc index 0f23b9ca653..52b515f00fb 100644 --- a/chromium/content/public/browser/site_isolation_policy.cc +++ b/chromium/content/public/browser/site_isolation_policy.cc @@ -76,8 +76,10 @@ void SiteIsolationPolicy::PopulateURLLoaderFactoryParamsPtrForCORB( } params->is_corb_enabled = true; - params->corb_detachable_resource_type = RESOURCE_TYPE_PREFETCH; - params->corb_excluded_resource_type = RESOURCE_TYPE_PLUGIN_RESOURCE; + params->corb_detachable_resource_type = + static_cast<int>(ResourceType::kPrefetch); + params->corb_excluded_resource_type = + static_cast<int>(ResourceType::kPluginResource); } // static diff --git a/chromium/content/public/browser/site_isolation_policy.h b/chromium/content/public/browser/site_isolation_policy.h index d236aa4c9db..793b9fb176b 100644 --- a/chromium/content/public/browser/site_isolation_policy.h +++ b/chromium/content/public/browser/site_isolation_policy.h @@ -62,12 +62,11 @@ class CONTENT_EXPORT SiteIsolationPolicy { // called once on browser startup. static void StartRecordingSiteIsolationFlagUsage(); - private: - SiteIsolationPolicy(); // Not instantiable. - // Parses |arg| into a list of origins. static std::vector<url::Origin> ParseIsolatedOrigins(base::StringPiece arg); - FRIEND_TEST_ALL_PREFIXES(SiteIsolationPolicyTest, ParseIsolatedOrigins); + + private: + SiteIsolationPolicy(); // Not instantiable. // Gets isolated origins from cmdline and/or from field trial param. static std::vector<url::Origin> GetIsolatedOriginsFromEnvironment(); diff --git a/chromium/content/public/browser/storage_partition.h b/chromium/content/public/browser/storage_partition.h index f3bf35ed1ff..de7455a49e3 100644 --- a/chromium/content/public/browser/storage_partition.h +++ b/chromium/content/public/browser/storage_partition.h @@ -160,8 +160,8 @@ class CONTENT_EXPORT StoragePartition { // A callback type to check if a given origin matches a storage policy. // Can be passed empty/null where used, which means the origin will always // match. - typedef base::Callback<bool(const GURL&, storage::SpecialStoragePolicy*)> - OriginMatcherFunction; + using OriginMatcherFunction = + base::Callback<bool(const url::Origin&, storage::SpecialStoragePolicy*)>; // Similar to ClearDataForOrigin(). // Deletes all data out for the StoragePartition if |storage_origin| is empty. diff --git a/chromium/content/public/browser/tracing_controller.h b/chromium/content/public/browser/tracing_controller.h index c2e3e98d8bd..a26f45e9db1 100644 --- a/chromium/content/public/browser/tracing_controller.h +++ b/chromium/content/public/browser/tracing_controller.h @@ -121,7 +121,7 @@ class TracingController { virtual bool GetTraceBufferUsage(GetTraceBufferUsageCallback callback) = 0; // Check if the tracing system is tracing - virtual bool IsTracing() const = 0; + virtual bool IsTracing() = 0; protected: virtual ~TracingController() {} diff --git a/chromium/content/public/browser/tts_controller_delegate.h b/chromium/content/public/browser/tts_controller_delegate.h index 58070f81168..57b1c3200b2 100644 --- a/chromium/content/public/browser/tts_controller_delegate.h +++ b/chromium/content/public/browser/tts_controller_delegate.h @@ -15,7 +15,7 @@ class TtsControllerDelegate { public: // Given an utterance and a vector of voices, return the // index of the voice that best matches the utterance. - virtual int GetMatchingVoice(const TtsUtterance* utterance, + virtual int GetMatchingVoice(TtsUtterance* utterance, std::vector<VoiceData>& voices) = 0; // Uses the user preferences to update the |rate|, |pitch| and |volume| for diff --git a/chromium/content/public/browser/tts_platform.h b/chromium/content/public/browser/tts_platform.h index e3448339a95..3f26101add6 100644 --- a/chromium/content/public/browser/tts_platform.h +++ b/chromium/content/public/browser/tts_platform.h @@ -62,7 +62,7 @@ class CONTENT_EXPORT TtsPlatform { // Allows the platform to monitor speech commands and the voices used // for each one. - virtual void WillSpeakUtteranceWithVoice(const TtsUtterance* utterance, + virtual void WillSpeakUtteranceWithVoice(TtsUtterance* utterance, const VoiceData& voice_data) = 0; virtual std::string GetError() = 0; diff --git a/chromium/content/public/browser/tts_utterance.h b/chromium/content/public/browser/tts_utterance.h index 534e6144326..68ef1b9430a 100644 --- a/chromium/content/public/browser/tts_utterance.h +++ b/chromium/content/public/browser/tts_utterance.h @@ -78,10 +78,10 @@ class CONTENT_EXPORT TtsUtterance { // Getters and setters for the text to speak and other speech options. virtual void SetText(const std::string& text) = 0; - virtual const std::string& GetText() const = 0; + virtual const std::string& GetText() = 0; virtual void SetOptions(const base::Value* options) = 0; - virtual const base::Value* GetOptions() const = 0; + virtual const base::Value* GetOptions() = 0; virtual void SetSrcId(int src_id) = 0; virtual int GetSrcId() = 0; @@ -90,10 +90,10 @@ class CONTENT_EXPORT TtsUtterance { virtual const GURL& GetSrcUrl() = 0; virtual void SetVoiceName(const std::string& voice_name) = 0; - virtual const std::string& GetVoiceName() const = 0; + virtual const std::string& GetVoiceName() = 0; virtual void SetLang(const std::string& lang) = 0; - virtual const std::string& GetLang() const = 0; + virtual const std::string& GetLang() = 0; virtual void SetContinuousParameters(const double rate, const double pitch, @@ -101,24 +101,24 @@ class CONTENT_EXPORT TtsUtterance { virtual const UtteranceContinuousParameters& GetContinuousParameters() = 0; virtual void SetCanEnqueue(bool can_enqueue) = 0; - virtual bool GetCanEnqueue() const = 0; + virtual bool GetCanEnqueue() = 0; virtual void SetRequiredEventTypes(const std::set<TtsEventType>& types) = 0; - virtual const std::set<TtsEventType>& GetRequiredEventTypes() const = 0; + virtual const std::set<TtsEventType>& GetRequiredEventTypes() = 0; virtual void SetDesiredEventTypes(const std::set<TtsEventType>& types) = 0; - virtual const std::set<TtsEventType>& GetDesiredEventTypes() const = 0; + virtual const std::set<TtsEventType>& GetDesiredEventTypes() = 0; virtual void SetEngineId(const std::string& engine_id) = 0; - virtual const std::string& GetEngineId() const = 0; + virtual const std::string& GetEngineId() = 0; virtual void SetEventDelegate(UtteranceEventDelegate* event_delegate) = 0; - virtual UtteranceEventDelegate* GetEventDelegate() const = 0; + virtual UtteranceEventDelegate* GetEventDelegate() = 0; // Getters and setters for internal state. - virtual BrowserContext* GetBrowserContext() const = 0; - virtual int GetId() const = 0; - virtual bool IsFinished() const = 0; + virtual BrowserContext* GetBrowserContext() = 0; + virtual int GetId() = 0; + virtual bool IsFinished() = 0; }; } // namespace content diff --git a/chromium/content/public/browser/web_contents.h b/chromium/content/public/browser/web_contents.h index 2fe0a25aed9..6cf2ca2a0ec 100644 --- a/chromium/content/public/browser/web_contents.h +++ b/chromium/content/public/browser/web_contents.h @@ -361,8 +361,8 @@ class WebContents : public PageNavigator, virtual RenderWidgetHostView* GetFullscreenRenderWidgetHostView() = 0; // Returns the theme color for the underlying content as set by the - // theme-color meta tag. - virtual SkColor GetThemeColor() = 0; + // theme-color meta tag if any. + virtual base::Optional<SkColor> GetThemeColor() = 0; // Returns the committed WebUI if one exists, otherwise the pending one. virtual WebUI* GetWebUI() = 0; @@ -474,6 +474,10 @@ class WebContents : public PageNavigator, // Device. virtual bool IsConnectedToBluetoothDevice() = 0; + // Indicates whether any frame in the WebContents is connected to a serial + // port. + virtual bool IsConnectedToSerialPort() const = 0; + // Indicates whether a video is in Picture-in-Picture for |this|. virtual bool HasPictureInPictureVideo() = 0; diff --git a/chromium/content/public/browser/web_contents_delegate.cc b/chromium/content/public/browser/web_contents_delegate.cc index 51bc80f0f78..b077a21e537 100644 --- a/chromium/content/public/browser/web_contents_delegate.cc +++ b/chromium/content/public/browser/web_contents_delegate.cc @@ -76,11 +76,10 @@ bool WebContentsDelegate::TakeFocus(WebContents* source, bool reverse) { return false; } -void WebContentsDelegate::CanDownload( - const GURL& url, - const std::string& request_method, - const base::Callback<void(bool)>& callback) { - callback.Run(true); +void WebContentsDelegate::CanDownload(const GURL& url, + const std::string& request_method, + base::OnceCallback<void(bool)> callback) { + std::move(callback).Run(true); } bool WebContentsDelegate::HandleContextMenu(RenderFrameHost* render_frame_host, @@ -211,12 +210,12 @@ bool WebContentsDelegate::ShouldBlockMediaRequest(const GURL& url) { } #endif -bool WebContentsDelegate::RequestPpapiBrokerPermission( +void WebContentsDelegate::RequestPpapiBrokerPermission( WebContents* web_contents, const GURL& url, const base::FilePath& plugin_path, - const base::Callback<void(bool)>& callback) { - return false; + base::OnceCallback<void(bool)> callback) { + std::move(callback).Run(false); } WebContentsDelegate::~WebContentsDelegate() { diff --git a/chromium/content/public/browser/web_contents_delegate.h b/chromium/content/public/browser/web_contents_delegate.h index cb139112070..3789137953a 100644 --- a/chromium/content/public/browser/web_contents_delegate.h +++ b/chromium/content/public/browser/web_contents_delegate.h @@ -243,7 +243,7 @@ class CONTENT_EXPORT WebContentsDelegate { // Invoking the |callback| synchronously is OK. virtual void CanDownload(const GURL& url, const std::string& request_method, - const base::Callback<void(bool)>& callback); + base::OnceCallback<void(bool)> callback); // Returns true if the context menu operation was handled by the delegate. virtual bool HandleContextMenu(RenderFrameHost* render_frame_host, @@ -520,14 +520,14 @@ class CONTENT_EXPORT WebContentsDelegate { virtual void SetOverlayMode(bool use_overlay_mode) {} #endif - // Requests permission to access the PPAPI broker. The delegate should return - // true and call the passed in |callback| with the result, or return false + // Requests permission to access the PPAPI broker. The delegate must either + // call the passed in |callback| with the result, or call it with false // to indicate that it does not support asking for permission. - virtual bool RequestPpapiBrokerPermission( + virtual void RequestPpapiBrokerPermission( WebContents* web_contents, const GURL& url, const base::FilePath& plugin_path, - const base::Callback<void(bool)>& callback); + base::OnceCallback<void(bool)> callback); // Returns the size for the new render view created for the pending entry in // |web_contents|; if there's no size, returns an empty size. diff --git a/chromium/content/public/browser/web_contents_observer.cc b/chromium/content/public/browser/web_contents_observer.cc index 8f2128db8f3..7ddad66ffde 100644 --- a/chromium/content/public/browser/web_contents_observer.cc +++ b/chromium/content/public/browser/web_contents_observer.cc @@ -6,7 +6,6 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/navigation_details.h" -#include "content/public/browser/render_view_host.h" namespace content { @@ -24,35 +23,6 @@ WebContentsObserver::~WebContentsObserver() { web_contents_->RemoveObserver(this); } -WebContentsObserver::MediaPlayerId::MediaPlayerId( - RenderFrameHost* render_frame_host, - int delegate_id) - : render_frame_host(render_frame_host), delegate_id(delegate_id) {} - -WebContentsObserver::MediaPlayerId -WebContentsObserver::MediaPlayerId::createMediaPlayerIdForTests() { - return WebContentsObserver::MediaPlayerId(); -} - -bool WebContentsObserver::MediaPlayerId::operator==( - WebContentsObserver::MediaPlayerId const& other) const { - return render_frame_host == other.render_frame_host && - delegate_id == other.delegate_id; -} - -bool WebContentsObserver::MediaPlayerId::operator!=( - const MediaPlayerId& other) const { - return render_frame_host != other.render_frame_host || - delegate_id != other.delegate_id; -} - -bool WebContentsObserver::MediaPlayerId::operator<( - const MediaPlayerId& other) const { - if (render_frame_host == other.render_frame_host) - return delegate_id < other.delegate_id; - return render_frame_host < other.render_frame_host; -} - WebContents* WebContentsObserver::web_contents() const { return web_contents_; } diff --git a/chromium/content/public/browser/web_contents_observer.h b/chromium/content/public/browser/web_contents_observer.h index d35cdd3a4aa..68273fe6e3e 100644 --- a/chromium/content/public/browser/web_contents_observer.h +++ b/chromium/content/public/browser/web_contents_observer.h @@ -51,6 +51,7 @@ struct AXLocationChangeNotificationDetails; struct EntryChangedDetails; struct FaviconURL; struct LoadCommittedDetails; +struct MediaPlayerId; struct PrunedDetails; struct Referrer; @@ -472,7 +473,7 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { const std::vector<AXLocationChangeNotificationDetails>& details) {} // Invoked when theme color is changed to |theme_color|. - virtual void DidChangeThemeColor(SkColor theme_color) {} + virtual void DidChangeThemeColor(base::Optional<SkColor> theme_color) {} // Invoked when media is playing or paused. |id| is unique per player and per // RenderFrameHost. There may be multiple players within a RenderFrameHost @@ -489,23 +490,6 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener { bool has_audio; }; - struct CONTENT_EXPORT MediaPlayerId { - public: - static MediaPlayerId createMediaPlayerIdForTests(); - - MediaPlayerId(RenderFrameHost* render_frame_host, int delegate_id); - - bool operator==(const MediaPlayerId& other) const; - bool operator!=(const MediaPlayerId& other) const; - bool operator<(const MediaPlayerId& other) const; - - RenderFrameHost* render_frame_host = nullptr; - int delegate_id = 0; - - private: - MediaPlayerId() = default; - }; - virtual void MediaStartedPlaying(const MediaPlayerInfo& video_type, const MediaPlayerId& id) {} enum class MediaStoppedReason { diff --git a/chromium/content/public/browser/web_contents_user_data.h b/chromium/content/public/browser/web_contents_user_data.h index 74a657fe7ff..28996e5253e 100644 --- a/chromium/content/public/browser/web_contents_user_data.h +++ b/chromium/content/public/browser/web_contents_user_data.h @@ -10,10 +10,6 @@ #include "base/supports_user_data.h" #include "content/public/browser/web_contents.h" -#define WEB_CONTENTS_USER_DATA_KEY_DECL() static constexpr int kUserDataKey = 0 - -#define WEB_CONTENTS_USER_DATA_KEY_IMPL(Type) const int Type::kUserDataKey; - namespace content { // A base class for classes attached to, and scoped to, the lifetime of a @@ -59,6 +55,23 @@ class WebContentsUserData : public base::SupportsUserData::Data { static const void* UserDataKey() { return &T::kUserDataKey; } }; +// This macro declares a static variable inside the class that inherits from +// WebContentsUserData The address of this static variable is used as the key to +// store/retrieve an instance of the class on/from a WebState. +#define WEB_CONTENTS_USER_DATA_KEY_DECL() static constexpr int kUserDataKey = 0 + +// This macro instantiates the static variable declared by the previous macro. +// It must live in a .cc file to ensure that there is only one instantiation +// of the static variable. +#define WEB_CONTENTS_USER_DATA_KEY_IMPL(Type) const int Type::kUserDataKey; + +// We tried using the address of a static local variable in UserDataKey() as a +// key instead of the address of a member variable. That solution allowed us to +// get rid of the macros above. Unfortately, each dynamic library that accessed +// UserDataKey() had its own instantiation of the method, resulting in different +// keys for the same WebContentsUserData type. Because of that, the solution was +// reverted. https://crbug.com/589840#c16 + } // namespace content #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_USER_DATA_H_ diff --git a/chromium/content/public/browser/web_ui_data_source.h b/chromium/content/public/browser/web_ui_data_source.h index 7acb32b3a68..bdcfff5bc9c 100644 --- a/chromium/content/public/browser/web_ui_data_source.h +++ b/chromium/content/public/browser/web_ui_data_source.h @@ -83,14 +83,24 @@ class WebUIDataSource { GotDataCallback; // Used by SetRequestFilter. The string parameter is the path of the request. - // If the callee doesn't want to handle the data, false is returned. Otherwise - // true is returned and the GotDataCallback parameter is called either then or - // asynchronously with the response. - typedef base::Callback<bool(const std::string&, const GotDataCallback&)> + // The return value indicates if the callee wants to handle the request. Iff + // true is returned, |handle_request_callback| will be called to provide the + // request's response. + typedef base::RepeatingCallback<bool(const std::string&)> + ShouldHandleRequestCallback; + + // Used by SetRequestFilter. The string parameter is the path of the request. + // This callback is only called if a prior call to ShouldHandleRequestCallback + // returned true. GotDataCallback should be used to provide the response + // bytes. + typedef base::RepeatingCallback<void(const std::string&, + const GotDataCallback&)> HandleRequestCallback; // Allows a caller to add a filter for URL requests. - virtual void SetRequestFilter(const HandleRequestCallback& callback) = 0; + virtual void SetRequestFilter( + const ShouldHandleRequestCallback& should_handle_request_callback, + const HandleRequestCallback& handle_request_callback) = 0; // The following map to methods on URLDataSource. See the documentation there. // NOTE: it's not acceptable to call DisableContentSecurityPolicy for new |