# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

XPIDL_SOURCES += [
    "mozIThirdPartyUtil.idl",
    "nsIAndroidContentInputStream.idl",
    "nsIArrayBufferInputStream.idl",
    "nsIAsyncStreamCopier.idl",
    "nsIAsyncStreamCopier2.idl",
    "nsIAsyncVerifyRedirectCallback.idl",
    "nsIAuthInformation.idl",
    "nsIAuthModule.idl",
    "nsIAuthPrompt.idl",
    "nsIAuthPrompt2.idl",
    "nsIAuthPromptAdapterFactory.idl",
    "nsIAuthPromptCallback.idl",
    "nsIAuthPromptProvider.idl",
    "nsIBackgroundFileSaver.idl",
    "nsIBaseChannel.idl",
    "nsIBufferedStreams.idl",
    "nsIByteRangeRequest.idl",
    "nsICacheInfoChannel.idl",
    "nsICachingChannel.idl",
    "nsICancelable.idl",
    "nsICaptivePortalService.idl",
    "nsIChannel.idl",
    "nsIChannelEventSink.idl",
    "nsIChildChannel.idl",
    "nsIClassifiedChannel.idl",
    "nsIClassOfService.idl",
    "nsIContentSniffer.idl",
    "nsIDashboard.idl",
    "nsIDashboardEventNotifier.idl",
    "nsIDHCPClient.idl",
    "nsIDownloader.idl",
    "nsIEncodedChannel.idl",
    "nsIExternalProtocolHandler.idl",
    "nsIFileStreams.idl",
    "nsIFileURL.idl",
    "nsIForcePendingChannel.idl",
    "nsIFormPOSTActionChannel.idl",
    "nsIHttpAuthenticatorCallback.idl",
    "nsIIncrementalDownload.idl",
    "nsIIncrementalStreamLoader.idl",
    "nsIInputStreamChannel.idl",
    "nsIInputStreamPump.idl",
    "nsIInterceptionInfo.idl",
    "nsIIOService.idl",
    "nsILoadContextInfo.idl",
    "nsILoadGroup.idl",
    "nsILoadGroupChild.idl",
    "nsILoadInfo.idl",
    "nsIMIMEInputStream.idl",
    "nsIMockNetworkLayerController.idl",
    "nsIMultiPartChannel.idl",
    "nsINestedURI.idl",
    "nsINetAddr.idl",
    "nsINetUtil.idl",
    "nsINetworkConnectivityService.idl",
    "nsINetworkInfoService.idl",
    "nsINetworkInterceptController.idl",
    "nsINetworkLinkService.idl",
    "nsINullChannel.idl",
    "nsIParentChannel.idl",
    "nsIParentRedirectingChannel.idl",
    "nsIPermission.idl",
    "nsIPermissionManager.idl",
    "nsIPrivateBrowsingChannel.idl",
    "nsIProgressEventSink.idl",
    "nsIPrompt.idl",
    "nsIProtocolHandler.idl",
    "nsIProtocolProxyCallback.idl",
    "nsIProtocolProxyFilter.idl",
    "nsIProtocolProxyService.idl",
    "nsIProtocolProxyService2.idl",
    "nsIProxiedChannel.idl",
    "nsIProxiedProtocolHandler.idl",
    "nsIProxyInfo.idl",
    "nsIRandomGenerator.idl",
    "nsIRedirectChannelRegistrar.idl",
    "nsIRedirectHistoryEntry.idl",
    "nsIRedirectResultListener.idl",
    "nsIRequest.idl",
    "nsIRequestContext.idl",
    "nsIRequestObserver.idl",
    "nsIRequestObserverProxy.idl",
    "nsIResumableChannel.idl",
    "nsISecCheckWrapChannel.idl",
    "nsISecureBrowserUI.idl",
    "nsISensitiveInfoHiddenURI.idl",
    "nsISerializationHelper.idl",
    "nsIServerSocket.idl",
    "nsISimpleStreamListener.idl",
    "nsISimpleURIMutator.idl",
    "nsISocketFilter.idl",
    "nsISocketTransport.idl",
    "nsISocketTransportService.idl",
    "nsISpeculativeConnect.idl",
    "nsISSLTokensCache.idl",
    "nsIStandardURL.idl",
    "nsIStreamListener.idl",
    "nsIStreamListenerTee.idl",
    "nsIStreamLoader.idl",
    "nsIStreamTransportService.idl",
    "nsISuspendableChannelWrapper.idl",
    "nsISyncStreamListener.idl",
    "nsISystemProxySettings.idl",
    "nsIThreadRetargetableRequest.idl",
    "nsIThreadRetargetableStreamListener.idl",
    "nsIThrottledInputChannel.idl",
    "nsITimedChannel.idl",
    "nsITLSServerSocket.idl",
    "nsITraceableChannel.idl",
    "nsITransport.idl",
    "nsIUDPSocket.idl",
    "nsIUploadChannel.idl",
    "nsIUploadChannel2.idl",
    "nsIURI.idl",
    "nsIURIMutator.idl",
    "nsIURIWithSpecialOrigin.idl",
    "nsIURL.idl",
    "nsIURLParser.idl",
    "nsPISocketTransportService.idl",
]

