WebHistory.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (C) 2003, 2004 Apple Computer, Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  14. * its contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #import <Foundation/Foundation.h>
  29. @class NSError;
  30. @class WebHistoryItem;
  31. @class WebHistoryPrivate;
  32. /*
  33. @discussion Notifications sent when history is modified.
  34. @constant WebHistoryItemsAddedNotification Posted from addItems:. This
  35. notification comes with a userInfo dictionary that contains the array of
  36. items added. The key for the array is WebHistoryItemsKey.
  37. @constant WebHistoryItemsRemovedNotification Posted from removeItems:.
  38. This notification comes with a userInfo dictionary that contains the array of
  39. items removed. The key for the array is WebHistoryItemsKey.
  40. @constant WebHistoryAllItemsRemovedNotification Posted from removeAllItems
  41. @constant WebHistoryLoadedNotification Posted from loadFromURL:error:.
  42. */
  43. extern NSString *WebHistoryItemsAddedNotification;
  44. extern NSString *WebHistoryItemsRemovedNotification;
  45. extern NSString *WebHistoryAllItemsRemovedNotification;
  46. extern NSString *WebHistoryLoadedNotification;
  47. extern NSString *WebHistorySavedNotification;
  48. extern NSString *WebHistoryItemsKey;
  49. /*!
  50. @class WebHistory
  51. @discussion WebHistory is used to track pages that have been loaded
  52. by WebKit.
  53. */
  54. @interface WebHistory : NSObject {
  55. @private
  56. WebHistoryPrivate *_historyPrivate;
  57. }
  58. /*!
  59. @method optionalSharedHistory
  60. @abstract Returns a shared WebHistory instance initialized with the default history file.
  61. @result A WebHistory object.
  62. */
  63. + (WebHistory *)optionalSharedHistory;
  64. /*!
  65. @method setOptionalSharedHistory:
  66. @param history The history to use for the global WebHistory.
  67. */
  68. + (void)setOptionalSharedHistory:(WebHistory *)history;
  69. /*!
  70. @method loadFromURL:error:
  71. @param URL The URL to use to initialize the WebHistory.
  72. @param error Set to nil or an NSError instance if an error occurred.
  73. @abstract The designated initializer for WebHistory.
  74. @result Returns YES if successful, NO otherwise.
  75. */
  76. - (BOOL)loadFromURL:(NSURL *)URL error:(NSError **)error;
  77. /*!
  78. @method saveToURL:error:
  79. @discussion Save history to URL. It is the client's responsibility to call this at appropriate times.
  80. @param URL The URL to use to save the WebHistory.
  81. @param error Set to nil or an NSError instance if an error occurred.
  82. @result Returns YES if successful, NO otherwise.
  83. */
  84. - (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error;
  85. /*!
  86. @method addItems:
  87. @param newItems An array of WebHistoryItems to add to the WebHistory.
  88. */
  89. - (void)addItems:(NSArray *)newItems;
  90. /*!
  91. @method removeItems:
  92. @param items An array of WebHistoryItems to remove from the WebHistory.
  93. */
  94. - (void)removeItems:(NSArray *)items;
  95. /*!
  96. @method removeAllItems
  97. */
  98. - (void)removeAllItems;
  99. /*!
  100. @method orderedLastVisitedDays
  101. @discussion Get an array of NSCalendarDates, each one representing a unique day that contains one
  102. or more history items, ordered from most recent to oldest.
  103. @result Returns an array of NSCalendarDates for which history items exist in the WebHistory.
  104. */
  105. - (NSArray *)orderedLastVisitedDays;
  106. /*!
  107. @method orderedItemsLastVisitedOnDay:
  108. @discussion Get an array of WebHistoryItem that were last visited on the day represented by the
  109. specified NSCalendarDate, ordered from most recent to oldest.
  110. @param calendarDate A date identifying the unique day of interest.
  111. @result Returns an array of WebHistoryItems last visited on the indicated day.
  112. */
  113. - (NSArray *)orderedItemsLastVisitedOnDay:(NSCalendarDate *)calendarDate;
  114. /*!
  115. @method itemForURL:
  116. @abstract Get an item for a specific URL
  117. @param URL The URL of the history item to search for
  118. @result Returns an item matching the URL
  119. */
  120. - (WebHistoryItem *)itemForURL:(NSURL *)URL;
  121. /*!
  122. @method setHistoryItemLimit:
  123. @discussion Limits the number of items that will be stored by the WebHistory.
  124. @param limit The maximum number of items that will be stored by the WebHistory.
  125. */
  126. - (void)setHistoryItemLimit:(int)limit;
  127. /*!
  128. @method historyItemLimit
  129. @result The maximum number of items that will be stored by the WebHistory.
  130. */
  131. - (int)historyItemLimit;
  132. /*!
  133. @method setHistoryAgeInDaysLimit:
  134. @discussion setHistoryAgeInDaysLimit: sets the maximum number of days to be read from
  135. stored history.
  136. @param limit The maximum number of days to be read from stored history.
  137. */
  138. - (void)setHistoryAgeInDaysLimit:(int)limit;
  139. /*!
  140. @method historyAgeInDaysLimit
  141. @return Returns the maximum number of days to be read from stored history.
  142. */
  143. - (int)historyAgeInDaysLimit;
  144. @end