1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: ft=cpp tw=78 sw=2 et ts=2 sts=2 cin
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 "nsISupports.idl"
8
9interface mozIDOMWindowProxy;
10interface nsIDOMElement;
11
12%{C++
13#ifdef MOZILLA_INTERNAL_API
14#include "mozilla/BasePrincipal.h" // for DocShellOriginAttributes
15#endif
16%}
17
18/**
19 * An nsILoadContext represents the context of a load.  This interface
20 * can be queried for various information about where the load is
21 * happening.
22 */
23[scriptable, uuid(2813a7a3-d084-4d00-acd0-f76620315c02)]
24interface nsILoadContext : nsISupports
25{
26  /**
27   * associatedWindow is the window with which the load is associated, if any.
28   * Note that the load may be triggered by a document which is different from
29   * the document in associatedWindow, and in fact the source of the load need
30   * not be same-origin with the document in associatedWindow.  This attribute
31   * may be null if there is no associated window.
32   */
33  readonly attribute mozIDOMWindowProxy associatedWindow;
34
35  /**
36   * topWindow is the top window which is of same type as associatedWindow.
37   * This is equivalent to associatedWindow.top, but is provided here as a
38   * convenience.  All the same caveats as associatedWindow of apply, of
39   * course.  This attribute may be null if there is no associated window.
40   */
41  readonly attribute mozIDOMWindowProxy topWindow;
42
43  /**
44   * topFrameElement is the <iframe>, <frame>, or <browser> element which
45   * contains the topWindow with which the load is associated.
46   *
47   * Note that we may have a topFrameElement even when we don't have an
48   * associatedWindow, if the topFrameElement's content lives out of process.
49   * topFrameElement is available in single-process and multiprocess contexts.
50   * Note that topFrameElement may be in chrome even when the nsILoadContext is
51   * associated with content.
52   */
53  readonly attribute nsIDOMElement topFrameElement;
54
55  /**
56   * If this LoadContext corresponds to a nested remote iframe, we don't have
57   * access to the topFrameElement.  Instead, we must use this id to send
58   * messages. A return value of 0 signifies that this load context is not for
59   * a nested frame.
60   */
61  readonly attribute unsigned long long nestedFrameId;
62
63  /**
64   * True if the load context is content (as opposed to chrome).  This is
65   * determined based on the type of window the load is performed in, NOT based
66   * on any URIs that might be around.
67   */
68  readonly attribute boolean isContent;
69
70  /*
71   * Attribute that determines if private browsing should be used. May not be
72   * changed after a document has been loaded in this context.
73   */
74  attribute boolean usePrivateBrowsing;
75
76  /**
77   * Attribute that determines if remote (out-of-process) tabs should be used.
78   */
79  readonly attribute boolean useRemoteTabs;
80
81%{C++
82  /**
83   * De-XPCOMed getter to make call-sites cleaner.
84   */
85  bool UsePrivateBrowsing() {
86    bool usingPB;
87    GetUsePrivateBrowsing(&usingPB);
88    return usingPB;
89  }
90
91  bool UseRemoteTabs() {
92    bool usingRT;
93    GetUseRemoteTabs(&usingRT);
94    return usingRT;
95  }
96%}
97
98  /**
99   * Set the private browsing state of the load context, meant to be used internally.
100   */
101  [noscript] void SetPrivateBrowsing(in boolean aInPrivateBrowsing);
102
103  /**
104   * Set the remote tabs state of the load context, meant to be used internally.
105   */
106  [noscript] void SetRemoteTabs(in boolean aUseRemoteTabs);
107
108  /**
109   * Returns true iff the load is occurring inside an isolated mozbrowser
110   * element. <iframe mozbrowser mozapp> and <xul:browser> are not considered to
111   * be mozbrowser elements.  <iframe mozbrowser noisolation> does not count as
112   * isolated since isolation is disabled.  Isolation can only be disabled if
113   * the containing document is chrome.
114   */
115  readonly attribute boolean isInIsolatedMozBrowserElement;
116
117  /**
118   * Returns the app id of the app the load is occurring is in. Returns
119   * nsIScriptSecurityManager::NO_APP_ID if the load is not part of an app.
120   */
121  readonly attribute unsigned long appId;
122
123  /**
124   * A dictionary of the non-default origin attributes associated with this
125   * nsILoadContext.
126   */
127  readonly attribute jsval originAttributes;
128
129%{C++
130#ifdef MOZILLA_INTERNAL_API
131  /**
132   * The C++ getter for origin attributes.
133   *
134   * Defined in LoadContext.cpp
135   */
136  bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs);
137#endif
138%}
139
140  /**
141   * Returns true if tracking protection is enabled for the load context.
142   */
143  boolean IsTrackingProtectionOn();
144
145%{C++
146  /**
147   * De-XPCOMed getter to make call-sites cleaner.
148   */
149  bool UseTrackingProtection() {
150    bool usingTP;
151    IsTrackingProtectionOn(&usingTP);
152    return usingTP;
153  }
154%}
155};
156