Bug 1867190 - Initialise the PHC allocate delay later r=glandium
[gecko.git] / layout / style / URLExtraData.cpp
blob730576cad39d5253f037a728739ac22568e5885c
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* thread-safe container of information for resolving url values */
9 #include "mozilla/URLExtraData.h"
11 #include "mozilla/NullPrincipal.h"
12 #include "nsAboutProtocolUtils.h"
13 #include "ReferrerInfo.h"
15 namespace mozilla {
17 StaticRefPtr<URLExtraData> URLExtraData::sDummy;
18 StaticRefPtr<URLExtraData> URLExtraData::sDummyChrome;
20 /* static */
21 void URLExtraData::Init() {
22 RefPtr<nsIURI> baseURI = NullPrincipal::CreateURI();
23 nsCOMPtr<nsIReferrerInfo> referrerInfo = new dom::ReferrerInfo(nullptr);
24 sDummy = new URLExtraData(do_AddRef(baseURI), do_AddRef(referrerInfo),
25 NullPrincipal::CreateWithoutOriginAttributes());
27 sDummyChrome =
28 new URLExtraData(baseURI.forget(), referrerInfo.forget(),
29 NullPrincipal::CreateWithoutOriginAttributes());
30 sDummyChrome->mChromeRulesEnabled = true;
33 bool URLExtraData::ChromeRulesEnabled(nsIURI* aURI) {
34 if (!aURI) {
35 return false;
37 return aURI->SchemeIs("chrome") || aURI->SchemeIs("resource") ||
38 (aURI->SchemeIs("about") && !NS_IsContentAccessibleAboutURI(aURI));
41 /* static */
42 void URLExtraData::Shutdown() {
43 sDummy = nullptr;
44 sDummyChrome = nullptr;
47 URLExtraData::~URLExtraData() = default;
49 StaticRefPtr<URLExtraData>
50 URLExtraData::sShared[size_t(UserAgentStyleSheetID::Count)];
52 } // namespace mozilla