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 #pragma once
22
23 #include <stdarg.h>
24
25 #define COBJMACROS
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #ifdef __REACTOS__
32 #include <winnls.h>
33 #include <wincon.h>
34 #endif
35
36 #include "ole2.h"
37 #include "olectl.h"
38 #include "shlobj.h"
39 #include "mshtmhst.h"
40 #include "exdisp.h"
41 #include "hlink.h"
42 #include "htiface.h"
43 #include "shdeprecated.h"
44 #include "docobjectservice.h"
45
46 #include "wine/heap.h"
47 #include "wine/list.h"
48
49 typedef struct ConnectionPoint ConnectionPoint;
50 typedef struct DocHost DocHost;
51
52 typedef struct {
53 IConnectionPointContainer IConnectionPointContainer_iface;
54
55 ConnectionPoint *wbe2;
56 ConnectionPoint *wbe;
57 ConnectionPoint *pns;
58
59 IUnknown *impl;
60 } ConnectionPointContainer;
61
62 typedef struct {
63 IHlinkFrame IHlinkFrame_iface;
64 ITargetFrame ITargetFrame_iface;
65 ITargetFrame2 ITargetFrame2_iface;
66 ITargetFramePriv2 ITargetFramePriv2_iface;
67 IWebBrowserPriv2IE9 IWebBrowserPriv2IE9_iface;
68
69 IUnknown *outer;
70 DocHost *doc_host;
71 } HlinkFrame;
72
73 struct _task_header_t;
74
75 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
76 typedef void (*task_destr_t)(struct _task_header_t*);
77
78 typedef struct _task_header_t {
79 struct list entry;
80 task_proc_t proc;
81 task_destr_t destr;
82 } task_header_t;
83
84 typedef struct {
85 IShellBrowser IShellBrowser_iface;
86 IBrowserService IBrowserService_iface;
87 IDocObjectService IDocObjectService_iface;
88
89 LONG ref;
90
91 DocHost *doc_host;
92 } ShellBrowser;
93
94 typedef struct {
95 IHTMLWindow2 IHTMLWindow2_iface;
96 DocHost *doc_host;
97 } IEHTMLWindow;
98
99 typedef struct {
100 INewWindowManager INewWindowManager_iface;
101 DocHost *doc_host;
102 } NewWindowManager;
103
104 typedef struct {
105 WCHAR *url;
106 IStream *stream;
107 } travellog_entry_t;
108
109 typedef struct _IDocHostContainerVtbl
110 {
111 ULONG (*addref)(DocHost*);
112 ULONG (*release)(DocHost*);
113 void (*get_docobj_rect)(DocHost*,RECT*);
114 HRESULT (*set_status_text)(DocHost*,const WCHAR*);
115 void (*on_command_state_change)(DocHost*,LONG,BOOL);
116 void (*set_url)(DocHost*,const WCHAR*);
117 } IDocHostContainerVtbl;
118
119 struct DocHost {
120 IOleClientSite IOleClientSite_iface;
121 IOleInPlaceSiteEx IOleInPlaceSiteEx_iface;
122 IDocHostUIHandler2 IDocHostUIHandler2_iface;
123 IOleDocumentSite IOleDocumentSite_iface;
124 IOleControlSite IOleControlSite_iface;
125 IOleCommandTarget IOleCommandTarget_iface;
126 IDispatch IDispatch_iface;
127 IPropertyNotifySink IPropertyNotifySink_iface;
128 IServiceProvider IServiceProvider_iface;
129
130 /* Interfaces of InPlaceFrame object */
131 IOleInPlaceFrame IOleInPlaceFrame_iface;
132
133 IWebBrowser2 *wb;
134
135 IDispatch *client_disp;
136 IDocHostUIHandler *hostui;
137 IOleInPlaceFrame *frame;
138 IOleCommandTarget *olecmd;
139
140 IUnknown *document;
141 IOleDocumentView *view;
142 IUnknown *doc_navigate;
143
144 const IDocHostContainerVtbl *container_vtbl;
145
146 HWND hwnd;
147 HWND frame_hwnd;
148
149 struct list task_queue;
150
151 LPOLESTR url;
152
153 VARIANT_BOOL silent;
154 VARIANT_BOOL offline;
155 VARIANT_BOOL busy;
156
157 READYSTATE ready_state;
158 READYSTATE doc_state;
159 DWORD prop_notif_cookie;
160 BOOL is_prop_notif;
161
162 ShellBrowser *browser_service;
163 IShellUIHelper2 *shell_ui_helper;
164
165 struct {
166 travellog_entry_t *log;
167 unsigned size;
168 unsigned length;
169 unsigned position;
170 int loading_pos;
171 } travellog;
172
173 ConnectionPointContainer cps;
174 IEHTMLWindow html_window;
175 NewWindowManager nwm;
176 };
177
178 struct WebBrowser {
179 IWebBrowser2 IWebBrowser2_iface;
180 IOleObject IOleObject_iface;
181 IOleInPlaceObject IOleInPlaceObject_iface;
182 IOleControl IOleControl_iface;
183 IPersistStorage IPersistStorage_iface;
184 IPersistMemory IPersistMemory_iface;
185 IPersistStreamInit IPersistStreamInit_iface;
186 IProvideClassInfo2 IProvideClassInfo2_iface;
187 IViewObject2 IViewObject2_iface;
188 IOleInPlaceActiveObject IOleInPlaceActiveObject_iface;
189 IOleCommandTarget IOleCommandTarget_iface;
190 IServiceProvider IServiceProvider_iface;
191 IDataObject IDataObject_iface;
192 HlinkFrame hlink_frame;
193
194 LONG ref;
195
196 INT version;
197
198 IOleClientSite *client;
199 IOleClientSite *client_closed;
200 IOleContainer *container;
201 IOleInPlaceSiteEx *inplace;
202
203 IAdviseSink *sink;
204 DWORD sink_aspects;
205 DWORD sink_flags;
206
207 /* window context */
208
209 HWND frame_hwnd;
210 IOleInPlaceUIWindow *uiwindow;
211 RECT pos_rect;
212 RECT clip_rect;
213 OLEINPLACEFRAMEINFO frameinfo;
214 SIZEL extent;
215
216 HWND shell_embedding_hwnd;
217
218 VARIANT_BOOL register_browser;
219 VARIANT_BOOL visible;
220 VARIANT_BOOL menu_bar;
221 VARIANT_BOOL address_bar;
222 VARIANT_BOOL status_bar;
223 VARIANT_BOOL tool_bar;
224 VARIANT_BOOL full_screen;
225 VARIANT_BOOL theater_mode;
226
227 DocHost doc_host;
228 };
229
230 struct InternetExplorer {
231 DocHost doc_host;
232 IWebBrowser2 IWebBrowser2_iface;
233 IExternalConnection IExternalConnection_iface;
234 IServiceProvider IServiceProvider_iface;
235 HlinkFrame hlink_frame;
236
237 LONG ref;
238 LONG extern_ref;
239
240 HWND frame_hwnd;
241 HWND status_hwnd;
242 HWND toolbar_hwnd;
243 HMENU menu;
244 BOOL nohome;
245
246 struct list entry;
247 };
248
249 void WebBrowser_OleObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
250 void WebBrowser_ViewObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
251 void WebBrowser_Persist_Init(WebBrowser*) DECLSPEC_HIDDEN;
252 void WebBrowser_ClassInfo_Init(WebBrowser*) DECLSPEC_HIDDEN;
253
254 void WebBrowser_OleObject_Destroy(WebBrowser*) DECLSPEC_HIDDEN;
255
256 void DocHost_Init(DocHost*,IWebBrowser2*,const IDocHostContainerVtbl*) DECLSPEC_HIDDEN;
257 void DocHost_Release(DocHost*) DECLSPEC_HIDDEN;
258 void DocHost_ClientSite_Init(DocHost*) DECLSPEC_HIDDEN;
259 void DocHost_ClientSite_Release(DocHost*) DECLSPEC_HIDDEN;
260 void DocHost_Frame_Init(DocHost*) DECLSPEC_HIDDEN;
261 void release_dochost_client(DocHost*) DECLSPEC_HIDDEN;
262
263 void IEHTMLWindow_Init(DocHost*) DECLSPEC_HIDDEN;
264 void NewWindowManager_Init(DocHost*) DECLSPEC_HIDDEN;
265
266 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*) DECLSPEC_HIDDEN;
267 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**) DECLSPEC_HIDDEN;
268
269 HRESULT create_browser_service(DocHost*,ShellBrowser**) DECLSPEC_HIDDEN;
270 void detach_browser_service(ShellBrowser*) DECLSPEC_HIDDEN;
271 HRESULT create_shell_ui_helper(IShellUIHelper2**) DECLSPEC_HIDDEN;
272
273 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*) DECLSPEC_HIDDEN;
274 void ConnectionPointContainer_Destroy(ConnectionPointContainer*) DECLSPEC_HIDDEN;
275
276 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
277 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
278 HRESULT go_home(DocHost*) DECLSPEC_HIDDEN;
279 HRESULT go_back(DocHost*) DECLSPEC_HIDDEN;
280 HRESULT go_forward(DocHost*) DECLSPEC_HIDDEN;
281 HRESULT refresh_document(DocHost*,const VARIANT*) DECLSPEC_HIDDEN;
282 HRESULT get_location_url(DocHost*,BSTR*) DECLSPEC_HIDDEN;
283 HRESULT set_dochost_url(DocHost*,const WCHAR*) DECLSPEC_HIDDEN;
284 void handle_navigation_error(DocHost*,HRESULT,BSTR,IHTMLWindow2*) DECLSPEC_HIDDEN;
285 HRESULT dochost_object_available(DocHost*,IUnknown*) DECLSPEC_HIDDEN;
286 void set_doc_state(DocHost*,READYSTATE) DECLSPEC_HIDDEN;
287 void deactivate_document(DocHost*) DECLSPEC_HIDDEN;
288 void create_doc_view_hwnd(DocHost*) DECLSPEC_HIDDEN;
289 void on_commandstate_change(DocHost*,LONG,BOOL) DECLSPEC_HIDDEN;
290 void notify_download_state(DocHost*,BOOL) DECLSPEC_HIDDEN;
291 void update_navigation_commands(DocHost *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
322 HRESULT WINAPI CUrlHistory_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
323 HRESULT WINAPI InternetExplorer_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
324 HRESULT WINAPI InternetShortcut_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
325 HRESULT WINAPI WebBrowser_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
326 HRESULT WINAPI WebBrowserV1_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
327 HRESULT WINAPI InternetExplorerManager_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
328
329 extern IClassFactory InternetExplorerFactory DECLSPEC_HIDDEN;
330 extern IClassFactory InternetExplorerManagerFactory DECLSPEC_HIDDEN;
331
332 extern LONG module_ref DECLSPEC_HIDDEN;
333 extern HINSTANCE ieframe_instance DECLSPEC_HIDDEN;
334
lock_module(void)335 static inline void lock_module(void) {
336 InterlockedIncrement(&module_ref);
337 }
338
unlock_module(void)339 static inline void unlock_module(void) {
340 InterlockedDecrement(&module_ref);
341 }
342
heap_strdupW(LPCWSTR str)343 static inline LPWSTR heap_strdupW(LPCWSTR str)
344 {
345 LPWSTR ret = NULL;
346
347 if(str) {
348 DWORD size;
349
350 size = (lstrlenW(str)+1)*sizeof(WCHAR);
351 ret = heap_alloc(size);
352 if(ret)
353 memcpy(ret, str, size);
354 }
355
356 return ret;
357 }
358
co_strdupW(LPCWSTR str)359 static inline LPWSTR co_strdupW(LPCWSTR str)
360 {
361 WCHAR *ret = CoTaskMemAlloc((lstrlenW(str) + 1)*sizeof(WCHAR));
362 if (ret)
363 lstrcpyW(ret, str);
364 return ret;
365 }
366
co_strdupAtoW(LPCSTR str)367 static inline LPWSTR co_strdupAtoW(LPCSTR str)
368 {
369 INT len;
370 WCHAR *ret;
371 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
372 ret = CoTaskMemAlloc(len*sizeof(WCHAR));
373 if (ret)
374 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
375 return ret;
376 }
377
co_strdupWtoA(LPCWSTR str)378 static inline LPSTR co_strdupWtoA(LPCWSTR str)
379 {
380 INT len;
381 CHAR *ret;
382 len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
383 ret = CoTaskMemAlloc(len);
384 if (ret)
385 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
386 return ret;
387 }
388