|
1 /* |
|
2 * Copyright (C) 2006, 2007 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 |
|
26 #ifndef WebHistory_H |
|
27 #define WebHistory_H |
|
28 |
|
29 #include "IWebHistory.h" |
|
30 |
|
31 #include "COMPtr.h" |
|
32 #include <CoreFoundation/CoreFoundation.h> |
|
33 #include <wtf/RetainPtr.h> |
|
34 |
|
35 //----------------------------------------------------------------------------- |
|
36 |
|
37 // {3DE04E59-93F9-4369-8B43-976458D7E319} |
|
38 DEFINE_GUID(IID_IWebHistoryPrivate, 0x3de04e59, 0x93f9, 0x4369, 0x8b, 0x43, 0x97, 0x64, 0x58, 0xd7, 0xe3, 0x19); |
|
39 |
|
40 interface IWebHistoryPrivate : public IUnknown |
|
41 { |
|
42 public: |
|
43 virtual HRESULT STDMETHODCALLTYPE addItemForURL( |
|
44 /* [in] */ BSTR url, |
|
45 /* [in] */ BSTR title) = 0; |
|
46 virtual HRESULT STDMETHODCALLTYPE containsItemForURLString( |
|
47 /* [in] */ void* urlCFString, |
|
48 /* [retval][out] */ BOOL* contains) = 0; |
|
49 }; |
|
50 |
|
51 //----------------------------------------------------------------------------- |
|
52 |
|
53 class WebPreferences; |
|
54 |
|
55 class WebHistory : public IWebHistory, IWebHistoryPrivate |
|
56 { |
|
57 public: |
|
58 static WebHistory* createInstance(); |
|
59 protected: |
|
60 WebHistory(); |
|
61 ~WebHistory(); |
|
62 |
|
63 public: |
|
64 // IUnknown |
|
65 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); |
|
66 virtual ULONG STDMETHODCALLTYPE AddRef(void); |
|
67 virtual ULONG STDMETHODCALLTYPE Release(void); |
|
68 |
|
69 // IWebHistory |
|
70 virtual HRESULT STDMETHODCALLTYPE optionalSharedHistory( |
|
71 /* [retval][out] */ IWebHistory** history); |
|
72 |
|
73 virtual HRESULT STDMETHODCALLTYPE setOptionalSharedHistory( |
|
74 /* [in] */ IWebHistory* history); |
|
75 |
|
76 virtual HRESULT STDMETHODCALLTYPE loadFromURL( |
|
77 /* [in] */ BSTR url, |
|
78 /* [out] */ IWebError** error, |
|
79 /* [retval][out] */ BOOL* succeeded); |
|
80 |
|
81 virtual HRESULT STDMETHODCALLTYPE saveToURL( |
|
82 /* [in] */ BSTR url, |
|
83 /* [out] */ IWebError** error, |
|
84 /* [retval][out] */ BOOL* succeeded); |
|
85 |
|
86 virtual HRESULT STDMETHODCALLTYPE addItems( |
|
87 /* [in] */ int itemCount, |
|
88 /* [in] */ IWebHistoryItem** items); |
|
89 |
|
90 virtual HRESULT STDMETHODCALLTYPE removeItems( |
|
91 /* [in] */ int itemCount, |
|
92 /* [in] */ IWebHistoryItem** items); |
|
93 |
|
94 virtual HRESULT STDMETHODCALLTYPE removeAllItems( void); |
|
95 |
|
96 virtual HRESULT STDMETHODCALLTYPE orderedLastVisitedDays( |
|
97 /* [out][in] */ int* count, |
|
98 /* [in] */ DATE* calendarDates); |
|
99 |
|
100 virtual HRESULT STDMETHODCALLTYPE orderedItemsLastVisitedOnDay( |
|
101 /* [out][in] */ int* count, |
|
102 /* [in] */ IWebHistoryItem** items, |
|
103 /* [in] */ DATE calendarDate); |
|
104 |
|
105 virtual HRESULT STDMETHODCALLTYPE itemForURL( |
|
106 /* [in] */ BSTR url, |
|
107 /* [retval][out] */ IWebHistoryItem** item); |
|
108 |
|
109 virtual HRESULT STDMETHODCALLTYPE setHistoryItemLimit( |
|
110 /* [in] */ int limit); |
|
111 |
|
112 virtual HRESULT STDMETHODCALLTYPE historyItemLimit( |
|
113 /* [retval][out] */ int* limit); |
|
114 |
|
115 virtual HRESULT STDMETHODCALLTYPE setHistoryAgeInDaysLimit( |
|
116 /* [in] */ int limit); |
|
117 |
|
118 virtual HRESULT STDMETHODCALLTYPE historyAgeInDaysLimit( |
|
119 /* [retval][out] */ int* limit); |
|
120 |
|
121 // WebHistory |
|
122 static IWebHistoryPrivate* optionalSharedHistoryInternal(); |
|
123 virtual HRESULT STDMETHODCALLTYPE addItemForURL(BSTR url, BSTR title); |
|
124 virtual HRESULT STDMETHODCALLTYPE containsItemForURLString(void* urlCFString, BOOL* contains); |
|
125 |
|
126 protected: |
|
127 enum NotificationType |
|
128 { |
|
129 kWebHistoryItemsAddedNotification = 0, |
|
130 kWebHistoryItemsRemovedNotification = 1, |
|
131 kWebHistoryAllItemsRemovedNotification = 2, |
|
132 kWebHistoryLoadedNotification = 3, |
|
133 kWebHistoryItemsDiscardedWhileLoadingNotification = 4, |
|
134 kWebHistorySavedNotification = 5 |
|
135 }; |
|
136 |
|
137 HRESULT loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** error); |
|
138 HRESULT saveHistoryGuts(CFURLRef url, IWebError** error); |
|
139 HRESULT postNotification(NotificationType notifyType, IPropertyBag* userInfo = 0); |
|
140 HRESULT removeItem(IWebHistoryItem* entry); |
|
141 HRESULT addItem(IWebHistoryItem* entry); |
|
142 HRESULT removeItemForURLString(CFStringRef urlString); |
|
143 HRESULT addItemToDateCaches(IWebHistoryItem* entry); |
|
144 HRESULT removeItemFromDateCaches(IWebHistoryItem* entry); |
|
145 HRESULT insertItem(IWebHistoryItem* entry, int dateIndex); |
|
146 HRESULT ageLimitDate(CFAbsoluteTime* time); |
|
147 HRESULT datesArray(CFMutableArrayRef* datesArray); |
|
148 bool findIndex(int* index, CFAbsoluteTime forDay); |
|
149 static CFAbsoluteTime timeToDate(CFAbsoluteTime time); |
|
150 BSTR getNotificationString(NotificationType notifyType); |
|
151 HRESULT itemForURLString(CFStringRef urlString, IWebHistoryItem** item); |
|
152 |
|
153 protected: |
|
154 ULONG m_refCount; |
|
155 RetainPtr<CFMutableDictionaryRef> m_entriesByURL; |
|
156 RetainPtr<CFMutableArrayRef> m_datesWithEntries; |
|
157 RetainPtr<CFMutableArrayRef> m_entriesByDate; |
|
158 COMPtr<WebPreferences> m_preferences; |
|
159 static IWebHistory* m_optionalSharedHistory; |
|
160 }; |
|
161 |
|
162 #endif |