chromium/third_party/blink/public/common/chrome_debug_urls.h

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

#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_CHROME_DEBUG_URLS_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_CHROME_DEBUG_URLS_H_

#include "base/check_op.h"
#include "base/dcheck_is_on.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/buildflags.h"
#include "third_party/blink/public/common/common_export.h"

class GURL;

namespace blink {

// TODO(https://crbug.com/1197375): This file defines ChromeUI URLs that support
// triggering debug functionalities. These functionalities do not need to be
// Chrome-specific, and therefore defined in Blink, while they use ChromeUI
// specific URLs. Revisit to see if these URLs (and therefore functionalities
// too) should rather be implemented by embedders.

// Full about URLs (including schemes).
inline constexpr char kChromeUIBadCastCrashURL[] =;
inline constexpr char kChromeUIBrowserCrashURL[] =;
inline constexpr char kChromeUIBrowserDcheckURL[] =;
inline constexpr char kChromeUIBrowserUIHang[] =;
inline constexpr char kChromeUICheckCrashURL[] =;
inline constexpr char kChromeUICrashURL[] =;
inline constexpr char kChromeUIDelayedBrowserUIHang[] =;
inline constexpr char kChromeUIDumpURL[] =;
inline constexpr char kChromeUIGpuCleanURL[] =;
inline constexpr char kChromeUIGpuCrashURL[] =;
inline constexpr char kChromeUIGpuHangURL[] =;
inline constexpr char kChromeUIHangURL[] =;
inline constexpr char kChromeUIKillURL[] =;
inline constexpr char kChromeUIMemoryExhaustURL[] =;
inline constexpr char kChromeUIMemoryPressureCriticalURL[] =;
inline constexpr char kChromeUIMemoryPressureModerateURL[] =;
inline constexpr char kChromeUINetworkErrorsListingURL[] =;
inline constexpr char kChromeUINetworkErrorURL[] =;
inline constexpr char kChromeUIProcessInternalsURL[] =;

#if BUILDFLAG(IS_ANDROID)
inline constexpr char kChromeUIGpuJavaCrashURL[] = "chrome://gpu-java-crash/";
#endif
#if BUILDFLAG(ENABLE_RUST_CRASH)
inline constexpr char kChromeUICrashRustURL[] =;
#endif
#if BUILDFLAG(IS_WIN)
inline constexpr char kChromeUIBrowserHeapCorruptionURL[] =
    "chrome://inducebrowserheapcorruption/";
inline constexpr char kChromeUICfgViolationCrashURL[] = "chrome://crash/cfg";
inline constexpr char kChromeUIHeapCorruptionCrashURL[] =
    "chrome://heapcorruptioncrash/";
#endif

#if defined(ADDRESS_SANITIZER)
inline constexpr char kChromeUICrashHeapOverflowURL[] =
    "chrome://crash/heap-overflow";
inline constexpr char kChromeUICrashHeapUnderflowURL[] =
    "chrome://crash/heap-underflow";
inline constexpr char kChromeUICrashUseAfterFreeURL[] =
    "chrome://crash/use-after-free";
#if BUILDFLAG(IS_WIN)
inline constexpr char kChromeUICrashCorruptHeapBlockURL[] =
    "chrome://crash/corrupt-heap-block";
inline constexpr char kChromeUICrashCorruptHeapURL[] =
    "chrome://crash/corrupt-heap";
#endif  // BUILDFLAG(IS_WIN)
#if BUILDFLAG(ENABLE_RUST_CRASH)
inline constexpr char kChromeUICrashRustOverflowURL[] =
    "chrome://crash/rust-overflow";
#endif  // BUILDFLAG(ENABLE_RUST_CRASH)
#endif  // ADDRESS_SANITIZER

#if DCHECK_IS_ON()
inline constexpr char kChromeUICrashDcheckURL[] =;
#endif

// Full about URLs (including schemes).
inline constexpr char kChromeUIResourcesURL[] =;
inline constexpr char kChromeUIShorthangURL[] =;

// Returns whether the given url is either a debugging url handled in the
// renderer process, such as one that crashes or hangs the renderer, or a
// javascript: URL that operates on the current page in the renderer.  Such URLs
// do not represent actual navigations and can be loaded in any SiteInstance.
BLINK_COMMON_EXPORT bool IsRendererDebugURL(const GURL& url);

// Handles the given debug URL. These URLs do not commit, though they are
// intentionally left in the address bar above the effect they cause
// (e.g., a sad tab).
BLINK_COMMON_EXPORT void HandleChromeDebugURL(const GURL& url);

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_CHROME_DEBUG_URLS_H_