nsILoadContext.idl 4.8 KB

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