summaryrefslogtreecommitdiffstats
path: root/netwerk/base/nsILoadContextInfo.idl
blob: b344a15443458e7614ec62695a0fd43843804fbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

%{ C++
#include "mozilla/BasePrincipal.h"
%}
native OriginAttributesNativePtr(const mozilla::NeckoOriginAttributes*);

interface nsILoadContext;
interface nsIDOMWindow;

/**
 * Helper interface to carry informatin about the load context
 * encapsulating origin attributes and IsAnonymous, IsPrivite properties.
 * It shall be used where nsILoadContext cannot be used or is not
 * available.
 */

[scriptable, builtinclass, uuid(555e2f8a-a1f6-41dd-88ca-ed4ed6b98a22)]
interface nsILoadContextInfo : nsISupports
{
  const unsigned long NO_APP_ID = 0;
  const unsigned long UNKNOWN_APP_ID = 4294967295; // UINT32_MAX

  /**
   * Whether the context is in a Private Browsing mode
   */
  readonly attribute boolean isPrivate;

  /**
   * Whether the load is initiated as anonymous
   */
  readonly attribute boolean isAnonymous;

  /**
   * NeckoOriginAttributes hiding all the security context attributes
   */
  [implicit_jscontext]
  readonly attribute jsval originAttributes;
  [noscript, notxpcom, nostdcall, binaryname(OriginAttributesPtr)]
  OriginAttributesNativePtr binaryOriginAttributesPtr();

%{C++
  /**
   * De-XPCOMed getters
   */
  bool IsPrivate()
  {
    bool pb;
    GetIsPrivate(&pb);
    return pb;
  }

  bool IsAnonymous()
  {
    bool anon;
    GetIsAnonymous(&anon);
    return anon;
  }

  bool Equals(nsILoadContextInfo *aOther)
  {
    return IsAnonymous() == aOther->IsAnonymous() &&
           *OriginAttributesPtr() == *aOther->OriginAttributesPtr();
  }
%}
};

/**
 * Since NeckoOriginAttributes struct limits the implementation of
 * nsILoadContextInfo (that needs to be thread safe) to C++,
 * we need a scriptable factory to create instances of that
 * interface from JS.
 */
[scriptable, uuid(c1c7023d-4318-4f99-8307-b5ccf0558793)]
interface nsILoadContextInfoFactory : nsISupports
{
  readonly attribute nsILoadContextInfo default;
  readonly attribute nsILoadContextInfo private;
  readonly attribute nsILoadContextInfo anonymous;
  [implicit_jscontext]
  nsILoadContextInfo custom(in boolean aAnonymous, in jsval aOriginAttributes);
  nsILoadContextInfo fromLoadContext(in nsILoadContext aLoadContext, in boolean aAnonymous);
  nsILoadContextInfo fromWindow(in nsIDOMWindow aWindow, in boolean aAnonymous);
};