diff dwt/browser/PromptService2.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents e831403a80a9
children 5583f8eeee6c
line wrap: on
line diff
--- a/dwt/browser/PromptService2.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/browser/PromptService2.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2003, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -22,15 +22,12 @@
 import dwt.internal.mozilla.nsIChannel;
 import dwt.internal.mozilla.nsID;
 import dwt.internal.mozilla.nsIDOMWindow;
-import dwt.internal.mozilla.nsIEmbeddingSiteWindow;
 import dwt.internal.mozilla.nsIMemory;
 import dwt.internal.mozilla.nsIPromptService;
 import dwt.internal.mozilla.nsIPromptService2;
 import dwt.internal.mozilla.nsIServiceManager;
 import dwt.internal.mozilla.nsISupports;
 import dwt.internal.mozilla.nsIURI;
-import dwt.internal.mozilla.nsIWebBrowserChrome;
-import dwt.internal.mozilla.nsIWindowWatcher;
 import dwt.widgets.MessageBox;
 import dwt.widgets.Shell;
 
@@ -142,60 +139,19 @@
 
 Browser getBrowser (int /*long*/ aDOMWindow) {
     if (aDOMWindow is 0) return null;
-
-    int /*long*/[] result = new int /*long*/[1];
-    int rc = XPCOM.NS_GetServiceManager (result);
-    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
-    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
-    
-    nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
-    result[0] = 0;
-    byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
-    rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
-    if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
-    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
-    serviceManager.Release ();
-    
-    nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
-    result[0] = 0;
-    /* the chrome will only be answered for the top-level nsIDOMWindow */
     nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
-    rc = window.GetTop (result);
-    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
-    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
-    aDOMWindow = result[0];
-    result[0] = 0;
-    rc = windowWatcher.GetChromeForWindow (aDOMWindow, result);
-    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
-    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
-    windowWatcher.Release ();   
-    
-    nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
-    result[0] = 0;
-    rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID, result);
-    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
-    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
-    webBrowserChrome.Release ();
-    
-    nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
-    result[0] = 0;
-    rc = embeddingSiteWindow.GetSiteWindow (result);
-    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
-    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
-    embeddingSiteWindow.Release ();
-    
-    return Mozilla.findBrowser (result[0]); 
+    return Mozilla.findBrowser (window);
 }
 
 String getLabel (int buttonFlag, int index, int /*long*/ buttonTitle) {
     String label = null;
     int flag = (buttonFlag & (0xff * index)) / index;
     switch (flag) {
-        case nsIPromptService.BUTTON_TITLE_CANCEL : label = DWT.getMessage ("SWT_Cancel"); break; //$NON-NLS-1$
-        case nsIPromptService.BUTTON_TITLE_NO : label = DWT.getMessage ("SWT_No"); break; //$NON-NLS-1$
-        case nsIPromptService.BUTTON_TITLE_OK : label = DWT.getMessage ("SWT_OK"); break; //$NON-NLS-1$
-        case nsIPromptService.BUTTON_TITLE_SAVE : label = DWT.getMessage ("SWT_Save"); break; //$NON-NLS-1$
-        case nsIPromptService.BUTTON_TITLE_YES : label = DWT.getMessage ("SWT_Yes"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_CANCEL : label = DWT.getMessage ("DWT_Cancel"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_NO : label = DWT.getMessage ("DWT_No"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_OK : label = DWT.getMessage ("DWT_OK"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_SAVE : label = DWT.getMessage ("DWT_Save"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_YES : label = DWT.getMessage ("DWT_Yes"); break; //$NON-NLS-1$
         case nsIPromptService.BUTTON_TITLE_IS_STRING : {
             int length = XPCOM.strlen_PRUnichar (buttonTitle);
             char[] dest = new char[length];
@@ -420,7 +376,7 @@
     int[] checkValue = new int[1];
     String[] userLabel = new String[1], passLabel = new String[1];
 
-    String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+    String title = DWT.getMessage ("DWT_Authentication_Required"); //$NON-NLS-1$
 
     if (checkboxLabel !is 0 && checkboxValue !is 0) {
         int length = XPCOM.strlen_PRUnichar (checkboxLabel);
@@ -486,7 +442,7 @@
 
     String message;
     if (realm.length () > 0 && host.length () > 0) {
-        message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
+        message = Compatibility.getMessage ("DWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
     } else {
         message = ""; //$NON-NLS-1$
     }
@@ -526,7 +482,7 @@
         XPCOM.memmove (dest, aDialogTitle, length * 2);
         titleLabel = new String (dest);
     } else {
-        titleLabel = DWT.getMessage ("SWT_Authentication_Required");    //$NON-NLS-1$
+        titleLabel = DWT.getMessage ("DWT_Authentication_Required");    //$NON-NLS-1$
     }
     
     length = XPCOM.strlen_PRUnichar (aText);
@@ -564,7 +520,7 @@
     Shell shell = browser is null ? new Shell () : browser.getShell ();
     PromptDialog dialog = new PromptDialog (shell);
     int[] check = new int[1], result = new int[1];
-    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4);    /* PRBool */
+    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4);   /* PRBool */
     dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result);
 
     XPCOM.memmove (_retval, result, 4); /* PRBool */