IWebIconDatabase.idl 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (C) 2006, 2007, 2008, 2009 Apple 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. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. cpp_quote("#define WebIconDatabaseDidAddIconNotification TEXT(\"WebIconDatabaseDidAddIconNotification\")")
  26. cpp_quote("#define WebIconNotificationUserInfoURLKey TEXT(\"WebIconNotificationUserInfoURLKey\")")
  27. cpp_quote("#define WebIconDatabaseDidRemoveAllIconsNotification TEXT(\"WebIconDatabaseDidRemoveAllIconsNotification\")")
  28. #ifndef DO_NO_IMPORTS
  29. import "oaidl.idl";
  30. import "ocidl.idl";
  31. #endif
  32. /*!
  33. @class WebIconDatabase
  34. @discussion Features:
  35. - memory cache icons at different sizes
  36. - disk storage
  37. - icon update notification
  38. Uses:
  39. - WebIconLoader to cache icon images
  40. - UI elements to retrieve icons that represent site URLs.
  41. - Save icons to disk for later use.
  42. Every icon in the database has a retain count. If an icon has a retain count greater than 0, it will be written to disk for later use. If an icon's retain count equals zero it will be removed from disk. The retain count is not persistent across launches. If the WebKit client wishes to retain an icon it should retain the icon once for every launch. This is best done at initialization time before the database begins removing icons. To make sure that the database does not remove unretained icons prematurely, call delayDatabaseCleanup until all desired icons are retained. Once all are retained, call allowDatabaseCleanup.
  43. Note that an icon can be retained after the database clean-up has begun. This just has to be done before the icon is removed. Icons are removed from the database whenever new icons are added to it.
  44. Retention methods can be called for icons that are not yet in the database.
  45. @interface WebIconDatabase : NSObject
  46. */
  47. [
  48. object,
  49. oleautomation,
  50. hidden,
  51. uuid(E93F2616-2560-47d9-BD4D-6E2F1E1D3174),
  52. pointer_default(unique)
  53. ]
  54. interface IWebIconDatabase : IUnknown
  55. {
  56. /*!
  57. @method sharedIconDatabase
  58. @abstract Returns a shared instance of the icon database
  59. + (WebIconDatabase *)sharedIconDatabase;
  60. */
  61. HRESULT sharedIconDatabase([out, retval] IWebIconDatabase** result);
  62. /*!
  63. @method iconForURL:withSize:
  64. @discussion Calls iconForURL:withSize:cache: with YES for cache.
  65. @param URL
  66. @param size
  67. - (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size;
  68. */
  69. /*!
  70. @method iconForURL:withSize:cache:
  71. @discussion Returns an icon for a web site URL from memory or disk. nil if none is found.
  72. Usually called by a UI element to determine if a site URL has an associated icon.
  73. Often called by the observer of WebIconChangedNotification after the notification is sent.
  74. @param URL
  75. @param size
  76. @param cache If yes, caches the returned image in memory if not already cached
  77. - (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size cache:(BOOL)cache;
  78. */
  79. /*!
  80. @method iconURLForURL:withSize:cache:
  81. @discussion Returns an icon URL for a web site URL from memory or disk. nil if none is found.
  82. @param URL
  83. - (NSString *)iconURLForURL:(NSString *)URL;
  84. */
  85. HRESULT iconForURL([in] BSTR url, [in] LPSIZE size, [in] BOOL cache, [out, retval] OLE_HANDLE* hBitmap);
  86. /*!
  87. @method defaultIconWithSize:
  88. @param size
  89. - (NSImage *)defaultIconWithSize:(NSSize)size;
  90. */
  91. HRESULT defaultIconWithSize([in] LPSIZE size, [out, retval] OLE_HANDLE* hBitmap);
  92. /*!
  93. @method retainIconForURL:
  94. @abstract Increments the retain count of the icon.
  95. @param URL
  96. - (void)retainIconForURL:(NSString *)URL;
  97. */
  98. HRESULT retainIconForURL([in] BSTR url);
  99. /*!
  100. @method releaseIconForURL:
  101. @abstract Decrements the retain count of the icon.
  102. @param URL
  103. - (void)releaseIconForURL:(NSString *)URL;
  104. */
  105. HRESULT releaseIconForURL([in] BSTR url);
  106. /*!
  107. @method removeAllIcons:
  108. @abstract Emtpies the Icon Database
  109. - (void)removeAllIcons;
  110. */
  111. HRESULT removeAllIcons();
  112. /*!
  113. @method delayDatabaseCleanup:
  114. @discussion Only effective if called before the database begins removing icons.
  115. delayDatabaseCleanUp increments an internal counter that when 0 begins the database clean-up.
  116. The counter equals 0 at initialization.
  117. - (void)delayDatabaseCleanup;
  118. */
  119. HRESULT delayDatabaseCleanup();
  120. /*!
  121. @method allowDatabaseCleanup:
  122. @discussion Informs the database that it now can begin removing icons.
  123. allowDatabaseCleanup decrements an internal counter that when 0 begins the database clean-up.
  124. The counter equals 0 at initialization.
  125. - (void)allowDatabaseCleanup;
  126. */
  127. HRESULT allowDatabaseCleanup();
  128. /*!
  129. @method iconURLForURL:withSize:cache:
  130. @discussion Returns an icon URL for a web site URL from memory or disk. nil if none is found.
  131. @param URL
  132. - (NSString *)iconURLForURL:(NSString *)URL;
  133. */
  134. HRESULT iconURLForURL([in] BSTR url, [out, retval] BSTR* iconURL);
  135. /*!
  136. @method isEnabled
  137. @discussion Returns true if the icon database is currently enabled, or false if it
  138. is disabled.
  139. - (BOOL)isEnabled;
  140. */
  141. HRESULT isEnabled([out, retval] BOOL* result);
  142. /*!
  143. @method setEnabled:
  144. @discussion Enables or disables the icon database based on the flag passed in.
  145. @param flag Pass true to enable the icon database, or false to disable it.
  146. - (void)setEnabled:(BOOL)flag;
  147. */
  148. HRESULT setEnabled([in] BOOL flag);
  149. /*!
  150. @method hasIconForURL:
  151. @discussion Returns whether or not the icon database has an icon for this URL.
  152. @parm url The URL to test for.
  153. */
  154. HRESULT hasIconForURL([in] BSTR url, [out, retval] BOOL* result);
  155. }