Files
electron/shell/browser/preload_code_cache.h
18f7d6cc5c chore: bump chromium to 157.0.8085.0 (main) (#54590)
* chore: bump chromium in DEPS to 157.0.8079.0

* chore: update patches

* 8426044: Deduplicate notifications for find-in-page

Upstream removed WebContentsDelegate::FindReply() in favor of
WebContentsObserver::DidReceiveFindReply(). Moved Electron's
found-in-page handling from the delegate forwarder to the observer
forwarder on the NativeLifecycle peer.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8426044

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8471431: siso: don't include optional LLVM tools in clang inputs

https://crrev.com/c/8471431 narrowed the
third_party/llvm-build/Release+Asserts:headers filegroup glob from
bin/clang-* to bin/clang-cl, bin/clang-cl.exe and bin/clang-[0-9]*.
siso uploads that filegroup as a precomputed subtree and drops other
inputs under it, so bin/clang-tidy no longer reached the RBE workers and
the clang-tidy steps failed with exit 127.

build-tools now adds bin/clang-tidy back to that filegroup:
https://github.com/electron/build-tools/pull/910

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8471431

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V38FjDEdZgMvFpf5Fmp65m

* chore: bump chromium in DEPS to 157.0.8081.0

* 8469895: [VideoCapture] Remove unsafe lifetime assumptions in InProcessVideoCaptureDeviceLauncher

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8469895

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8261571: dbus: Let desktop Linux end the session instead of crashing when a bus is lost

Upstream landed Bus::Options::disconnected_callback and a reworked
dbus_thread_linux that takes the embedder's callback via Initialize(),
which supersedes both the backport patch and the downstream
SetDisconnectedCallback() shim. Removed both patches and switched
ElectronBrowserMainParts to dbus_thread_linux::Initialize().

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8261571

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8470272: [find-in-page] Fix endless frame traversal around an inner WebContents

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8470272

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: update patches

* 8424588: [mojo] (Mostly) ban untyped `handle` use

TakeHeapSnapshot now takes handle<platform>, so the browser passes the
mojo::PlatformHandle directly and the renderer receives it without
unwrapping.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8424588

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8465643: Forward proxy auth for requests without login prompts

Plumb the new do_not_prompt_for_login flag through
URLLoaderNetworkObserver, SimpleURLLoaderClient and CreateLoginDelegate.
Electron keeps routing these challenges to the 'login' event, which is
its non-UI credential source, mirroring how Chrome still consults
extensions for them.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8465643

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8422739: Enforce cross-origin access control in WebUIURLLoaderFactory

CreateWebUIURLLoaderFactory now requires a request initiator origin
lock. Pass the frame's initiator origin that content already hands to
RegisterNonNetworkSubresourceURLLoaderFactories; the lock only gates
chrome-untrusted:// initiators, so component extensions keep their
access to chrome://resources.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8422739

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: bump chromium in DEPS to 157.0.8083.0

* 8497008: CATransaction: Clean up old flags

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8497008

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8499815: Ruff: reformat third_party/blink.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8499815

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8455902: gin: Mark Invoker as stack allocated and drop raw_ptr for its Arguments

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8455902

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: update patches

* 8469168: Change DataPipeGetter::Read to return result as base::expected

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8469168

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8480632: Ignore stale UpdateDragOperation replies from non-current RWH on Android

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8480632

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: bump chromium in DEPS to 157.0.8085.0

* chore: update patches

* 8463605: [Clear-Site-Data] Prevent cross-site fetch clearing unpartitioned data

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8463605

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* 8448270: [Linux] Support XDG NetworkMonitor portal in NetworkChangeNotifierLinux

The browser process now opens a private session bus for the portal, with
no Bus::Options::disconnected_callback, so it aborts when the session bus
is lost. That is what fails "when a D-Bus bus goes away > exits cleanly
instead of crashing" on Linux. Carry the upstream fix until it rolls in.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8448270
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8512441#nolint

* 8465423: Use C++20 std::numbers::pi in blink

Backport the upstream fix for Windows math constants.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8465423
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8510323#nolint

* 8489251: Exit tab fullscreen when the held-Esc timer fires under keyboard lock

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8489251

* 8366647: [snapshot] Optional SHA256 code cache source hashing

Ref: https://chromium-review.googlesource.com/c/v8/v8/+/8366647

* fix: disable V8 metagen feature

Refs https://issues.chromium.org/issues/531344950
Skip-Lint: General feature disablement, no specific to a particular CL.

* 8503816: Enable AperitifHelpers by default

Disable AperitifHelpers on macOS until Electron adopts the new helpers.
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/8503816

* build: pin build-tools to merged siso clang-tidy fix

electron/build-tools#910 squash-merged as 32e2253f7c5696d85a77fe19d54d284cf9a62322; re-pin from the PR branch commit a411ee5 so CI no longer depends on the deleted branch.

Skip-Lint: build-tools pin, not a Chromium CL adaptation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V38FjDEdZgMvFpf5Fmp65m

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: electron-claude[bot] <279139701+electron-claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2026-10-07 22:34:15 -04:00

93 lines
3.9 KiB
C++

// Copyright (c) 2026 Anthropic, PBC.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_PRELOAD_CODE_CACHE_H_
#define ELECTRON_SHELL_BROWSER_PRELOAD_CODE_CACHE_H_
#include <array>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "crypto/hash.h"
namespace content {
class RenderFrameHost;
}
namespace electron::preload_code_cache {
// sha256 of a preload script's source bytes.
using SourceHash = std::array<uint8_t, crypto::hash::kSha256Size>;
// One preload served to a frame: its cache id and the sha256 of the exact
// bytes the browser served.
using ServedPreload = std::pair<std::string, SourceHash>;
// Cache id for a webPreferences.preload script (stable across launches).
std::string IdForWebPreferencesPreload(const base::FilePath& path);
// Who a cache entry belongs to: the frame's BrowserContext (its data dir,
// under which the disk tier lives) plus its renderer's process lock (site,
// origin keying, sandboxing, guest and cross-origin-isolation status,
// storage partition). Entries are only ever served back within an equal
// scope, so a blob produced by one principal's renderer is never handed to
// another. Scope is the security boundary for cached blobs; see the note in
// SetFromRenderer(). |dir| is empty for off-the-record contexts (memory tier
// only).
struct Scope {
Scope();
Scope(const Scope&);
Scope(Scope&&);
~Scope();
base::FilePath dir;
std::string context_id;
std::string process_lock;
};
Scope ScopeForFrame(content::RenderFrameHost* rfh);
// Returns the V8 code cache blob recorded for |id| within |scope| and bound
// to source bytes whose sha256 is |source_hash| — or empty. Checks an
// in-memory tier first, then |scope.dir|. Disk I/O is synchronous (call behind
// a ScopedAllowBlocking) and happens at most once per (scope, id) per session.
//
// Entries are bound to the source hash: unless its optional SHA256 source
// hashing is enabled, V8's CachedData source check hashes only the source
// *length*, so without this a same-length source change would execute stale
// bytecode. V8 still validates version/flags at consume time.
std::vector<uint8_t> Get(const Scope& scope,
const std::string& id,
const SourceHash& source_hash);
// Records the preloads — id plus the sha256 of the exact bytes — that the
// browser served to |rfh| in a RendererStartupData push, replacing any
// previous record for that frame. SetFromRenderer() only accepts cache
// writes for tuples recorded here: the browser, not the renderer, is the
// authority for which source bytes a cache entry validates against. The
// record's lifetime is tied to the frame (cleared when the frame or its
// WebContents goes away).
void RecordServedPreloads(content::RenderFrameHost* rfh,
std::vector<ServedPreload> served);
// Stores a code cache blob reported by |rfh|'s renderer for a preload that
// was served to it. The write is dropped unless RecordServedPreloads()
// recorded the id for this exact frame and |claimed_source_hash| equals the
// browser-recorded hash of the served bytes. The claimed hash is only a
// cross-check (it detects a write racing a newer push after the preload
// changed on disk); what is persisted is the browser-recorded hash, keyed by
// the frame's Scope — the renderer never supplies the metadata that future
// loads validate against. The in-memory tier is written immediately; the
// disk write is fire-and-forget on the thread pool.
void SetFromRenderer(content::RenderFrameHost* rfh,
const std::string& id,
base::span<const uint8_t> claimed_source_hash,
base::span<const uint8_t> blob);
} // namespace electron::preload_code_cache
#endif // ELECTRON_SHELL_BROWSER_PRELOAD_CODE_CACHE_H_