chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>

#include "base/base64.h"
#include "base/containers/to_value_list.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/time_formatting.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/net_internals_resources.h"
#include "chrome/grit/net_internals_resources_map.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/address_list.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/network_isolation_key.h"
#include "net/base/schemeful_site.h"
#include "net/dns/public/host_resolver_results.h"
#include "net/dns/public/resolve_error_info.h"
#include "net/extras/shared_dictionary/shared_dictionary_usage_info.h"
#include "net/shared_dictionary/shared_dictionary_isolation_key.h"
#include "services/network/public/cpp/request_destination.h"
#include "services/network/public/mojom/clear_data_filter.mojom.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "services/network/public/mojom/host_resolver.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "ui/resources/grit/webui_resources.h"
#include "url/origin.h"
#include "url/scheme_host_port.h"

BrowserThread;

namespace {

void CreateAndAddNetInternalsHTMLSource(Profile* profile) {}

void IgnoreBoolCallback(bool result) {}

// This function converts std::vector<net::IPEndPoint> to base::Value::List.
base::Value::List IPEndpointsToBaseList(
    const std::vector<net::IPEndPoint>& resolved_addresses) {}

// This function converts std::optional<net::HostResolverEndpointResults> to
// base::Value::List.
base::Value::List HostResolverEndpointResultsToBaseList(
    const std::optional<net::HostResolverEndpointResults>& endpoint_results) {}

base::Value::List GetMatchDestList(
    const std::vector<::network::mojom::RequestDestination>& match_dest) {}

// This class implements network::mojom::ResolveHostClient.
class NetInternalsResolveHostClient : public network::mojom::ResolveHostClient {};

// This class receives javascript messages from the renderer.
// Note that the WebUI infrastructure runs on the UI thread, therefore all of
// this class's methods are expected to run on the UI thread.
class NetInternalsMessageHandler : public content::WebUIMessageHandler {};

NetInternalsMessageHandler::NetInternalsMessageHandler(content::WebUI* web_ui)
    :{}

void NetInternalsMessageHandler::RegisterMessages() {}

void NetInternalsMessageHandler::OnJavascriptDisallowed() {}

void NetInternalsMessageHandler::OnReloadProxySettings(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnClearBadProxies(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnResolveHost(const base::Value::List& list) {}

void NetInternalsMessageHandler::OnClearHostResolverCache(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnClearSharedDictionary(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnClearSharedDictionaryCacheForIsolationKey(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnGetSharedDictionaryUsageInfo(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnGetSharedDictionaryInfo(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnDomainSecurityPolicyDelete(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnHSTSQuery(const base::Value::List& list) {}

void NetInternalsMessageHandler::ResolveCallbackWithResult(
    const std::string& callback_id,
    base::Value::Dict result) {}

void NetInternalsMessageHandler::OnHSTSAdd(const base::Value::List& list) {}

void NetInternalsMessageHandler::OnFlushSocketPools(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnCloseIdleSockets(
    const base::Value::List& list) {}

void NetInternalsMessageHandler::OnResolveHostDone(
    const std::string& callback_id,
    const net::ResolveErrorInfo& resolve_error_info,
    const std::optional<net::AddressList>& resolved_addresses,
    const std::optional<net::HostResolverEndpointResults>&
        endpoint_results_with_metadata,
    NetInternalsResolveHostClient* dns_lookup_client) {}

void NetInternalsMessageHandler::OnGetSharedDictionaryUsageInfoDone(
    const std::string& callback_id,
    const std::vector<net::SharedDictionaryUsageInfo>& usage_info) {}

void NetInternalsMessageHandler::OnGetSharedDictionaryInfoDone(
    const std::string& callback_id,
    std::vector<network::mojom::SharedDictionaryInfoPtr> dictionaries) {}

void NetInternalsMessageHandler::OnClearSharedDictionaryDone(
    const std::string& callback_id) {}

void NetInternalsMessageHandler::OnClearSharedDictionaryForIsolationKeyDone(
    const std::string& callback_id) {}

// g_network_context_for_testing is used only for testing.
network::mojom::NetworkContext* g_network_context_for_testing =;

network::mojom::NetworkContext*
NetInternalsMessageHandler::GetNetworkContext() {}

}  // namespace


////////////////////////////////////////////////////////////////////////////////
//
// NetInternalsUI
//
////////////////////////////////////////////////////////////////////////////////

NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
    :{}

// static
void NetInternalsUI::SetNetworkContextForTesting(
    network::mojom::NetworkContext* network_context_for_testing) {}