4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
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.
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.
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
22 Used by the address band to dispatch navigation changes to the main browser object.
30 CBandProxy::CBandProxy()
34 CBandProxy::~CBandProxy()
38 HRESULT
CBandProxy::FindBrowserWindow(IUnknown
**browser
)
40 IWebBrowser2
* webBrowser
;
45 hResult
= IUnknown_QueryService(fSite
, SID_IWebBrowserApp
, IID_PPV_ARG(IWebBrowser2
, &webBrowser
));
46 if (FAILED_UNEXPECTEDLY(hResult
))
48 *browser
= webBrowser
;
52 HRESULT STDMETHODCALLTYPE
CBandProxy::SetSite(IUnknown
*paramC
)
58 HRESULT STDMETHODCALLTYPE
CBandProxy::CreateNewWindow(long paramC
)
63 HRESULT STDMETHODCALLTYPE
CBandProxy::GetBrowserWindow(IUnknown
**paramC
)
67 return FindBrowserWindow(paramC
);
70 HRESULT STDMETHODCALLTYPE
CBandProxy::IsConnected()
72 CComPtr
<IUnknown
> webBrowser
;
75 hResult
= FindBrowserWindow(&webBrowser
);
76 if (FAILED_UNEXPECTEDLY(hResult
) || webBrowser
.p
== NULL
)
81 HRESULT STDMETHODCALLTYPE
CBandProxy::NavigateToPIDL(LPCITEMIDLIST pidl
)
83 CComPtr
<IOleWindow
> oleWindow
;
84 CComPtr
<IServiceProvider
> serviceProvider
;
85 CComPtr
<IUnknown
> webBrowserUnknown
;
86 CComPtr
<IWebBrowser2
> webBrowser
;
89 CComVariant emptyVariant
;
90 unsigned int arraySize
;
93 hResult
= FindBrowserWindow(&webBrowserUnknown
);
94 if (FAILED_UNEXPECTEDLY(hResult
))
96 hResult
= webBrowserUnknown
->QueryInterface(IID_PPV_ARG(IWebBrowser2
, &webBrowser
));
97 if (FAILED_UNEXPECTEDLY(hResult
))
99 hResult
= webBrowser
->put_Visible(TRUE
);
100 hResult
= webBrowser
->QueryInterface(IID_PPV_ARG(IServiceProvider
, &serviceProvider
));
101 if (SUCCEEDED(hResult
))
103 hResult
= serviceProvider
->QueryService(SID_STopLevelBrowser
,
104 IID_PPV_ARG(IOleWindow
, &oleWindow
));
105 if (SUCCEEDED(hResult
))
107 hResult
= oleWindow
->GetWindow(&browserWindow
);
108 if (IsIconic(browserWindow
))
109 ShowWindow(browserWindow
, SW_RESTORE
);
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
))
124 HRESULT STDMETHODCALLTYPE
CBandProxy::NavigateToURL(long paramC
, long param10
)
129 HRESULT
CreateBandProxy(REFIID riid
, void **ppv
)
131 return ShellObjectCreator
<CBandProxy
>(riid
, ppv
);