From 6494975f047f3594630010db777700afa2f8f7e8 Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Wed, 11 Feb 2004 03:46:30 +0000 Subject: [PATCH] 227796 - XPInstall InstallTrigger API changes - add a parameter to the install js object that supports an icon, also make the install FE parameterizable via a pref. r=bsmedberg, dveditz. 230768 - add the ability to make a window flash only a certain number of times in the taskbar. dom stuff r/sr=jst, widget changes r=danm, sr=bryner git-svn-id: svn://10.0.0.236/trunk@152640 18797224-902f-48f8-a5cc-f745e15eee43 --- .../public/idl/base/nsIDOMChromeWindow.idl | 2 + mozilla/dom/src/base/nsGlobalWindow.cpp | 8 ++- mozilla/widget/public/nsIWidget.h | 5 +- mozilla/widget/src/cocoa/nsChildView.h | 2 +- mozilla/widget/src/cocoa/nsChildView.mm | 2 +- mozilla/widget/src/gtk/nsWindow.cpp | 4 +- mozilla/widget/src/gtk/nsWindow.h | 2 +- mozilla/widget/src/gtk2/nsWindow.cpp | 4 +- mozilla/widget/src/gtk2/nsWindow.h | 2 +- mozilla/widget/src/mac/nsWindow.cpp | 2 +- mozilla/widget/src/mac/nsWindow.h | 2 +- mozilla/widget/src/photon/nsWindow.h | 2 +- mozilla/widget/src/windows/nsWindow.cpp | 43 ++++++++++++-- mozilla/widget/src/windows/nsWindow.h | 2 +- mozilla/widget/src/xlib/nsWindow.cpp | 2 +- mozilla/widget/src/xlib/nsWindow.h | 2 +- mozilla/widget/src/xpwidgets/nsBaseWidget.cpp | 2 +- mozilla/widget/src/xpwidgets/nsBaseWidget.h | 2 +- mozilla/xpfe/bootstrap/browser-prefs.js | 3 + mozilla/xpinstall/res/content/institems.js | 3 +- mozilla/xpinstall/res/content/xpistatus.js | 1 + mozilla/xpinstall/src/Makefile.in | 1 + mozilla/xpinstall/src/nsInstallTrigger.cpp | 2 +- .../src/nsJSInstallTriggerGlobal.cpp | 19 +++++- mozilla/xpinstall/src/nsXPITriggerInfo.cpp | 3 +- mozilla/xpinstall/src/nsXPITriggerInfo.h | 3 +- mozilla/xpinstall/src/nsXPInstallManager.cpp | 58 +++++++++++++++++-- 27 files changed, 151 insertions(+), 32 deletions(-) diff --git a/mozilla/dom/public/idl/base/nsIDOMChromeWindow.idl b/mozilla/dom/public/idl/base/nsIDOMChromeWindow.idl index 1f5a6170e39..7e301da750d 100644 --- a/mozilla/dom/public/idl/base/nsIDOMChromeWindow.idl +++ b/mozilla/dom/public/idl/base/nsIDOMChromeWindow.idl @@ -51,6 +51,8 @@ interface nsIDOMChromeWindow : nsISupports void getAttention(); + void getAttentionWithCycleCount(in long aCycleCount); + void setCursor(in DOMString cursor); void maximize(); diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 843bea89a67..51f20b4735a 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -5759,12 +5759,18 @@ nsGlobalChromeWindow::Restore() NS_IMETHODIMP nsGlobalChromeWindow::GetAttention() +{ + return GetAttentionWithCycleCount(-1); +} + +NS_IMETHODIMP +nsGlobalChromeWindow::GetAttentionWithCycleCount(PRInt32 aCycleCount) { nsCOMPtr widget; nsresult rv = GetMainWidget(getter_AddRefs(widget)); if (widget) { - rv = widget->GetAttention(); + rv = widget->GetAttention(aCycleCount); } return rv; diff --git a/mozilla/widget/public/nsIWidget.h b/mozilla/widget/public/nsIWidget.h index 777a1ea26c0..8cb7a001d04 100644 --- a/mozilla/widget/public/nsIWidget.h +++ b/mozilla/widget/public/nsIWidget.h @@ -958,8 +958,11 @@ class nsIWidget : public nsISupports { * the Mac. The notification should be suppressed if the window is already * in the foreground and should be dismissed when the user brings this window * to the foreground. + * @param aCycleCount Maximum number of times to animate the window per system + * conventions. If set to -1, cycles indefinitely until + * window is brought into the foreground. */ - NS_IMETHOD GetAttention() = 0; + NS_IMETHOD GetAttention(PRInt32 aCycleCount) = 0; /** * Get the last user input event time in milliseconds. If there are any pending diff --git a/mozilla/widget/src/cocoa/nsChildView.h b/mozilla/widget/src/cocoa/nsChildView.h index 6cc9bc9101b..c6f88cf654f 100644 --- a/mozilla/widget/src/cocoa/nsChildView.h +++ b/mozilla/widget/src/cocoa/nsChildView.h @@ -216,7 +216,7 @@ public: NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); NS_IMETHOD SetTitle(const nsString& title); - NS_IMETHOD GetAttention(); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); // nsIPluginWidget NS_IMETHOD GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible); diff --git a/mozilla/widget/src/cocoa/nsChildView.mm b/mozilla/widget/src/cocoa/nsChildView.mm index 4c760f8bf6b..6543d06ab3e 100644 --- a/mozilla/widget/src/cocoa/nsChildView.mm +++ b/mozilla/widget/src/cocoa/nsChildView.mm @@ -2027,7 +2027,7 @@ NS_IMETHODIMP nsChildView::SetTitle(const nsString& title) } -NS_IMETHODIMP nsChildView::GetAttention() +NS_IMETHODIMP nsChildView::GetAttention(PRInt32 aCycleCount) { // Since the Mac doesn't consider each window a separate process this call functions // slightly different than on other platforms. We first check to see if we're the diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index 298ab337f3c..a376aa7bb19 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -1320,7 +1320,7 @@ nsWindow::SetFocus(PRBool aRaise) // toplevel window has focus if (gRaiseWindows && aRaise && toplevel && top_mozarea && (!GTK_WIDGET_HAS_FOCUS(top_mozarea) && !GTK_WIDGET_HAS_FOCUS(toplevel))) - GetAttention(); + GetAttention(-1); #ifdef DEBUG_FOCUS printf("top moz area is %p\n", NS_STATIC_CAST(void *, top_mozarea)); @@ -2830,7 +2830,7 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, return NS_OK; } -NS_IMETHODIMP nsWindow::GetAttention(void) +NS_IMETHODIMP nsWindow::GetAttention(PRInt32 aCycleCount) { // get the next up moz area GtkWidget *top_mozarea = GetOwningWidget(); diff --git a/mozilla/widget/src/gtk/nsWindow.h b/mozilla/widget/src/gtk/nsWindow.h index b51bc80b8ee..c2fbef74962 100644 --- a/mozilla/widget/src/gtk/nsWindow.h +++ b/mozilla/widget/src/gtk/nsWindow.h @@ -113,7 +113,7 @@ public: NS_IMETHOD Enable (PRBool aState); NS_IMETHOD IsEnabled (PRBool *aState); NS_IMETHOD SetFocus(PRBool aRaise); - NS_IMETHOD GetAttention(void); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD Destroy(); void ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight); void ApplyTransparencyBitmap(); diff --git a/mozilla/widget/src/gtk2/nsWindow.cpp b/mozilla/widget/src/gtk2/nsWindow.cpp index a646f1d69a7..1b996ff9150 100644 --- a/mozilla/widget/src/gtk2/nsWindow.cpp +++ b/mozilla/widget/src/gtk2/nsWindow.cpp @@ -577,7 +577,7 @@ nsWindow::SetFocus(PRBool aRaise) if (gRaiseWindows && aRaise && toplevelWidget && !GTK_WIDGET_HAS_FOCUS(owningWidget) && !GTK_WIDGET_HAS_FOCUS(toplevelWidget)) - GetAttention(); + GetAttention(-1); nsWindow *owningWindow = get_window_for_gtk_widget(owningWidget); if (!owningWindow) @@ -1125,7 +1125,7 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener, } NS_IMETHODIMP -nsWindow::GetAttention() +nsWindow::GetAttention(PRInt32 aCycleCount) { LOG(("nsWindow::GetAttention [%p]\n", (void *)this)); diff --git a/mozilla/widget/src/gtk2/nsWindow.h b/mozilla/widget/src/gtk2/nsWindow.h index c2370c5d320..057120035a3 100644 --- a/mozilla/widget/src/gtk2/nsWindow.h +++ b/mozilla/widget/src/gtk2/nsWindow.h @@ -142,7 +142,7 @@ public: NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); - NS_IMETHOD GetAttention(); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD HideWindowChrome(PRBool aShouldHide); // utility methods diff --git a/mozilla/widget/src/mac/nsWindow.cpp b/mozilla/widget/src/mac/nsWindow.cpp index 848e462c063..ce6a33c4815 100644 --- a/mozilla/widget/src/mac/nsWindow.cpp +++ b/mozilla/widget/src/mac/nsWindow.cpp @@ -2516,7 +2516,7 @@ NS_IMETHODIMP nsWindow::SetTitle(const nsString& title) return NS_OK; } -NS_IMETHODIMP nsWindow::GetAttention() +NS_IMETHODIMP nsWindow::GetAttention(PRInt32 aCycleCount) { // Since the Mac doesn't consider each window a separate process this call functions // slightly different than on other platforms. We first check to see if we're the diff --git a/mozilla/widget/src/mac/nsWindow.h b/mozilla/widget/src/mac/nsWindow.h index 35cde052a9e..04e573fea40 100644 --- a/mozilla/widget/src/mac/nsWindow.h +++ b/mozilla/widget/src/mac/nsWindow.h @@ -200,7 +200,7 @@ public: NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); NS_IMETHOD SetTitle(const nsString& title); - NS_IMETHOD GetAttention(); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); // Mac specific methods static void nsRectToMacRect(const nsRect& aRect, Rect& aMacRect); diff --git a/mozilla/widget/src/photon/nsWindow.h b/mozilla/widget/src/photon/nsWindow.h index fb3f4c1351c..87587593f7b 100644 --- a/mozilla/widget/src/photon/nsWindow.h +++ b/mozilla/widget/src/photon/nsWindow.h @@ -97,7 +97,7 @@ public: PRBool aDoCapture, PRBool aConsumeRollupEvent); - inline NS_IMETHOD GetAttention(void) + inline NS_IMETHOD GetAttention(PRInt32 aCycleCount) { if( mWidget ) PtWindowToFront( mWidget ); return NS_OK; diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index 2cada42e3b1..8b03daf6651 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -553,7 +553,7 @@ public: delete current; } } - void AddTimer(HWND timerWindow, HWND flashWindow, UINT timerID) { + void AddTimer(HWND timerWindow, HWND flashWindow, PRInt32 maxFlashCount, UINT timerID) { TimerInfo *info; PRBool newInfo = PR_FALSE; info = FindInfo(timerWindow); @@ -564,6 +564,8 @@ public: if (info) { info->timerWindow = timerWindow; info->flashWindow = flashWindow; + info->maxFlashCount = maxFlashCount; + info->flashCount = 0; info->timerID = timerID; info->hasFlashed = PR_FALSE; info->next = 0; @@ -575,6 +577,18 @@ public: TimerInfo *info = FindInfo(timerWindow); return info ? info->flashWindow : 0; } + PRInt32 GetMaxFlashCount(HWND timerWindow) { + TimerInfo *info = FindInfo(timerWindow); + return info ? info->maxFlashCount : -1; + } + PRInt32 GetFlashCount(HWND timerWindow) { + TimerInfo *info = FindInfo(timerWindow); + return info ? info->flashCount : -1; + } + void IncrementFlashCount(HWND timerWindow) { + TimerInfo *info = FindInfo(timerWindow); + ++(info->flashCount); + } void KillTimer(HWND timerWindow) { TimerInfo *info = FindInfo(timerWindow); if (info) { @@ -597,6 +611,8 @@ private: HWND timerWindow, flashWindow; UINT timerID; + PRInt32 maxFlashCount; + PRInt32 flashCount; PRBool hasFlashed; TimerInfo *next; }; @@ -6696,7 +6712,22 @@ static VOID CALLBACK nsGetAttentionTimerFunc(HWND hwnd, UINT uMsg, UINT idEvent, // flash the outermost owner HWND flashwnd = gAttentionTimerMonitor->GetFlashWindowFor(hwnd); - ::FlashWindow(flashwnd, TRUE); + PRInt32 maxFlashCount = gAttentionTimerMonitor->GetMaxFlashCount(hwnd); + PRInt32 flashCount = gAttentionTimerMonitor->GetFlashCount(hwnd); + if (maxFlashCount > 0) { + // We have a max flash count, if we haven't met it yet, flash again. + if (flashCount < maxFlashCount) { + ::FlashWindow(flashwnd, TRUE); + gAttentionTimerMonitor->IncrementFlashCount(hwnd); + } + else + gAttentionTimerMonitor->KillTimer(hwnd); + } + else { + // The caller didn't specify a flash count. + ::FlashWindow(flashwnd, TRUE); + } + gAttentionTimerMonitor->SetFlashed(hwnd); } else @@ -6705,12 +6736,16 @@ static VOID CALLBACK nsGetAttentionTimerFunc(HWND hwnd, UINT uMsg, UINT idEvent, // Draw user's attention to this window until it comes to foreground. NS_IMETHODIMP -nsWindow::GetAttention() { +nsWindow::GetAttention(PRInt32 aCycleCount) { // Got window? if (!mWnd) return NS_ERROR_NOT_INITIALIZED; + // Don't flash if the flash count is 0. + if (aCycleCount == 0) + return NS_OK; + // timer is on the parentmost window; window to flash is its ownermost HWND nextwnd, flashwnd, @@ -6727,7 +6762,7 @@ nsWindow::GetAttention() { if (!gAttentionTimerMonitor) gAttentionTimerMonitor = new nsAttentionTimerMonitor; if (gAttentionTimerMonitor) { - gAttentionTimerMonitor->AddTimer(timerwnd, flashwnd, NS_FLASH_TIMER_ID); + gAttentionTimerMonitor->AddTimer(timerwnd, flashwnd, aCycleCount, NS_FLASH_TIMER_ID); ::SetTimer(timerwnd, NS_FLASH_TIMER_ID, GetCaretBlinkTime(), (TIMERPROC)nsGetAttentionTimerFunc); } } diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index 336e4d341f6..ee46b325cd0 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -371,7 +371,7 @@ public: NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); - NS_IMETHOD GetAttention(); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetLastInputEventTime(PRUint32& aTime); // nsIKBStateControl interface diff --git a/mozilla/widget/src/xlib/nsWindow.cpp b/mozilla/widget/src/xlib/nsWindow.cpp index 13eae43a636..6a405cbd28e 100644 --- a/mozilla/widget/src/xlib/nsWindow.cpp +++ b/mozilla/widget/src/xlib/nsWindow.cpp @@ -169,7 +169,7 @@ nsWindow::UpdateIdle (void *data) // Just raises the window. // There should probably be checks on this. // FIXME KenF -NS_IMETHODIMP nsWindow::GetAttention(void) +NS_IMETHODIMP nsWindow::GetAttention(PRInt32 aCycleCount) { XRaiseWindow(mDisplay, mBaseWindow); return NS_OK; diff --git a/mozilla/widget/src/xlib/nsWindow.h b/mozilla/widget/src/xlib/nsWindow.h index e07c4e630cc..78cdd8702c6 100644 --- a/mozilla/widget/src/xlib/nsWindow.h +++ b/mozilla/widget/src/xlib/nsWindow.h @@ -115,7 +115,7 @@ class nsWindow : public nsWidget NS_IMETHOD SetFocus(PRBool aRaise); virtual PRBool OnExpose(nsPaintEvent &event); - NS_IMETHOD GetAttention(void); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); protected: virtual long GetEventMask(); diff --git a/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp b/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp index 5bd26530da6..2ad968eb16b 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp @@ -890,7 +890,7 @@ NS_METHOD nsBaseWidget::ModalEventFilter(PRBool aRealEvent, void *aEvent, } NS_IMETHODIMP -nsBaseWidget::GetAttention() { +nsBaseWidget::GetAttention(PRInt32 aCycleCount) { return NS_OK; } diff --git a/mozilla/widget/src/xpwidgets/nsBaseWidget.h b/mozilla/widget/src/xpwidgets/nsBaseWidget.h index 8d149955e72..37d4b0b9472 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseWidget.h +++ b/mozilla/widget/src/xpwidgets/nsBaseWidget.h @@ -128,7 +128,7 @@ public: NS_IMETHOD ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy); NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy); NS_IMETHOD EnableDragDrop(PRBool aEnable); - NS_IMETHOD GetAttention(); + NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetLastInputEventTime(PRUint32& aTime); NS_IMETHOD SetIcon(const nsAString &anIconSpec); virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {} diff --git a/mozilla/xpfe/bootstrap/browser-prefs.js b/mozilla/xpfe/bootstrap/browser-prefs.js index b3ef714e1e0..98f494e6e04 100644 --- a/mozilla/xpfe/bootstrap/browser-prefs.js +++ b/mozilla/xpfe/bootstrap/browser-prefs.js @@ -159,6 +159,9 @@ pref("browser.editor.disabled", false); pref("spellchecker.dictionary", ""); pref("autoupdate.enabled", true); +pref("xpinstall.dialog.confirm", "chrome://communicator/content/xpinstall/institems.xul"); +pref("xpinstall.dialog.progress", "chrome://communicator/content/xpinstall/xpistatus.xul"); +pref("xpinstall.dialog.progress.type", ""); // Customizable toolbar stuff pref("custtoolbar.personal_toolbar_folder", ""); diff --git a/mozilla/xpinstall/res/content/institems.js b/mozilla/xpinstall/res/content/institems.js index 7071f027c14..a0dd0d87fa7 100644 --- a/mozilla/xpinstall/res/content/institems.js +++ b/mozilla/xpinstall/res/content/institems.js @@ -58,7 +58,7 @@ function addTreeItem(num, aName, aUrl, aCertName) function onLoad() { var row = 0; - var moduleName, URL, certName, numberOfDialogTreeElements; + var moduleName, URL, IconURL, certName, numberOfDialogTreeElements; gBundle = document.getElementById("xpinstallBundle"); gParam = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock); @@ -71,6 +71,7 @@ function onLoad() { moduleName = gParam.GetString(i); URL = gParam.GetString(++i); + IconURL = gParam.GetString(++i); // Advance the enumeration, parameter is unused just now. certName = gParam.GetString(++i); addTreeItem(row++, moduleName, URL, certName); diff --git a/mozilla/xpinstall/res/content/xpistatus.js b/mozilla/xpinstall/res/content/xpistatus.js index 6692191b48b..c5cc002e8f6 100644 --- a/mozilla/xpinstall/res/content/xpistatus.js +++ b/mozilla/xpinstall/res/content/xpistatus.js @@ -122,6 +122,7 @@ function onLoad() { var moduleName = param.GetString(i++); var URL = param.GetString(i++); + var IconURL = param.GetString(i++); // Advance the enumeration, parameter is unused just now. var certName = param.GetString(i++); addTreeItem(row++, moduleName, URL); } diff --git a/mozilla/xpinstall/src/Makefile.in b/mozilla/xpinstall/src/Makefile.in index dea7970c378..89eef9edb27 100644 --- a/mozilla/xpinstall/src/Makefile.in +++ b/mozilla/xpinstall/src/Makefile.in @@ -59,6 +59,7 @@ REQUIRES = xpcom \ windowwatcher \ plugin \ unicharutil \ + appshell \ $(ZLIB_REQUIRES) \ $(NULL) diff --git a/mozilla/xpinstall/src/nsInstallTrigger.cpp b/mozilla/xpinstall/src/nsInstallTrigger.cpp index 681703174bf..fc302115c63 100644 --- a/mozilla/xpinstall/src/nsInstallTrigger.cpp +++ b/mozilla/xpinstall/src/nsInstallTrigger.cpp @@ -274,7 +274,7 @@ nsInstallTrigger::StartSoftwareUpdate(nsIScriptGlobalObject* aGlobalObject, cons nsXPITriggerInfo* trigger = new nsXPITriggerInfo(); if ( trigger ) { - nsXPITriggerItem* item = new nsXPITriggerItem(0,aURL.get()); + nsXPITriggerItem* item = new nsXPITriggerItem(0,aURL.get(),nsnull); if (item) { trigger->Add( item ); diff --git a/mozilla/xpinstall/src/nsJSInstallTriggerGlobal.cpp b/mozilla/xpinstall/src/nsJSInstallTriggerGlobal.cpp index a9bc1a2516d..251bfa45e29 100644 --- a/mozilla/xpinstall/src/nsJSInstallTriggerGlobal.cpp +++ b/mozilla/xpinstall/src/nsJSInstallTriggerGlobal.cpp @@ -195,6 +195,7 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg { jsval v; const PRUnichar *name, *URL; + const PRUnichar *iconURL = nsnull; for (int i = 0; i < ida->length; i++ ) { @@ -202,11 +203,24 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg name = NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars( JS_ValueToString( cx, v ) )); JS_GetUCProperty( cx, JSVAL_TO_OBJECT(argv[0]), NS_REINTERPRET_CAST(const jschar*, name), nsCRT::strlen(name), &v ); + if ( JSVAL_IS_OBJECT(v) ) + { + + jsval v2; + JS_GetProperty( cx, JSVAL_TO_OBJECT(v), "URL", &v2 ); + URL = NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars( JS_ValueToString( cx, v2 ) )); + + JS_GetProperty( cx, JSVAL_TO_OBJECT(v), "IconURL", &v2 ); + iconURL = NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars( JS_ValueToString( cx, v2 ) )); + } + else + { URL = NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars( JS_ValueToString( cx, v ) )); + } if ( name && URL ) { - nsXPITriggerItem *item = new nsXPITriggerItem( name, URL ); + nsXPITriggerItem *item = new nsXPITriggerItem( name, URL, iconURL ); if ( item ) { if ( item->IsRelativeURL() ) @@ -313,7 +327,8 @@ InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsva { // there's at least one known chrome type nsXPITriggerItem* item = new nsXPITriggerItem(name.get(), - sourceURL.get()); + sourceURL.get(), + nsnull); if (item && item->IsRelativeURL()) item->mURL.Insert( baseURL, 0 ); diff --git a/mozilla/xpinstall/src/nsXPITriggerInfo.cpp b/mozilla/xpinstall/src/nsXPITriggerInfo.cpp index 0079f645985..059a6a44756 100644 --- a/mozilla/xpinstall/src/nsXPITriggerInfo.cpp +++ b/mozilla/xpinstall/src/nsXPITriggerInfo.cpp @@ -38,8 +38,9 @@ MOZ_DECL_CTOR_COUNTER(nsXPITriggerItem) nsXPITriggerItem::nsXPITriggerItem( const PRUnichar* aName, const PRUnichar* aURL, + const PRUnichar* aIconURL, PRInt32 aFlags) - : mName(aName), mURL(aURL), mFlags(aFlags) + : mName(aName), mURL(aURL), mIconURL(aIconURL), mFlags(aFlags) { MOZ_COUNT_CTOR(nsXPITriggerItem); diff --git a/mozilla/xpinstall/src/nsXPITriggerInfo.h b/mozilla/xpinstall/src/nsXPITriggerInfo.h index 483c701e3cf..ff3752eaf9c 100644 --- a/mozilla/xpinstall/src/nsXPITriggerInfo.h +++ b/mozilla/xpinstall/src/nsXPITriggerInfo.h @@ -54,11 +54,12 @@ typedef struct XPITriggerEvent { class nsXPITriggerItem { public: - nsXPITriggerItem( const PRUnichar* name, const PRUnichar* URL, PRInt32 flags = 0); + nsXPITriggerItem( const PRUnichar* name, const PRUnichar* URL, const PRUnichar* iconURL, PRInt32 flags = 0); ~nsXPITriggerItem(); nsString mName; nsString mURL; + nsString mIconURL; nsString mArguments; nsString mCertName; PRInt32 mFlags; diff --git a/mozilla/xpinstall/src/nsXPInstallManager.cpp b/mozilla/xpinstall/src/nsXPInstallManager.cpp index aa55d980097..5edb17c59ee 100644 --- a/mozilla/xpinstall/src/nsXPInstallManager.cpp +++ b/mozilla/xpinstall/src/nsXPInstallManager.cpp @@ -49,6 +49,7 @@ #include "nsInstallResources.h" #include "nsIProxyObjectManager.h" #include "nsIWindowWatcher.h" +#include "nsIWindowMediator.h" #include "nsIDOMWindowInternal.h" #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" @@ -60,6 +61,10 @@ #include "nsIScriptGlobalObject.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" +#include "nsIObserverService.h" + +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" #include "CertReader.h" @@ -68,6 +73,9 @@ static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); #include "nsIEventQueueService.h" +#define PREF_XPINSTALL_CONFIRM_DLG "xpinstall.dialog.confirm" +#define PREF_XPINSTALL_STATUS_DLG "xpinstall.dialog.progress" +#define PREF_XPINSTALL_STATUS_DLG_TYPE "xpinstall.dialog.progress.type" #define UPDATE_DLG(x) (((x) - mLastUpdate) > 250000) @@ -91,11 +99,17 @@ nsXPInstallManager::nsXPInstallManager() // initialize mLastUpdate to the current time mLastUpdate = PR_Now(); + + nsCOMPtr os(do_GetService("@mozilla.org/observer-service;1")); + os->AddObserver(this, XPI_PROGRESS_TOPIC, PR_FALSE); } nsXPInstallManager::~nsXPInstallManager() { + nsCOMPtr os(do_GetService("@mozilla.org/observer-service;1")); + os->RemoveObserver(this, XPI_PROGRESS_TOPIC); + if (mTriggers) delete mTriggers; } @@ -169,7 +183,7 @@ nsXPInstallManager::InitManagerInternal() // --- prepare dialog params PRUint32 numTriggers = mTriggers->Size(); - PRUint32 numStrings = 3 * numTriggers; + PRUint32 numStrings = 4 * numTriggers; const PRUnichar** packageList = (const PRUnichar**)malloc( sizeof(PRUnichar*) * numStrings ); @@ -181,6 +195,7 @@ nsXPInstallManager::InitManagerInternal() nsXPITriggerItem *item = mTriggers->Get(i); packageList[j++] = item->mName.get(); packageList[j++] = item->mURL.get(); + packageList[j++] = item->mIconURL.get(); packageList[j++] = item->mCertName.get(); } @@ -266,9 +281,18 @@ nsXPInstallManager::ConfirmInstall(nsIDOMWindow *aParent, const PRUnichar **aPac ifptr->SetData(params); ifptr->SetDataIID(&NS_GET_IID(nsIDialogParamBlock)); - rv = parentWindow->OpenDialog(NS_LITERAL_STRING("chrome://communicator/content/xpinstall/institems.xul"), + char* confirmDialogURL; + nsCOMPtr pref(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (pref) { + rv = pref->GetCharPref(PREF_XPINSTALL_CONFIRM_DLG, &confirmDialogURL); + NS_ASSERTION(NS_SUCCEEDED(rv), "Can't invoke XPInstall FE without a FE URL! Set xpinstall.dialog.confirm"); + if (NS_FAILED(rv)) + return rv; + } + + rv = parentWindow->OpenDialog(NS_ConvertASCIItoUCS2(confirmDialogURL), NS_LITERAL_STRING("_blank"), - NS_LITERAL_STRING("chrome,centerscreen,modal,titlebar,resizable"), + NS_LITERAL_STRING("chrome,centerscreen,modal,titlebar"), ifptr, getter_AddRefs(newWindow)); @@ -377,9 +401,35 @@ nsXPInstallManager::OpenProgressDialog(const PRUnichar **aPackageList, PRUint32 // --- open the window nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv)); if (wwatch) { + char *statusDialogURL, *statusDialogType; + nsCOMPtr pref(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (pref) { + rv = pref->GetCharPref(PREF_XPINSTALL_STATUS_DLG, &statusDialogURL); + NS_ASSERTION(NS_SUCCEEDED(rv), "Can't invoke XPInstall FE without a FE URL! Set xpinstall.dialog.status"); + if (NS_FAILED(rv)) + return rv; + + rv = pref->GetCharPref(PREF_XPINSTALL_STATUS_DLG_TYPE, &statusDialogType); + nsAutoString type; + type.AssignWithConversion(statusDialogType); + if (NS_SUCCEEDED(rv) && !type.IsEmpty()) { + nsCOMPtr wm = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID); + + nsCOMPtr recentWindow; + wm->GetMostRecentWindow(type.get(), getter_AddRefs(recentWindow)); + if (recentWindow) { + nsCOMPtr os(do_GetService("@mozilla.org/observer-service;1")); + os->NotifyObservers(params, "xpinstall-download-started", nsnull); + + recentWindow->Focus(); + return NS_OK; + } + } + } + nsCOMPtr newWindow; rv = wwatch->OpenWindow(0, - "chrome://communicator/content/xpinstall/xpistatus.xul", + statusDialogURL, "_blank", "chrome,centerscreen,titlebar,resizable", params,