nsILoadContextInfo.idl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. %{ C++
  7. #include "mozilla/BasePrincipal.h"
  8. %}
  9. native OriginAttributesNativePtr(const mozilla::NeckoOriginAttributes*);
  10. interface nsILoadContext;
  11. interface nsIDOMWindow;
  12. /**
  13. * Helper interface to carry informatin about the load context
  14. * encapsulating origin attributes and IsAnonymous, IsPrivite properties.
  15. * It shall be used where nsILoadContext cannot be used or is not
  16. * available.
  17. */
  18. [scriptable, builtinclass, uuid(555e2f8a-a1f6-41dd-88ca-ed4ed6b98a22)]
  19. interface nsILoadContextInfo : nsISupports
  20. {
  21. const unsigned long NO_APP_ID = 0;
  22. const unsigned long UNKNOWN_APP_ID = 4294967295; // UINT32_MAX
  23. /**
  24. * Whether the context is in a Private Browsing mode
  25. */
  26. readonly attribute boolean isPrivate;
  27. /**
  28. * Whether the load is initiated as anonymous
  29. */
  30. readonly attribute boolean isAnonymous;
  31. /**
  32. * NeckoOriginAttributes hiding all the security context attributes
  33. */
  34. [implicit_jscontext]
  35. readonly attribute jsval originAttributes;
  36. [noscript, notxpcom, nostdcall, binaryname(OriginAttributesPtr)]
  37. OriginAttributesNativePtr binaryOriginAttributesPtr();
  38. %{C++
  39. /**
  40. * De-XPCOMed getters
  41. */
  42. bool IsPrivate()
  43. {
  44. bool pb;
  45. GetIsPrivate(&pb);
  46. return pb;
  47. }
  48. bool IsAnonymous()
  49. {
  50. bool anon;
  51. GetIsAnonymous(&anon);
  52. return anon;
  53. }
  54. bool Equals(nsILoadContextInfo *aOther)
  55. {
  56. return IsAnonymous() == aOther->IsAnonymous() &&
  57. *OriginAttributesPtr() == *aOther->OriginAttributesPtr();
  58. }
  59. %}
  60. };
  61. /**
  62. * Since NeckoOriginAttributes struct limits the implementation of
  63. * nsILoadContextInfo (that needs to be thread safe) to C++,
  64. * we need a scriptable factory to create instances of that
  65. * interface from JS.
  66. */
  67. [scriptable, uuid(c1c7023d-4318-4f99-8307-b5ccf0558793)]
  68. interface nsILoadContextInfoFactory : nsISupports
  69. {
  70. readonly attribute nsILoadContextInfo default;
  71. readonly attribute nsILoadContextInfo private;
  72. readonly attribute nsILoadContextInfo anonymous;
  73. [implicit_jscontext]
  74. nsILoadContextInfo custom(in boolean aAnonymous, in jsval aOriginAttributes);
  75. nsILoadContextInfo fromLoadContext(in nsILoadContext aLoadContext, in boolean aAnonymous);
  76. nsILoadContextInfo fromWindow(in nsIDOMWindow aWindow, in boolean aAnonymous);
  77. };