FontPreloader.cpp (1222B)
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/. */ 6 7 #include "FontPreloader.h" 8 9 #include "gfxPlatform.h" 10 #include "mozilla/FontLoaderUtils.h" 11 12 namespace mozilla { 13 14 FontPreloader::FontPreloader() 15 : FetchPreloader(nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD) {} 16 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; 25 } 26 27 return FontLoaderUtils::BuildChannel( 28 aChannel, aURI, aCORSMode, aReferrerPolicy, nullptr, nullptr, aDocument, 29 aLoadGroup, aCallbacks, true, aSupportsPriorityValue); 30 } 31 32 } // namespace mozilla