webbrowser.c 27.5 KB
Newer Older
1
/*
2
 * Implementation of IWebBrowser interface for WebBrowser control
3 4
 *
 * Copyright 2001 John R. Sheets (for CodeWeavers)
5
 * Copyright 2005 Jacek Caban
6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 21 22 23
 */

#include "wine/debug.h"
#include "shdocvw.h"
24
#include "exdispid.h"
25 26 27 28 29 30 31

WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);

/**********************************************************************
 * Implement the IWebBrowser interface
 */

32
#define WEBBROWSER_THIS(iface) DEFINE_THIS(WebBrowser, WebBrowser2, iface)
33

34
static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
35 36 37 38 39 40 41 42 43 44
{
    WebBrowser *This = WEBBROWSER_THIS(iface);

    if (ppv == NULL)
        return E_POINTER;
    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
        *ppv = WEBBROWSER(This);
45
    }else if(IsEqualGUID(&IID_IDispatch, riid)) {
46
        TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
47 48 49 50
        *ppv = WEBBROWSER(This);
    }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
        TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
        *ppv = WEBBROWSER(This);
51 52 53 54 55 56
    }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
        TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
        *ppv = WEBBROWSER(This);
    }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
        TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
        *ppv = WEBBROWSER(This);
57
    }else if(IsEqualGUID(&IID_IOleObject, riid)) {
58
        TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
59
        *ppv = OLEOBJ(This);
60 61 62 63 64 65
    }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
        TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
        *ppv = INPLACEOBJ(This);
    }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
        TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
        *ppv = INPLACEOBJ(This);
66 67
    }else if(IsEqualGUID(&IID_IOleControl, riid)) {
        TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
68
        *ppv = CONTROL(This);
69 70 71 72 73 74
    }else if(IsEqualGUID(&IID_IPersist, riid)) {
        TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
        *ppv = PERSTORAGE(This);
    }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
        TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
        *ppv = PERSTORAGE(This);
75
    }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
76 77
        TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
        *ppv = PERSTRINIT(This);
78
    }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
79 80
        TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
        *ppv = CLASSINFO(This);
81
    }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
82 83
        TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
        *ppv = CLASSINFO(This);
84
    }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
85
        TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
86
        *ppv = CONPTCONT(&This->doc_host.cps);
87 88 89 90 91 92
    }else if(IsEqualGUID(&IID_IViewObject, riid)) {
        TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
        *ppv = VIEWOBJ(This);
    }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
        TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
        *ppv = VIEWOBJ2(This);
93 94 95
    }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
        TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
        *ppv = ACTIVEOBJ(This);
96 97
    }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
        TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
Jacek Caban's avatar
Jacek Caban committed
98
        *ppv = OLECMD(This);
99 100 101
    }else if(IsEqualGUID(&IID_IHlinkFrame, riid)) {
        TRACE("(%p)->(IID_IHlinkFrame %p)\n", This, ppv);
        *ppv = HLINKFRAME(This);
102 103 104 105 106 107
    }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
        TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
        return E_NOINTERFACE;
    }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
        TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
        return E_NOINTERFACE;
108 109 110 111 112 113 114 115
    }

    if(*ppv) {
        IUnknown_AddRef((IUnknown*)*ppv);
        return S_OK;
    }

    FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
116 117 118
    return E_NOINTERFACE;
}

119
static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
120
{
121 122
    WebBrowser *This = WEBBROWSER_THIS(iface);
    LONG ref = InterlockedIncrement(&This->ref);
123
    TRACE("(%p) ref=%d\n", This, ref);
124
    return ref;
125 126
}

127
static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
128
{
129 130 131
    WebBrowser *This = WEBBROWSER_THIS(iface);
    LONG ref = InterlockedDecrement(&This->ref);

132
    TRACE("(%p) ref=%d\n", This, ref);
133

134
    if(!ref) {
135 136
        if(This->doc_host.document)
            IUnknown_Release(This->doc_host.document);
137

138 139
        DocHost_Release(&This->doc_host);

140 141
        WebBrowser_OleObject_Destroy(This);

142
        shdocvw_free(This);
143 144 145 146
        SHDOCVW_UnlockModule();
    }

    return ref;
147 148 149
}

