// 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 "services/network/public/mojom/schemeful_site.mojom";
import "services/network/public/mojom/url_loader_factory.mojom";
import "third_party/blink/public/mojom/blob/blob.mojom";
import "url/mojom/url.mojom";
// This interface is implemented by the browser to give renderers the ability to
// create and revoke blob URLs. This interface is directly exposed to the
// renderer either via BrowserInterfaceBrokers or as a navigation-associated
// interface.
interface BlobURLStore {
// Registers a public Blob URL. When the connection to the BlobURLStore closes
// all URLs registered through it will be revoked.
// TODO(https://crbug.com/1376126): This should probably create and return a
// new blob: URL rather than letting the caller in the renderer provide one.
[Sync] Register(
pending_remote<blink.mojom.Blob> blob,
url.mojom.Url url,
// TODO(https://crbug.com/1224926): Remove these once experiment is over.
mojo_base.mojom.UnguessableToken unsafe_agent_cluster_id,
network.mojom.SchemefulSite? unsafe_top_level_site) => ();
// Revokes a public Blob URL.
Revoke(url.mojom.Url url);
// Resolves a public Blob URL to a URLLoaderFactory that can only load the
// specified URL. The reason the API is shaped like this rather than just
// having a URLLoaderFactory for all Blob URLs is that resolution of blob URLs
// has to happen separately before fetching starts.
// As long as the resulting URLLoaderFactory is alive the resolved blob will
// also be kept alive, so it is possible to start loading the blob long after
// both the blob URL and all other references to the blob have been dropped.
ResolveAsURLLoaderFactory(
url.mojom.Url url,
pending_receiver<network.mojom.URLLoaderFactory> factory) => (
// TODO(https://crbug.com/1224926): Remove these once experiment is over.
mojo_base.mojom.UnguessableToken? unsafe_agent_cluster_id,
network.mojom.SchemefulSite? unsafe_top_level_site);
// Resolves a public Blob URL into a BlobURLToken. The BlobURLToken can be
// used by the browser process to securely look up the blob a URL used to
// refer to, even after the URL is revoked.
// As long as the token is alive, the resolved blob will also be kept alive.
ResolveForNavigation(url.mojom.Url url,
pending_receiver<BlobURLToken> token) => (
// TODO(https://crbug.com/1224926): Remove this once experiment is over.
mojo_base.mojom.UnguessableToken? unsafe_agent_cluster_id);
};
// A token representing a Blob URL. The browser process can use this to look up
// the blob URL and blob it referred to, even after the blob URL itself is
// revoked. For the renderer this is just an opaque token without any meaning.
interface BlobURLToken {
Clone(pending_receiver<BlobURLToken> token);
GetToken() => (mojo_base.mojom.UnguessableToken token);
};