IHistory.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  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. #ifndef mozilla_IHistory_h_
  6. #define mozilla_IHistory_h_
  7. #include "nsISupports.h"
  8. class nsIURI;
  9. namespace mozilla {
  10. namespace dom {
  11. class Link;
  12. } // namespace dom
  13. // 0057c9d3-b98e-4933-bdc5-0275d06705e1
  14. #define IHISTORY_IID \
  15. {0x0057c9d3, 0xb98e, 0x4933, {0xbd, 0xc5, 0x02, 0x75, 0xd0, 0x67, 0x05, 0xe1}}
  16. class IHistory : public nsISupports
  17. {
  18. public:
  19. NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
  20. /**
  21. * Registers the Link for notifications about the visited-ness of aURI.
  22. * Consumers should assume that the URI is unvisited after calling this, and
  23. * they will be notified if that state (unvisited) changes by having
  24. * SetLinkState called on themselves. This function is guaranteed to run to
  25. * completion before aLink is notified. After the node is notified, it will
  26. * be unregistered.
  27. *
  28. * @note SetLinkState must not call RegisterVisitedCallback or
  29. * UnregisterVisitedCallback.
  30. *
  31. * @pre aURI must not be null.
  32. * @pre aLink may be null only in the parent (chrome) process.
  33. *
  34. * @param aURI
  35. * The URI to check.
  36. * @param aLink
  37. * The link to update whenever the history status changes. The
  38. * implementation will only hold onto a raw pointer, so if this
  39. * object should be destroyed, be sure to call
  40. * UnregisterVistedCallback first.
  41. */
  42. NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
  43. /**
  44. * Unregisters a previously registered Link object. This must be called
  45. * before destroying the registered object.
  46. *
  47. * @pre aURI must not be null.
  48. * @pre aLink must not be null.
  49. *
  50. * @param aURI
  51. * The URI that aLink was registered for.
  52. * @param aLink
  53. * The link object to unregister for aURI.
  54. */
  55. NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
  56. enum VisitFlags
  57. {
  58. /**
  59. * Indicates whether the URI was loaded in a top-level window.
  60. */
  61. TOP_LEVEL = 1 << 0,
  62. /**
  63. * Indicates whether the URI was loaded as part of a permanent redirect.
  64. */
  65. REDIRECT_PERMANENT = 1 << 1,
  66. /**
  67. * Indicates whether the URI was loaded as part of a temporary redirect.
  68. */
  69. REDIRECT_TEMPORARY = 1 << 2,
  70. /**
  71. * Indicates the URI is redirecting (Response code 3xx).
  72. */
  73. REDIRECT_SOURCE = 1 << 3,
  74. /**
  75. * Indicates the URI caused an error that is unlikely fixable by a
  76. * retry, like a not found or unfetchable page.
  77. */
  78. UNRECOVERABLE_ERROR = 1 << 4
  79. };
  80. /**
  81. * Adds a history visit for the URI.
  82. *
  83. * @pre aURI must not be null.
  84. *
  85. * @param aURI
  86. * The URI of the page being visited.
  87. * @param aLastVisitedURI
  88. * The URI of the last visit in the chain.
  89. * @param aFlags
  90. * The VisitFlags describing this visit.
  91. */
  92. NS_IMETHOD VisitURI(nsIURI* aURI,
  93. nsIURI* aLastVisitedURI,
  94. uint32_t aFlags) = 0;
  95. /**
  96. * Set the title of the URI.
  97. *
  98. * @pre aURI must not be null.
  99. *
  100. * @param aURI
  101. * The URI to set the title for.
  102. * @param aTitle
  103. * The title string.
  104. */
  105. NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
  106. /**
  107. * Notifies about the visited status of a given URI.
  108. *
  109. * @param aURI
  110. * The URI to notify about.
  111. */
  112. NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
  113. };
  114. NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
  115. #define NS_DECL_IHISTORY \
  116. NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, \
  117. mozilla::dom::Link* aContent) override; \
  118. NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, \
  119. mozilla::dom::Link* aContent) override; \
  120. NS_IMETHOD VisitURI(nsIURI* aURI, \
  121. nsIURI* aLastVisitedURI, \
  122. uint32_t aFlags) override; \
  123. NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) override; \
  124. NS_IMETHOD NotifyVisited(nsIURI* aURI) override;
  125. } // namespace mozilla
  126. #endif // mozilla_IHistory_h_