зеркало из https://github.com/mozilla/pjs.git
New Progress dialog and support code.Fixes bug #7753 (and others) r=dveditz
This commit is contained in:
Родитель
58000ea4b5
Коммит
bb15b852d1
|
@ -35,6 +35,7 @@ XPIDLSRCS = \
|
|||
nsIXPINotifier.idl \
|
||||
nsIXPIProgressDlg.idl \
|
||||
nsPIXPIStubHook.idl \
|
||||
nsPIXPIManagerCallbacks.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 <dbragg@netscape.com>
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#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();
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
xpistatus.xul
|
||||
xpistatus.js
|
||||
progress.xul
|
||||
institems.xul
|
||||
institems.js
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -1,28 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://xpinstall/locale/progress.dtd" >
|
||||
|
||||
<window xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="OnLoad()"
|
||||
title="&downloadWindow.title;"
|
||||
class="dialog"
|
||||
width="425"
|
||||
height="225">
|
||||
|
||||
<html:script language="javascript" src="progress.js"/>
|
||||
|
||||
<data>
|
||||
<broadcaster id="data.canceled" type="string" value="false"/>
|
||||
</data>
|
||||
|
||||
<html:script>
|
||||
|
||||
function cancelInstall()
|
||||
{
|
||||
var cancelData = document.getElementById("data.canceled");
|
||||
cancelData.setAttribute( "value", "true");
|
||||
}
|
||||
|
||||
</html:script>
|
||||
|
||||
<html:center>
|
||||
<html:table style="width:100%;">
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,60 +1,99 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="resource:/res/xpinstall/xpistatus.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://xpinstall/locale/xpistatus.dtd" >
|
||||
|
||||
|
||||
<window xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="onLoad()"
|
||||
title="Items to Install">
|
||||
title="&progress.label;"
|
||||
align = "vertical"
|
||||
class = "dialog"
|
||||
width="350"
|
||||
height="300">
|
||||
|
||||
<html:script language="javascript" src="xpistatus.js">
|
||||
</html:script>
|
||||
|
||||
<box align="vertical" style="height: 30%; width: 50%">
|
||||
|
||||
<box align="horizontal">
|
||||
<box align="horizontal" flex="100%" >
|
||||
<html:div> <html:h3> &dialogTitle.label; </html:h3> </html:div>
|
||||
</box>
|
||||
<spring flex="100%"/>
|
||||
<box align="horizontal">
|
||||
<html:img src="resource:/res/throbber/anims00.gif"/>
|
||||
<html:div> <html:h3> &progress.label; </html:h3> </html:div>
|
||||
</box>
|
||||
<spring flex="80%"/>
|
||||
<!--box align="vertical"-->
|
||||
<!--html:img src="chrome://global/skin/aler-icon.gif"/-->
|
||||
<!--/box-->
|
||||
</box>
|
||||
|
||||
<box align="vertical">
|
||||
<html:div style="height:10px; width:100%"><html:hr/></html:div>
|
||||
<html:div style="height:10px; width:100%">
|
||||
<html:hr/>
|
||||
</html:div>
|
||||
|
||||
<html:div> <html:h5> ¤tlyProcessing.text; </html:h5> </html:div>
|
||||
|
||||
<spring style="height: 1em"/>
|
||||
|
||||
<box align="vertical">
|
||||
<html:div id="table-housing" flex="100%">
|
||||
<tree id="tree">
|
||||
<treecol style="width:55%"/>
|
||||
<treecol style="width:40%"/>
|
||||
|
||||
<treehead>
|
||||
<treerow>
|
||||
<treecell value="&moduleName.label;" />
|
||||
<treecell value="&moduleSource.label;"/>
|
||||
</treerow>
|
||||
</treehead>
|
||||
|
||||
<treechildren id="theTreeBody">
|
||||
</treechildren>
|
||||
</tree>
|
||||
</html:div>
|
||||
</box>
|
||||
|
||||
<spring flex="100%"/>
|
||||
|
||||
<!--Testing
|
||||
<html:table flex="100%">
|
||||
<html:tr>
|
||||
<html:td>
|
||||
-->
|
||||
<html:input id="dialog.uiPackageName" readonly="" style="width:100%" />
|
||||
<!--Testing
|
||||
</html:td>
|
||||
</html:tr>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<html:tr>
|
||||
<html:td>
|
||||
-->
|
||||
<html:input id="dialog.currentAction" readonly="" style="width:100%" />
|
||||
<!--
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:table>
|
||||
-->
|
||||
|
||||
<spring style="height:1em"/>
|
||||
|
||||
<box align="horizontal">
|
||||
<spring style="width:10px"/>
|
||||
<html:div> <html:h5> ¤tlyProcessing.text; </html:h5> </html:div>
|
||||
<spring style="width:2px"/>
|
||||
|
||||
<box align="vertical">
|
||||
<spring style="height:6px"/>
|
||||
<progressmeter id="dialog.progress" mode="undetermined" style="width:200px;height:10px">
|
||||
</progressmeter>
|
||||
</box>
|
||||
|
||||
<spring flex="80%"/>
|
||||
|
||||
<!--box align="horizontal"-->
|
||||
<html:button id="dialog.cancel" onclick="cancel()">&dialogCancel.label;</html:button>
|
||||
<!--/box-->
|
||||
</box>
|
||||
|
||||
<spring style="height:10px"/>
|
||||
|
||||
<box align="horizontal">
|
||||
<spring style="width:10px"/>
|
||||
<html:div> &downloadBeforeUpdate.text; </html:div>
|
||||
</box>
|
||||
|
||||
<spring style="height:20px"></spring>
|
||||
|
||||
<box align="horizontal">
|
||||
<spring style="width:10px"/>
|
||||
<box align="vertical">
|
||||
<spring style="height:6px"/>
|
||||
<progressmeter id="dialog.progress" mode="undetermined" style="width:200px;height:10px">
|
||||
</progressmeter>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<html:button id="dialog.cancel" onclick="cancel()">&dialogCancel.label;</html:button>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
</box>
|
||||
|
||||
</window>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<!ENTITY dialogCancel.label "Cancel">
|
||||
<!ENTITY dialogTitle.label "Downloading">
|
||||
<!ENTITY progress.label "Downloading">
|
||||
<!ENTITY currentlyProcessing.text "Netscape Products">
|
||||
<!ENTITY downloadBeforeUpdate.text "All items will be downloaded before they are updated.">
|
||||
<!ENTITY moduleName.label "Module name">
|
||||
<!ENTITY moduleSource.label "Location">
|
|
@ -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<nsIContentViewer> contentViewer;
|
||||
rv = aWebShell ? aWebShell->GetContentViewer(getter_AddRefs(contentViewer))
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
|
||||
if ( contentViewer ) {
|
||||
// Up-cast to a document viewer.
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer( do_QueryInterface( contentViewer, &rv ) );
|
||||
if ( docViewer ) {
|
||||
// Get the document from the doc viewer.
|
||||
nsCOMPtr<nsIDocument> 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<nsIDOMWindow> 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<nsPIXPIManagerCallbacks> 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<nsIDOMDocument> 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<nsIDOMElement> elem;
|
||||
|
@ -356,6 +299,17 @@ nsresult nsInstallProgressDialog::getDlgAttribute( const char *id,
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mDocument)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> 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<nsIDOMElement> elem;
|
||||
|
|
|
@ -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<nsIDOMXULDocument> mDocument; // why is this owned?
|
||||
nsCOMPtr<nsIWebShellWindow> mWindow; // why is this owned?
|
||||
nsPIXPIManagerCallbacks* mManager;
|
||||
nsCOMPtr<nsIDOMXULDocument> mDocument; // Should this be a weak reference?
|
||||
nsCOMPtr<nsIDOMWindow> mWindow; // Should this be a weak reference?
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -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<nsIDOMWindow> 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<nsIDOMWindow> 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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче