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