Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / dom / clients / manager / ClientPrincipalUtils.cpp
blob25a25b2ee9ed228dac35322ca5fcefe55f31e960
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 #include "ClientPrincipalUtils.h"
9 #include "mozilla/ipc/PBackgroundSharedTypes.h"
11 namespace mozilla::dom {
13 using mozilla::ipc::ContentPrincipalInfo;
14 using mozilla::ipc::PrincipalInfo;
16 bool ClientMatchPrincipalInfo(const PrincipalInfo& aLeft,
17 const PrincipalInfo& aRight) {
18 if (aLeft.type() != aRight.type()) {
19 return false;
22 switch (aLeft.type()) {
23 case PrincipalInfo::TContentPrincipalInfo: {
24 const ContentPrincipalInfo& leftContent =
25 aLeft.get_ContentPrincipalInfo();
26 const ContentPrincipalInfo& rightContent =
27 aRight.get_ContentPrincipalInfo();
28 return leftContent.attrs() == rightContent.attrs() &&
29 leftContent.originNoSuffix() == rightContent.originNoSuffix();
31 case PrincipalInfo::TSystemPrincipalInfo: {
32 // system principal always matches
33 return true;
35 case PrincipalInfo::TNullPrincipalInfo: {
36 // null principal never matches
37 return false;
39 default: {
40 break;
44 // Clients (windows/workers) should never have an expanded principal type.
45 MOZ_CRASH("unexpected principal type!");
48 } // namespace mozilla::dom