Diff for /chimera/MyBrowserView.mm between versions 1.25 and 1.30

version 1.25, 2002/03/10 19:26:16 version 1.30, 2002/04/12 09:56:34
Line 46 Line 46
 #include "nsIChromeEventHandler.h"  #include "nsIChromeEventHandler.h"
 #include "nsPIDOMWindow.h"  #include "nsPIDOMWindow.h"
 #include "nsIDOMEventReceiver.h"  #include "nsIDOMEventReceiver.h"
   #include "nsIPrefBranch.h"
   #include "nsIPrefService.h"
   #include "nsCocoaBrowserService.h"
   
 #define DOCUMENT_DONE_STRING @"Document: Done"  #define DOCUMENT_DONE_STRING @"Document: Done"
 #define LOADING_STRING @"Loading..."  #define LOADING_STRING @"Loading..."
Line 56  static const char* ioServiceContractID = Line 59  static const char* ioServiceContractID =
   
 -(void)windowClosed  -(void)windowClosed
 {  {
    // Break the cycle.  // Break the cycle.
    [browserView setContainer: nil];  [browserView destroyWebBrowser];
    [browserView removeListener: self];  [browserView setContainer: nil];
    [browserView destroyWebBrowser];  [browserView removeListener: self];
 }  }
   
 -(void)dealloc  -(void)dealloc
 {  {
    printf("My browser view died.\n");  printf("My browser view died.\n");
    
    [[NSNotificationCenter defaultCenter] removeObserver: self];  [[NSNotificationCenter defaultCenter] removeObserver: self];
           
         [defaultStatus release];          [defaultStatus release];
    [loadingStatus release];  [loadingStatus release];
    
        [super dealloc];  [super dealloc];
 }  }
   
 - (IBAction)load:(id)sender  - (IBAction)load:(id)sender
Line 125  static const char* ioServiceContractID = Line 128  static const char* ioServiceContractID =
   [status setStringValue:loadingStatus];    [status setStringValue:loadingStatus];
       
   mIsPrimary = YES;    mIsPrimary = YES;
 
   if ([[self window] isKeyWindow])
     [browserView setActive: YES];
   
   nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));    nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
   if (!ioService)    if (!ioService)
     return;      return;
Line 300  static const char* ioServiceContractID = Line 306  static const char* ioServiceContractID =
         [mTab setLabel:@"Untitled"];          [mTab setLabel:@"Untitled"];
 }  }
   
   // Called when a context menu should be shown.
   - (void)onShowContextMenu:(int)flags domEvent:(nsIDOMEvent*)aEvent domNode:(nsIDOMNode*)aNode
   {
     [mWindowController onShowContextMenu: flags domEvent: aEvent domNode: aNode];
   }
   
   -(NSMenu*)getContextMenu
   {
     return [mWindowController getContextMenu];
   }
   
 - (void)offlineModeChanged: (NSNotification*)aNotification  - (void)offlineModeChanged: (NSNotification*)aNotification
 {  {
     nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));      nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
Line 332  static const char* ioServiceContractID = Line 349  static const char* ioServiceContractID =
   [[self window] setFrame:frame display:YES];    [[self window] setFrame:frame display:YES];
 }  }
   
- (NSBrowserView*)createBrowserWindow:(unsigned int)mask#define NS_POPUP_BLOCK @"This Web site is attempting to open an unrequested popup window.  Navigator can \
{automatically prevent Web sites from opening popup advertisements.  Would you like to turn on \
 popup blocking now?"
 
 - (NSBrowserView*)createBrowserWindow:(unsigned int)aMask
 {
   nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
   if (!pref)
     return NS_OK; // Something bad happened if we can't get prefs.
 
   PRBool showBlocker;
   pref->GetBoolPref("browser.popups.showPopupBlocker", &showBlocker);
 
   if (showBlocker) {
     nsCOMPtr<nsIDOMWindow> domWindow = getter_AddRefs([browserView getContentWindow]);
     nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(domWindow));
     PRBool isUnrequested;
     piWindow->IsLoadingOrRunningTimeout(&isUnrequested);
     if (isUnrequested) {
       // A popup is being opened while the page is currently loading.  Offer to block the
       // popup.
       nsAlertController* controller = nsCocoaBrowserService::GetAlertController();
       BOOL checkValue = YES;
       BOOL confirm = [controller confirmCheck: [self window] title: @"Unrequested Popup Detected"
                                 text: NS_POPUP_BLOCK
                                 checkMsg:@"Always ask before opening unrequested popups." checkValue: &checkValue];
       PRBool needToSave = PR_FALSE;
       if (checkValue != showBlocker) {
         needToSave = PR_TRUE;
         pref->SetBoolPref("browser.popups.showPopupBlocker", checkValue);
       }
       
       if (confirm) {
         needToSave = PR_TRUE;
         pref->SetBoolPref("dom.disable_open_during_load", PR_TRUE);
         pref->SetIntPref("dom.disable_open_click_delay", 1000);
       }
 
       if (needToSave) {
         nsCOMPtr<nsIPrefService> prefService(do_QueryInterface(pref));
         prefService->SavePrefFile(nsnull);
       }
       
       if (confirm)
         return nil;
     }
   }
   
   BrowserWindowController* controller = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];    BrowserWindowController* controller = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
     [controller setChromeMask: aMask];
   [controller disableAutosave]; // The Web page opened this window, so we don't ever use its settings.    [controller disableAutosave]; // The Web page opened this window, so we don't ever use its settings.
   [controller enterModalSession];    [controller enterModalSession];
   return [[controller getMyBrowserView] getBrowserView];    return [[controller getMyBrowserView] getBrowserView];

Removed from v.1.25  
changed lines
  Added in v.1.30


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