/src/mozilla-central/dom/clients/manager/ClientPrincipalUtils.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include "ClientPrincipalUtils.h" |
8 | | |
9 | | namespace mozilla { |
10 | | namespace dom { |
11 | | |
12 | | using mozilla::ipc::ContentPrincipalInfo; |
13 | | using mozilla::ipc::PrincipalInfo; |
14 | | |
15 | | bool |
16 | | ClientMatchPrincipalInfo(const PrincipalInfo& aLeft, const PrincipalInfo& aRight) |
17 | 0 | { |
18 | 0 | if (aLeft.type() != aRight.type()) { |
19 | 0 | return false; |
20 | 0 | } |
21 | 0 | |
22 | 0 | switch (aLeft.type()) { |
23 | 0 | case PrincipalInfo::TContentPrincipalInfo: |
24 | 0 | { |
25 | 0 | const ContentPrincipalInfo& leftContent = aLeft.get_ContentPrincipalInfo(); |
26 | 0 | const ContentPrincipalInfo& rightContent = aRight.get_ContentPrincipalInfo(); |
27 | 0 | return leftContent.attrs() == rightContent.attrs() && |
28 | 0 | leftContent.originNoSuffix() == rightContent.originNoSuffix(); |
29 | 0 | } |
30 | 0 | case PrincipalInfo::TSystemPrincipalInfo: |
31 | 0 | { |
32 | 0 | // system principal always matches |
33 | 0 | return true; |
34 | 0 | } |
35 | 0 | case PrincipalInfo::TNullPrincipalInfo: |
36 | 0 | { |
37 | 0 | // null principal never matches |
38 | 0 | return false; |
39 | 0 | } |
40 | 0 | default: |
41 | 0 | { |
42 | 0 | break; |
43 | 0 | } |
44 | 0 | } |
45 | 0 | |
46 | 0 | // Clients (windows/workers) should never have an expanded principal type. |
47 | 0 | MOZ_CRASH("unexpected principal type!"); |
48 | 0 | } |
49 | | |
50 | | } // namespace dom |
51 | | } // namespace mozilla |