chromium/third_party/blink/public/mojom/worker/shared_worker_factory.mojom

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

import "mojo/public/mojom/base/unguessable_token.mojom";
import "third_party/blink/public/mojom/user_agent/user_agent_metadata.mojom";
import "third_party/blink/public/mojom/browser_interface_broker.mojom";
import "third_party/blink/public/mojom/loader/url_loader_factory_bundle.mojom";
import "third_party/blink/public/mojom/renderer_preference_watcher.mojom";
import "third_party/blink/public/mojom/frame/policy_container.mojom";
import "third_party/blink/public/mojom/renderer_preferences.mojom";
import "third_party/blink/public/mojom/service_worker/controller_service_worker.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_container.mojom";
import "third_party/blink/public/mojom/storage_key/storage_key.mojom";
import "third_party/blink/public/mojom/tokens/tokens.mojom";
import "third_party/blink/public/mojom/worker/shared_worker.mojom";
import "third_party/blink/public/mojom/worker/shared_worker_host.mojom";
import "third_party/blink/public/mojom/worker/shared_worker_info.mojom";
import "third_party/blink/public/mojom/worker/worker_content_settings_proxy.mojom";
import "third_party/blink/public/mojom/worker/worker_main_script_load_params.mojom";
import "url/mojom/origin.mojom";

// The name of the InterfaceProviderSpec in service manifests used by the
// frame tree to expose shared-worker-specific interfaces between renderer and
// browser.
const string kNavigation_SharedWorkerSpec = "navigation:shared_worker";

// This interface is used to instantiate a shared worker. It is exported from a
// renderer process where the shared worker should run. The method on this
// interface is called by the browser process.
interface SharedWorkerFactory {
  // Create a new shared worker. The |host| interface receives events from the
  // shared worker.
  //
  // TODO(sammc): Change shared workers to obtain |content_settings| via
  // |browser_interface_broker| instead of receiving plumbing it here.
  CreateSharedWorker(
      SharedWorkerInfo info,

      // The token that uniquely identifies this worker. Generated in the
      // browser, and communicated to the worker in the renderer. This token
      // should not be shared with any renderer except that hosting the worker.
      SharedWorkerToken token,

      // The StorageKey of the page where `new SharedWorker()` is called.
      // StorageKey.origin must be able to access shared workers.
      // (see blink::SecurityOrigin::CanAccessSharedWorkers())
      // https://html.spec.whatwg.org/C/#concept-sharedworkerglobalscope-constructor-origin
      blink.mojom.StorageKey constructor_key,

      // `origin` is the origin that will be used by the worker on the renderer
      // side. It might differ from the origin that is used on the browser side
      // when `script_url` is a data: URL, due to the linked bug.
      // TODO(crbug.com/40051700): Remove the mismatch cases.
      url.mojom.Origin origin,

      // Whether the page where `new SharedWorker()` is called is a secure
      // context or not. Note that this may be false even if
      // `constructor_origin` is potentially-trustworthy.
      bool is_constructor_secure_context,

      string user_agent,
      UserAgentMetadata ua_metadata,
      bool pause_on_start,
      mojo_base.mojom.UnguessableToken devtools_worker_token,
      RendererPreferences renderer_preferences,
      pending_receiver<RendererPreferenceWatcher> preference_watcher_receiver,
      pending_remote<WorkerContentSettingsProxy> content_settings,

      // The info about the service worker container host in the browser process
      // that provides support for this worker to be a service worker client.
      //
      // This is null if the shared worker cannot be a service
      // worker client, because for example, the worker's URL is
      // not http(s) or another service worker supported scheme.
      ServiceWorkerContainerInfoForClient? service_worker_container_info,

      // Used for passing the main script pre-requested by the browser process
      // and its redirect information.
      WorkerMainScriptLoadParams main_script_load_params,

      // Used for loading subresources. This also supports non-network URLs like
      // chrome-extension:// URLs.
      URLLoaderFactoryBundle subresource_loader_factories,

      // Used to make fetches from the worker go through the controller service
      // worker. This is null when there're no controller service worker.
      ControllerServiceWorkerInfo? controller_info,

      PolicyContainer policy_container,

      pending_remote<SharedWorkerHost> host,
      pending_receiver<SharedWorker> shared_worker,

      // BrowserInterfaceBroker for providing browser interfaces.
      pending_remote<blink.mojom.BrowserInterfaceBroker>
          browser_interface_broker,

      // The UKM SourceId associated with the SharedWorkerHost. This is distinct
      // from the IDs that are associated with the connected clients.
      int64 ukm_source_id,

      // If `require_cross_site_request_for_cookies` is true, then all
      // requests made will have an empty site_for_cookies to ensure only
      // SameSite=None cookies can be attached to the request.
      // For context on usage see:
      // https://privacycg.github.io/saa-non-cookie-storage/shared-workers.html
      bool require_cross_site_request_for_cookies);
};