chromium/third_party/blink/public/mojom/back_forward_cache_not_restored_reasons.mojom

// Copyright 2022 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 "third_party/blink/public/mojom/script_source_location.mojom";
import "url/mojom/url.mojom";

// This is a recursive struct which has HTML attributes and information
// about whether this document blocked back/forward cache.  This struct
// contains the information that is reported for same-origin iframes.
// This will be sent from browser to renderer as part of
// BackForwardCacheNotRestoredReasons.
struct SameOriginBfcacheNotRestoredDetails {
  // URL when the frame navigated away. This could be cut down if the
  // reported value was longer than a limit.
  url.mojom.Url url;
  // List of children frames' information.
  array<BackForwardCacheNotRestoredReasons> children;
};

// Detailed information for why the frame in question was blocked
// from BFCache.
struct BFCacheBlockingDetailedReason {
  // The name of the reason.
  // TODO(crbug.com/1519483): Define enums of reasons and use them instead of strings.
  string name;
  // The JavaScript source location of the reason. This should be null if the reason
  // doesn't have a source location.
  ScriptSourceLocation? source;
};

// Struct for NotRestoredReasons API to report from browser to renderer. This
// contains the information that is common to both same-origin and cross-origin iframes.
struct BackForwardCacheNotRestoredReasons {
  // HTML src attribute of the frame. This could be cut down if the reported
  // value was longer than a limit.
  string? src;
  // HTML id attribute of the frame.
  string? id;
  // HTML name attribute of the frame.
  string? name;
  // List of reasons that blocked back/forward cache if any.
  array<BFCacheBlockingDetailedReason> reasons;
  // This will be std::nullopt when this document is cross-origin from the main
  // document.
  SameOriginBfcacheNotRestoredDetails? same_origin_details;
};