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.
29 #include <shlobj_undoc.h>
31 #include <shlguid_undoc.h>
39 #include "bandproxy.h"
41 CBandProxy::CBandProxy()
45 CBandProxy::~CBandProxy()
49 HRESULT
CBandProxy::FindBrowserWindow(IUnknown
**browser
)
51 CComPtr
<IServiceProvider
> serviceProvider
;
52 CComPtr
<IWebBrowser2
> webBrowser
;
57 hResult
= fSite
->QueryInterface(IID_IServiceProvider
, (void **)&serviceProvider
);
60 hResult
= serviceProvider
->QueryService(SID_IWebBrowserApp
, IID_IWebBrowser2
, (void **)&webBrowser
);
63 *browser
= webBrowser
.Detach();
67 HRESULT STDMETHODCALLTYPE
CBandProxy::SetSite(IUnknown
*paramC
)
73 HRESULT STDMETHODCALLTYPE
CBandProxy::CreateNewWindow(long paramC
)
78 HRESULT STDMETHODCALLTYPE
CBandProxy::GetBrowserWindow(IUnknown
**paramC
)
82 return FindBrowserWindow(paramC
);
85 HRESULT STDMETHODCALLTYPE
CBandProxy::IsConnected()
87 CComPtr
<IUnknown
> webBrowser
;
90 hResult
= FindBrowserWindow(&webBrowser
);
91 if (FAILED (hResult
) || webBrowser
.p
== NULL
)
96 HRESULT STDMETHODCALLTYPE
CBandProxy::NavigateToPIDL(LPCITEMIDLIST pidl
)
98 CComPtr
<IOleWindow
> oleWindow
;
99 CComPtr
<IServiceProvider
> serviceProvider
;
100 CComPtr
<IUnknown
> webBrowserUnknown
;
101 CComPtr
<IWebBrowser2
> webBrowser
;
104 CComVariant emptyVariant
;
105 unsigned int arraySize
;
108 hResult
= FindBrowserWindow(&webBrowserUnknown
);
109 if (FAILED (hResult
))
111 hResult
= webBrowserUnknown
->QueryInterface(IID_IWebBrowserApp
, (void **)&webBrowser
);
112 if (FAILED (hResult
))
114 hResult
= webBrowser
->put_Visible(TRUE
);
115 hResult
= webBrowser
->QueryInterface(IID_IServiceProvider
, (void **)&serviceProvider
);
116 if (SUCCEEDED (hResult
))
118 hResult
= serviceProvider
->QueryService(SID_STopLevelBrowser
, IID_IOleWindow
, (void **)&oleWindow
);
119 if (SUCCEEDED (hResult
))
121 hResult
= oleWindow
->GetWindow(&browserWindow
);
122 if (IsIconic(browserWindow
))
123 ShowWindow(browserWindow
, SW_RESTORE
);
126 arraySize
= ILGetSize(pidl
);
127 V_VT(&args
) = VT_ARRAY
| VT_UI1
;
128 V_ARRAY(&args
) = SafeArrayCreateVector(VT_UI1
, 0, arraySize
);
129 if (V_ARRAY(&args
) == NULL
)
130 return E_OUTOFMEMORY
;
131 memcpy(V_ARRAY(&args
)->pvData
, pidl
, arraySize
);
132 hResult
= webBrowser
->Navigate2(&args
, &emptyVariant
, &emptyVariant
, &emptyVariant
, &emptyVariant
);
133 if (FAILED (hResult
))
138 HRESULT STDMETHODCALLTYPE
CBandProxy::NavigateToURL(long paramC
, long param10
)
143 HRESULT
CreateBandProxy(REFIID riid
, void **ppv
)
145 CComObject
<CBandProxy
> *theBandProxy
;
151 ATLTRY (theBandProxy
= new CComObject
<CBandProxy
>);
152 if (theBandProxy
== NULL
)
153 return E_OUTOFMEMORY
;
154 hResult
= theBandProxy
->QueryInterface (riid
, (void **)ppv
);
155 if (FAILED (hResult
))