/* IDispatch methods */
150
static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
151
{
152 153 154
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pctinfo);
    return E_NOTIMPL;
155 156
}

157
static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
158 159
                                     LPTYPEINFO *ppTInfo)
{
160
    WebBrowser *This = WEBBROWSER_THIS(iface);
161
    FIXME("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
162
    return E_NOTIMPL;
163 164
}

165
static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
166 167 168
                                       LPOLESTR *rgszNames, UINT cNames,
                                       LCID lcid, DISPID *rgDispId)
{
169
    WebBrowser *This = WEBBROWSER_THIS(iface);
170
    FIXME("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
171 172
            lcid, rgDispId);
    return E_NOTIMPL;
173 174
}

175
static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
176 177 178 179
                                REFIID riid, LCID lcid, WORD wFlags,
                                DISPPARAMS *pDispParams, VARIANT *pVarResult,
                                EXCEPINFO *pExepInfo, UINT *puArgErr)
{
180
    WebBrowser *This = WEBBROWSER_THIS(iface);
181 182 183
    ITypeInfo *typeinfo;
    HRESULT hres;

184
    TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
185
            lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
186 187 188 189 190 191 192

    hres = get_typeinfo(&typeinfo);
    if(FAILED(hres))
        return hres;

    return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
                            pVarResult, pExepInfo, puArgErr);
193 194 195
}

/* IWebBrowser methods */
196
static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
197
{
198 199 200
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
201 202
}

203
static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
204
{
205 206 207
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
208 209
}

210
static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
211
{
212 213 214
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
215 216
}

217
static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
218
{
219 220 221
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
222 223
}

224
static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
225 226 227
                                  VARIANT *Flags, VARIANT *TargetFrameName,
                                  VARIANT *PostData, VARIANT *Headers)
{
228
    WebBrowser *This = WEBBROWSER_THIS(iface);
229

230
    TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName,
231
          PostData, Headers);
232

233
    return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
234 235
}

236
static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
237
{
238 239 240
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
241 242
}

243
static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
244
{
245 246 247
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, Level);
    return E_NOTIMPL;
248 249
}

250
static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
251
{
252 253 254
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
255 256
}

257
static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
258
{
259 260 261
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, ppDisp);
    return E_NOTIMPL;
262 263
}

264
static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
265
{
266 267 268
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, ppDisp);
    return E_NOTIMPL;
269 270
}

271
static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
272
{
273 274 275
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, ppDisp);
    return E_NOTIMPL;
276 277
}

278
static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
279
{
280
    WebBrowser *This = WEBBROWSER_THIS(iface);
281 282 283 284

    TRACE("(%p)->(%p)\n", This, ppDisp);

    *ppDisp = NULL;
285 286
    if(This->doc_host.document)
        IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
287 288

    return S_OK;
289 290
}

291
static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
292
{
293 294 295
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pBool);
    return E_NOTIMPL;
296 297
}

298
static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
299
{
300 301 302
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, Type);
    return E_NOTIMPL;
303 304
}

305
static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, long *pl)
306
{
307
    WebBrowser *This = WEBBROWSER_THIS(iface);
308 309 310 311 312

    TRACE("(%p)->(%p)\n", This, pl);

    *pl = This->pos_rect.left;
    return S_OK;
313 314
}

315
static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, long Left)
316
{
317
    WebBrowser *This = WEBBROWSER_THIS(iface);
318 319 320 321 322 323 324 325 326 327
    RECT rect;

    TRACE("(%p)->(%ld)\n", This, Left);

    if(!This->inplace)
        return E_UNEXPECTED;

    memcpy(&rect, &This->pos_rect, sizeof(RECT));
    rect.left = Left;

328 329
    /* We don't really change the window position here.
     * We just notify the embedder that he should do so. */
330
    return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
331 332
}

333
static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, long *pl)
334
{
335
    WebBrowser *This = WEBBROWSER_THIS(iface);
336 337 338 339 340

    TRACE("(%p)->(%p)\n", This, pl);

    *pl = This->pos_rect.top;
    return S_OK;
341 342
}

