Diff for /chimera/nsCocoaBrowserService.mm between versions 1.1 and 1.8

version 1.1, 2002/01/31 20:18:48 version 1.8, 2002/02/25 08:44:17
Line 45 Line 45
 #include "nsCRT.h"  #include "nsCRT.h"
 #include "nsString.h"  #include "nsString.h"
   
 PRUint32 nsCocoaBrowserService::sNumBrowsers = 0;  
 nsAlertController* nsCocoaBrowserService::sController = nsnull;  nsAlertController* nsCocoaBrowserService::sController = nsnull;
 nsCocoaBrowserService* nsCocoaBrowserService::sSingleton = nsnull;  nsCocoaBrowserService* nsCocoaBrowserService::sSingleton = nsnull;
   PRUint32 nsCocoaBrowserService::sNumBrowsers = 0;
   
 // nsCocoaBrowserService implementation  // nsCocoaBrowserService implementation
 nsCocoaBrowserService::nsCocoaBrowserService()  nsCocoaBrowserService::nsCocoaBrowserService()
Line 57  nsCocoaBrowserService::nsCocoaBrowserSer Line 57  nsCocoaBrowserService::nsCocoaBrowserSer
   
 nsCocoaBrowserService::~nsCocoaBrowserService()  nsCocoaBrowserService::~nsCocoaBrowserService()
 {  {
   NS_TermEmbedding();  
 }  }
   
 NS_IMPL_ISUPPORTS3(nsCocoaBrowserService,  NS_IMPL_ISUPPORTS3(nsCocoaBrowserService,
Line 68  NS_IMPL_ISUPPORTS3(nsCocoaBrowserService Line 67  NS_IMPL_ISUPPORTS3(nsCocoaBrowserService
 nsresult  nsresult
 nsCocoaBrowserService::InitEmbedding()  nsCocoaBrowserService::InitEmbedding()
 {  {
  if (sSingleton) {  sNumBrowsers++;
    sNumBrowsers++;  
   if (sSingleton)
     return NS_OK;      return NS_OK;
   }  
   
   // XXX Temporary hack to make sure we find the     // XXX Temporary hack to make sure we find the 
   // right executable directory    // right executable directory
Line 87  nsCocoaBrowserService::InitEmbedding() Line 86  nsCocoaBrowserService::InitEmbedding()
     return NS_ERROR_OUT_OF_MEMORY;      return NS_ERROR_OUT_OF_MEMORY;
   }    }
   NS_ADDREF(sSingleton);    NS_ADDREF(sSingleton);
  sNumBrowsers = 1;  
 
   nsresult rv = NS_InitEmbedding(nsnull, nsnull);    nsresult rv = NS_InitEmbedding(nsnull, nsnull);
   if (NS_FAILED(rv)) {    if (NS_FAILED(rv)) {
     return rv;      return rv;
Line 142  nsCocoaBrowserService::InitEmbedding() Line 140  nsCocoaBrowserService::InitEmbedding()
 }  }
   
 void  void
   nsCocoaBrowserService::BrowserClosed()
   {
       sNumBrowsers--;
       if (!sSingleton && sNumBrowsers == 0) {
           // The app is terminating *and* our count dropped to 0.
           NS_TermEmbedding();
           printf("Shutting down embedding!\n");
       }
   }
   
   void
 nsCocoaBrowserService::TermEmbedding()  nsCocoaBrowserService::TermEmbedding()
 {  {
   if (--sNumBrowsers == 0) {  
     NS_RELEASE(sSingleton);      NS_RELEASE(sSingleton);
  }    
     if (sNumBrowsers == 0) {
         NS_TermEmbedding(); // Safe to terminate now.
         printf("Shutting down embedding.\n");
     }
     
     // Otherwise we cannot yet terminate.  We have to let the death of the browser windows
     // induce termination.
 }  }
   
 #define NS_ALERT_NIB_NAME "alert"  #define NS_ALERT_NIB_NAME "alert"
Line 329  nsCocoaBrowserService::ConfirmEx(nsIDOMW Line 344  nsCocoaBrowserService::ConfirmEx(nsIDOMW
                                  const PRUnichar *checkMsg,                                    const PRUnichar *checkMsg, 
                                  PRBool *checkValue, PRInt32 *buttonPressed)                                   PRBool *checkValue, PRInt32 *buttonPressed)
 {  {
  return NS_ERROR_NOT_IMPLEMENTED;  nsAlertController* controller = GetAlertController();
   if (!controller) {
     return NS_ERROR_FAILURE;
   }
 
   NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
   NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
   NSString* msgStr = [NSString stringWithCharacters:checkMsg length:(checkMsg ? nsCRT::strlen(checkMsg) : 0)];
   NSWindow* window = GetNSWindowForDOMWindow(parent);
 
   NSString* btn1Str = [NSString stringWithCharacters:button0Title length:(button0Title ? nsCRT::strlen(button0Title) : 0)];
   NSString* btn2Str = [NSString stringWithCharacters:button1Title length:(button1Title ? nsCRT::strlen(button1Title) : 0)];
   NSString* btn3Str = [NSString stringWithCharacters:button2Title length:(button2Title ? nsCRT::strlen(button2Title) : 0)];
   
   if (checkValue) {
     BOOL valueBool = *checkValue ? YES : NO;
     
     *buttonPressed = (PRInt32)[controller confirmCheckEx:window title:titleStr text:textStr 
                                button1: btn1Str button2: btn2Str button3: btn3Str
                                checkMsg:msgStr checkValue:&valueBool];
     
     *checkValue = (valueBool == YES) ? PR_TRUE : PR_FALSE;
   }
   else {
     *buttonPressed = (PRInt32)[controller confirmEx:window title:titleStr text:textStr
                                button1: btn1Str button2: btn2Str button3: btn3Str];
   }
   
   printf("Uh-oh! Not posing the confirm yet, but just assuming OK was pressed.\n");
   
   return NS_OK;
 
 }  }
   
 /* boolean prompt (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, inout wstring value, in wstring checkMsg, inout boolean checkValue); */  /* boolean prompt (in nsIDOMWindow parent, in wstring dialogTitle, in wstring text, inout wstring value, in wstring checkMsg, inout boolean checkValue); */
Line 472  nsCocoaBrowserService::Select(nsIDOMWind Line 518  nsCocoaBrowserService::Select(nsIDOMWind
                               PRInt32 *outSelection,                                 PRInt32 *outSelection, 
                               PRBool *_retval)                                PRBool *_retval)
 {  {
     printf("Uh-oh. Select has not been implemented.\n");
   return NS_ERROR_NOT_IMPLEMENTED;    return NS_ERROR_NOT_IMPLEMENTED;
 }  }
   
Line 482  nsCocoaBrowserService::CreateChromeWindo Line 529  nsCocoaBrowserService::CreateChromeWindo
                                           PRUint32 chromeFlags,                                             PRUint32 chromeFlags, 
                                           nsIWebBrowserChrome **_retval)                                            nsIWebBrowserChrome **_retval)
 {  {
  return NS_ERROR_NOT_IMPLEMENTED;  if (!parent) {
     printf("Uh-oh. Attempt to create a new browser window with a null parent.  Should not happen in Chimera.\n");
     return NS_ERROR_FAILURE;
   }
     
   nsCOMPtr<nsIWindowCreator> browserChrome(do_QueryInterface(parent));
   return browserChrome->CreateChromeWindow(parent, chromeFlags, _retval);
 }  }
   

Removed from v.1.1  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>