1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "FontPreloader.h"
9 #include "mozilla/FontLoaderUtils.h"
10 #include "gfxPlatform.h"
14 FontPreloader::FontPreloader()
15 : FetchPreloader(nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD
) {}
17 nsresult
FontPreloader::CreateChannel(
18 nsIChannel
** aChannel
, nsIURI
* aURI
, const CORSMode aCORSMode
,
19 const dom::ReferrerPolicy
& aReferrerPolicy
, dom::Document
* aDocument
,
20 nsILoadGroup
* aLoadGroup
, nsIInterfaceRequestor
* aCallbacks
,
21 uint64_t aEarlyHintPreloaderId
, int32_t aSupportsPriorityValue
) {
22 // Don't preload fonts if they've been preffed-off.
23 if (!gfxPlatform::GetPlatform()->DownloadableFontsEnabled()) {
24 return NS_ERROR_NOT_AVAILABLE
;
27 return FontLoaderUtils::BuildChannel(
28 aChannel
, aURI
, aCORSMode
, aReferrerPolicy
, nullptr, nullptr, aDocument
,
29 aLoadGroup
, aCallbacks
, true, aSupportsPriorityValue
);
32 } // namespace mozilla