343
static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, long Top)
344
{
345
    WebBrowser *This = WEBBROWSER_THIS(iface);
346 347 348 349 350 351 352 353 354 355
    RECT rect;

    TRACE("(%p)->(%ld)\n", This, Top);

    if(!This->inplace)
        return E_UNEXPECTED;

    memcpy(&rect, &This->pos_rect, sizeof(RECT));
    rect.top = Top;

356 357
    /* We don't really change the window position here.
     * We just notify the embedder that he should do so. */
358
    return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
359 360
}

361
static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, long *pl)
362
{
363
    WebBrowser *This = WEBBROWSER_THIS(iface);
364 365 366 367 368

    TRACE("(%p)->(%p)\n", This, pl);

    *pl = This->pos_rect.right - This->pos_rect.left;
    return S_OK;
369 370
}

371
static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, long Width)
372
{
373
    WebBrowser *This = WEBBROWSER_THIS(iface);
374 375 376 377 378 379 380 381 382
    RECT rect;

    TRACE("(%p)->(%ld)\n", This, Width);

    if(!This->inplace)
        return E_UNEXPECTED;

    memcpy(&rect, &This->pos_rect, sizeof(RECT));
    rect.right = rect.left+Width;
383 384 385 386
 
    /* We don't really change the window size here.
     * We just notify the embedder that he should do so. */
   return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
387 388
}

389
static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, long *pl)
390
{
391
    WebBrowser *This = WEBBROWSER_THIS(iface);
392 393 394 395 396

    TRACE("(%p)->(%p)\n", This, pl);

    *pl = This->pos_rect.bottom - This->pos_rect.top;
    return S_OK;
397 398
}

399
static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, long Height)
400
{
401
    WebBrowser *This = WEBBROWSER_THIS(iface);
402 403 404 405 406 407 408 409 410 411
    RECT rect;

    TRACE("(%p)->(%ld)\n", This, Height);

    if(!This->inplace)
        return E_UNEXPECTED;

    memcpy(&rect, &This->pos_rect, sizeof(RECT));
    rect.bottom = rect.top+Height;

412 413
    /* We don't really change the window size here.
     * We just notify the embedder that he should do so. */
414
    return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
415 416
}

417
static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
418
{
419 420 421
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, LocationName);
    return E_NOTIMPL;
422 423
}

424
static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
425
{
426
    WebBrowser *This = WEBBROWSER_THIS(iface);
427

428
    FIXME("(%p)->(%p)\n", This, LocationURL);
429

430
    if(!This->doc_host.url) {
431 432 433 434 435
        static const WCHAR null_char = 0;
        *LocationURL = SysAllocString(&null_char);
        return S_FALSE;
    }

436
    *LocationURL = SysAllocString(This->doc_host.url);
437
    return S_OK;
438 439
}

440
static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
441
{
442 443 444
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pBool);
    return E_NOTIMPL;
445 446
}

447 448 449 450 451 452
static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)\n", This);
    return E_NOTIMPL;
}
453

454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty));
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, Name);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, long *pHWND)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
485 486 487

    TRACE("(%p)->(%p)\n", This, pHWND);

488
    /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
489 490
    *pHWND = 0;
    return E_FAIL;
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
}

static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, FullName);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, Path);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
510 511 512 513 514

    TRACE("(%p)->(%p)\n", This, pBool);

    *pBool = This->visible;
    return S_OK;
515 516 517 518 519
}

static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
520 521 522 523 524 525 526 527 528
    VARIANTARG arg;
    DISPPARAMS dispparams = {&arg, NULL, 1, 0};

    TRACE("(%p)->(%x)\n", This, Value);

    This->visible = Value;

    V_VT(&arg) = VT_BOOL;
    V_BOOL(&arg) = Value;
529
    call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
530 531

    return S_OK;
532 533 534 535 536
}

static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
537 538 539 540 541

    TRACE("(%p)->(%p)\n", This, pBool);

    *pBool = This->status_bar;
    return S_OK;
542 543 544 545 546
}

static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
547 548 549 550 551
    VARIANTARG arg;
    DISPPARAMS dispparams = {&arg, NULL, 1, 0};

    TRACE("(%p)->(%x)\n", This, Value);

