imgILoader.idl 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  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 imgINotificationObserver;
  8. interface imgIRequest;
  9. interface nsIChannel;
  10. interface nsILoadGroup;
  11. interface nsIPrincipal;
  12. interface nsIStreamListener;
  13. interface nsIURI;
  14. interface nsISimpleEnumerator;
  15. #include "nsIRequest.idl" // for nsLoadFlags
  16. #include "nsIContentPolicy.idl" // for nsContentPolicyType
  17. /**
  18. * imgILoader interface
  19. *
  20. * @author Stuart Parmenter <pavlov@netscape.com>
  21. * @version 0.3
  22. * @see imagelib2
  23. */
  24. [scriptable, builtinclass, uuid(e61377d2-910e-4c65-a64b-428d150e1fd1)]
  25. interface imgILoader : nsISupports
  26. {
  27. // Extra flags to pass to loadImage if you want a load to use CORS
  28. // validation.
  29. const unsigned long LOAD_CORS_ANONYMOUS = 1 << 16;
  30. const unsigned long LOAD_CORS_USE_CREDENTIALS = 1 << 17;
  31. /**
  32. * Start the load and decode of an image.
  33. * @param aURI the URI to load
  34. * @param aInitialDocumentURI the URI that 'initiated' the load -- used for
  35. * 3rd party cookie blocking
  36. * @param aReferrerURI the 'referring' URI
  37. * @param aReferrerPolicy the policy to apply to sending referrers.
  38. * examples: "default", "never", "always", "origin"
  39. * (see W3C referrer-policy spec for valid policy strings)
  40. * @param aLoadingPrincipal the principal of the loading document
  41. * @param aLoadGroup Loadgroup to put the image load into
  42. * @param aObserver the observer (may be null)
  43. * @param aCX some random data
  44. * @param aLoadFlags Load flags for the request
  45. * @param aCacheKey cache key to use for a load if the original
  46. * image came from a request that had post data
  47. * @param aContentPolicyType [optional] the nsContentPolicyType to
  48. * use for this load. Defaults to
  49. * nsIContentPolicy::TYPE_IMAGE
  50. * ImageLib does NOT keep a strong ref to the observer; this prevents
  51. * reference cycles. This means that callers of loadImage should
  52. * make sure to Cancel() the resulting request before the observer
  53. * goes away.
  54. */
  55. imgIRequest loadImageXPCOM(in nsIURI aURI,
  56. in nsIURI aInitialDocumentURL,
  57. in nsIURI aReferrerURI,
  58. in AString aReferrerPolicy,
  59. in nsIPrincipal aLoadingPrincipal,
  60. in nsILoadGroup aLoadGroup,
  61. in imgINotificationObserver aObserver,
  62. in nsISupports aCX,
  63. in nsLoadFlags aLoadFlags,
  64. in nsISupports cacheKey,
  65. [optional]
  66. in nsContentPolicyType aContentPolicyType);
  67. /**
  68. * Start the load and decode of an image.
  69. * @param aChannel the channel to load the image from. This must
  70. * already be opened before ths method is called, and there
  71. * must have been no OnDataAvailable calls for it yet.
  72. * @param aObserver the observer (may be null)
  73. * @param cx some random data
  74. * @param aListener [out]
  75. * A listener that you must send the channel's notifications and data
  76. * to. Can be null, in which case imagelib has found a cached image
  77. * and is not interested in the data. @aChannel will be canceled for
  78. * you in this case.
  79. *
  80. * ImageLib does NOT keep a strong ref to the observer; this prevents
  81. * reference cycles. This means that callers of loadImageWithChannel should
  82. * make sure to Cancel() the resulting request before the observer goes away.
  83. */
  84. imgIRequest loadImageWithChannelXPCOM(in nsIChannel aChannel,
  85. in imgINotificationObserver aObserver,
  86. in nsISupports cx,
  87. out nsIStreamListener aListener);
  88. };