0
Files
src/content/browser/font_access
Daniel Cheng ccd5b41390 Use base::test::FeatureRef for feature vectors in //content.
A base::Feature should not be copyable; a feature is intended to have a
single global instance, as it caches internal mutable state.

Feature vectors in conjunction with `base::test::ScopedFeatureList` are
by far the most common use of the base::Feature copy constructor. This
is a mostly automated replacement of `std::vector<base::Feature>` with
`std::vector<base::test::FeatureRef>` to remove that dependency.

This CL was uploaded by git cl split.

R=nasko@chromium.org

Bug: 1370572
Change-Id: Iecfb813c08c475e042234aab91577cff999b4101
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3933905
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1055143}
2022-10-05 06:20:45 +00:00
..

Font Access API

This directory contains the browser-side implementation of Font Access API.

//third_party/blink/renderer/modules/font_access/ contains the renderer-side implementation, and //third_party/blink/public/mojom/font_access contains the mojom interface for this API.

Code map

It consists of the following parts:

  • FontAccessManager: content::FontAccessManager implements blink::mojom::FontAccessManager, providing a way to enumerate local fonts. It checks for the requirements to access local fonts such as user permission, page visibility and transient user activation. Once all the requirements are met, it returns the fonts data from FontEnumerationCache. In terms of code ownership, there is one FontAccessManager per StoragePartitionImpl; Frames are bound to FontAccessManager via a BindingContext.

  • FontEnumerationCache: content::FontEnumerationCache is a cache-like object that memoizes the data about locally installed fonts as well as the operation status, given the user locale. The data is read via content::FontEnumerationDataSource.GetFonts() and is stored and served in ReadOnlySharedMemoryRegion. This class is not thread-safe. Each instance must be accessed from a single sequence, which must allow blocking.

  • FontEnumerationDataSource: content::FontEnumerationDataSource, inherited by OS-specific subclasses, reads locally installed fonts from the underlying OS. While the subclasses of this class contains the implementation for reading font data, this class itself does not, as it is instantiated for non-supported OS. It is not thread-safe; all methods except for the constructor must be used on the same sequence, and the sequence must allow blocking I/O operations.