ReactOS 0.4.16-dev-297-gc569aee
bandproxy.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22Used by the address band to dispatch navigation changes to the main browser object.
23
24TODO:
25
26*/
27
28#include "precomp.h"
29
31{
32}
33
35{
36}
37
39{
40 IWebBrowser2* webBrowser;
41 HRESULT hResult;
42
43 if (browser == NULL)
44 return E_POINTER;
45 hResult = IUnknown_QueryService(fSite, SID_IWebBrowserApp, IID_PPV_ARG(IWebBrowser2, &webBrowser));
46 if (FAILED_UNEXPECTEDLY(hResult))
47 return hResult;
48 *browser = webBrowser;
49 return S_OK;
50}
51
53{
54 fSite = paramC;
55 return S_OK;
56}
57
59{
60 return E_NOTIMPL;
61}
62
64{
65 if (paramC == NULL)
66 return E_POINTER;
67 return FindBrowserWindow(paramC);
68}
69
71{
72 CComPtr<IUnknown> webBrowser;
73 HRESULT hResult;
74
75 hResult = FindBrowserWindow(&webBrowser);
76 if (FAILED_UNEXPECTEDLY(hResult) || webBrowser.p == NULL)
77 return S_FALSE;
78 return S_OK;
79}
80
82{
83 CComPtr<IOleWindow> oleWindow;
84 CComPtr<IServiceProvider> serviceProvider;
85 CComPtr<IUnknown> webBrowserUnknown;
86 CComPtr<IWebBrowser2> webBrowser;
87 HWND browserWindow;
89 CComVariant emptyVariant;
90 unsigned int arraySize;
91 HRESULT hResult;
92
93 hResult = FindBrowserWindow(&webBrowserUnknown);
94 if (FAILED_UNEXPECTEDLY(hResult))
95 return hResult;
96 hResult = webBrowserUnknown->QueryInterface(IID_PPV_ARG(IWebBrowser2, &webBrowser));
97 if (FAILED_UNEXPECTEDLY(hResult))
98 return hResult;
99 hResult = webBrowser->put_Visible(TRUE);
100 hResult = webBrowser->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
101 if (SUCCEEDED(hResult))
102 {
103 hResult = serviceProvider->QueryService(SID_STopLevelBrowser,
104 IID_PPV_ARG(IOleWindow, &oleWindow));
105 if (SUCCEEDED(hResult))
106 {
107 hResult = oleWindow->GetWindow(&browserWindow);
108 if (IsIconic(browserWindow))
109 ShowWindow(browserWindow, SW_RESTORE);
110 }
111 }
112 arraySize = ILGetSize(pidl);
113 V_VT(&args) = VT_ARRAY | VT_UI1;
114 V_ARRAY(&args) = SafeArrayCreateVector(VT_UI1, 0, arraySize);
115 if (V_ARRAY(&args) == NULL)
116 return E_OUTOFMEMORY;
117 memcpy(V_ARRAY(&args)->pvData, pidl, arraySize);
118 hResult = webBrowser->Navigate2(&args, &emptyVariant, &emptyVariant, &emptyVariant, &emptyVariant);
119 if (FAILED_UNEXPECTEDLY(hResult))
120 return hResult;
121 return S_OK;
122}
123
125{
126 return E_NOTIMPL;
127}
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
CComPtr< IUnknown > fSite
Definition: bandproxy.h:29
STDMETHOD() IsConnected() override
Definition: bandproxy.cpp:70
STDMETHOD() CreateNewWindow(long paramC) override
Definition: bandproxy.cpp:58
STDMETHOD() SetSite(IUnknown *paramC) override
Definition: bandproxy.cpp:52
STDMETHOD() NavigateToURL(long paramC, long param10) override
Definition: bandproxy.cpp:124
HRESULT FindBrowserWindow(IUnknown **browser)
Definition: bandproxy.cpp:38
STDMETHOD() NavigateToPIDL(LPCITEMIDLIST pidl) override
Definition: bandproxy.cpp:81
STDMETHOD() GetBrowserWindow(IUnknown **paramC) override
Definition: bandproxy.cpp:63
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
@ VT_ARRAY
Definition: compat.h:2341
@ VT_UI1
Definition: compat.h:2311
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
SAFEARRAY *WINAPI SafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements)
Definition: safearray.c:677
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1501
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_VT(A)
Definition: oleauto.h:211
#define ILGetSize
Definition: shellclasses.h:638
#define SID_IWebBrowserApp
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
Definition: match.c:390
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI IsIconic(_In_ HWND)
#define SW_RESTORE
Definition: winuser.h:782
#define IID_PPV_ARG(Itype, ppType)