if CONFIG["ENABLE_TESTS"]:
    XPIDL_SOURCES += ["nsISSLTokensCacheTest.idl"]

XPIDL_MODULE = "necko"

EXPORTS += [
    "netCore.h",
    "nsASocketHandler.h",
    "nsAsyncRedirectVerifyHelper.h",
    "nsBaseChannel.h",
    "nsBaseParentChannel.h",
    "nsFileStreams.h",
    "nsInputStreamPump.h",
    "nsIURIWithSizeOf.h",
    "nsMIMEInputStream.h",
    "nsNetUtil.h",
    "nsReadLine.h",
    "nsSerializationHelper.h",
    "nsSimpleNestedURI.h",
    "nsSimpleURI.h",
    "nsStandardURL.h",
    "nsStreamListenerWrapper.h",
    "nsURIHashKey.h",
    "nsURLHelper.h",
    "nsURLParsers.h",
    "SimpleChannel.h",
    "URIHasher.h",
]

EXPORTS.mozilla += [
    "LoadContextInfo.h",
    "LoadInfo.h",
    "LoadTainting.h",
    "nsRedirectHistoryEntry.h",
]

EXPORTS.mozilla.net += [
    "CacheInfoIPCTypes.h",
    "CaptivePortalService.h",
    "ContentRange.h",
    "Dashboard.h",
    "DashboardTypes.h",
    "DefaultURI.h",
    "ExecuteIfOnMainThreadEventTarget.h",
    "InterceptionInfo.h",
    "IPv4Parser.h",
    "NetworkConnectivityService.h",
    "NoVarySearchUtils.h",
    "PrivateBrowsingChannel.h",
    "ProtocolHandlerInfo.h",
    "RedirectChannelRegistrar.h",
    "RequestContextService.h",
    "SimpleURIUnknownSchemes.h",
    "SSLTokensCache.h",
    "ThrottleQueue.h",
]

