Back to index

lightning-sunbird  0.9+nobinonly
XPCDocument.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Adam Lock <adamlock@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "StdAfx.h"
00040 
00041 #include <mshtml.h>
00042 #include <hlink.h>
00043 
00044 // A barely documented interface called ITargetFrame from IE
00045 // This is needed for targeted Hlink* calls (e.g. HlinkNavigateString) to
00046 // work. During the call, the Hlink API QIs and calls ITargetFrame::FindFrame
00047 // to determine the named target frame before calling IHlinkFrame::Navigate.
00048 //
00049 // MS mentions the methods at the url below:
00050 //
00051 // http://msdn.microsoft.com/workshop/browser/browser/Reference/IFaces/ITargetFrame/ITargetFrame.asp
00052 //
00053 // The interface is defined in very recent versions of Internet SDK part of
00054 // the PlatformSDK, from Dec 2002 onwards.
00055 //
00056 // http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ 
00057 //
00058 // Neither Visual C++ 6.0 or 7.0 ship with this interface.
00059 //
00060 #ifdef USE_HTIFACE
00061 #include <htiface.h>
00062 #endif
00063 #ifndef __ITargetFrame_INTERFACE_DEFINED__
00064 // No ITargetFrame so make a binary compatible one
00065 MIDL_INTERFACE("d5f78c80-5252-11cf-90fa-00AA0042106e")
00066 IMozTargetFrame : public IUnknown
00067 {
00068 public:
00069     virtual HRESULT STDMETHODCALLTYPE SetFrameName(
00070         /* [in] */ LPCWSTR pszFrameName) = 0;
00071     virtual HRESULT STDMETHODCALLTYPE GetFrameName(
00072         /* [out] */ LPWSTR *ppszFrameName) = 0;
00073     virtual HRESULT STDMETHODCALLTYPE GetParentFrame(
00074         /* [out] */ IUnknown **ppunkParent) = 0;
00075     virtual HRESULT STDMETHODCALLTYPE FindFrame( 
00076         /* [in] */ LPCWSTR pszTargetName,
00077         /* [in] */ IUnknown *ppunkContextFrame,
00078         /* [in] */ DWORD dwFlags,
00079         /* [out] */ IUnknown **ppunkTargetFrame) = 0;
00080     virtual HRESULT STDMETHODCALLTYPE SetFrameSrc( 
00081         /* [in] */ LPCWSTR pszFrameSrc) = 0;
00082     virtual HRESULT STDMETHODCALLTYPE GetFrameSrc( 
00083         /* [out] */ LPWSTR *ppszFrameSrc) = 0;
00084     virtual HRESULT STDMETHODCALLTYPE GetFramesContainer( 
00085         /* [out] */ IOleContainer **ppContainer) = 0;
00086     virtual HRESULT STDMETHODCALLTYPE SetFrameOptions( 
00087         /* [in] */ DWORD dwFlags) = 0;
00088     virtual HRESULT STDMETHODCALLTYPE GetFrameOptions( 
00089         /* [out] */ DWORD *pdwFlags) = 0;
00090     virtual HRESULT STDMETHODCALLTYPE SetFrameMargins( 
00091         /* [in] */ DWORD dwWidth,
00092         /* [in] */ DWORD dwHeight) = 0;
00093     virtual HRESULT STDMETHODCALLTYPE GetFrameMargins( 
00094         /* [out] */ DWORD *pdwWidth,
00095         /* [out] */ DWORD *pdwHeight) = 0;
00096     virtual HRESULT STDMETHODCALLTYPE RemoteNavigate( 
00097         /* [in] */ ULONG cLength,
00098         /* [size_is][in] */ ULONG *pulData) = 0;
00099     virtual HRESULT STDMETHODCALLTYPE OnChildFrameActivate( 
00100         /* [in] */ IUnknown *pUnkChildFrame) = 0;
00101     virtual HRESULT STDMETHODCALLTYPE OnChildFrameDeactivate( 
00102         /* [in] */ IUnknown *pUnkChildFrame) = 0;
00103 };
00104 #define __ITargetFrame_INTERFACE_DEFINED__
00105 #define ITargetFrame IMozTargetFrame
00106 #endif
00107 
00108 #include "npapi.h"
00109 
00110 #include "nsCOMPtr.h"
00111 #include "nsIInterfaceRequestorUtils.h"
00112 #include "nsString.h"
00113 #include "nsNetUtil.h"
00114 
00115 #include "nsIContent.h"
00116 #include "nsIURI.h"
00117 #include "nsIDocument.h"
00118 #include "nsIDOMWindow.h"
00119 #include "nsIDOMElement.h"
00120 #include "nsIDOMDocument.h"
00121 #include "nsIDOMWindowInternal.h"
00122 #include "nsIDOMLocation.h"
00123 #include "nsIWebNavigation.h"
00124 #include "nsILinkHandler.h"
00125 #include "nsIScriptGlobalObject.h"
00126 #include "nsIScriptContext.h"
00127 #include "nsIPrincipal.h"
00128 #include "nsPIDOMWindow.h"
00129 
00130 #include "XPConnect.h"
00131 #include "XPCBrowser.h"
00132 #include "LegacyPlugin.h"
00133 
00134 #include "IEHtmlElementCollection.h"
00135 #include "IHTMLLocationImpl.h"
00136 
00137 /*
00138  * This file contains partial implementations of various IE objects and
00139  * interfaces that many ActiveX controls expect to be able to obtain and
00140  * call from their control site. Typically controls will use these methods
00141  * in order to integrate themselves with the browser, e.g. a control
00142  * might want to initiate a load, or obtain the user agent.
00143  */
00144 
00145 class IELocation :
00146     public CComObjectRootEx<CComSingleThreadModel>,
00147     public IHTMLLocationImpl<IELocation>
00148 {
00149 public:
00150 BEGIN_COM_MAP(IELocation)
00151     COM_INTERFACE_ENTRY(IDispatch)
00152     COM_INTERFACE_ENTRY(IHTMLLocation)
00153 END_COM_MAP()
00154 
00155     PluginInstanceData *mData;
00156     nsCOMPtr<nsIDOMLocation> mDOMLocation;
00157 
00158     IELocation() : mData(NULL)
00159     {
00160     }
00161 
00162     HRESULT Init(PluginInstanceData *pData)
00163     {
00164         NS_PRECONDITION(pData != nsnull, "null ptr");
00165 
00166         mData = pData;
00167 
00168         // Get the DOM window
00169         nsCOMPtr<nsIDOMWindow> domWindow;
00170         NPN_GetValue(mData->pPluginInstance, NPNVDOMWindow, 
00171                      NS_STATIC_CAST(nsIDOMWindow **, getter_AddRefs(domWindow)));
00172         if (!domWindow)
00173         {
00174             return E_FAIL;
00175         }
00176         nsCOMPtr<nsIDOMWindowInternal> windowInternal = do_QueryInterface(domWindow);
00177         if (windowInternal)
00178         {
00179             windowInternal->GetLocation(getter_AddRefs(mDOMLocation));
00180         }
00181         if (!mDOMLocation)
00182             return E_FAIL;
00183 
00184         return S_OK;
00185     }
00186 
00187     virtual nsresult GetDOMLocation(nsIDOMLocation **aLocation)
00188     {
00189         *aLocation = mDOMLocation;
00190         NS_IF_ADDREF(*aLocation);
00191         return NS_OK;
00192     }
00193 };
00194 
00195 // Note: corresponds to the window.navigator property in the IE DOM
00196 class IENavigator :
00197     public CComObjectRootEx<CComSingleThreadModel>,
00198     public IDispatchImpl<IOmNavigator, &__uuidof(IOmNavigator), &LIBID_MSHTML>
00199 {
00200 public:
00201 BEGIN_COM_MAP(IENavigator)
00202     COM_INTERFACE_ENTRY(IDispatch)
00203     COM_INTERFACE_ENTRY(IOmNavigator)
00204 END_COM_MAP()
00205 
00206     PluginInstanceData *mData;
00207     CComBSTR mUserAgent;
00208 
00209     HRESULT Init(PluginInstanceData *pData)
00210     {
00211         mData = pData;
00212         USES_CONVERSION;
00213         const char *userAgent = NPN_UserAgent(mData->pPluginInstance);
00214         mUserAgent.Attach(::SysAllocString(A2CW(userAgent)));
00215         return S_OK;
00216     }
00217 
00218 // IOmNavigator
00219     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_appCodeName( 
00220         /* [out][retval] */ BSTR __RPC_FAR *p)
00221     {
00222         return E_NOTIMPL;
00223     }
00224 
00225     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_appName( 
00226         /* [out][retval] */ BSTR __RPC_FAR *p)
00227     {
00228         return E_NOTIMPL;
00229     }
00230 
00231     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_appVersion( 
00232         /* [out][retval] */ BSTR __RPC_FAR *p)
00233     {
00234         return E_NOTIMPL;
00235     }
00236 
00237     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_userAgent( 
00238         /* [out][retval] */ BSTR __RPC_FAR *p)
00239     {
00240         *p = mUserAgent.Copy();
00241         return S_OK;
00242     }
00243 
00244     virtual /* [id] */ HRESULT STDMETHODCALLTYPE javaEnabled( 
00245         /* [out][retval] */ VARIANT_BOOL __RPC_FAR *enabled)
00246     {
00247         return E_NOTIMPL;
00248     }
00249         
00250     virtual /* [id] */ HRESULT STDMETHODCALLTYPE taintEnabled( 
00251         /* [out][retval] */ VARIANT_BOOL __RPC_FAR *enabled)
00252     {
00253         return E_NOTIMPL;
00254     }
00255         
00256     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_mimeTypes( 
00257         /* [out][retval] */ IHTMLMimeTypesCollection __RPC_FAR *__RPC_FAR *p)
00258     {
00259         return E_NOTIMPL;
00260     }
00261         
00262     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_plugins( 
00263         /* [out][retval] */ IHTMLPluginsCollection __RPC_FAR *__RPC_FAR *p)
00264     {
00265         return E_NOTIMPL;
00266     }
00267         
00268     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_cookieEnabled( 
00269         /* [out][retval] */ VARIANT_BOOL __RPC_FAR *p)
00270     {
00271         return E_NOTIMPL;
00272     }
00273         
00274     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_opsProfile( 
00275         /* [out][retval] */ IHTMLOpsProfile __RPC_FAR *__RPC_FAR *p)
00276     {
00277         return E_NOTIMPL;
00278     }
00279         
00280     virtual /* [id] */ HRESULT STDMETHODCALLTYPE toString( 
00281         /* [out][retval] */ BSTR __RPC_FAR *string)
00282     {
00283         return E_NOTIMPL;
00284     }
00285         
00286     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_cpuClass( 
00287         /* [out][retval] */ BSTR __RPC_FAR *p)
00288     {
00289         return E_NOTIMPL;
00290     }
00291         
00292     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_systemLanguage( 
00293         /* [out][retval] */ BSTR __RPC_FAR *p)
00294     {
00295         return E_NOTIMPL;
00296     }
00297         
00298     virtual /* [hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get_browserLanguage( 
00299         /* [out][retval] */ BSTR __RPC_FAR *p)
00300     {
00301         return E_NOTIMPL;
00302     }
00303         
00304     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_userLanguage( 
00305         /* [out][retval] */ BSTR __RPC_FAR *p)
00306     {
00307         return E_NOTIMPL;
00308     }
00309         
00310     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_platform( 
00311         /* [out][retval] */ BSTR __RPC_FAR *p)
00312     {
00313         return E_NOTIMPL;
00314     }
00315         
00316     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_appMinorVersion( 
00317         /* [out][retval] */ BSTR __RPC_FAR *p)
00318     {
00319         return E_NOTIMPL;
00320     }
00321         
00322     virtual /* [hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get_connectionSpeed( 
00323         /* [out][retval] */ long __RPC_FAR *p)
00324     {
00325         return E_NOTIMPL;
00326     }
00327         
00328     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_onLine( 
00329         /* [out][retval] */ VARIANT_BOOL __RPC_FAR *p)
00330     {
00331         return E_NOTIMPL;
00332     }
00333         
00334     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_userProfile( 
00335         /* [out][retval] */ IHTMLOpsProfile __RPC_FAR *__RPC_FAR *p)
00336     {
00337         return E_NOTIMPL;
00338     }
00339 };
00340 
00341 
00342 // Note: Corresponds to the window object in the IE DOM
00343 class IEWindow :
00344     public CComObjectRootEx<CComSingleThreadModel>,
00345     public IDispatchImpl<IHTMLWindow2, &__uuidof(IHTMLWindow2), &LIBID_MSHTML>
00346 {
00347 public:
00348     PluginInstanceData *mData;
00349     CComObject<IENavigator> *mNavigator;
00350     CComObject<IELocation>  *mLocation;
00351 
00352     IEWindow() : mNavigator(NULL), mLocation(NULL), mData(NULL)
00353     {
00354     }
00355 
00356     HRESULT Init(PluginInstanceData *pData)
00357     {
00358         mData = pData;
00359 
00360         CComObject<IENavigator>::CreateInstance(&mNavigator);
00361         if (!mNavigator)
00362         {
00363             return E_UNEXPECTED;
00364         }
00365         mNavigator->AddRef();
00366         mNavigator->Init(mData);
00367 
00368         CComObject<IELocation>::CreateInstance(&mLocation);
00369         if (!mLocation)
00370         {
00371             return E_UNEXPECTED;
00372         }
00373         mLocation->AddRef();
00374         mLocation->Init(mData);
00375 
00376         return S_OK;
00377     }
00378 
00379 protected:
00380     virtual ~IEWindow()
00381     {
00382         if (mNavigator)
00383         {
00384             mNavigator->Release();
00385         }
00386         if (mLocation)
00387         {
00388             mLocation->Release();
00389         }
00390     }
00391 
00392 public:
00393     
00394 BEGIN_COM_MAP(IEWindow)
00395     COM_INTERFACE_ENTRY(IDispatch)
00396     COM_INTERFACE_ENTRY(IHTMLWindow2)
00397     COM_INTERFACE_ENTRY(IHTMLFramesCollection2)
00398     COM_INTERFACE_ENTRY_BREAK(IHlinkFrame)
00399 END_COM_MAP()
00400 
00401 //IHTMLFramesCollection2
00402     virtual /* [id] */ HRESULT STDMETHODCALLTYPE item( 
00403         /* [in] */ VARIANT __RPC_FAR *pvarIndex,
00404         /* [out][retval] */ VARIANT __RPC_FAR *pvarResult)
00405     {
00406         return E_NOTIMPL;
00407     }
00408     
00409     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_length( 
00410         /* [out][retval] */ long __RPC_FAR *p)
00411     {
00412         return E_NOTIMPL;
00413     }
00414 
00415 // IHTMLWindow2
00416     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_frames( 
00417         /* [out][retval] */ IHTMLFramesCollection2 __RPC_FAR *__RPC_FAR *p)
00418     {
00419         return E_NOTIMPL;
00420     }
00421     
00422     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_defaultStatus( 
00423         /* [in] */ BSTR v)
00424     {
00425         return E_NOTIMPL;
00426     }
00427     
00428     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_defaultStatus( 
00429         /* [out][retval] */ BSTR __RPC_FAR *p)
00430     {
00431         return E_NOTIMPL;
00432     }
00433     
00434     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_status( 
00435         /* [in] */ BSTR v)
00436     {
00437         return E_NOTIMPL;
00438     }
00439     
00440     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_status( 
00441         /* [out][retval] */ BSTR __RPC_FAR *p)
00442     {
00443         return E_NOTIMPL;
00444     }
00445     
00446     virtual /* [id] */ HRESULT STDMETHODCALLTYPE setTimeout( 
00447         /* [in] */ BSTR expression,
00448         /* [in] */ long msec,
00449         /* [in][optional] */ VARIANT __RPC_FAR *language,
00450         /* [out][retval] */ long __RPC_FAR *timerID)
00451     {
00452         return E_NOTIMPL;
00453     }
00454     
00455     virtual /* [id] */ HRESULT STDMETHODCALLTYPE clearTimeout( 
00456         /* [in] */ long timerID)
00457     {
00458         return E_NOTIMPL;
00459     }
00460     
00461     virtual /* [id] */ HRESULT STDMETHODCALLTYPE alert( 
00462         /* [in][defaultvalue] */ BSTR message)
00463     {
00464         return E_NOTIMPL;
00465     }
00466     
00467     virtual /* [id] */ HRESULT STDMETHODCALLTYPE confirm( 
00468         /* [in][defaultvalue] */ BSTR message,
00469         /* [out][retval] */ VARIANT_BOOL __RPC_FAR *confirmed)
00470     {
00471         return E_NOTIMPL;
00472     }
00473     
00474     virtual /* [id] */ HRESULT STDMETHODCALLTYPE prompt( 
00475         /* [in][defaultvalue] */ BSTR message,
00476         /* [in][defaultvalue] */ BSTR defstr,
00477         /* [out][retval] */ VARIANT __RPC_FAR *textdata)
00478     {
00479         return E_NOTIMPL;
00480     }
00481     
00482     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Image( 
00483         /* [out][retval] */ IHTMLImageElementFactory __RPC_FAR *__RPC_FAR *p)
00484     {
00485         return E_NOTIMPL;
00486     }
00487     
00488     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_location( 
00489         /* [out][retval] */ IHTMLLocation __RPC_FAR *__RPC_FAR *p)
00490     {
00491         if (mLocation)
00492             return mLocation->QueryInterface(__uuidof(IHTMLLocation), (void **) p);
00493         return E_FAIL;
00494     }
00495     
00496     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_history( 
00497         /* [out][retval] */ IOmHistory __RPC_FAR *__RPC_FAR *p)
00498     {
00499         return E_NOTIMPL;
00500     }
00501     
00502     virtual /* [id] */ HRESULT STDMETHODCALLTYPE close( void)
00503     {
00504         return E_NOTIMPL;
00505     }
00506     
00507     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_opener( 
00508         /* [in] */ VARIANT v)
00509     {
00510         return E_NOTIMPL;
00511     }
00512     
00513     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_opener( 
00514         /* [out][retval] */ VARIANT __RPC_FAR *p)
00515     {
00516         return E_NOTIMPL;
00517     }
00518     
00519     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_navigator( 
00520         /* [out][retval] */ IOmNavigator __RPC_FAR *__RPC_FAR *p)
00521     {
00522         if (mNavigator)
00523             return mNavigator->QueryInterface(__uuidof(IOmNavigator), (void **) p);
00524         return E_FAIL;
00525     }
00526     
00527     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_name( 
00528         /* [in] */ BSTR v)
00529     {
00530         return E_NOTIMPL;
00531     }
00532     
00533     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_name( 
00534         /* [out][retval] */ BSTR __RPC_FAR *p)
00535     {
00536         return E_NOTIMPL;
00537     }
00538     
00539     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_parent( 
00540         /* [out][retval] */ IHTMLWindow2 __RPC_FAR *__RPC_FAR *p)
00541     {
00542         *p = NULL;
00543         return S_OK;
00544     }
00545     
00546     virtual /* [id] */ HRESULT STDMETHODCALLTYPE open( 
00547         /* [in][defaultvalue] */ BSTR url,
00548         /* [in][defaultvalue] */ BSTR name,
00549         /* [in][defaultvalue] */ BSTR features,
00550         /* [in][defaultvalue] */ VARIANT_BOOL replace,
00551         /* [out][retval] */ IHTMLWindow2 __RPC_FAR *__RPC_FAR *pomWindowResult)
00552     {
00553         *pomWindowResult = NULL;
00554         return E_FAIL;
00555     }
00556     
00557     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_self( 
00558         /* [out][retval] */ IHTMLWindow2 __RPC_FAR *__RPC_FAR *p)
00559     {
00560         return E_NOTIMPL;
00561     }
00562     
00563     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_top( 
00564         /* [out][retval] */ IHTMLWindow2 __RPC_FAR *__RPC_FAR *p)
00565     {
00566         *p = NULL;
00567         return S_OK;
00568     }
00569     
00570     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_window( 
00571         /* [out][retval] */ IHTMLWindow2 __RPC_FAR *__RPC_FAR *p)
00572     {
00573         *p = NULL;
00574         return S_OK;
00575     }
00576     
00577     virtual /* [id] */ HRESULT STDMETHODCALLTYPE navigate( 
00578         /* [in] */ BSTR url)
00579     {
00580         return E_NOTIMPL;
00581     }
00582     
00583     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onfocus( 
00584         /* [in] */ VARIANT v)
00585     {
00586         return E_NOTIMPL;
00587     }
00588     
00589     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onfocus( 
00590         /* [out][retval] */ VARIANT __RPC_FAR *p)
00591     {
00592         return E_NOTIMPL;
00593     }
00594     
00595     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onblur( 
00596         /* [in] */ VARIANT v)
00597     {
00598         return E_NOTIMPL;
00599     }
00600 
00601     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onblur( 
00602         /* [out][retval] */ VARIANT __RPC_FAR *p)
00603     {
00604         return E_NOTIMPL;
00605     }
00606     
00607     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onload( 
00608         /* [in] */ VARIANT v)
00609     {
00610         return E_NOTIMPL;
00611     }
00612     
00613     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onload( 
00614         /* [out][retval] */ VARIANT __RPC_FAR *p)
00615     {
00616         return E_NOTIMPL;
00617     }
00618     
00619     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onbeforeunload( 
00620         /* [in] */ VARIANT v)
00621     {
00622         return E_NOTIMPL;
00623     }
00624     
00625     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onbeforeunload( 
00626         /* [out][retval] */ VARIANT __RPC_FAR *p)
00627     {
00628         return E_NOTIMPL;
00629     }
00630     
00631     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onunload( 
00632         /* [in] */ VARIANT v)
00633     {
00634         return E_NOTIMPL;
00635     }
00636     
00637     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onunload( 
00638         /* [out][retval] */ VARIANT __RPC_FAR *p)
00639     {
00640         return E_NOTIMPL;
00641     }
00642     
00643     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onhelp( 
00644         /* [in] */ VARIANT v)
00645     {
00646         return E_NOTIMPL;
00647     }
00648     
00649     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onhelp( 
00650         /* [out][retval] */ VARIANT __RPC_FAR *p)
00651     {
00652         return E_NOTIMPL;
00653     }
00654     
00655     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onerror( 
00656         /* [in] */ VARIANT v)
00657     {
00658         return E_NOTIMPL;
00659     }
00660     
00661     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onerror( 
00662         /* [out][retval] */ VARIANT __RPC_FAR *p)
00663     {
00664         return E_NOTIMPL;
00665     }
00666     
00667     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onresize( 
00668         /* [in] */ VARIANT v)
00669     {
00670         return E_NOTIMPL;
00671     }
00672     
00673     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onresize( 
00674         /* [out][retval] */ VARIANT __RPC_FAR *p)
00675     {
00676         return E_NOTIMPL;
00677     }
00678     
00679     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onscroll( 
00680         /* [in] */ VARIANT v)
00681     {
00682         return E_NOTIMPL;
00683     }
00684     
00685     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onscroll( 
00686         /* [out][retval] */ VARIANT __RPC_FAR *p)
00687     {
00688         return E_NOTIMPL;
00689     }
00690     
00691     virtual /* [source][id][propget] */ HRESULT STDMETHODCALLTYPE get_document( 
00692         /* [out][retval] */ IHTMLDocument2 __RPC_FAR *__RPC_FAR *p)
00693     {
00694         return E_NOTIMPL;
00695     }
00696     
00697     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_event( 
00698         /* [out][retval] */ IHTMLEventObj __RPC_FAR *__RPC_FAR *p)
00699     {
00700         return E_NOTIMPL;
00701     }
00702     
00703     virtual /* [restricted][hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get__newEnum( 
00704         /* [out][retval] */ IUnknown __RPC_FAR *__RPC_FAR *p)
00705     {
00706         return E_NOTIMPL;
00707     }
00708     
00709     virtual /* [id] */ HRESULT STDMETHODCALLTYPE showModalDialog( 
00710         /* [in] */ BSTR dialog,
00711         /* [in][optional] */ VARIANT __RPC_FAR *varArgIn,
00712         /* [in][optional] */ VARIANT __RPC_FAR *varOptions,
00713         /* [out][retval] */ VARIANT __RPC_FAR *varArgOut)
00714     {
00715         return E_NOTIMPL;
00716     }
00717     
00718     virtual /* [id] */ HRESULT STDMETHODCALLTYPE showHelp( 
00719         /* [in] */ BSTR helpURL,
00720         /* [in][optional] */ VARIANT helpArg,
00721         /* [in][defaultvalue] */ BSTR features)
00722     {
00723         return E_NOTIMPL;
00724     }
00725     
00726     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_screen( 
00727         /* [out][retval] */ IHTMLScreen __RPC_FAR *__RPC_FAR *p)
00728     {
00729         return E_NOTIMPL;
00730     }
00731     
00732     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Option( 
00733         /* [out][retval] */ IHTMLOptionElementFactory __RPC_FAR *__RPC_FAR *p)
00734     {
00735         return E_NOTIMPL;
00736     }
00737     
00738     virtual /* [id] */ HRESULT STDMETHODCALLTYPE focus( void)
00739     {
00740         return E_NOTIMPL;
00741     }
00742     
00743     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_closed( 
00744         /* [out][retval] */ VARIANT_BOOL __RPC_FAR *p)
00745     {
00746         return E_NOTIMPL;
00747     }
00748     
00749     virtual /* [id] */ HRESULT STDMETHODCALLTYPE blur( void)
00750     {
00751         return E_NOTIMPL;
00752     }
00753     
00754     virtual /* [id] */ HRESULT STDMETHODCALLTYPE scroll( 
00755         /* [in] */ long x,
00756         /* [in] */ long y)
00757     {
00758         return E_NOTIMPL;
00759     }
00760     
00761     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_clientInformation( 
00762         /* [out][retval] */ IOmNavigator __RPC_FAR *__RPC_FAR *p)
00763     {
00764         return get_navigator(p);
00765     }
00766     
00767     virtual /* [id] */ HRESULT STDMETHODCALLTYPE setInterval( 
00768         /* [in] */ BSTR expression,
00769         /* [in] */ long msec,
00770         /* [in][optional] */ VARIANT __RPC_FAR *language,
00771         /* [out][retval] */ long __RPC_FAR *timerID)
00772     {
00773         return E_NOTIMPL;
00774     }
00775     
00776     virtual /* [id] */ HRESULT STDMETHODCALLTYPE clearInterval( 
00777         /* [in] */ long timerID)
00778     {
00779         return E_NOTIMPL;
00780     }
00781     
00782     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_offscreenBuffering( 
00783         /* [in] */ VARIANT v)
00784     {
00785         return E_NOTIMPL;
00786     }
00787     
00788     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_offscreenBuffering( 
00789         /* [out][retval] */ VARIANT __RPC_FAR *p)
00790     {
00791         return E_NOTIMPL;
00792     }
00793     
00794     virtual /* [id] */ HRESULT STDMETHODCALLTYPE execScript( 
00795         /* [in] */ BSTR code,
00796         /* [in][defaultvalue] */ BSTR language,
00797         /* [out][retval] */ VARIANT __RPC_FAR *pvarRet)
00798     {
00799         nsresult rv;
00800 
00801         nsCOMPtr<nsIDOMWindow> domWindow;
00802         NPN_GetValue(mData->pPluginInstance, NPNVDOMWindow, 
00803                      NS_STATIC_CAST(nsIDOMWindow **, getter_AddRefs(domWindow)));
00804         if (!domWindow)
00805         {
00806             return E_UNEXPECTED;
00807         }
00808 
00809         // Now get the DOM Document.  Accessing the document will create one
00810         // if necessary.  So, basically, this call ensures that a document gets
00811         // created -- if necessary.
00812         nsCOMPtr<nsIDOMDocument> domDocument;
00813         rv = domWindow->GetDocument(getter_AddRefs(domDocument));
00814         NS_ASSERTION(domDocument, "No DOMDocument!");
00815         if (NS_FAILED(rv)) {
00816             return E_UNEXPECTED;
00817         }
00818 
00819         nsCOMPtr<nsIScriptGlobalObject> globalObject(do_QueryInterface(domWindow));
00820         if (!globalObject)
00821             return E_UNEXPECTED;
00822 
00823         nsCOMPtr<nsIScriptContext> scriptContext = globalObject->GetContext();
00824         if (!scriptContext)
00825             return E_UNEXPECTED;
00826 
00827         nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument));
00828         if (!doc)
00829             return E_UNEXPECTED;
00830 
00831         nsIPrincipal *principal = doc->GetPrincipal();
00832         if (!principal)
00833             return E_UNEXPECTED;
00834 
00835         // Execute the script.
00836         //
00837         // Note: The script context takes care of the JS stack and of ensuring
00838         //       nothing is executed when JS is disabled.
00839         //
00840         nsAutoString scriptString(code);
00841         NS_NAMED_LITERAL_CSTRING(url, "javascript:axplugin");
00842         rv = scriptContext->EvaluateString(scriptString,
00843                                            nsnull,      // obj
00844                                            principal,
00845                                            url.get(),   // url
00846                                            1,           // line no
00847                                            nsnull,
00848                                            nsnull,
00849                                            nsnull);
00850 
00851         if (NS_FAILED(rv))
00852             return NS_ERROR_FAILURE;
00853 
00854         return S_OK;
00855     }
00856     
00857     virtual /* [id] */ HRESULT STDMETHODCALLTYPE toString( 
00858         /* [out][retval] */ BSTR __RPC_FAR *String)
00859     {
00860         return E_NOTIMPL;
00861     }
00862     
00863     virtual /* [id] */ HRESULT STDMETHODCALLTYPE scrollBy( 
00864         /* [in] */ long x,
00865         /* [in] */ long y)
00866     {
00867         return E_NOTIMPL;
00868     }
00869     
00870     virtual /* [id] */ HRESULT STDMETHODCALLTYPE scrollTo( 
00871         /* [in] */ long x,
00872         /* [in] */ long y)
00873     {
00874         return E_NOTIMPL;
00875     }
00876     
00877     virtual /* [id] */ HRESULT STDMETHODCALLTYPE moveTo( 
00878         /* [in] */ long x,
00879         /* [in] */ long y)
00880     {
00881         return E_NOTIMPL;
00882     }
00883     
00884     virtual /* [id] */ HRESULT STDMETHODCALLTYPE moveBy( 
00885         /* [in] */ long x,
00886         /* [in] */ long y)
00887     {
00888         return E_NOTIMPL;
00889     }
00890     
00891     virtual /* [id] */ HRESULT STDMETHODCALLTYPE resizeTo( 
00892         /* [in] */ long x,
00893         /* [in] */ long y)
00894     {
00895         return E_NOTIMPL;
00896     }
00897     
00898     virtual /* [id] */ HRESULT STDMETHODCALLTYPE resizeBy( 
00899         /* [in] */ long x,
00900         /* [in] */ long y)
00901     {
00902         return E_NOTIMPL;
00903     }
00904     
00905     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_external( 
00906         /* [out][retval] */ IDispatch __RPC_FAR *__RPC_FAR *p)
00907     {
00908         return E_NOTIMPL;
00909     }
00910         
00911 };
00912 
00913 
00914 // Note: Corresponds to the document object in the IE DOM
00915 class IEDocument :
00916     public CComObjectRootEx<CComSingleThreadModel>,
00917     public IDispatchImpl<IHTMLDocument2, &__uuidof(IHTMLDocument2), &LIBID_MSHTML>,
00918     public IServiceProvider,
00919     public IOleContainer,
00920     public IBindHost,
00921     public IHlinkFrame,
00922     public ITargetFrame
00923 {
00924 public:
00925     PluginInstanceData *mData;
00926 
00927     nsCOMPtr<nsIDOMWindow> mDOMWindow;
00928     nsCOMPtr<nsIDOMDocument> mDOMDocument;
00929     nsCOMPtr<nsIDOMElement> mDOMElement;
00930     CComObject<IEWindow> *mWindow;
00931     CComObject<IEBrowser> *mBrowser;
00932     CComBSTR mURL;
00933     BSTR mUseTarget;
00934 
00935     IEDocument() :
00936         mWindow(NULL),
00937         mBrowser(NULL),
00938         mData(NULL),
00939         mUseTarget(NULL)
00940     {
00941         MozAxPlugin::AddRef();
00942     }
00943 
00944     HRESULT Init(PluginInstanceData *pData)
00945     {
00946         mData = pData;
00947 
00948         // Get the DOM document
00949         NPN_GetValue(mData->pPluginInstance, NPNVDOMElement, 
00950                      NS_STATIC_CAST(nsIDOMElement **, getter_AddRefs(mDOMElement)));
00951         if (mDOMElement)
00952         {
00953             mDOMElement->GetOwnerDocument(getter_AddRefs(mDOMDocument));
00954         }
00955 
00956         // Get the DOM window
00957         NPN_GetValue(mData->pPluginInstance, NPNVDOMWindow, 
00958                      NS_STATIC_CAST(nsIDOMWindow **, getter_AddRefs(mDOMWindow)));
00959         if (mDOMWindow)
00960         {
00961             nsCOMPtr<nsIDOMWindowInternal> windowInternal = do_QueryInterface(mDOMWindow);
00962             if (windowInternal)
00963             {
00964                 nsCOMPtr<nsIDOMLocation> location;
00965                 nsAutoString href;
00966                 windowInternal->GetLocation(getter_AddRefs(location));
00967                 if (location &&
00968                     NS_SUCCEEDED(location->GetHref(href)))
00969                 {
00970                     const PRUnichar *s = href.get();
00971                     mURL.Attach(::SysAllocString(s));
00972                 }
00973             }
00974         }
00975 
00976         CComObject<IEWindow>::CreateInstance(&mWindow);
00977         ATLASSERT(mWindow);
00978         if (!mWindow)
00979         {
00980             return E_OUTOFMEMORY;
00981         }
00982         mWindow->AddRef();
00983         mWindow->Init(mData);
00984 
00985         CComObject<IEBrowser>::CreateInstance(&mBrowser);
00986         ATLASSERT(mBrowser);
00987         if (!mBrowser)
00988         {
00989             return E_OUTOFMEMORY;
00990         }
00991         mBrowser->AddRef();
00992         mBrowser->Init(mData);
00993  
00994         return S_OK;
00995     }
00996 
00997     virtual ~IEDocument()
00998     {
00999         if (mUseTarget)
01000         {
01001             SysFreeString(mUseTarget);
01002         }
01003         if (mBrowser)
01004         {
01005             mBrowser->Release();
01006         }
01007         if (mWindow)
01008         {
01009             mWindow->Release();
01010         }
01011         MozAxPlugin::Release();
01012     }
01013 
01014 BEGIN_COM_MAP(IEDocument)
01015     COM_INTERFACE_ENTRY(IServiceProvider)
01016     COM_INTERFACE_ENTRY(IDispatch)
01017     COM_INTERFACE_ENTRY(IHTMLDocument)
01018     COM_INTERFACE_ENTRY(IHTMLDocument2)
01019     COM_INTERFACE_ENTRY(IParseDisplayName)
01020     COM_INTERFACE_ENTRY(IOleContainer)
01021     COM_INTERFACE_ENTRY(IBindHost)
01022     COM_INTERFACE_ENTRY_BREAK(IHlinkTarget)
01023     COM_INTERFACE_ENTRY(IHlinkFrame)
01024     COM_INTERFACE_ENTRY(ITargetFrame)
01025 END_COM_MAP()
01026 
01027 // IServiceProvider
01028     virtual /* [local] */ HRESULT STDMETHODCALLTYPE QueryService( 
01029         /* [in] */ REFGUID guidService,
01030         /* [in] */ REFIID riid,
01031         /* [out] */ void **ppvObject)
01032     {
01033 #ifdef DEBUG
01034         ATLTRACE(_T("IEDocument::QueryService\n"));
01035         if (IsEqualIID(riid, __uuidof(IWebBrowser)) ||
01036             IsEqualIID(riid, __uuidof(IWebBrowser2)) ||
01037             IsEqualIID(riid, __uuidof(IWebBrowserApp)))
01038         {
01039             ATLTRACE(_T("  IWebBrowserApp\n"));
01040             if (mBrowser)
01041             {
01042                 return mBrowser->QueryInterface(riid, ppvObject);
01043             }
01044         }
01045         else if (IsEqualIID(riid, __uuidof(IHTMLWindow2)))
01046         {
01047             ATLTRACE(_T("  IHTMLWindow2\n"));
01048             if (mWindow)
01049             {
01050                 return mWindow->QueryInterface(riid, ppvObject);
01051             }
01052         }
01053         else if (IsEqualIID(riid, __uuidof(IHTMLDocument2)))
01054         {
01055             ATLTRACE(_T("  IHTMLDocument2\n"));
01056         }
01057         else if (IsEqualIID(riid, __uuidof(IBindHost)))
01058         {
01059             ATLTRACE(_T("  IBindHost\n"));
01060         }
01061         else
01062         {
01063             USES_CONVERSION;
01064             LPOLESTR szClsid = NULL;
01065             StringFromIID(riid, &szClsid);
01066             ATLTRACE(_T("  Unknown interface %s\n"), OLE2T(szClsid));
01067             CoTaskMemFree(szClsid);
01068         }
01069 #endif
01070         return QueryInterface(riid, ppvObject);
01071     }
01072 
01073 // IHTMLDocument
01074     virtual /* [nonbrowsable][hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get_Script( 
01075         /* [out][retval] */ IDispatch **p)
01076     {
01077         *p = NULL;
01078         return S_OK;
01079     }
01080 
01081 // IHTMLDocument2
01082     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_all( 
01083         /* [out][retval] */ IHTMLElementCollection **p)
01084     {
01085         // Validate parameters
01086         if (p == NULL)
01087         {
01088             return E_INVALIDARG;
01089         }
01090 
01091         *p = NULL;
01092 
01093         // Create a collection object
01094         CIEHtmlElementCollectionInstance *pCollection = NULL;
01095         CIEHtmlElementCollectionInstance::CreateInstance(&pCollection);
01096         if (pCollection == NULL)
01097         {
01098             return E_OUTOFMEMORY;
01099         }
01100 
01101         // Initialise and populate the collection
01102         nsCOMPtr<nsIDOMNode> docNode = do_QueryInterface(mDOMDocument);
01103         pCollection->PopulateFromDOMNode(docNode, PR_TRUE);
01104         pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
01105 
01106         return *p ? S_OK : E_UNEXPECTED;
01107     }
01108     
01109     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_body( 
01110         /* [out][retval] */ IHTMLElement **p)
01111     {
01112         return E_NOTIMPL;
01113     }
01114     
01115     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_activeElement( 
01116         /* [out][retval] */ IHTMLElement **p)
01117     {
01118         return E_NOTIMPL;
01119     }
01120     
01121     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_images( 
01122         /* [out][retval] */ IHTMLElementCollection **p)
01123     {
01124         return E_NOTIMPL;
01125     }
01126     
01127     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_applets( 
01128         /* [out][retval] */ IHTMLElementCollection **p)
01129     {
01130         return E_NOTIMPL;
01131     }
01132     
01133     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_links( 
01134         /* [out][retval] */ IHTMLElementCollection **p)
01135     {
01136         return E_NOTIMPL;
01137     }
01138     
01139     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_forms( 
01140         /* [out][retval] */ IHTMLElementCollection **p)
01141     {
01142         return E_NOTIMPL;
01143     }
01144     
01145     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_anchors( 
01146         /* [out][retval] */ IHTMLElementCollection **p)
01147     {
01148         return E_NOTIMPL;
01149     }
01150     
01151     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_title( 
01152         /* [in] */ BSTR v)
01153     {
01154         return E_NOTIMPL;
01155     }
01156     
01157     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_title( 
01158         /* [out][retval] */ BSTR *p)
01159     {
01160         return E_NOTIMPL;
01161     }
01162     
01163     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_scripts( 
01164         /* [out][retval] */ IHTMLElementCollection **p)
01165     {
01166         return E_NOTIMPL;
01167     }
01168     
01169     virtual /* [hidden][id][propput] */ HRESULT STDMETHODCALLTYPE put_designMode( 
01170         /* [in] */ BSTR v)
01171     {
01172         return E_NOTIMPL;
01173     }
01174     
01175     virtual /* [hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get_designMode( 
01176         /* [out][retval] */ BSTR *p)
01177     {
01178         return E_NOTIMPL;
01179     }
01180     
01181     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_selection( 
01182         /* [out][retval] */ IHTMLSelectionObject **p)
01183     {
01184         return E_NOTIMPL;
01185     }
01186     
01187     virtual /* [bindable][id][propget] */ HRESULT STDMETHODCALLTYPE get_readyState( 
01188         /* [out][retval] */ BSTR *p)
01189     {
01190         return E_NOTIMPL;
01191     }
01192     
01193     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_frames( 
01194         /* [out][retval] */ IHTMLFramesCollection2 **p)
01195     {
01196         return E_NOTIMPL;
01197     }
01198     
01199     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_embeds( 
01200         /* [out][retval] */ IHTMLElementCollection **p)
01201     {
01202         return E_NOTIMPL;
01203     }
01204     
01205     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_plugins( 
01206         /* [out][retval] */ IHTMLElementCollection **p)
01207     {
01208         return E_NOTIMPL;
01209     }
01210     
01211     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_alinkColor( 
01212         /* [in] */ VARIANT v)
01213     {
01214         return E_NOTIMPL;
01215     }
01216     
01217     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_alinkColor( 
01218         /* [out][retval] */ VARIANT *p)
01219     {
01220         return E_NOTIMPL;
01221     }
01222     
01223     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_bgColor( 
01224         /* [in] */ VARIANT v)
01225     {
01226         return E_NOTIMPL;
01227     }
01228     
01229     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_bgColor( 
01230         /* [out][retval] */ VARIANT *p)
01231     {
01232         return E_NOTIMPL;
01233     }
01234     
01235     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_fgColor( 
01236         /* [in] */ VARIANT v)
01237     {
01238         return E_NOTIMPL;
01239     }
01240     
01241     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_fgColor( 
01242         /* [out][retval] */ VARIANT *p)
01243     {
01244         return E_NOTIMPL;
01245     }
01246     
01247     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_linkColor( 
01248         /* [in] */ VARIANT v)
01249     {
01250         return E_NOTIMPL;
01251     }
01252     
01253     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_linkColor( 
01254         /* [out][retval] */ VARIANT *p)
01255     {
01256         return E_NOTIMPL;
01257     }
01258     
01259     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_vlinkColor( 
01260         /* [in] */ VARIANT v)
01261     {
01262         return E_NOTIMPL;
01263     }
01264     
01265     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_vlinkColor( 
01266         /* [out][retval] */ VARIANT *p)
01267     {
01268         return E_NOTIMPL;
01269     }
01270     
01271     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_referrer( 
01272         /* [out][retval] */ BSTR *p)
01273     {
01274         return E_NOTIMPL;
01275     }
01276     
01277     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_location( 
01278         /* [out][retval] */ IHTMLLocation **p)
01279     {
01280         if (mWindow)
01281             return mWindow->get_location(p);
01282         return E_FAIL;
01283     }
01284     
01285     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_lastModified( 
01286         /* [out][retval] */ BSTR *p)
01287     {
01288         return E_NOTIMPL;
01289     }
01290     
01291     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_URL( 
01292         /* [in] */ BSTR v)
01293     {
01294         return E_NOTIMPL;
01295     }
01296     
01297     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_URL( 
01298         /* [out][retval] */ BSTR *p)
01299     {
01300         *p = mURL.Copy();
01301         return S_OK;
01302     }
01303     
01304     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_domain( 
01305         /* [in] */ BSTR v)
01306     {
01307         return E_NOTIMPL;
01308     }
01309     
01310     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_domain( 
01311         /* [out][retval] */ BSTR *p)
01312     {
01313         return E_NOTIMPL;
01314     }
01315     
01316     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_cookie( 
01317         /* [in] */ BSTR v)
01318     {
01319         return E_NOTIMPL;
01320     }
01321     
01322     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_cookie( 
01323         /* [out][retval] */ BSTR *p)
01324     {
01325         return E_NOTIMPL;
01326     }
01327     
01328     virtual /* [hidden][bindable][id][propput] */ HRESULT STDMETHODCALLTYPE put_expando( 
01329         /* [in] */ VARIANT_BOOL v)
01330     {
01331         return E_NOTIMPL;
01332     }
01333     
01334     virtual /* [hidden][bindable][id][propget] */ HRESULT STDMETHODCALLTYPE get_expando( 
01335         /* [out][retval] */ VARIANT_BOOL *p)
01336     {
01337         return E_NOTIMPL;
01338     }
01339     
01340     virtual /* [hidden][id][propput] */ HRESULT STDMETHODCALLTYPE put_charset( 
01341         /* [in] */ BSTR v)
01342     {
01343         return E_NOTIMPL;
01344     }
01345     
01346     virtual /* [hidden][id][propget] */ HRESULT STDMETHODCALLTYPE get_charset( 
01347         /* [out][retval] */ BSTR *p)
01348     {
01349         return E_NOTIMPL;
01350     }
01351     
01352     virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_defaultCharset( 
01353         /* [in] */ BSTR v)
01354     {
01355         return E_NOTIMPL;
01356     }
01357     
01358     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_defaultCharset( 
01359         /* [out][retval] */ BSTR *p)
01360     {
01361         return E_NOTIMPL;
01362     }
01363     
01364     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_mimeType( 
01365         /* [out][retval] */ BSTR *p)
01366     {
01367         return E_NOTIMPL;
01368     }
01369     
01370     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_fileSize( 
01371         /* [out][retval] */ BSTR *p)
01372     {
01373         return E_NOTIMPL;
01374     }
01375     
01376     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_fileCreatedDate( 
01377         /* [out][retval] */ BSTR *p)
01378     {
01379         return E_NOTIMPL;
01380     }
01381     
01382     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_fileModifiedDate( 
01383         /* [out][retval] */ BSTR *p)
01384     {
01385         return E_NOTIMPL;
01386     }
01387     
01388     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_fileUpdatedDate( 
01389         /* [out][retval] */ BSTR *p)
01390     {
01391         return E_NOTIMPL;
01392     }
01393     
01394     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_security( 
01395         /* [out][retval] */ BSTR *p)
01396     {
01397         return E_NOTIMPL;
01398     }
01399     
01400     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_protocol( 
01401         /* [out][retval] */ BSTR *p)
01402     {
01403         return E_NOTIMPL;
01404     }
01405     
01406     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nameProp( 
01407         /* [out][retval] */ BSTR *p)
01408     {
01409         return E_NOTIMPL;
01410     }
01411     
01412     virtual /* [id][vararg] */ HRESULT STDMETHODCALLTYPE write( 
01413         /* [in] */ SAFEARRAY * psarray)
01414     {
01415         return E_NOTIMPL;
01416     }
01417     
01418     virtual /* [id][vararg] */ HRESULT STDMETHODCALLTYPE writeln( 
01419         /* [in] */ SAFEARRAY * psarray)
01420     {
01421         return E_NOTIMPL;
01422     }
01423     
01424     virtual /* [id] */ HRESULT STDMETHODCALLTYPE open( 
01425         /* [in][defaultvalue] */ BSTR url,
01426         /* [in][optional] */ VARIANT name,
01427         /* [in][optional] */ VARIANT features,
01428         /* [in][optional] */ VARIANT replace,
01429         /* [out][retval] */ IDispatch **pomWindowResult)
01430     {
01431         return E_NOTIMPL;
01432     }
01433     
01434     virtual /* [id] */ HRESULT STDMETHODCALLTYPE close( void)
01435     {
01436         return E_NOTIMPL;
01437     }
01438     
01439     virtual /* [id] */ HRESULT STDMETHODCALLTYPE clear( void)
01440     {
01441         return E_NOTIMPL;
01442     }
01443     
01444     virtual /* [id] */ HRESULT STDMETHODCALLTYPE queryCommandSupported( 
01445         /* [in] */ BSTR cmdID,
01446         /* [out][retval] */ VARIANT_BOOL *pfRet)
01447     {
01448         return E_NOTIMPL;
01449     }
01450     
01451     virtual /* [id] */ HRESULT STDMETHODCALLTYPE queryCommandEnabled( 
01452         /* [in] */ BSTR cmdID,
01453         /* [out][retval] */ VARIANT_BOOL *pfRet)
01454     {
01455         return E_NOTIMPL;
01456     }
01457     
01458     virtual /* [id] */ HRESULT STDMETHODCALLTYPE queryCommandState( 
01459         /* [in] */ BSTR cmdID,
01460         /* [out][retval] */ VARIANT_BOOL *pfRet)
01461     {
01462         return E_NOTIMPL;
01463     }
01464     
01465     virtual /* [id] */ HRESULT STDMETHODCALLTYPE queryCommandIndeterm( 
01466         /* [in] */ BSTR cmdID,
01467         /* [out][retval] */ VARIANT_BOOL *pfRet)
01468     {
01469         return E_NOTIMPL;
01470     }
01471     
01472     virtual /* [id] */ HRESULT STDMETHODCALLTYPE queryCommandText( 
01473         /* [in] */ BSTR cmdID,
01474         /* [out][retval] */ BSTR *pcmdText)
01475     {
01476         return E_NOTIMPL;
01477     }
01478     
01479     virtual /* [id] */ HRESULT STDMETHODCALLTYPE queryCommandValue( 
01480         /* [in] */ BSTR cmdID,
01481         /* [out][retval] */ VARIANT *pcmdValue)
01482     {
01483         return E_NOTIMPL;
01484     }
01485     
01486     virtual /* [id] */ HRESULT STDMETHODCALLTYPE execCommand( 
01487         /* [in] */ BSTR cmdID,
01488         /* [in][defaultvalue] */ VARIANT_BOOL showUI,
01489         /* [in][optional] */ VARIANT value,
01490         /* [out][retval] */ VARIANT_BOOL *pfRet)
01491     {
01492         return E_NOTIMPL;
01493     }
01494     
01495     virtual /* [id] */ HRESULT STDMETHODCALLTYPE execCommandShowHelp( 
01496         /* [in] */ BSTR cmdID,
01497         /* [out][retval] */ VARIANT_BOOL *pfRet)
01498     {
01499         return E_NOTIMPL;
01500     }
01501     
01502     virtual /* [id] */ HRESULT STDMETHODCALLTYPE createElement( 
01503         /* [in] */ BSTR eTag,
01504         /* [out][retval] */ IHTMLElement **newElem)
01505     {
01506         return E_NOTIMPL;
01507     }
01508     
01509     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onhelp( 
01510         /* [in] */ VARIANT v)
01511     {
01512         return E_NOTIMPL;
01513     }
01514     
01515     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onhelp( 
01516         /* [out][retval] */ VARIANT *p)
01517     {
01518         return E_NOTIMPL;
01519     }
01520     
01521     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onclick( 
01522         /* [in] */ VARIANT v)
01523     {
01524         return E_NOTIMPL;
01525     }
01526     
01527     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onclick( 
01528         /* [out][retval] */ VARIANT *p)
01529     {
01530         return E_NOTIMPL;
01531     }
01532     
01533     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_ondblclick( 
01534         /* [in] */ VARIANT v)
01535     {
01536         return E_NOTIMPL;
01537     }
01538     
01539     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_ondblclick( 
01540         /* [out][retval] */ VARIANT *p)
01541     {
01542         return E_NOTIMPL;
01543     }
01544     
01545     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onkeyup( 
01546         /* [in] */ VARIANT v)
01547     {
01548         return E_NOTIMPL;
01549     }
01550     
01551     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onkeyup( 
01552         /* [out][retval] */ VARIANT *p)
01553     {
01554         return E_NOTIMPL;
01555     }
01556     
01557     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onkeydown( 
01558         /* [in] */ VARIANT v)
01559     {
01560         return E_NOTIMPL;
01561     }
01562     
01563     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onkeydown( 
01564         /* [out][retval] */ VARIANT *p)
01565     {
01566         return E_NOTIMPL;
01567     }
01568     
01569     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onkeypress( 
01570         /* [in] */ VARIANT v)
01571     {
01572         return E_NOTIMPL;
01573     }
01574     
01575     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onkeypress( 
01576         /* [out][retval] */ VARIANT *p)
01577     {
01578         return E_NOTIMPL;
01579     }
01580     
01581     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onmouseup( 
01582         /* [in] */ VARIANT v)
01583     {
01584         return E_NOTIMPL;
01585     }
01586     
01587     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onmouseup( 
01588         /* [out][retval] */ VARIANT *p)
01589     {
01590         return E_NOTIMPL;
01591     }
01592     
01593     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onmousedown( 
01594         /* [in] */ VARIANT v)
01595     {
01596         return E_NOTIMPL;
01597     }
01598     
01599     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onmousedown( 
01600         /* [out][retval] */ VARIANT *p)
01601     {
01602         return E_NOTIMPL;
01603     }
01604     
01605     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onmousemove( 
01606         /* [in] */ VARIANT v)
01607     {
01608         return E_NOTIMPL;
01609     }
01610     
01611     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onmousemove( 
01612         /* [out][retval] */ VARIANT *p)
01613     {
01614         return E_NOTIMPL;
01615     }
01616     
01617     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onmouseout( 
01618         /* [in] */ VARIANT v)
01619     {
01620         return E_NOTIMPL;
01621     }
01622     
01623     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onmouseout( 
01624         /* [out][retval] */ VARIANT *p)
01625     {
01626         return E_NOTIMPL;
01627     }
01628     
01629     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onmouseover( 
01630         /* [in] */ VARIANT v)
01631     {
01632         return E_NOTIMPL;
01633     }
01634     
01635     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onmouseover( 
01636         /* [out][retval] */ VARIANT *p)
01637     {
01638         return E_NOTIMPL;
01639     }
01640     
01641     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onreadystatechange( 
01642         /* [in] */ VARIANT v)
01643     {
01644         return E_NOTIMPL;
01645     }
01646     
01647     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onreadystatechange( 
01648         /* [out][retval] */ VARIANT *p)
01649     {
01650         return E_NOTIMPL;
01651     }
01652     
01653     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onafterupdate( 
01654         /* [in] */ VARIANT v)
01655     {
01656         return E_NOTIMPL;
01657     }
01658     
01659     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onafterupdate( 
01660         /* [out][retval] */ VARIANT *p)
01661     {
01662         return E_NOTIMPL;
01663     }
01664     
01665     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onrowexit( 
01666         /* [in] */ VARIANT v)
01667     {
01668         return E_NOTIMPL;
01669     }
01670     
01671     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onrowexit( 
01672         /* [out][retval] */ VARIANT *p)
01673     {
01674         return E_NOTIMPL;
01675     }
01676     
01677     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onrowenter( 
01678         /* [in] */ VARIANT v)
01679     {
01680         return E_NOTIMPL;
01681     }
01682     
01683     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onrowenter( 
01684         /* [out][retval] */ VARIANT *p)
01685     {
01686         return E_NOTIMPL;
01687     }
01688     
01689     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_ondragstart( 
01690         /* [in] */ VARIANT v)
01691     {
01692         return E_NOTIMPL;
01693     }
01694     
01695     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_ondragstart( 
01696         /* [out][retval] */ VARIANT *p)
01697     {
01698         return E_NOTIMPL;
01699     }
01700     
01701     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onselectstart( 
01702         /* [in] */ VARIANT v)
01703     {
01704         return E_NOTIMPL;
01705     }
01706     
01707     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onselectstart( 
01708         /* [out][retval] */ VARIANT *p)
01709     {
01710         return E_NOTIMPL;
01711     }
01712     
01713     virtual /* [id] */ HRESULT STDMETHODCALLTYPE elementFromPoint( 
01714         /* [in] */ long x,
01715         /* [in] */ long y,
01716         /* [out][retval] */ IHTMLElement **elementHit)
01717     {
01718         return E_NOTIMPL;
01719     }
01720     
01721     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_parentWindow( 
01722         /* [out][retval] */ IHTMLWindow2 **p)
01723     {
01724         return mWindow->QueryInterface(_uuidof(IHTMLWindow2), (void **) p);
01725     }
01726     
01727     virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_styleSheets( 
01728         /* [out][retval] */ IHTMLStyleSheetsCollection **p)
01729     {
01730         return E_NOTIMPL;
01731     }
01732     
01733     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onbeforeupdate( 
01734         /* [in] */ VARIANT v)
01735     {
01736         return E_NOTIMPL;
01737     }
01738     
01739     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onbeforeupdate( 
01740         /* [out][retval] */ VARIANT *p)
01741     {
01742         return E_NOTIMPL;
01743     }
01744     
01745     virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_onerrorupdate( 
01746         /* [in] */ VARIANT v)
01747     {
01748         return E_NOTIMPL;
01749     }
01750     
01751     virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_onerrorupdate( 
01752         /* [out][retval] */ VARIANT *p)
01753     {
01754         return E_NOTIMPL;
01755     }
01756     
01757     virtual /* [id] */ HRESULT STDMETHODCALLTYPE toString( 
01758         /* [out][retval] */ BSTR *String)
01759     {
01760         return E_NOTIMPL;
01761     }
01762     
01763     virtual /* [id] */ HRESULT STDMETHODCALLTYPE createStyleSheet( 
01764         /* [in][defaultvalue] */ BSTR bstrHref,
01765         /* [in][defaultvalue] */ long lIndex,
01766         /* [out][retval] */ IHTMLStyleSheet **ppnewStyleSheet)
01767     {
01768         return E_NOTIMPL;
01769     }
01770 
01771 // IParseDisplayName
01772     virtual HRESULT STDMETHODCALLTYPE ParseDisplayName( 
01773         /* [unique][in] */ IBindCtx *pbc,
01774         /* [in] */ LPOLESTR pszDisplayName,
01775         /* [out] */ ULONG *pchEaten,
01776         /* [out] */ IMoniker **ppmkOut)
01777     {
01778         return E_NOTIMPL;
01779     }
01780 
01781 // IOleContainer
01782     virtual HRESULT STDMETHODCALLTYPE EnumObjects( 
01783         /* [in] */ DWORD grfFlags,
01784         /* [out] */ IEnumUnknown **ppenum)
01785     {
01786         return E_NOTIMPL;
01787     }
01788     
01789     virtual HRESULT STDMETHODCALLTYPE LockContainer( 
01790         /* [in] */ BOOL fLock)
01791     {
01792         return E_NOTIMPL;
01793     }
01794 
01795 
01796 // IHlinkFrame
01797     virtual HRESULT STDMETHODCALLTYPE SetBrowseContext( 
01798         /* [unique][in] */ IHlinkBrowseContext *pihlbc)
01799     {
01800         return E_NOTIMPL;
01801     }
01802     
01803     virtual HRESULT STDMETHODCALLTYPE GetBrowseContext( 
01804         /* [out] */ IHlinkBrowseContext **ppihlbc)
01805     {
01806         return E_NOTIMPL;
01807     }
01808     
01809     virtual HRESULT STDMETHODCALLTYPE Navigate( 
01810         /* [in] */ DWORD grfHLNF,
01811         /* [unique][in] */ LPBC pbc,
01812         /* [unique][in] */ IBindStatusCallback *pibsc,
01813         /* [unique][in] */ IHlink *pihlNavigate)
01814     {
01815         if (!pihlNavigate) return E_INVALIDARG;
01816         // TODO check grfHLNF for type of link
01817         LPWSTR szTarget = NULL;
01818         LPWSTR szLocation = NULL;
01819         LPWSTR szTargetFrame = NULL;
01820         HRESULT hr;
01821         hr = pihlNavigate->GetStringReference(HLINKGETREF_DEFAULT, &szTarget, &szLocation);
01822         hr = pihlNavigate->GetTargetFrameName(&szTargetFrame);
01823         if (szTarget && szTarget[0] != WCHAR('\0'))
01824         {
01825             NS_ConvertUTF16toUTF8 spec(szTarget);
01826             nsCOMPtr<nsIURI> uri;
01827             nsresult rv = NS_NewURI(getter_AddRefs(uri), spec);
01828             if (NS_SUCCEEDED(rv) && uri)
01829             {
01830                 nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mDOMWindow);
01831                 if (webNav)
01832                 {
01833                     nsCOMPtr<nsILinkHandler> lh = do_QueryInterface(webNav);
01834                     if (lh)
01835                     {
01836                         nsCOMPtr<nsPIDOMWindow> window =
01837                             do_GetInterface(mDOMWindow);
01838 
01839                         nsAutoPopupStatePusher popupStatePusher(window,
01840                                                                 openAllowed);
01841 
01842                         nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMElement));
01843 
01844                         lh->OnLinkClick(content, eLinkVerb_Replace,
01845                             uri, szTargetFrame ? szTargetFrame : mUseTarget);
01846                     }
01847                 }
01848                 hr = S_OK;
01849             }
01850             else
01851             {
01852                 hr = E_FAIL;
01853             }
01854         }
01855         else
01856         {
01857             hr = E_FAIL;
01858         }
01859         if (szTarget)
01860             CoTaskMemFree(szTarget);
01861         if (szLocation)
01862             CoTaskMemFree(szLocation);
01863         if (szTargetFrame)
01864             CoTaskMemFree(szTargetFrame);
01865         if (mUseTarget)
01866         {
01867             SysFreeString(mUseTarget);
01868             mUseTarget = NULL;
01869         }
01870         return hr;
01871     }
01872     
01873     virtual HRESULT STDMETHODCALLTYPE OnNavigate( 
01874         /* [in] */ DWORD grfHLNF,
01875         /* [unique][in] */ IMoniker *pimkTarget,
01876         /* [unique][in] */ LPCWSTR pwzLocation,
01877         /* [unique][in] */ LPCWSTR pwzFriendlyName,
01878         /* [in] */ DWORD dwreserved)
01879     {
01880         return E_NOTIMPL;
01881     }
01882     
01883     virtual HRESULT STDMETHODCALLTYPE UpdateHlink( 
01884         /* [in] */ ULONG uHLID,
01885         /* [unique][in] */ IMoniker *pimkTarget,
01886         /* [unique][in] */ LPCWSTR pwzLocation,
01887         /* [unique][in] */ LPCWSTR pwzFriendlyName)
01888     {
01889         return E_NOTIMPL;
01890     }
01891 
01892 // IBindHost
01893     virtual HRESULT STDMETHODCALLTYPE CreateMoniker( 
01894         /* [in] */ LPOLESTR szName,
01895         /* [in] */ IBindCtx *pBC,
01896         /* [out] */ IMoniker **ppmk,
01897         /* [in] */ DWORD dwReserved)
01898     {
01899         if (!szName || !ppmk) return E_POINTER;
01900         if (!*szName) return E_INVALIDARG;
01901 
01902         *ppmk = NULL;
01903 
01904         // Get the BASE url
01905         CComPtr<IMoniker> baseURLMoniker;
01906         nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDOMDocument));
01907         if (doc)
01908         {
01909             nsIURI *baseURI = doc->GetBaseURI();
01910             nsCAutoString spec;
01911             if (baseURI &&
01912                 NS_SUCCEEDED(baseURI->GetSpec(spec)))
01913             {
01914                 USES_CONVERSION;
01915                 if (FAILED(CreateURLMoniker(NULL, T2CW(spec.get()), &baseURLMoniker)))
01916                     return E_UNEXPECTED;
01917             }
01918         }
01919 
01920         // Make the moniker
01921         HRESULT hr = CreateURLMoniker(baseURLMoniker, szName, ppmk);
01922         if (SUCCEEDED(hr) && !*ppmk)
01923             hr = E_FAIL;
01924         return hr;
01925     }
01926     
01927     virtual /* [local] */ HRESULT STDMETHODCALLTYPE MonikerBindToStorage( 
01928         /* [in] */ IMoniker *pMk,
01929         /* [in] */ IBindCtx *pBC,
01930         /* [in] */ IBindStatusCallback *pBSC,
01931         /* [in] */ REFIID riid,
01932         /* [out] */ void **ppvObj)
01933     {
01934         if (!pMk || !ppvObj) return E_POINTER;
01935 
01936         *ppvObj = NULL;
01937         HRESULT hr = S_OK;
01938         CComPtr<IBindCtx> spBindCtx;
01939         if (pBC)
01940         {
01941             spBindCtx = pBC;
01942             if (pBSC)
01943             {
01944                 hr = RegisterBindStatusCallback(spBindCtx, pBSC, NULL, 0);
01945                 if (FAILED(hr))
01946                     return hr;
01947             }
01948         }
01949         else
01950         {
01951             if (pBSC)
01952                 hr = CreateAsyncBindCtx(0, pBSC, NULL, &spBindCtx);
01953             else
01954                 hr = CreateBindCtx(0, &spBindCtx);
01955             if (SUCCEEDED(hr) && !spBindCtx)
01956                 hr = E_FAIL;
01957             if (FAILED(hr))
01958                 return hr;
01959         }
01960         return pMk->BindToStorage(spBindCtx, NULL, riid, ppvObj);
01961     }
01962     
01963     virtual /* [local] */ HRESULT STDMETHODCALLTYPE MonikerBindToObject( 
01964         /* [in] */ IMoniker *pMk,
01965         /* [in] */ IBindCtx *pBC,
01966         /* [in] */ IBindStatusCallback *pBSC,
01967         /* [in] */ REFIID riid,
01968         /* [out] */ void **ppvObj)
01969     {
01970         return E_NOTIMPL;
01971     }
01972 
01973 // ITargetFrame
01974     virtual HRESULT STDMETHODCALLTYPE SetFrameName(
01975         /* [in] */ LPCWSTR pszFrameName)
01976     {
01977         NS_ASSERTION(FALSE, "ITargetFrame::SetFrameName is not implemented");
01978         return E_NOTIMPL;
01979     }
01980 
01981     virtual HRESULT STDMETHODCALLTYPE GetFrameName(
01982         /* [out] */ LPWSTR *ppszFrameName)
01983     {
01984         NS_ASSERTION(FALSE, "ITargetFrame::GetFrameName is not implemented");
01985         return E_NOTIMPL;
01986     }
01987 
01988     virtual HRESULT STDMETHODCALLTYPE GetParentFrame(
01989         /* [out] */ IUnknown **ppunkParent)
01990     {
01991         NS_ASSERTION(FALSE, "ITargetFrame::GetParentFrame is not implemented");
01992         return E_NOTIMPL;
01993     }
01994 
01995     virtual HRESULT STDMETHODCALLTYPE FindFrame( 
01996         /* [in] */ LPCWSTR pszTargetName,
01997         /* [in] */ IUnknown *ppunkContextFrame,
01998         /* [in] */ DWORD dwFlags,
01999         /* [out] */ IUnknown **ppunkTargetFrame)
02000     {
02001         if (dwFlags & 0x1) // TODO test if the named frame exists and presumably return NULL if it doesn't
02002         {
02003         }
02004 
02005         if (mUseTarget)
02006         {
02007             SysFreeString(mUseTarget);
02008             mUseTarget = NULL;
02009         }
02010         if (pszTargetName)
02011         {
02012             mUseTarget = SysAllocString(pszTargetName);
02013         }
02014 
02015         QueryInterface(__uuidof(IUnknown), (void **) ppunkTargetFrame);
02016         return S_OK;;
02017     }
02018 
02019     virtual HRESULT STDMETHODCALLTYPE SetFrameSrc( 
02020         /* [in] */ LPCWSTR pszFrameSrc)
02021     {
02022         NS_ASSERTION(FALSE, "ITargetFrame::SetFrameSrc is not implemented");
02023         return E_NOTIMPL;
02024     }
02025 
02026     virtual HRESULT STDMETHODCALLTYPE GetFrameSrc( 
02027         /* [out] */ LPWSTR *ppszFrameSrc)
02028     {
02029         NS_ASSERTION(FALSE, "ITargetFrame::GetFrameSrc is not implemented");
02030         return E_NOTIMPL;
02031     }
02032 
02033     virtual HRESULT STDMETHODCALLTYPE GetFramesContainer( 
02034         /* [out] */ IOleContainer **ppContainer)
02035     {
02036         NS_ASSERTION(FALSE, "ITargetFrame::GetFramesContainer is not implemented");
02037         return E_NOTIMPL;
02038     }
02039 
02040     virtual HRESULT STDMETHODCALLTYPE SetFrameOptions( 
02041         /* [in] */ DWORD dwFlags)
02042     {
02043         NS_ASSERTION(FALSE, "ITargetFrame::SetFrameOptions is not implemented");
02044         return E_NOTIMPL;
02045     }
02046 
02047     virtual HRESULT STDMETHODCALLTYPE GetFrameOptions( 
02048         /* [out] */ DWORD *pdwFlags)
02049     {
02050         NS_ASSERTION(FALSE, "ITargetFrame::GetFrameOptions is not implemented");
02051         return E_NOTIMPL;
02052     }
02053 
02054     virtual HRESULT STDMETHODCALLTYPE SetFrameMargins( 
02055         /* [in] */ DWORD dwWidth,
02056         /* [in] */ DWORD dwHeight)
02057     {
02058         NS_ASSERTION(FALSE, "ITargetFrame::SetFrameMargins is not implemented");
02059         return E_NOTIMPL;
02060     }
02061 
02062     virtual HRESULT STDMETHODCALLTYPE GetFrameMargins( 
02063         /* [out] */ DWORD *pdwWidth,
02064         /* [out] */ DWORD *pdwHeight)
02065     {
02066         NS_ASSERTION(FALSE, "ITargetFrame::GetFrameMargins is not implemented");
02067         return E_NOTIMPL;
02068     }
02069 
02070     virtual HRESULT STDMETHODCALLTYPE RemoteNavigate( 
02071         /* [in] */ ULONG cLength,
02072         /* [size_is][in] */ ULONG *pulData)
02073     {
02074         NS_ASSERTION(FALSE, "ITargetFrame::RemoteNavigate is not implemented");
02075         return E_NOTIMPL;
02076     }
02077 
02078     virtual HRESULT STDMETHODCALLTYPE OnChildFrameActivate( 
02079         /* [in] */ IUnknown *pUnkChildFrame)
02080     {
02081         NS_ASSERTION(FALSE, "ITargetFrame::OnChildFrameActivate is not implemented");
02082         return E_NOTIMPL;
02083     }
02084 
02085     virtual HRESULT STDMETHODCALLTYPE OnChildFrameDeactivate( 
02086         /* [in] */ IUnknown *pUnkChildFrame)
02087     {
02088         NS_ASSERTION(FALSE, "ITargetFrame::OnChildFrameDeactivate is not implemented");
02089         return E_NOTIMPL;
02090     }
02091 };
02092 
02093 HRESULT MozAxPlugin::GetServiceProvider(PluginInstanceData *pData, IServiceProvider **pSP)
02094 {
02095     // Note this should be called on the main NPAPI thread
02096     CComObject<IEDocument> *pDoc = NULL;
02097     CComObject<IEDocument>::CreateInstance(&pDoc);
02098     ATLASSERT(pDoc);
02099     if (!pDoc)
02100     {
02101         return E_OUTOFMEMORY;
02102     }
02103     pDoc->Init(pData);
02104     // QI does the AddRef
02105     return pDoc->QueryInterface(_uuidof(IServiceProvider), (void **) pSP);
02106 }