552
    This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
553

554 555 556
    /* In opposition to InternetExplorer, all we should do here is
     * inform the embedder about the status bar change. */

557 558
    V_VT(&arg) = VT_BOOL;
    V_BOOL(&arg) = Value;
559
    call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
560 561

    return S_OK;
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
}

static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, StatusText);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
581 582 583 584 585

    TRACE("(%p)->(%p)\n", This, Value);

    *Value = This->tool_bar;
    return S_OK;
586 587 588 589 590
}

static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
591 592 593 594 595 596 597
    VARIANTARG arg;
    DISPPARAMS dispparams = {&arg, NULL, 1, 0};

    TRACE("(%p)->(%x)\n", This, Value);

    This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;

598 599 600
    /* In opposition to InternetExplorer, all we should do here is
     * inform the embedder about the tool bar change. */

601 602
    V_VT(&arg) = VT_BOOL;
    V_BOOL(&arg) = Value;
603
    call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
604 605

    return S_OK;
606 607 608 609 610
}

static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
611 612 613 614 615

    TRACE("(%p)->(%p)\n", This, Value);

    *Value = This->menu_bar;
    return S_OK;
616 617 618 619 620
}

static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
621 622 623 624 625
    VARIANTARG arg;
    DISPPARAMS dispparams = {&arg, NULL, 1, 0};

    TRACE("(%p)->(%x)\n", This, Value);

626
    This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
627

628 629 630
    /* In opposition to InternetExplorer, all we should do here is
     * inform the embedder about the menu bar change. */

631 632
    V_VT(&arg) = VT_BOOL;
    V_BOOL(&arg) = Value;
633
    call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
634 635

    return S_OK;
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
}

static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pbFullScreen);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%x)\n", This, bFullScreen);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
        VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
656 657 658 659 660 661

    TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);

    if(!This->client)
        return E_FAIL;

662 663
    if(!URL)
        return S_OK;
664

665 666
    if(V_VT(URL) != VT_BSTR) {
        FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
667
        return E_INVALIDARG;
668 669
    }

670
    return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
}

static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
        OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
        VARIANT *pvarShow, VARIANT *pvarSize)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, lpReadyState);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pbOffline);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%x)\n", This, bOffline);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
720 721 722 723 724

    TRACE("(%p)->(%p)\n", This, pbSilent);

    *pbSilent = This->silent;
    return S_OK;
725 726 727 728 729
}

static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
730 731 732 733 734

    TRACE("(%p)->(%x)\n", This, bSilent);

    This->silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
    return S_OK;
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
}

static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
        VARIANT_BOOL *pbRegister)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pbRegister);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
        VARIANT_BOOL bRegister)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%x)\n", This, bRegister);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
        VARIANT_BOOL *pbRegister)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pbRegister);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
        VARIANT_BOOL bRegister)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%x)\n", This, bRegister);
766
    return S_OK;
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785
}

static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, pbRegister);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%x)\n", This, bRegister);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
786 787 788 789 790

    TRACE("(%p)->(%p)\n", This, Value);

    *Value = This->address_bar;
    return S_OK;
791 792 793 794 795
}

static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
796 797 798 799 800
    VARIANTARG arg;
    DISPPARAMS dispparams = {&arg, NULL, 1, 0};

    TRACE("(%p)->(%x)\n", This, Value);

801
    This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
802

803 804 805
    /* In opposition to InternetExplorer, all we should do here is
     * inform the embedder about the address bar change. */

806 807
    V_VT(&arg) = VT_BOOL;
    V_BOOL(&arg) = Value;
808
    call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
809 810

    return S_OK;
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
}

static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%p)\n", This, Value);
    return E_NOTIMPL;
}

static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
{
    WebBrowser *This = WEBBROWSER_THIS(iface);
    FIXME("(%p)->(%x)\n", This, Value);
    return E_NOTIMPL;
}

#undef WEBBROWSER_THIS
828

