Revert r66580 and r66579.
[reactos.git] / reactos / dll / win32 / ieframe / ieframe.h
1 /*
2 * Header includes for ieframe.dll
3 *
4 * Copyright 2011 Jacek Caban for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifndef _IEFRAME_H_
22 #define _IEFRAME_H_
23
24 #include <stdio.h>
25
26 #define WIN32_NO_STATUS
27 #define _INC_WINDOWS
28 #define COM_NO_WINDOWS_H
29
30 #define COBJMACROS
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
33
34 #include <windef.h>
35 #include <winbase.h>
36 #include <wingdi.h>
37 #include <winreg.h>
38 #include <wincon.h>
39 #include <shlobj.h>
40 #include <mshtmhst.h>
41 #include <mshtmdid.h>
42 #include <exdispid.h>
43 #include <htiface.h>
44 #include <idispids.h>
45 #include <intshcut.h>
46 #include <perhist.h>
47 #include <shellapi.h>
48 #include <shlwapi.h>
49 #include <shdeprecated.h>
50 #include <docobjectservice.h>
51
52 #include <wine/unicode.h>
53 #include <wine/list.h>
54
55 #include <wine/debug.h>
56 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
57
58 #include "resource.h"
59
60 typedef struct ConnectionPoint ConnectionPoint;
61 typedef struct DocHost DocHost;
62
63 typedef struct {
64 IConnectionPointContainer IConnectionPointContainer_iface;
65
66 ConnectionPoint *wbe2;
67 ConnectionPoint *wbe;
68 ConnectionPoint *pns;
69
70 IUnknown *impl;
71 } ConnectionPointContainer;
72
73 typedef struct {
74 IHlinkFrame IHlinkFrame_iface;
75 ITargetFrame2 ITargetFrame2_iface;
76 ITargetFramePriv2 ITargetFramePriv2_iface;
77 IWebBrowserPriv2IE9 IWebBrowserPriv2IE9_iface;
78
79 IUnknown *outer;
80 DocHost *doc_host;
81 } HlinkFrame;
82
83 struct _task_header_t;
84
85 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
86 typedef void (*task_destr_t)(struct _task_header_t*);
87
88 typedef struct _task_header_t {
89 struct list entry;
90 task_proc_t proc;
91 task_destr_t destr;
92 } task_header_t;
93
94 typedef struct {
95 IShellBrowser IShellBrowser_iface;
96 IBrowserService IBrowserService_iface;
97 IDocObjectService IDocObjectService_iface;
98
99 LONG ref;
100
101 DocHost *doc_host;
102 } ShellBrowser;
103
104 typedef struct {
105 IHTMLWindow2 IHTMLWindow2_iface;
106 DocHost *doc_host;
107 } IEHTMLWindow;
108
109 typedef struct {
110 INewWindowManager INewWindowManager_iface;
111 DocHost *doc_host;
112 } NewWindowManager;
113
114 typedef struct {
115 WCHAR *url;
116 IStream *stream;
117 } travellog_entry_t;
118
119 typedef struct _IDocHostContainerVtbl
120 {
121 ULONG (*addref)(DocHost*);
122 ULONG (*release)(DocHost*);
123 void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
124 HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
125 void (WINAPI* SetURL)(DocHost*,LPCWSTR);
126 HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
127 } IDocHostContainerVtbl;
128
129 struct DocHost {
130 IOleClientSite IOleClientSite_iface;
131 IOleInPlaceSiteEx IOleInPlaceSiteEx_iface;
132 IDocHostUIHandler2 IDocHostUIHandler2_iface;
133 IOleDocumentSite IOleDocumentSite_iface;
134 IOleControlSite IOleControlSite_iface;
135 IOleCommandTarget IOleCommandTarget_iface;
136 IDispatch IDispatch_iface;
137 IPropertyNotifySink IPropertyNotifySink_iface;
138 IServiceProvider IServiceProvider_iface;
139
140 /* Interfaces of InPlaceFrame object */
141 IOleInPlaceFrame IOleInPlaceFrame_iface;
142
143 IWebBrowser2 *wb;
144
145 IDispatch *client_disp;
146 IDocHostUIHandler *hostui;
147 IOleInPlaceFrame *frame;
148
149 IUnknown *document;
150 IOleDocumentView *view;
151 IUnknown *doc_navigate;
152
153 const IDocHostContainerVtbl *container_vtbl;
154
155 HWND hwnd;
156 HWND frame_hwnd;
157
158 struct list task_queue;
159
160 LPOLESTR url;
161
162 VARIANT_BOOL silent;
163 VARIANT_BOOL offline;
164 VARIANT_BOOL busy;
165
166 READYSTATE ready_state;
167 READYSTATE doc_state;
168 DWORD prop_notif_cookie;
169 BOOL is_prop_notif;
170
171 ShellBrowser *browser_service;
172 IShellUIHelper2 *shell_ui_helper;
173
174 struct {
175 travellog_entry_t *log;
176 unsigned size;
177 unsigned length;
178 unsigned position;
179 int loading_pos;
180 } travellog;
181
182 ConnectionPointContainer cps;
183 IEHTMLWindow html_window;
184 NewWindowManager nwm;
185 };
186
187 struct WebBrowser {
188 IWebBrowser2 IWebBrowser2_iface;
189 IOleObject IOleObject_iface;
190 IOleInPlaceObject IOleInPlaceObject_iface;
191 IOleControl IOleControl_iface;
192 IPersistStorage IPersistStorage_iface;
193 IPersistMemory IPersistMemory_iface;
194 IPersistStreamInit IPersistStreamInit_iface;
195 IProvideClassInfo2 IProvideClassInfo2_iface;
196 IViewObject2 IViewObject2_iface;
197 IOleInPlaceActiveObject IOleInPlaceActiveObject_iface;
198 IOleCommandTarget IOleCommandTarget_iface;
199 IServiceProvider IServiceProvider_iface;
200 IDataObject IDataObject_iface;
201 HlinkFrame hlink_frame;
202
203 LONG ref;
204
205 INT version;
206
207 IOleClientSite *client;
208 IOleContainer *container;
209 IOleInPlaceSiteEx *inplace;
210
211 /* window context */
212
213 HWND frame_hwnd;
214 IOleInPlaceUIWindow *uiwindow;
215 RECT pos_rect;
216 RECT clip_rect;
217 OLEINPLACEFRAMEINFO frameinfo;
218 SIZEL extent;
219
220 HWND shell_embedding_hwnd;
221
222 VARIANT_BOOL register_browser;
223 VARIANT_BOOL visible;
224 VARIANT_BOOL menu_bar;
225 VARIANT_BOOL address_bar;
226 VARIANT_BOOL status_bar;
227 VARIANT_BOOL tool_bar;
228 VARIANT_BOOL full_screen;
229 VARIANT_BOOL theater_mode;
230
231 DocHost doc_host;
232 };
233
234 struct InternetExplorer {
235 DocHost doc_host;
236 IWebBrowser2 IWebBrowser2_iface;
237 IExternalConnection IExternalConnection_iface;
238 IServiceProvider IServiceProvider_iface;
239 HlinkFrame hlink_frame;
240
241 LONG ref;
242 LONG extern_ref;
243
244 HWND frame_hwnd;
245 HWND status_hwnd;
246 HMENU menu;
247 BOOL nohome;
248
249 struct list entry;
250 };
251
252 void WebBrowser_OleObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
253 void WebBrowser_ViewObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
254 void WebBrowser_Persist_Init(WebBrowser*) DECLSPEC_HIDDEN;
255 void WebBrowser_ClassInfo_Init(WebBrowser*) DECLSPEC_HIDDEN;
256
257 void WebBrowser_OleObject_Destroy(WebBrowser*) DECLSPEC_HIDDEN;
258
259 void DocHost_Init(DocHost*,IWebBrowser2*,const IDocHostContainerVtbl*) DECLSPEC_HIDDEN;
260 void DocHost_Release(DocHost*) DECLSPEC_HIDDEN;
261 void DocHost_ClientSite_Init(DocHost*) DECLSPEC_HIDDEN;
262 void DocHost_ClientSite_Release(DocHost*) DECLSPEC_HIDDEN;
263 void DocHost_Frame_Init(DocHost*) DECLSPEC_HIDDEN;
264 void release_dochost_client(DocHost*) DECLSPEC_HIDDEN;
265
266 void IEHTMLWindow_Init(DocHost*) DECLSPEC_HIDDEN;
267 void NewWindowManager_Init(DocHost*) DECLSPEC_HIDDEN;
268
269 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*) DECLSPEC_HIDDEN;
270 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**) DECLSPEC_HIDDEN;
271
272 HRESULT create_browser_service(DocHost*,ShellBrowser**) DECLSPEC_HIDDEN;
273 void detach_browser_service(ShellBrowser*) DECLSPEC_HIDDEN;
274 HRESULT create_shell_ui_helper(IShellUIHelper2**) DECLSPEC_HIDDEN;
275
276 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*) DECLSPEC_HIDDEN;
277 void ConnectionPointContainer_Destroy(ConnectionPointContainer*) DECLSPEC_HIDDEN;
278
279 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
280 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
281 HRESULT go_home(DocHost*) DECLSPEC_HIDDEN;
282 HRESULT go_back(DocHost*) DECLSPEC_HIDDEN;
283 HRESULT go_forward(DocHost*) DECLSPEC_HIDDEN;
284 HRESULT refresh_document(DocHost*) DECLSPEC_HIDDEN;
285 HRESULT get_location_url(DocHost*,BSTR*) DECLSPEC_HIDDEN;
286 HRESULT set_dochost_url(DocHost*,const WCHAR*) DECLSPEC_HIDDEN;
287 void handle_navigation_error(DocHost*,HRESULT,BSTR,IHTMLWindow2*) DECLSPEC_HIDDEN;
288 HRESULT dochost_object_available(DocHost*,IUnknown*) DECLSPEC_HIDDEN;
289 void set_doc_state(DocHost*,READYSTATE) DECLSPEC_HIDDEN;
290 void deactivate_document(DocHost*) DECLSPEC_HIDDEN;
291 void create_doc_view_hwnd(DocHost*) DECLSPEC_HIDDEN;
292
293 #define WM_DOCHOSTTASK (WM_USER+0x300)
294 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,task_destr_t,BOOL) DECLSPEC_HIDDEN;
295 void abort_dochost_tasks(DocHost*,task_proc_t) DECLSPEC_HIDDEN;
296 LRESULT process_dochost_tasks(DocHost*) DECLSPEC_HIDDEN;
297
298 void InternetExplorer_WebBrowser_Init(InternetExplorer*) DECLSPEC_HIDDEN;
299 HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR) DECLSPEC_HIDDEN;
300 void released_obj(void) DECLSPEC_HIDDEN;
301 DWORD release_extern_ref(InternetExplorer*,BOOL) DECLSPEC_HIDDEN;
302
303 void register_iewindow_class(void) DECLSPEC_HIDDEN;
304 void unregister_iewindow_class(void) DECLSPEC_HIDDEN;
305
306 #define TID_LIST \
307 XCLSID(WebBrowser) \
308 XCLSID(WebBrowser_V1) \
309 XIID(IWebBrowser2)
310
311 typedef enum {
312 #define XIID(iface) iface ## _tid,
313 #define XCLSID(class) class ## _tid,
314 TID_LIST
315 #undef XIID
316 #undef XCLSID
317 LAST_tid
318 } tid_t;
319
320 HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
321 HRESULT register_class_object(BOOL) DECLSPEC_HIDDEN;
322
323 HRESULT WINAPI CUrlHistory_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
324 HRESULT WINAPI InternetExplorer_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
325 HRESULT WINAPI InternetShortcut_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
326 HRESULT WINAPI WebBrowser_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
327 HRESULT WINAPI WebBrowserV1_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
328
329 extern LONG module_ref DECLSPEC_HIDDEN;
330 extern HINSTANCE ieframe_instance DECLSPEC_HIDDEN;
331
332 static inline void lock_module(void) {
333 InterlockedIncrement(&module_ref);
334 }
335
336 static inline void unlock_module(void) {
337 InterlockedDecrement(&module_ref);
338 }
339
340 static inline void *heap_alloc(size_t len)
341 {
342 return HeapAlloc(GetProcessHeap(), 0, len);
343 }
344
345 static inline void *heap_alloc_zero(size_t len)
346 {
347 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
348 }
349
350 static inline void *heap_realloc(void *mem, size_t len)
351 {
352 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
353 }
354
355 static inline BOOL heap_free(void *mem)
356 {
357 return HeapFree(GetProcessHeap(), 0, mem);
358 }
359
360 static inline LPWSTR heap_strdupW(LPCWSTR str)
361 {
362 LPWSTR ret = NULL;
363
364 if(str) {
365 DWORD size;
366
367 size = (strlenW(str)+1)*sizeof(WCHAR);
368 ret = heap_alloc(size);
369 if(ret)
370 memcpy(ret, str, size);
371 }
372
373 return ret;
374 }
375
376 static inline LPWSTR co_strdupW(LPCWSTR str)
377 {
378 WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
379 if (ret)
380 lstrcpyW(ret, str);
381 return ret;
382 }
383
384 static inline LPWSTR co_strdupAtoW(LPCSTR str)
385 {
386 INT len;
387 WCHAR *ret;
388 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
389 ret = CoTaskMemAlloc(len*sizeof(WCHAR));
390 if (ret)
391 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
392 return ret;
393 }
394
395 static inline LPSTR co_strdupWtoA(LPCWSTR str)
396 {
397 INT len;
398 CHAR *ret;
399 len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
400 ret = CoTaskMemAlloc(len);
401 if (ret)
402 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
403 return ret;
404 }
405
406 #endif /* _IEFRAME_H_ */