From 4ca0cc54faa2d5c19bd13bf4cf976e2ee07e09bd Mon Sep 17 00:00:00 2001 From: "dbragg@netscape.com" Date: Wed, 8 Dec 1999 00:09:16 +0000 Subject: [PATCH] New Progress dialog and support code.Fixes bug #7753 (and others) r=dveditz --- xpinstall/public/Makefile.in | 1 + xpinstall/public/makefile.win | 9 +- xpinstall/public/nsIXPIProgressDlg.idl | 3 +- xpinstall/public/nsPIXPIManagerCallbacks.idl | 39 +++++ xpinstall/res/content/MANIFEST | 1 - xpinstall/res/content/Makefile.in | 2 - xpinstall/res/content/makefile.win | 4 - xpinstall/res/content/progress.js | 47 +++++ xpinstall/res/content/progress.xul | 14 +- xpinstall/res/content/xpistatus.js | 87 +++++----- xpinstall/res/content/xpistatus.xul | 111 ++++++++---- xpinstall/res/locale/en-US/xpistatus.dtd | 4 +- xpinstall/res/xpistatus.js | 80 --------- xpinstall/res/xpistatus.xul | 66 ------- xpinstall/src/nsInstallProgressDialog.cpp | 170 +++++++------------ xpinstall/src/nsInstallProgressDialog.h | 16 +- xpinstall/src/nsXPInstallManager.cpp | 37 ++-- xpinstall/src/nsXPInstallManager.h | 11 +- 18 files changed, 314 insertions(+), 388 deletions(-) create mode 100644 xpinstall/public/nsPIXPIManagerCallbacks.idl create mode 100644 xpinstall/res/content/progress.js delete mode 100644 xpinstall/res/xpistatus.js delete mode 100644 xpinstall/res/xpistatus.xul diff --git a/xpinstall/public/Makefile.in b/xpinstall/public/Makefile.in index 254797131941..275b4abbc4d8 100644 --- a/xpinstall/public/Makefile.in +++ b/xpinstall/public/Makefile.in @@ -35,6 +35,7 @@ XPIDLSRCS = \ nsIXPINotifier.idl \ nsIXPIProgressDlg.idl \ nsPIXPIStubHook.idl \ + nsPIXPIManagerCallbacks.idl \ $(NULL) EXPORTS = \ diff --git a/xpinstall/public/makefile.win b/xpinstall/public/makefile.win index edd9cf3d472c..101ac7357e46 100644 --- a/xpinstall/public/makefile.win +++ b/xpinstall/public/makefile.win @@ -31,10 +31,11 @@ EXPORTS= nsIDOMInstallTriggerGlobal.h \ nsISoftwareUpdate.h \ $(NULL) -XPIDLSRCS = \ - .\nsIXPINotifier.idl \ - .\nsIXPIProgressDlg.idl \ - .\nsPIXPIStubHook.idl \ +XPIDLSRCS = \ + .\nsIXPINotifier.idl \ + .\nsIXPIProgressDlg.idl \ + .\nsPIXPIStubHook.idl \ + .\nsPIXPIManagerCallbacks.idl \ $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/xpinstall/public/nsIXPIProgressDlg.idl b/xpinstall/public/nsIXPIProgressDlg.idl index c97f36be4bae..b0a2d736bac4 100644 --- a/xpinstall/public/nsIXPIProgressDlg.idl +++ b/xpinstall/public/nsIXPIProgressDlg.idl @@ -24,11 +24,12 @@ */ #include "nsISupports.idl" +#include "nsIDialogParamBlock.idl" [scriptable, uuid(597140A0-1C1D-11d3-8E10-914233F46847)] interface nsIXPIProgressDlg : nsISupports { - void Open(); + void Open(in nsIDialogParamBlock ioParamBlock); void Close(); void SetTitle( in wstring aTitle ); diff --git a/xpinstall/public/nsPIXPIManagerCallbacks.idl b/xpinstall/public/nsPIXPIManagerCallbacks.idl new file mode 100644 index 000000000000..a68cfe7dd2d7 --- /dev/null +++ b/xpinstall/public/nsPIXPIManagerCallbacks.idl @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Don Bragg + * Samir Gehani + */ + +#include "nsISupports.idl" + +/** + * nsPIXPIManagerCallbacks + * + * Private interface to allow the XPInstall XUL progress dialog to talk + * to the native progress dialog implementation. + */ +[scriptable, uuid(d63ed30a-a858-11d3-a446-0060b0eb5963)] +interface nsPIXPIManagerCallbacks: nsISupports +{ + void DialogOpened(in nsISupports aWindow); + void DownloadNext(); + void CancelInstall(); +}; diff --git a/xpinstall/res/content/MANIFEST b/xpinstall/res/content/MANIFEST index 3786eb8aeb14..8bd87b951acf 100644 --- a/xpinstall/res/content/MANIFEST +++ b/xpinstall/res/content/MANIFEST @@ -1,5 +1,4 @@ xpistatus.xul xpistatus.js -progress.xul institems.xul institems.js diff --git a/xpinstall/res/content/Makefile.in b/xpinstall/res/content/Makefile.in index d740aecfacf3..5e75af82199f 100644 --- a/xpinstall/res/content/Makefile.in +++ b/xpinstall/res/content/Makefile.in @@ -27,8 +27,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk EXPORT_RESOURCE_XPINSTALL = \ - $(srcdir)/progress.xul \ - $(srcdir)/progress.html \ $(srcdir)/xpistatus.xul \ $(srcdir)/xpistatus.js \ $(srcdir)/institems.xul \ diff --git a/xpinstall/res/content/makefile.win b/xpinstall/res/content/makefile.win index 9d8c7e49f9a4..28bba3c302cf 100644 --- a/xpinstall/res/content/makefile.win +++ b/xpinstall/res/content/makefile.win @@ -25,8 +25,6 @@ DEPTH=..\..\.. include <$(DEPTH)\config\rules.mak> install:: $(DLL) - $(MAKE_INSTALL) progress.xul $(DIST)\bin\chrome\xpinstall\content\default - $(MAKE_INSTALL) progress.html $(DIST)\bin\chrome\xpinstall\content\default $(MAKE_INSTALL) xpistatus.xul $(DIST)\bin\chrome\xpinstall\content\default $(MAKE_INSTALL) xpistatus.js $(DIST)\bin\chrome\xpinstall\content\default $(MAKE_INSTALL) institems.xul $(DIST)\bin\chrome\xpinstall\content\default @@ -34,8 +32,6 @@ install:: $(DLL) clobber:: - rm -f $(DIST)\bin\chrome\xpinstall\content\default\progress.xul - rm -f $(DIST)\bin\chrome\xpinstall\content\default\progress.html rm -f $(DIST)\bin\chrome\xpinstall\content\default\xpistatus.xul rm -f $(DIST)\bin\chrome\xpinstall\content\default\xpistatus.js rm -f $(DIST)\bin\chrome\xpinstall\content\default\institems.xul diff --git a/xpinstall/res/content/progress.js b/xpinstall/res/content/progress.js new file mode 100644 index 000000000000..9032e859b0e2 --- /dev/null +++ b/xpinstall/res/content/progress.js @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +var manager; +var param; +var rval; + +function OnLoad() +{ + dump("In OnLoad \n"); + param = window.arguments[0].QueryInterface( Components.interfaces.nsIDialogParamBlock ); + dump("After ParmBlock QI \n"); + dump( window.arguments ); + if ( window.arguments.length > 1) + { + manager = window.arguments[1]; + dump("After creation of manager \n"); + dump("manager = " + manager + "\n"); + manager.DialogOpened(window); + dump("After call to DialogOpened \n"); + } +} + +function onCancel() +{ + if (manager) + manager.CancelInstall(); + + window.close(); +} \ No newline at end of file diff --git a/xpinstall/res/content/progress.xul b/xpinstall/res/content/progress.xul index a7e194bbe4ad..acf536a0f37f 100644 --- a/xpinstall/res/content/progress.xul +++ b/xpinstall/res/content/progress.xul @@ -1,28 +1,22 @@ - + + + - - - function cancelInstall() - { - var cancelData = document.getElementById("data.canceled"); - cancelData.setAttribute( "value", "true"); - } - - diff --git a/xpinstall/res/content/xpistatus.js b/xpinstall/res/content/xpistatus.js index 23c3692294ea..374602541e1f 100644 --- a/xpinstall/res/content/xpistatus.js +++ b/xpinstall/res/content/xpistatus.js @@ -23,58 +23,59 @@ var browser; var dialog; +var param; +var manager; -function onLoad() { - dialog = new Object; - //dialog.title = document.getElementByID( "xpi.process" ); - //dialog.current = document.getElementByID( "xpi.currentlyprocessing"); - dialog.newWindow = document.getElementById( "dialog.newWindow" ); +function onLoad() +{ + var i = 0; + var row = 0; + var moduleName; + var URL; - browser = XPAppCoresManager.Find( window.arguments[0] ); - if ( !browser ) { - dump( "unable to get browser app core\n" ); - window.close(); + param = window.arguments[0].QueryInterface( Components.interfaces.nsIDialogParamBlock ); + if ( !param ) + { + dump (" error getting param block interface \n"); } - + manager = window.arguments[1]; + + while (moduleName != "") + { + moduleName = param.GetString(i++); + URL = param.GetString(i++); + addTreeItem(row++, moduleName, URL); + } + manager.DialogOpened(window); } -function onTyping( key ) { - // Look for enter key... - if ( key == 13 ) { - // If ok button not disabled, go for it. - if ( !dialog.ok.disabled ) { - open(); - } - } else { - // Check for valid input. - if ( dialog.input.value == "" ) { - // No input, disable ok button if enabled. - if ( !dialog.ok.disabled ) { - dialog.ok.setAttribute( "disabled", "" ); - } - } else { - // Input, enable ok button if disabled. - if ( dialog.ok.disabled ) { - dialog.ok.removeAttribute( "disabled" ); - } - } - } +function addTreeItem(num, modName, url) +{ + dump("Adding element " + num + " : " + name + "\n"); + var body = document.getElementById("theTreeBody"); + + var newitem = document.createElement('treeitem'); + var newrow = document.createElement('treerow'); + + newrow.setAttribute("rowNum", num); + newrow.setAttribute("rowName", modName); + + var elem = document.createElement('treecell'); + elem.setAttribute("value", modName); + newrow.appendChild(elem); + + var elem = document.createElement('treecell'); + elem.setAttribute("value", url); + newrow.appendChild(elem); + + newitem.appendChild(newrow); + body.appendChild(newitem); } -function open() { - if ( dialog.ok.disabled ) { - return; - } - var url = dialog.input.value; - browser.loadUrl( url ); - - /* Close dialog. */ - window.close(); -} - -function cancel() { +function cancel() +{ window.close(); } diff --git a/xpinstall/res/content/xpistatus.xul b/xpinstall/res/content/xpistatus.xul index fead56a238e4..beeb5de138b7 100644 --- a/xpinstall/res/content/xpistatus.xul +++ b/xpinstall/res/content/xpistatus.xul @@ -1,60 +1,99 @@ - - + + title="&progress.label;" + align = "vertical" + class = "dialog" + width="350" + height="300"> - - - &dialogTitle.label; - - - - + &progress.label; + + + + - - + + + + + ¤tlyProcessing.text; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - ¤tlyProcessing.text; + + + + + + + + + + + + &dialogCancel.label; + - - - - - &downloadBeforeUpdate.text; - - - - - - - - - - - - - &dialogCancel.label; - - - - diff --git a/xpinstall/res/locale/en-US/xpistatus.dtd b/xpinstall/res/locale/en-US/xpistatus.dtd index 994773e7cd71..638a6e160e9d 100644 --- a/xpinstall/res/locale/en-US/xpistatus.dtd +++ b/xpinstall/res/locale/en-US/xpistatus.dtd @@ -1,4 +1,6 @@ - + + + \ No newline at end of file diff --git a/xpinstall/res/xpistatus.js b/xpinstall/res/xpistatus.js deleted file mode 100644 index 23c3692294ea..000000000000 --- a/xpinstall/res/xpistatus.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code, released March - * 31, 1998. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -var browser; -var dialog; - -function onLoad() { - dialog = new Object; - //dialog.title = document.getElementByID( "xpi.process" ); - //dialog.current = document.getElementByID( "xpi.currentlyprocessing"); - dialog.newWindow = document.getElementById( "dialog.newWindow" ); - - browser = XPAppCoresManager.Find( window.arguments[0] ); - if ( !browser ) { - dump( "unable to get browser app core\n" ); - window.close(); - } - -} - -function onTyping( key ) { - // Look for enter key... - if ( key == 13 ) { - // If ok button not disabled, go for it. - if ( !dialog.ok.disabled ) { - open(); - } - } else { - // Check for valid input. - if ( dialog.input.value == "" ) { - // No input, disable ok button if enabled. - if ( !dialog.ok.disabled ) { - dialog.ok.setAttribute( "disabled", "" ); - } - } else { - // Input, enable ok button if disabled. - if ( dialog.ok.disabled ) { - dialog.ok.removeAttribute( "disabled" ); - } - } - } -} - -function open() { - if ( dialog.ok.disabled ) { - return; - } - - var url = dialog.input.value; - - browser.loadUrl( url ); - - /* Close dialog. */ - window.close(); -} - -function cancel() { - window.close(); -} - diff --git a/xpinstall/res/xpistatus.xul b/xpinstall/res/xpistatus.xul deleted file mode 100644 index 7f3914e4b7ee..000000000000 --- a/xpinstall/res/xpistatus.xul +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - -] -> - - - - - - - - - - - - &dialogTitle.label; - - - - - - - - - - - - - - ¤tlyProcessing.text; - - - - - - - &downloadBeforeUpdate.text; - - - - - - - - - - - - - &dialogCancel.label; - - - - - - diff --git a/xpinstall/src/nsInstallProgressDialog.cpp b/xpinstall/src/nsInstallProgressDialog.cpp index 1c89520f0c9a..7e556e171460 100644 --- a/xpinstall/src/nsInstallProgressDialog.cpp +++ b/xpinstall/src/nsInstallProgressDialog.cpp @@ -28,7 +28,9 @@ #include "nsIAppShellComponentImpl.h" + #include "nsIBrowserWindow.h" +#include "nsIDOMWindow.h" #include "nsIServiceManager.h" #include "nsIDocumentViewer.h" #include "nsIContent.h" @@ -39,12 +41,17 @@ #include "nsIURL.h" #include "nsIWebShell.h" #include "nsIWebShellWindow.h" +#include "nsICommonDialogs.h" +#include "nsPIXPIManagerCallbacks.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID( kAppShellServiceCID, NS_APPSHELL_SERVICE_CID ); -nsInstallProgressDialog::nsInstallProgressDialog(nsIXULWindowCallbacks* aManager) - : mManager(aManager) +static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID); +static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID); + +nsInstallProgressDialog::nsInstallProgressDialog(nsPIXPIManagerCallbacks *aManager) + : mManager(aManager) { NS_INIT_REFCNT(); } @@ -77,11 +84,6 @@ nsInstallProgressDialog::QueryInterface(REFNSIID aIID,void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(nsIXULWindowCallbacks::GetIID())) { - *aInstancePtr = (void*) ((nsIXULWindowCallbacks*)this); - NS_ADDREF_THIS(); - return NS_OK; - } if (aIID.Equals(kISupportsIID)) { *aInstancePtr = (void*) (nsISupports*)((nsIXPINotifier*)this); NS_ADDREF_THIS(); @@ -141,125 +143,55 @@ nsInstallProgressDialog::LogComment(const PRUnichar* comment) } -// Do startup stuff from C++ side. + NS_IMETHODIMP -nsInstallProgressDialog::ConstructBeforeJavaScript(nsIWebShell *aWebShell) +nsInstallProgressDialog::Open(nsIDialogParamBlock* ioParamBlock) { nsresult rv = NS_OK; - - // Get content viewer from the web shell. - nsCOMPtr contentViewer; - rv = aWebShell ? aWebShell->GetContentViewer(getter_AddRefs(contentViewer)) - : NS_ERROR_NULL_POINTER; - - if ( contentViewer ) { - // Up-cast to a document viewer. - nsCOMPtr docViewer( do_QueryInterface( contentViewer, &rv ) ); - if ( docViewer ) { - // Get the document from the doc viewer. - nsCOMPtr document; - rv = docViewer->GetDocument(*getter_AddRefs(document)); - if ( document ) { - // Upcast to XUL document. - mDocument = do_QueryInterface( document, &rv ); - if ( ! mDocument ) - { - DEBUG_PRINTF( PR_STDOUT, "%s %d: Upcast to nsIDOMXULDocument failed, rv=0x%X\n", - __FILE__, (int)__LINE__, (int)rv ); - } - } - else - { - DEBUG_PRINTF( PR_STDOUT, "%s %d: GetDocument failed, rv=0x%X\n", - __FILE__, (int)__LINE__, (int)rv ); - } - } - else - { - DEBUG_PRINTF( PR_STDOUT, "%s %d: Upcast to nsIDocumentViewer failed, rv=0x%X\n", - __FILE__, (int)__LINE__, (int)rv ); - } - } - else - { - DEBUG_PRINTF( PR_STDOUT, "%s %d: GetContentViewer failed, rv=0x%X\n", - __FILE__, (int)__LINE__, (int)rv ); - } - - if (mManager) - mManager->ConstructBeforeJavaScript(aWebShell); - - return rv; -} - - -NS_IMETHODIMP -nsInstallProgressDialog::ConstructAfterJavaScript(nsIWebShell *aWebShell) -{ - if (mManager) - return mManager->ConstructAfterJavaScript(aWebShell); - else - return NS_OK; -} - - - -NS_IMETHODIMP -nsInstallProgressDialog::Open() -{ - nsresult rv = NS_OK; - - // Get app shell service. + + // Now do the stuff to create a window and pass the JS args to it. NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv ); - if ( NS_SUCCEEDED( rv ) ) { - // Open "progress" dialog. - nsIURI *url; - char * urlStr = "chrome://xpinstall/content/progress.xul"; - rv = NS_NewURI( &url, urlStr ); - - if ( NS_SUCCEEDED(rv) ) + nsCOMPtr hiddenWindow; + JSContext* jsContext; + rv = appShell->GetHiddenWindowAndJSContext( getter_AddRefs(hiddenWindow), &jsContext); + if (NS_SUCCEEDED(rv)) { - rv = appShell->CreateTopLevelWindow( nsnull, - url, - PR_TRUE, - PR_TRUE, - NS_CHROME_ALL_CHROME, - this, // callbacks?? - 0, - 0, - getter_AddRefs(mWindow)); + nsCOMPtr mgr = do_QueryInterface(mManager); - if ( NS_SUCCEEDED( rv ) ) + void* stackPtr; + jsval *argv = JS_PushArguments( jsContext, + &stackPtr, + "sss%ip%ip", + "chrome://xpinstall/content/xpistatus.xul", + "_blank", + "chrome", + (const nsIID*)&nsIDialogParamBlock::GetIID(), + (nsISupports*)ioParamBlock, + (const nsIID*)&nsPIXPIManagerCallbacks::GetIID(), + (nsISupports*)mgr + ); + if (argv) { - if ( mWindow ) - mWindow->Show(PR_TRUE); - else - rv = NS_ERROR_NULL_POINTER; + rv = hiddenWindow->OpenDialog( jsContext, + argv, + 5, + getter_AddRefs( mWindow )); } - else - { - DEBUG_PRINTF( PR_STDOUT, "Error creating progress dialog, rv=0x%X\n", (int)rv ); - } - NS_RELEASE( url ); + + JS_PopArguments( jsContext, stackPtr); } - } - else - { - DEBUG_PRINTF( PR_STDOUT, "Unable to get app shell service, rv=0x%X\n", (int)rv ); + } - return rv; } + NS_IMETHODIMP nsInstallProgressDialog::Close() { - if (mWindow) - { - mWindow->Close(); - } + mWindow->Close(); return NS_OK; } @@ -327,6 +259,17 @@ nsresult nsInstallProgressDialog::setDlgAttribute( const char *id, { nsresult rv = NS_OK; + if (!mDocument) + { + nsCOMPtr doc; + rv = mWindow->GetDocument( getter_AddRefs(doc) ); + if (NS_SUCCEEDED(rv)) + { + mDocument = do_QueryInterface(doc,&rv); + } + NS_WARN_IF_FALSE(rv == NS_OK,"couldn't get nsIDOMXULDocument from nsXPIProgressDlg"); + } + if ( mDocument ) { // Find specified element. nsCOMPtr elem; @@ -356,6 +299,17 @@ nsresult nsInstallProgressDialog::getDlgAttribute( const char *id, { nsresult rv = NS_OK; + if (!mDocument) + { + nsCOMPtr doc; + rv = mWindow->GetDocument( getter_AddRefs(doc) ); + if (NS_SUCCEEDED(rv)) + { + mDocument = do_QueryInterface(doc,&rv); + } + NS_WARN_IF_FALSE(rv == NS_OK,"couldn't get nsIDOMXULDocument from nsXPIProgressDlg"); + } + if ( mDocument ) { // Find specified element. nsCOMPtr elem; diff --git a/xpinstall/src/nsInstallProgressDialog.h b/xpinstall/src/nsInstallProgressDialog.h index 1360e6be065e..81c6d81da548 100644 --- a/xpinstall/src/nsInstallProgressDialog.h +++ b/xpinstall/src/nsInstallProgressDialog.h @@ -34,19 +34,19 @@ #include "nsIWebShell.h" #include "nsIWebShellWindow.h" -#include "nsIXULWindowCallbacks.h" +#include "nsPIXPIManagerCallbacks.h" #include "nsIDocument.h" +#include "nsIDOMDocument.h" #include "nsIDOMXULDocument.h" class nsInstallProgressDialog : public nsIXPINotifier, - public nsIXULWindowCallbacks, public nsIXPIProgressDlg { public: - nsInstallProgressDialog(nsIXULWindowCallbacks* aManager); + nsInstallProgressDialog(nsPIXPIManagerCallbacks *aManager); virtual ~nsInstallProgressDialog(); NS_DECL_ISUPPORTS @@ -57,17 +57,15 @@ class nsInstallProgressDialog : public nsIXPINotifier, // implement nsIXPIProgressDlg NS_DECL_NSIXPIPROGRESSDLG - // Declare implementations of nsIXULWindowCallbacks interface functions. - NS_IMETHOD ConstructBeforeJavaScript(nsIWebShell *aWebShell); - NS_IMETHOD ConstructAfterJavaScript(nsIWebShell *aWebShell); +// void SetWindow(nsISupports* aWindow); protected: nsresult setDlgAttribute(const char *id, const char *name, const nsString &value); nsresult getDlgAttribute(const char *id, const char *name, nsString &value); private: - nsIXULWindowCallbacks* mManager; - nsCOMPtr mDocument; // why is this owned? - nsCOMPtr mWindow; // why is this owned? + nsPIXPIManagerCallbacks* mManager; + nsCOMPtr mDocument; // Should this be a weak reference? + nsCOMPtr mWindow; // Should this be a weak reference? }; #endif diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index f9035b373d5e..c7031a95beec 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -108,8 +108,8 @@ nsXPInstallManager::QueryInterface(REFNSIID aIID,void** aInstancePtr) *aInstancePtr = NS_STATIC_CAST(nsIXPINotifier*,this); else if (aIID.Equals(nsIStreamListener::GetIID())) *aInstancePtr = NS_STATIC_CAST(nsIStreamListener*,this); - else if (aIID.Equals(nsIXULWindowCallbacks::GetIID())) - *aInstancePtr = NS_STATIC_CAST(nsIXULWindowCallbacks*,this); + else if (aIID.Equals(nsPIXPIManagerCallbacks::GetIID())) + *aInstancePtr = NS_STATIC_CAST(nsPIXPIManagerCallbacks*,this); else if (aIID.Equals(nsIProgressEventSink::GetIID())) *aInstancePtr = NS_STATIC_CAST(nsIProgressEventSink*,this); else if (aIID.Equals(nsIInterfaceRequestor::GetIID())) @@ -182,6 +182,7 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers) "chrome,modal", (const nsIID*)(&nsIDialogParamBlock::GetIID()), (nsISupports*)ioParamBlock); + if (argv) { nsCOMPtr newWindow; @@ -231,7 +232,7 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers) if (NS_SUCCEEDED(rv)) { - rv = mDlg->Open(); + rv = mDlg->Open(ioParamBlock); } } } @@ -261,8 +262,16 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers) return rv; } +NS_IMETHODIMP nsXPInstallManager::DialogOpened(nsISupports* aWindow) +{ + nsresult rv; + nsCOMPtr win = do_QueryInterface(aWindow, &rv); + DownloadNext(); + return rv; +} -nsresult nsXPInstallManager::DownloadNext() + +NS_IMETHODIMP nsXPInstallManager::DownloadNext() { nsresult rv; if ( mNextItem < mTriggers->Size() ) @@ -382,6 +391,13 @@ nsresult nsXPInstallManager::DownloadNext() return rv; } +NS_IMETHODIMP +nsXPInstallManager::CancelInstall() +{ + nsresult rv = NS_OK; + return rv; +} + void nsXPInstallManager::Shutdown() { if (mProxy) @@ -621,16 +637,3 @@ nsXPInstallManager::LogComment(const PRUnichar* comment) return NS_OK; } -// nsIXULWindowCallbacks - -NS_IMETHODIMP -nsXPInstallManager::ConstructBeforeJavaScript(nsIWebShell *aWebShell) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsXPInstallManager::ConstructAfterJavaScript(nsIWebShell *aWebShell) -{ - return DownloadNext(); -} diff --git a/xpinstall/src/nsXPInstallManager.h b/xpinstall/src/nsXPInstallManager.h index f1233a9fcbb6..3a63b10f7759 100644 --- a/xpinstall/src/nsXPInstallManager.h +++ b/xpinstall/src/nsXPInstallManager.h @@ -44,9 +44,9 @@ #include "nsIWebShell.h" #include "nsIWebShellWindow.h" -#include "nsIXULWindowCallbacks.h" #include "nsIProgressEventSink.h" #include "nsIInterfaceRequestor.h" +#include "nsPIXPIManagerCallbacks.h" #include "nsIDialogParamBlock.h" @@ -55,7 +55,7 @@ class nsXPInstallManager : public nsIXPINotifier, public nsIStreamListener, public nsIProgressEventSink, public nsIInterfaceRequestor, - public nsIXULWindowCallbacks + public nsPIXPIManagerCallbacks { public: nsXPInstallManager(); @@ -80,12 +80,11 @@ class nsXPInstallManager : public nsIXPINotifier, // nsIInterfaceRequestor NS_DECL_NSIINTERFACEREQUESTOR - // IXULWindowCallbacks methods - NS_IMETHOD ConstructBeforeJavaScript(nsIWebShell *aWebShell); - NS_IMETHOD ConstructAfterJavaScript(nsIWebShell *aWebShell); + //nsPIXPIMANAGERCALLBACKS + NS_DECL_NSPIXPIMANAGERCALLBACKS + private: - nsresult DownloadNext(); void Shutdown(); void LoadDialogWithNames(nsIDialogParamBlock* ioParamBlock);