UNIFIED_SOURCES += [
    "ArrayBufferInputStream.cpp",
    "BackgroundFileSaver.cpp",
    "CaptivePortalService.cpp",
    "ContentRange.cpp",
    "Dashboard.cpp",
    "DefaultURI.cpp",
    "EventTokenBucket.cpp",
    "ExecuteIfOnMainThreadEventTarget.cpp",
    "InterceptionInfo.cpp",
    "IPv4Parser.cpp",
    "LNAPermissionRequest.cpp",
    "LoadContextInfo.cpp",
    "LoadInfo.cpp",
    "MockNetworkLayer.cpp",
    "MockNetworkLayerController.cpp",
    "NetworkConnectivityService.cpp",
    "NetworkDataCountLayer.cpp",
    "NoVarySearchUtils.cpp",
    "nsAsyncRedirectVerifyHelper.cpp",
    "nsAsyncStreamCopier.cpp",
    "nsAuthInformationHolder.cpp",
    "nsBase64Encoder.cpp",
    "nsBaseChannel.cpp",
    "nsBaseContentStream.cpp",
    "nsBaseParentChannel.cpp",
    "nsBufferedStreams.cpp",
    "nsDirectoryIndexStream.cpp",
    "nsDNSPrefetch.cpp",
    "nsDownloader.cpp",
    "nsFileStreams.cpp",
    "nsIncrementalDownload.cpp",
    "nsIncrementalStreamLoader.cpp",
    "nsInputStreamChannel.cpp",
    "nsInputStreamPump.cpp",
    "nsIOService.cpp",
    "nsIURIMutatorUtils.cpp",
    "nsLoadGroup.cpp",
    "nsMIMEInputStream.cpp",
    "nsNetAddr.cpp",
    "nsNetUtil.cpp",
    "nsPACMan.cpp",
    "nsPreloadedStream.cpp",
    "nsProtocolProxyService.cpp",
    "nsProxyInfo.cpp",
    "nsRedirectHistoryEntry.cpp",
    "nsRequestObserverProxy.cpp",
    "nsSerializationHelper.cpp",
    "nsServerSocket.cpp",
    "nsSimpleNestedURI.cpp",
    "nsSimpleStreamListener.cpp",
    "nsSimpleURI.cpp",
    "nsSocketTransport2.cpp",
    "nsSocketTransportService2.cpp",
    "nsStandardURL.cpp",
    "nsStreamListenerTee.cpp",
    "nsStreamListenerWrapper.cpp",
    "nsStreamLoader.cpp",
    "nsStreamTransportService.cpp",
    "nsSyncStreamListener.cpp",
    "nsTransportUtils.cpp",
    "nsUDPSocket.cpp",
    "PollableEvent.cpp",
    "ProtocolHandlerInfo.cpp",
    "ProxyAutoConfig.cpp",
    "RedirectChannelRegistrar.cpp",
    "RequestContextService.cpp",
    "SimpleBuffer.cpp",
    "SimpleChannel.cpp",
    "SimpleURIUnknownSchemes.cpp",
    "SSLTokensCache.cpp",
    "SuspendableChannelWrapper.cpp",
    "ThrottleQueue.cpp",
    "Tickler.cpp",
    "TLSServerSocket.cpp",
    "TRRLoadInfo.cpp",
]

if CONFIG["FUZZING"]:
    SOURCES += [
        "FuzzyLayer.cpp",
        "FuzzySecurityInfo.cpp",
        "FuzzySocketControl.cpp",
    ]

if CONFIG["FUZZING_INTERFACES"] and CONFIG["LIBFUZZER"]:
    include("/tools/fuzzing/libfuzzer-flags.mozbuild")
    SOURCES += [
        "nsURLHelper.cpp",
        "nsURLParsers.cpp",
    ]
    SOURCES["nsURLHelper.cpp"].flags += libfuzzer_flags
    SOURCES["nsURLParsers.cpp"].flags += libfuzzer_flags
else:
    UNIFIED_SOURCES += [
        "nsURLHelper.cpp",
        "nsURLParsers.cpp",
    ]


if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
    SOURCES += [
        "nsURLHelperWin.cpp",
        "ShutdownLayer.cpp",
    ]
else:
    SOURCES += [
        "nsURLHelperUnix.cpp",
    ]

EXTRA_JS_MODULES += [
    "EssentialDomainsRemoteSettings.sys.mjs",
    "NetUtil.sys.mjs",
    "SimpleURIUnknownSchemesRemoteObserver.sys.mjs",
]

DIRS += [
    "mozurl",
    "rust-helper",
    "http-sfv",
    "idna_glue",
    "ssl_tokens_cache",
    "uritemplate_glue",
    "urlpattern_glue",
]

include("/ipc/chromium/chromium-config.mozbuild")

FINAL_LIBRARY = "xul"

LOCAL_INCLUDES += [
    "!/xpcom/components",
    "/docshell/base",
    "/dom/base",
    "/js/xpconnect/src",
    "/netwerk/dns",
    "/netwerk/protocol/http",
    "/netwerk/protocol/webtransport",
    "/netwerk/socket",
    "/netwerk/url-classifier",
    "/security/manager/ssl",
    "/xpcom/components",
]

if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
    LOCAL_INCLUDES += [
        "/xpcom/base",
    ]

if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
    LOCAL_INCLUDES += [
        "/netwerk/system/android",
    ]

GeneratedFile(
    "ascii_pac_utils.inc", script="makecppstring.py", inputs=["ascii_pac_utils.js"]
)
