xref: /reactos/dll/win32/ieframe/ieframe.h (revision fc82f8e2)
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     ITargetFrame   ITargetFrame_iface;
76     ITargetFrame2  ITargetFrame2_iface;
77     ITargetFramePriv2 ITargetFramePriv2_iface;
78     IWebBrowserPriv2IE9 IWebBrowserPriv2IE9_iface;
79 
80     IUnknown *outer;
81     DocHost *doc_host;
82 } HlinkFrame;
83 
84 struct _task_header_t;
85 
86 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
87 typedef void (*task_destr_t)(struct _task_header_t*);
88 
89 typedef struct _task_header_t {
90     struct list entry;
91     task_proc_t proc;
92     task_destr_t destr;
93 } task_header_t;
94 
95 typedef struct {
96     IShellBrowser IShellBrowser_iface;
97     IBrowserService IBrowserService_iface;
98     IDocObjectService IDocObjectService_iface;
99 
100     LONG ref;
101 
102     DocHost *doc_host;
103 }  ShellBrowser;
104 
105 typedef struct {
106     IHTMLWindow2 IHTMLWindow2_iface;
107     DocHost *doc_host;
108 } IEHTMLWindow;
109 
110 typedef struct {
111     INewWindowManager INewWindowManager_iface;
112     DocHost *doc_host;
113 } NewWindowManager;
114 
115 typedef struct {
116     WCHAR *url;
117     IStream *stream;
118 } travellog_entry_t;
119 
120 typedef struct _IDocHostContainerVtbl
121 {
122     ULONG (*addref)(DocHost*);
123     ULONG (*release)(DocHost*);
124     void (*get_docobj_rect)(DocHost*,RECT*);
125     HRESULT (*set_status_text)(DocHost*,const WCHAR*);
126     void (*on_command_state_change)(DocHost*,LONG,BOOL);
127     void (*set_url)(DocHost*,const WCHAR*);
128 } IDocHostContainerVtbl;
129 
130 struct DocHost {
131     IOleClientSite      IOleClientSite_iface;
132     IOleInPlaceSiteEx   IOleInPlaceSiteEx_iface;
133     IDocHostUIHandler2  IDocHostUIHandler2_iface;
134     IOleDocumentSite    IOleDocumentSite_iface;
135     IOleControlSite     IOleControlSite_iface;
136     IOleCommandTarget   IOleCommandTarget_iface;
137     IDispatch           IDispatch_iface;
138     IPropertyNotifySink IPropertyNotifySink_iface;
139     IServiceProvider    IServiceProvider_iface;
140 
141     /* Interfaces of InPlaceFrame object */
142     IOleInPlaceFrame  IOleInPlaceFrame_iface;
143 
144     IWebBrowser2 *wb;
145 
146     IDispatch *client_disp;
147     IDocHostUIHandler *hostui;
148     IOleInPlaceFrame *frame;
149     IOleCommandTarget *olecmd;
150 
151     IUnknown *document;
152     IOleDocumentView *view;
153     IUnknown *doc_navigate;
154 
155     const IDocHostContainerVtbl *container_vtbl;
156 
157     HWND hwnd;
158     HWND frame_hwnd;
159 
160     struct list task_queue;
161 
162     LPOLESTR url;
163 
164     VARIANT_BOOL silent;
165     VARIANT_BOOL offline;
166     VARIANT_BOOL busy;
167 
168     READYSTATE ready_state;
169     READYSTATE doc_state;
170     DWORD prop_notif_cookie;
171     BOOL is_prop_notif;
172 
173     ShellBrowser *browser_service;
174     IShellUIHelper2 *shell_ui_helper;
175 
176     struct {
177         travellog_entry_t *log;
178         unsigned size;
179         unsigned length;
180         unsigned position;
181         int loading_pos;
182     } travellog;
183 
184     ConnectionPointContainer cps;
185     IEHTMLWindow html_window;
186     NewWindowManager nwm;
187 };
188 
189 struct WebBrowser {
190     IWebBrowser2             IWebBrowser2_iface;
191     IOleObject               IOleObject_iface;
192     IOleInPlaceObject        IOleInPlaceObject_iface;
193     IOleControl              IOleControl_iface;
194     IPersistStorage          IPersistStorage_iface;
195     IPersistMemory           IPersistMemory_iface;
196     IPersistStreamInit       IPersistStreamInit_iface;
197     IProvideClassInfo2       IProvideClassInfo2_iface;
198     IViewObject2             IViewObject2_iface;
199     IOleInPlaceActiveObject  IOleInPlaceActiveObject_iface;
200     IOleCommandTarget        IOleCommandTarget_iface;
201     IServiceProvider         IServiceProvider_iface;
202     IDataObject              IDataObject_iface;
203     HlinkFrame hlink_frame;
204 
205     LONG ref;
206 
207     INT version;
208 
209     IOleClientSite *client;
210     IOleClientSite *client_closed;
211     IOleContainer *container;
212     IOleInPlaceSiteEx *inplace;
213 
214     IAdviseSink *sink;
215     DWORD sink_aspects;
216     DWORD sink_flags;
217 
218     /* window context */
219 
220     HWND frame_hwnd;
221     IOleInPlaceUIWindow *uiwindow;
222     RECT pos_rect;
223     RECT clip_rect;
224     OLEINPLACEFRAMEINFO frameinfo;
225     SIZEL extent;
226 
227     HWND shell_embedding_hwnd;
228 
229     VARIANT_BOOL register_browser;
230     VARIANT_BOOL visible;
231     VARIANT_BOOL menu_bar;
232     VARIANT_BOOL address_bar;
233     VARIANT_BOOL status_bar;
234     VARIANT_BOOL tool_bar;
235     VARIANT_BOOL full_screen;
236     VARIANT_BOOL theater_mode;
237 
238     DocHost doc_host;
239 };
240 
241 struct InternetExplorer {
242     DocHost doc_host;
243     IWebBrowser2 IWebBrowser2_iface;
244     IExternalConnection IExternalConnection_iface;
245     IServiceProvider IServiceProvider_iface;
246     HlinkFrame hlink_frame;
247 
248     LONG ref;
249     LONG extern_ref;
250 
251     HWND frame_hwnd;
252     HWND status_hwnd;
253     HWND toolbar_hwnd;
254     HMENU menu;
255     BOOL nohome;
256 
257     struct list entry;
258 };
259 
260 void WebBrowser_OleObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
261 void WebBrowser_ViewObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
262 void WebBrowser_Persist_Init(WebBrowser*) DECLSPEC_HIDDEN;
263 void WebBrowser_ClassInfo_Init(WebBrowser*) DECLSPEC_HIDDEN;
264 
265 void WebBrowser_OleObject_Destroy(WebBrowser*) DECLSPEC_HIDDEN;
266 
267 void DocHost_Init(DocHost*,IWebBrowser2*,const IDocHostContainerVtbl*) DECLSPEC_HIDDEN;
268 void DocHost_Release(DocHost*) DECLSPEC_HIDDEN;
269 void DocHost_ClientSite_Init(DocHost*) DECLSPEC_HIDDEN;
270 void DocHost_ClientSite_Release(DocHost*) DECLSPEC_HIDDEN;
271 void DocHost_Frame_Init(DocHost*) DECLSPEC_HIDDEN;
272 void release_dochost_client(DocHost*) DECLSPEC_HIDDEN;
273 
274 void IEHTMLWindow_Init(DocHost*) DECLSPEC_HIDDEN;
275 void NewWindowManager_Init(DocHost*) DECLSPEC_HIDDEN;
276 
277 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*) DECLSPEC_HIDDEN;
278 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**) DECLSPEC_HIDDEN;
279 
280 HRESULT create_browser_service(DocHost*,ShellBrowser**) DECLSPEC_HIDDEN;
281 void detach_browser_service(ShellBrowser*) DECLSPEC_HIDDEN;
282 HRESULT create_shell_ui_helper(IShellUIHelper2**) DECLSPEC_HIDDEN;
283 
284 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*) DECLSPEC_HIDDEN;
285 void ConnectionPointContainer_Destroy(ConnectionPointContainer*) DECLSPEC_HIDDEN;
286 
287 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
288 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
289 HRESULT go_home(DocHost*) DECLSPEC_HIDDEN;
290 HRESULT go_back(DocHost*) DECLSPEC_HIDDEN;
291 HRESULT go_forward(DocHost*) DECLSPEC_HIDDEN;
292 HRESULT refresh_document(DocHost*,const VARIANT*) DECLSPEC_HIDDEN;
293 HRESULT get_location_url(DocHost*,BSTR*) DECLSPEC_HIDDEN;
294 HRESULT set_dochost_url(DocHost*,const WCHAR*) DECLSPEC_HIDDEN;
295 void handle_navigation_error(DocHost*,HRESULT,BSTR,IHTMLWindow2*) DECLSPEC_HIDDEN;
296 HRESULT dochost_object_available(DocHost*,IUnknown*) DECLSPEC_HIDDEN;
297 void set_doc_state(DocHost*,READYSTATE) DECLSPEC_HIDDEN;
298 void deactivate_document(DocHost*) DECLSPEC_HIDDEN;
299 void create_doc_view_hwnd(DocHost*) DECLSPEC_HIDDEN;
300 void on_commandstate_change(DocHost*,LONG,BOOL) DECLSPEC_HIDDEN;
301 void notify_download_state(DocHost*,BOOL) DECLSPEC_HIDDEN;
302 void update_navigation_commands(DocHost *dochost) DECLSPEC_HIDDEN;
303 
304 #define WM_DOCHOSTTASK (WM_USER+0x300)
305 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,task_destr_t,BOOL) DECLSPEC_HIDDEN;
306 void abort_dochost_tasks(DocHost*,task_proc_t) DECLSPEC_HIDDEN;
307 LRESULT process_dochost_tasks(DocHost*) DECLSPEC_HIDDEN;
308 
309 void InternetExplorer_WebBrowser_Init(InternetExplorer*) DECLSPEC_HIDDEN;
310 HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR) DECLSPEC_HIDDEN;
311 void released_obj(void) DECLSPEC_HIDDEN;
312 DWORD release_extern_ref(InternetExplorer*,BOOL) DECLSPEC_HIDDEN;
313 
314 void register_iewindow_class(void) DECLSPEC_HIDDEN;
315 void unregister_iewindow_class(void) DECLSPEC_HIDDEN;
316 
317 #define TID_LIST \
318     XCLSID(WebBrowser) \
319     XCLSID(WebBrowser_V1) \
320     XIID(IWebBrowser2)
321 
322 typedef enum {
323 #define XIID(iface) iface ## _tid,
324 #define XCLSID(class) class ## _tid,
325 TID_LIST
326 #undef XIID
327 #undef XCLSID
328     LAST_tid
329 } tid_t;
330 
331 HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
332 
333 HRESULT WINAPI CUrlHistory_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
334 HRESULT WINAPI InternetExplorer_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
335 HRESULT WINAPI InternetShortcut_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
336 HRESULT WINAPI WebBrowser_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
337 HRESULT WINAPI WebBrowserV1_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
338 HRESULT WINAPI InternetExplorerManager_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
339 
340 extern IClassFactory InternetExplorerFactory DECLSPEC_HIDDEN;
341 extern IClassFactory InternetExplorerManagerFactory DECLSPEC_HIDDEN;
342 
343 extern LONG module_ref DECLSPEC_HIDDEN;
344 extern HINSTANCE ieframe_instance DECLSPEC_HIDDEN;
345 
346 static inline void lock_module(void) {
347     InterlockedIncrement(&module_ref);
348 }
349 
350 static inline void unlock_module(void) {
351     InterlockedDecrement(&module_ref);
352 }
353 
354 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
355 {
356     return HeapAlloc(GetProcessHeap(), 0, size);
357 }
358 
359 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
360 {
361     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
362 }
363 
364 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
365 {
366     return HeapReAlloc(GetProcessHeap(), 0, mem, size);
367 }
368 
369 static inline BOOL heap_free(void *mem)
370 {
371     return HeapFree(GetProcessHeap(), 0, mem);
372 }
373 
374 static inline LPWSTR heap_strdupW(LPCWSTR str)
375 {
376     LPWSTR ret = NULL;
377 
378     if(str) {
379         DWORD size;
380 
381         size = (strlenW(str)+1)*sizeof(WCHAR);
382         ret = heap_alloc(size);
383         if(ret)
384             memcpy(ret, str, size);
385     }
386 
387     return ret;
388 }
389 
390 static inline LPWSTR co_strdupW(LPCWSTR str)
391 {
392     WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
393     if (ret)
394         lstrcpyW(ret, str);
395     return ret;
396 }
397 
398 static inline LPWSTR co_strdupAtoW(LPCSTR str)
399 {
400     INT len;
401     WCHAR *ret;
402     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
403     ret = CoTaskMemAlloc(len*sizeof(WCHAR));
404     if (ret)
405         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
406     return ret;
407 }
408 
409 static inline LPSTR co_strdupWtoA(LPCWSTR str)
410 {
411     INT len;
412     CHAR *ret;
413     len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
414     ret = CoTaskMemAlloc(len);
415     if (ret)
416         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
417     return ret;
418 }
419 
420 #endif /* _IEFRAME_H_ */
421