diff --git a/xpfe/AppCores/idl/ToolkitCore.idl b/xpfe/AppCores/idl/ToolkitCore.idl index 6e58ad64597..899721ec751 100644 --- a/xpfe/AppCores/idl/ToolkitCore.idl +++ b/xpfe/AppCores/idl/ToolkitCore.idl @@ -4,5 +4,6 @@ interface ToolkitCore : BaseAppCore {0x81, 0xb2, 0x00, 0x60, 0x08, 0x3a, 0x0b, 0xcf}} *\ void ToolkitCore(); + void ShowDialog(in wstring url, in Window parent); void ShowWindow(in wstring url, in Window parent); }; diff --git a/xpfe/AppCores/public/nsIDOMToolkitCore.h b/xpfe/AppCores/public/nsIDOMToolkitCore.h index 04b215644b9..ebfbc0cc1bf 100644 --- a/xpfe/AppCores/public/nsIDOMToolkitCore.h +++ b/xpfe/AppCores/public/nsIDOMToolkitCore.h @@ -35,20 +35,24 @@ class nsIDOMToolkitCore : public nsIDOMBaseAppCore { public: static const nsIID& GetIID() { static nsIID iid = NS_IDOMTOOLKITCORE_IID; return iid; } + NS_IMETHOD ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent)=0; + NS_IMETHOD ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent)=0; }; #define NS_DECL_IDOMTOOLKITCORE \ + NS_IMETHOD ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent); \ NS_IMETHOD ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent); \ #define NS_FORWARD_IDOMTOOLKITCORE(_to) \ + NS_IMETHOD ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) { return _to##ShowDialog(aUrl, aParent); } \ NS_IMETHOD ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) { return _to##ShowWindow(aUrl, aParent); } \ -extern nsresult NS_InitToolkitCoreClass(nsIScriptContext *aContext, void **aPrototype); +extern "C" NS_DOM nsresult NS_InitToolkitCoreClass(nsIScriptContext *aContext, void **aPrototype); extern "C" NS_DOM nsresult NS_NewScriptToolkitCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); diff --git a/xpfe/AppCores/src/nsToolkitCore.cpp b/xpfe/AppCores/src/nsToolkitCore.cpp index c3791979d7c..a9de73414e4 100644 --- a/xpfe/AppCores/src/nsToolkitCore.cpp +++ b/xpfe/AppCores/src/nsToolkitCore.cpp @@ -127,6 +127,44 @@ nsToolkitCore::Init(const nsString& aId) { } +NS_IMETHODIMP +nsToolkitCore::ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) { + + nsresult rv; + nsString controllerCID; + nsIAppShellService *appShell; + nsIWidget *window; + + window = nsnull; + + nsCOMPtr urlObj; + rv = NS_NewURL(getter_AddRefs(urlObj), aUrl); + if (NS_FAILED(rv)) + return rv; + + rv = nsServiceManager::GetService(kAppShellServiceCID, kIAppShellServiceIID, + (nsISupports**) &appShell); + if (NS_FAILED(rv)) + return rv; + + // hardwired temporary hack. See nsAppRunner.cpp at main() + controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081"; + + nsCOMPtr webWindow = DOMWindowToWebShellWindow(aParent); + nsCOMPtr parent; + if (webWindow) + webWindow->GetWidget(*getter_AddRefs(parent)); + + appShell->CreateTopLevelWindow(parent, urlObj, controllerCID, window, + nsnull, nsnull, 615, 650); + nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); + + if (window != nsnull) + window->Show(PR_TRUE); + + return rv; +} + NS_IMETHODIMP nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) {