829
static const IWebBrowser2Vtbl WebBrowser2Vtbl =
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
{
    WebBrowser_QueryInterface,
    WebBrowser_AddRef,
    WebBrowser_Release,
    WebBrowser_GetTypeInfoCount,
    WebBrowser_GetTypeInfo,
    WebBrowser_GetIDsOfNames,
    WebBrowser_Invoke,
    WebBrowser_GoBack,
    WebBrowser_GoForward,
    WebBrowser_GoHome,
    WebBrowser_GoSearch,
    WebBrowser_Navigate,
    WebBrowser_Refresh,
    WebBrowser_Refresh2,
    WebBrowser_Stop,
    WebBrowser_get_Application,
    WebBrowser_get_Parent,
    WebBrowser_get_Container,
    WebBrowser_get_Document,
    WebBrowser_get_TopLevelContainer,
    WebBrowser_get_Type,
    WebBrowser_get_Left,
    WebBrowser_put_Left,
    WebBrowser_get_Top,
    WebBrowser_put_Top,
    WebBrowser_get_Width,
    WebBrowser_put_Width,
    WebBrowser_get_Height,
    WebBrowser_put_Height,
    WebBrowser_get_LocationName,
    WebBrowser_get_LocationURL,
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
    WebBrowser_get_Busy,
    WebBrowser_Quit,
    WebBrowser_ClientToWindow,
    WebBrowser_PutProperty,
    WebBrowser_GetProperty,
    WebBrowser_get_Name,
    WebBrowser_get_HWND,
    WebBrowser_get_FullName,
    WebBrowser_get_Path,
    WebBrowser_get_Visible,
    WebBrowser_put_Visible,
    WebBrowser_get_StatusBar,
    WebBrowser_put_StatusBar,
    WebBrowser_get_StatusText,
    WebBrowser_put_StatusText,
    WebBrowser_get_ToolBar,
    WebBrowser_put_ToolBar,
    WebBrowser_get_MenuBar,
    WebBrowser_put_MenuBar,
    WebBrowser_get_FullScreen,
    WebBrowser_put_FullScreen,
    WebBrowser_Navigate2,
    WebBrowser_QueryStatusWB,
    WebBrowser_ExecWB,
    WebBrowser_ShowBrowserBar,
    WebBrowser_get_ReadyState,
    WebBrowser_get_Offline,
    WebBrowser_put_Offline,
    WebBrowser_get_Silent,
    WebBrowser_put_Silent,
    WebBrowser_get_RegisterAsBrowser,
    WebBrowser_put_RegisterAsBrowser,
    WebBrowser_get_RegisterAsDropTarget,
    WebBrowser_put_RegisterAsDropTarget,
    WebBrowser_get_TheaterMode,
    WebBrowser_put_TheaterMode,
    WebBrowser_get_AddressBar,
    WebBrowser_put_AddressBar,
    WebBrowser_get_Resizable,
    WebBrowser_put_Resizable
902 903
};

904
static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
905 906 907 908
{
    WebBrowser *ret;
    HRESULT hres;

909
    TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
910

911
    ret = shdocvw_alloc(sizeof(WebBrowser));
912

913
    ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
914
    ret->ref = 0;
915
    ret->version = version;
916

917
    DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
918

919
    ret->visible = VARIANT_TRUE;
920
    ret->menu_bar = VARIANT_TRUE;
921
    ret->address_bar = VARIANT_TRUE;
922
    ret->status_bar = VARIANT_TRUE;
923
    ret->tool_bar = VARIANT_TRUE;
924
    ret->silent = VARIANT_FALSE;
925

926
    WebBrowser_OleObject_Init(ret);
927
    WebBrowser_ViewObject_Init(ret);
928
    WebBrowser_Persist_Init(ret);
929
    WebBrowser_ClassInfo_Init(ret);
930
    WebBrowser_HlinkFrame_Init(ret);
931 932 933 934 935

    hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
    if(SUCCEEDED(hres)) {
        SHDOCVW_LockModule();
    }else {
936
        shdocvw_free(ret);
937 938 939 940 941
        return hres;
    }

    return hres;
}
942 943 944 945 946 947 948 949 950 951

HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
{
    return WebBrowser_Create(1, pOuter, riid, ppv);
}

HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
{
    return WebBrowser_Create(2, pOuter, riid, ppv);
}