Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
CHBrowserView Class Reference

#import <CHBrowserView.h>

Collaboration diagram for CHBrowserView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(id- initWithFrame:
(id- initWithFrame:andWindow:
(void- dealloc
(void- setFrame:
(void- addListener:
(void- removeListener:
(void- setContainer:
(nsIDOMWindow *) - getContentWindow
(void- loadURI:referrer:flags:
(void- reload:
(BOOL- canGoBack
(BOOL- canGoForward
(void- goBack
(void- goForward
(void- gotoIndex:
(void- stop:
(NSString *) - getCurrentURI
(void- saveDocument:filterList:
(void- saveURL:filterList:url:suggestedFilename:
(void- printDocument
(BOOL- findInPageWithPattern:caseSensitive:wrap:backwards:
(BOOL- validateMenuItem:
(IBAction) - cut:
(BOOL- canCut
(IBAction) - copy:
(BOOL- canCopy
(IBAction) - paste:
(BOOL- canPaste
(IBAction) - delete:
(BOOL- canDelete
(IBAction) - selectAll:
(IBAction) - undo:
(IBAction) - redo:
(BOOL- canUndo
(BOOL- canRedo
(NSString *) - getCurrentURLSpec
(void- setActive:
(NSMenu *) - getContextMenu
(NSWindow *) - getNativeWindow
(void- destroyWebBrowser
(nsIWebBrowser *) - getWebBrowser
(CHBrowserListener *) - getCocoaBrowserListener
(void- setWebBrowser:
(NSString *) - getFocusedURLString
(void- findEventSink:forPoint:inWindow:
(void- saveInternal:withDocument:suggestedFilename:bypassCache:filterView:filterList: [implementation]
(void- doCommand: [implementation]
(BOOL- isCommandEnabled: [implementation]
(BOOL- shouldAcceptDrag: [implementation]
(unsigned int- draggingEntered: [implementation]
(void- draggingExited: [implementation]
(unsigned int- draggingUpdated: [implementation]
(BOOL- prepareForDragOperation: [implementation]
(BOOL- performDragOperation: [implementation]

Protected Attributes

nsIWebBrowser_webBrowser
CHBrowserListener_listener
NSWindow * mWindow
nsIDragHelperServicemDragHelper
NSPoint mLastTrackedLocation
NSWindow * mLastTrackedWindow

Detailed Description

Definition at line 118 of file CHBrowserView.h.


Member Function Documentation

- (void) addListener: (id <CHBrowserListener>)  listener

Definition at line 194 of file CHBrowserView.mm.

                   :(id <CHBrowserListener>)listener
{
  _listener->AddListener(listener);
}

Here is the caller graph for this function:

Definition at line 647 of file CHBrowserView.mm.

{
  PRBool canCut = PR_FALSE;
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->CanCopySelection(&canCut);
  return canCut;
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (BOOL) canCut

Definition at line 631 of file CHBrowserView.mm.

{
  PRBool canCut = PR_FALSE;
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->CanCutSelection(&canCut);
  return canCut;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 677 of file CHBrowserView.mm.

{
  return [self isCommandEnabled: "cmd_delete"];
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 270 of file CHBrowserView.mm.

{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return NO;

  PRBool can;
  nav->GetCanGoBack(&can);

  return can ? YES : NO;
}

Here is the call graph for this function:

Definition at line 282 of file CHBrowserView.mm.

{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return NO;

  PRBool can;
  nav->GetCanGoForward(&can);

  return can ? YES : NO;
}

Here is the call graph for this function:

Definition at line 663 of file CHBrowserView.mm.

{
  PRBool canCut = PR_FALSE;
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->CanPaste(&canCut);
  return canCut;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 704 of file CHBrowserView.mm.

{
  return [self isCommandEnabled: "cmd_redo"];
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 699 of file CHBrowserView.mm.

{
  return [self isCommandEnabled: "cmd_undo"];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (IBAction) copy: (id aSender

Definition at line 640 of file CHBrowserView.mm.

               :(id)aSender
{
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->CopySelection();
}

Here is the call graph for this function:

- (IBAction) cut: (id aSender

Definition at line 624 of file CHBrowserView.mm.

              :(id)aSender
{
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->CutSelection();
}

Here is the call graph for this function:

Definition at line 166 of file CHBrowserView.mm.

{
  NS_RELEASE(_listener);
  
  // it is imperative that |destroyWebBrowser()| be called before we get here, otherwise
  // we will leak the webBrowser.
       NS_ASSERTION(!_webBrowser, "BrowserView going away, destroyWebBrowser not called; leaking webBrowser!");
  
  CHBrowserService::BrowserClosed();
  
#if DEBUG
  NSLog(@"CHBrowserView died.");
#endif

  [super dealloc];
}

Here is the call graph for this function:

- (IBAction) delete: (id aSender

Definition at line 672 of file CHBrowserView.mm.

                 :(id)aSender
{
  [self doCommand: "cmd_delete"];
}

Here is the call graph for this function:

Definition at line 154 of file CHBrowserView.mm.

{
  nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(_webBrowser);
  if ( baseWin ) {
    // clean up here rather than in the dtor so that if anyone tries to get our
    // web browser, it won't get a garbage object that's past its prime. As a result,
    // this routine MUST be called otherwise we will leak.
    baseWin->Destroy();
    NS_RELEASE(_webBrowser);
  }
}

Here is the call graph for this function:

- (void) doCommand: (const char*)  commandName [implementation]

Definition at line 586 of file CHBrowserView.mm.

                :(const char*)commandName
{
  nsCOMPtr<nsICommandManager> commandMgr(do_GetInterface(_webBrowser));
  if (commandMgr) {
    nsresult rv = commandMgr->DoCommand(commandName, nsnull, nsnull);
#if DEBUG
      if (NS_FAILED(rv))
        NSLog(@"DoCommand failed");
#endif
  }
  else {
#if DEBUG
    NSLog(@"No command manager");
#endif
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (unsigned int) draggingEntered: (id <NSDraggingInfo>)  sender [implementation]

Definition at line 814 of file CHBrowserView.mm.

                               :(id <NSDraggingInfo>)sender
{
  if (![self shouldAcceptDrag:sender])
    return NSDragOperationNone;

//  NSLog(@"draggingEntered");  
  nsCOMPtr<nsIDragHelperService> helper(do_GetService("@mozilla.org/widget/draghelperservice;1"));
  mDragHelper = helper.get();
  NS_IF_ADDREF(mDragHelper);
  NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in big trouble" );
  
  if ( mDragHelper ) {
    mLastTrackedLocation = [sender draggingLocation];
    mLastTrackedWindow   = [sender draggingDestinationWindow];
    nsCOMPtr<nsIEventSink> sink;
    [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow];
    if (sink)
      mDragHelper->Enter ( [sender draggingSequenceNumber], sink );
  }
  
  return NSDragOperationCopy;
}

Here is the call graph for this function:

- (void) draggingExited: (id <NSDraggingInfo>)  sender [implementation]

Definition at line 837 of file CHBrowserView.mm.

                      :(id <NSDraggingInfo>)sender
{
//  NSLog(@"draggingExited");
  if ( mDragHelper ) {
    nsCOMPtr<nsIEventSink> sink;
    
    /* [sender draggingLocation] *//* [sender draggingDestinationWindow] */[self findEventSink:getter_AddRefs(sink)
            forPoint:mLastTrackedLocation 
            inWindow:mLastTrackedWindow   
            ];
    if (sink)
      mDragHelper->Leave( [sender draggingSequenceNumber], sink );
    NS_RELEASE(mDragHelper);     
  }
}

Here is the call graph for this function:

- (unsigned int) draggingUpdated: (id <NSDraggingInfo>)  sender [implementation]

Definition at line 853 of file CHBrowserView.mm.

                               :(id <NSDraggingInfo>)sender
{
  if (![self shouldAcceptDrag:sender])
    return NSDragOperationNone;

//  NSLog(@"draggingUpdated");
  PRBool dropAllowed = PR_FALSE;
  if ( mDragHelper ) {
    mLastTrackedLocation = [sender draggingLocation];
    mLastTrackedWindow   = [sender draggingDestinationWindow];
    nsCOMPtr<nsIEventSink> sink;
    [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow];
    if (sink)
      mDragHelper->Tracking([sender draggingSequenceNumber], sink, &dropAllowed);
  }
  
  return dropAllowed ? NSDragOperationCopy : NSDragOperationNone;
}

Here is the call graph for this function:

- (void) findEventSink: (nsIEventSink**)  outSink
forPoint: (NSPoint)  inPoint
inWindow: (NSWindow*)  inWind 

Definition at line 791 of file CHBrowserView.mm.

                      :(nsIEventSink**)outSink forPoint:(NSPoint)inPoint inWindow:(NSWindow*)inWind
{
  NSPoint localPoint = [self convertPoint:inPoint fromView:[inWind contentView]];
  NSView<mozView>* hitView = [self hitTest:localPoint];
  if ( [hitView conformsToProtocol:@protocol(mozView)] ) {
    nsCOMPtr<nsIEventSink> sink (do_QueryInterface([hitView widget]));
    *outSink = sink.get();
    NS_IF_ADDREF(*outSink);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (BOOL) findInPageWithPattern: (NSString*)  inText
caseSensitive: (BOOL inCaseSensitive
wrap: (BOOL inWrap
backwards: (BOOL inBackwards 

Definition at line 467 of file CHBrowserView.mm.

                             :(NSString*)inText caseSensitive:(BOOL)inCaseSensitive
    wrap:(BOOL)inWrap backwards:(BOOL)inBackwards
{
    if (!_webBrowser)
      return NO;
    PRBool found =  PR_FALSE;
    
    nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
    nsCOMPtr<nsIDOMWindow> rootWindow;
    nsCOMPtr<nsIDOMWindow> focusedWindow;
    _webBrowser->GetContentDOMWindow(getter_AddRefs(rootWindow));
    wbf->GetFocusedWindow(getter_AddRefs(focusedWindow));
    if (!focusedWindow)
        focusedWindow = rootWindow;
    nsCOMPtr<nsIWebBrowserFind> webFind(do_GetInterface(_webBrowser));
    if ( webFind ) {
      nsCOMPtr<nsIWebBrowserFindInFrames> framesFind(do_QueryInterface(webFind));
      framesFind->SetRootSearchFrame(rootWindow);
      framesFind->SetCurrentSearchFrame(focusedWindow);
      
      webFind->SetMatchCase(inCaseSensitive ? PR_TRUE : PR_FALSE);
      webFind->SetWrapFind(inWrap ? PR_TRUE : PR_FALSE);
      webFind->SetFindBackwards(inBackwards ? PR_TRUE : PR_FALSE);
    
      PRUnichar* text = (PRUnichar*)nsMemory::Alloc(([inText length]+1)*sizeof(PRUnichar));
      if ( text ) {
        [inText getCharacters:text];
        text[[inText length]] = 0;
        webFind->SetSearchString(text);
        webFind->FindNext(&found);
        nsMemory::Free(text);
      }
    }
    return found;
}

Here is the call graph for this function:

Definition at line 364 of file CHBrowserView.mm.

{
  return _listener;
}

Definition at line 209 of file CHBrowserView.mm.

{
  nsIDOMWindow* window = nsnull;

  if ( _webBrowser )
    _webBrowser->GetContentDOMWindow(&window);

  return window;
}

Here is the caller graph for this function:

- (NSMenu *) getContextMenu

Definition at line 749 of file CHBrowserView.mm.

{
  if ([[self superview] conformsToProtocol:@protocol(CHBrowserContainer)])
  {
    id<CHBrowserContainer> browserContainer = [self superview];
       return [browserContainer getContextMenu];
  }
  
  return nil;
}

Definition at line 343 of file CHBrowserView.mm.

{
  nsCOMPtr<nsIURI> uri;
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return nsnull;

  nav->GetCurrentURI(getter_AddRefs(uri));
  if (!uri) {
    return nsnull;
  }

  nsCAutoString spec;
  uri->GetSpec(spec);
  
  const char* cstr = spec.get();
  NSString* str = [NSString stringWithCString:cstr];
  
  return str;
}

Here is the call graph for this function:

Definition at line 709 of file CHBrowserView.mm.

{
  NSString* empty = @"";
  if (!_webBrowser)
    return empty;
  nsCOMPtr<nsIDOMWindow> domWindow;
  _webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
  if (!domWindow)
    return empty;
  
  nsCOMPtr<nsIDOMDocument> domDocument;
  domWindow->GetDocument(getter_AddRefs(domDocument));
  if (!domDocument)
    return empty;

  nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(domDocument));
  if (!nsDoc)
    return empty;

  nsCOMPtr<nsIDOMLocation> location;
  nsDoc->GetLocation(getter_AddRefs(location));
  if (!location)
    return empty;

  nsAutoString urlStr;
  location->GetHref(urlStr);
  return [NSString stringWith_nsAString: urlStr];
}

Here is the call graph for this function:

Definition at line 519 of file CHBrowserView.mm.

{
  if (!_webBrowser)
    return @"";
  nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
  nsCOMPtr<nsIDOMWindow> domWindow;
  wbf->GetFocusedWindow(getter_AddRefs(domWindow));
  if (!domWindow)
    _webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
  if (!domWindow)
    return @"";

  nsCOMPtr<nsIDOMDocument> domDocument;
  domWindow->GetDocument(getter_AddRefs(domDocument));
  if (!domDocument)
    return @"";
  nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(domDocument));
  if (!nsDoc)
    return @"";
  nsCOMPtr<nsIDOMLocation> location;
  nsDoc->GetLocation(getter_AddRefs(location));
  if (!location)
    return @"";
  nsAutoString urlStr;
  location->GetHref(urlStr);
  return [NSString stringWith_nsAString: urlStr];
}

Here is the call graph for this function:

- (NSWindow *) getNativeWindow

Definition at line 760 of file CHBrowserView.mm.

{
  NSWindow* window = [self window];
  if (window)
    return window; // We're visible.  Just hand the window back.

  // We're invisible.  It's likely that we're in a Cocoa tab view.
  // First see if we have a cached window.
  if (mWindow)
    return mWindow;
  
  // Finally, see if our parent responds to the getNativeWindow selector,
  // and if they do, let them handle it.
  if ([[self superview] conformsToProtocol:@protocol(CHBrowserContainer)])
  {
    id<CHBrowserContainer> browserContainer = [self superview];
    return [browserContainer getNativeWindow];
  }
    
  return nil;
}

Definition at line 369 of file CHBrowserView.mm.

- (void) goBack

Definition at line 294 of file CHBrowserView.mm.

{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return;

  nsresult rv = nav->GoBack();
  if (NS_FAILED(rv)) {
    // XXX need to throw
  }  
}

Here is the call graph for this function:

Definition at line 306 of file CHBrowserView.mm.

{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return;

  nsresult rv = nav->GoForward();
  if (NS_FAILED(rv)) {
    // XXX need to throw
  }  
}

Here is the call graph for this function:

- (void) gotoIndex: (int index

Definition at line 318 of file CHBrowserView.mm.

                 :(int)index
{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return;

  nsresult rv = nav->GotoIndex(index);
  if (NS_FAILED(rv)) {
    // XXX need to throw
  }    
}

Here is the call graph for this function:

- (id) initWithFrame: (NSRect)  frame

Definition at line 102 of file CHBrowserView.mm.

                   :(NSRect)frame
{
  if ( (self = [super initWithFrame:frame]) )
  {
    nsresult rv = CHBrowserService::InitEmbedding();
    if (NS_FAILED(rv)) {
// XXX need to throw
    }

    _listener = new CHBrowserListener(self);
    NS_ADDREF(_listener);
    
// Create the web browser instance
    nsCOMPtr<nsIWebBrowser> browser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
    if (NS_FAILED(rv)) {
// XXX need to throw
    }

    _webBrowser = browser;
    NS_ADDREF(_webBrowser);
    
// Set the container nsIWebBrowserChrome
    _webBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome *, _listener));
    
// Register as a listener for web progress
    nsCOMPtr<nsIWeakReference> weak = do_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, _listener));
    _webBrowser->AddWebBrowserListener(weak, NS_GET_IID(nsIWebProgressListener));
    
// Hook up the widget hierarchy with us as the parent
    nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(_webBrowser);
    baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
                        frame.size.width, frame.size.height);
    baseWin->Create();
    
// register the view as a drop site for text, files, and urls. 
    [self registerForDraggedTypes: [NSArray arrayWithObjects:
              @"MozURLType", NSStringPboardType, NSURLPboardType, NSFilenamesPboardType, nil]];

    // hookup the listener for creating our own native menus on <SELECTS>
    CHClickListener* clickListener = new CHClickListener();
    if (!clickListener)
      return nil;
    
    nsCOMPtr<nsIDOMWindow> contentWindow = getter_AddRefs([self getContentWindow]);
    nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(contentWindow));
    nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(piWindow->GetChromeEventHandler()));
    if ( rec )
      rec->AddEventListenerByIID(clickListener, NS_GET_IID(nsIDOMMouseListener));
  }
  return self;
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) initWithFrame: (NSRect)  frame
andWindow: (NSWindow*)  aWindow 

Definition at line 96 of file CHBrowserView.mm.

                   :(NSRect)frame andWindow:(NSWindow*)aWindow
{
  mWindow = aWindow;
  return [self initWithFrame:frame];
}

Here is the call graph for this function:

- (BOOL) isCommandEnabled: (const char*)  commandName [implementation]

Definition at line 603 of file CHBrowserView.mm.

                       :(const char*)commandName
{
  PRBool      isEnabled = PR_FALSE;
  nsCOMPtr<nsICommandManager> commandMgr(do_GetInterface(_webBrowser));
  if (commandMgr) {
    nsresult rv = commandMgr->IsCommandEnabled(commandName, nsnull, &isEnabled);
#if DEBUG
    if (NS_FAILED(rv))
      NSLog(@"IsCommandEnabled failed");
#endif
  }
  else {
#if DEBUG
    NSLog(@"No command manager");
#endif
  }
  
  return (isEnabled) ? YES : NO;
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) loadURI: (NSString *)  urlSpec
referrer: (NSString*)  referrer
flags: (unsigned int flags 

Definition at line 219 of file CHBrowserView.mm.

               :(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags
{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  
  int length = [urlSpec length];
  PRUnichar* specStr = nsMemory::Alloc((length+1) * sizeof(PRUnichar));
  [urlSpec getCharacters:specStr];
  specStr[length] = PRUnichar(0);
  
  nsCOMPtr<nsIURI> referrerURI;
  if ( referrer )
    NS_NewURI(getter_AddRefs(referrerURI), [referrer UTF8String]);

  PRUint32 navFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
  if (flags & NSLoadFlagsDontPutInHistory) {
    navFlags |= nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY;
  }
  if (flags & NSLoadFlagsReplaceHistoryEntry) {
    navFlags |= nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY;
  }
  if (flags & NSLoadFlagsBypassCacheAndProxy) {
    navFlags |= nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | 
                nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
  }

  nsresult rv = nav->LoadURI(specStr, navFlags, referrerURI, nsnull, nsnull);
  if (NS_FAILED(rv)) {
    // XXX need to throw
  }

  nsMemory::Free(specStr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (IBAction) paste: (id aSender

Definition at line 656 of file CHBrowserView.mm.

                :(id)aSender
{
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->Paste();
}

Here is the call graph for this function:

- (BOOL) performDragOperation: (id <NSDraggingInfo>)  sender [implementation]

Definition at line 877 of file CHBrowserView.mm.

                            :(id <NSDraggingInfo>)sender
{
  if (![self shouldAcceptDrag:sender])
    return NO;

  PRBool dragAccepted = PR_FALSE;
    
  if ( mDragHelper ) {
    nsCOMPtr<nsIEventSink> sink;
    [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation]
            inWindow:[sender draggingDestinationWindow]];
    if (sink)
      mDragHelper->Drop([sender draggingSequenceNumber], sink, &dragAccepted);
  }
  
  return dragAccepted ? YES : NO;
}

Here is the call graph for this function:

- (BOOL) prepareForDragOperation: (id <NSDraggingInfo>)  sender [implementation]

Definition at line 872 of file CHBrowserView.mm.

                               :(id <NSDraggingInfo>)sender
{
  return YES;
}

Definition at line 455 of file CHBrowserView.mm.

{
  if (!_webBrowser)
    return;
  nsCOMPtr<nsIDOMWindow> domWindow;
  _webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
  nsCOMPtr<nsIInterfaceRequestor> ir(do_QueryInterface(domWindow));
  nsCOMPtr<nsIWebBrowserPrint> print;
  ir->GetInterface(NS_GET_IID(nsIWebBrowserPrint), getter_AddRefs(print));
  print->Print(nsnull, nsnull);
}

Here is the call graph for this function:

- (IBAction) redo: (id aSender

Definition at line 694 of file CHBrowserView.mm.

               :(id)aSender
{
  [self doCommand: "cmd_redo"];
}

Here is the call graph for this function:

- (void) reload: (unsigned int flags

Definition at line 252 of file CHBrowserView.mm.

Here is the call graph for this function:

Definition at line 199 of file CHBrowserView.mm.

                      :(id <CHBrowserListener>)listener
{
  _listener->RemoveListener(listener);
}
- (void) saveDocument: (NSView*)  aFilterView
filterList: (NSPopUpButton*)  aFilterList 

Definition at line 547 of file CHBrowserView.mm.

                    : (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
{
    if (!_webBrowser)
      return;
    nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
    nsCOMPtr<nsIDOMWindow> domWindow;
    wbf->GetFocusedWindow(getter_AddRefs(domWindow));
    if (!domWindow)
        _webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
    if (!domWindow)
        return;
    
    nsCOMPtr<nsIDOMDocument> domDocument;
    domWindow->GetDocument(getter_AddRefs(domDocument));
    if (!domDocument)
        return;
    nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(domDocument));
    if (!nsDoc)
        return;
    nsCOMPtr<nsIDOMLocation> location;
    nsDoc->GetLocation(getter_AddRefs(location));
    if (!location)
        return;
    nsAutoString urlStr;
    location->GetHref(urlStr);
#warning fix me
    nsCOMPtr<nsIURI> url;
    nsresult rv = NS_NewURI(getter_AddRefs(url), urlStr);
    if (NS_FAILED(rv))
        return;
    
    [self saveInternal: url.get()
          withDocument: domDocument
          suggestedFilename: ""
          bypassCache: NO
          filterView: aFilterView
          filterList: aFilterList];
}

Here is the call graph for this function:

- (void) saveInternal: (nsIURI*)  aURI
withDocument: (nsIDOMDocument*)  aDocument
suggestedFilename: (const char*)  aFilename
bypassCache: (BOOL aBypassCache
filterView: (NSView*)  aFilterView
filterList: (NSPopUpButton*)  aFilterList 
[implementation]

Definition at line 397 of file CHBrowserView.mm.

                    : (nsIURI*)aURI
        withDocument: (nsIDOMDocument*)aDocument
        suggestedFilename: (const char*)aFilename
        bypassCache: (BOOL)aBypassCache
        filterView: (NSView*)aFilterView
        filterList: (NSPopUpButton*)aFilterList
{
    // Create our web browser persist object.  This is the object that knows
    // how to actually perform the saving of the page (and of the images
    // on the page).
    nsCOMPtr<nsIWebBrowserPersist> webPersist(do_CreateInstance(kPersistContractID));
    if (!webPersist)
        return;
    
    // Make a temporary file object that we can save to.
    nsCOMPtr<nsIProperties> dirService(do_GetService(kDirServiceContractID));
    if (!dirService)
        return;
    nsCOMPtr<nsIFile> tmpFile;
    dirService->Get("TmpD", NS_GET_IID(nsIFile), getter_AddRefs(tmpFile));
    static short unsigned int tmpRandom = 0;
    nsAutoString tmpNo; tmpNo.AppendInt(tmpRandom++);
    nsAutoString saveFile(NS_LITERAL_STRING("-sav"));
    saveFile += tmpNo;
    saveFile += NS_LITERAL_STRING("tmp");
    tmpFile->Append(saveFile); 
    
    // Get the post data if we're an HTML doc.
    nsCOMPtr<nsIInputStream> postData;
    if (aDocument) {
      nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(_webBrowser));
      if (webNav) {
        nsCOMPtr<nsISHistory> sessionHistory;
        webNav->GetSessionHistory(getter_AddRefs(sessionHistory));
        nsCOMPtr<nsIHistoryEntry> entry;
        PRInt32 sindex;
        sessionHistory->GetIndex(&sindex);
        sessionHistory->GetEntryAtIndex(sindex, PR_FALSE, getter_AddRefs(entry));
        nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(entry));
        if (shEntry)
            shEntry->GetPostData(getter_AddRefs(postData));
      }
    }

    // when saving, we first fire off a save with a nsHeaderSniffer as a progress
    // listener. This allows us to look for the content-disposition header, which
    // can supply a filename, and maybe has something to do with CGI-generated
    // content (?)
    nsCAutoString fileName(aFilename);
    nsHeaderSniffer* sniffer = new nsHeaderSniffer(webPersist, tmpFile, aURI, 
                                                   aDocument, postData, fileName, aBypassCache,
                                                   aFilterView, aFilterList);
    if (!sniffer)
        return;
    webPersist->SetProgressListener(sniffer);  // owned
    webPersist->SaveURI(aURI, nsnull, nsnull, nsnull, nsnull, tmpFile);
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) saveURL: (NSView*)  aFilterView
filterList: (NSPopUpButton*)  aFilterList
url: (NSString*)  aURLSpec
suggestedFilename: (NSString*)  aFilename 

Definition at line 503 of file CHBrowserView.mm.

               : (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
            url: (NSString*)aURLSpec suggestedFilename: (NSString*)aFilename
{
  nsCOMPtr<nsIURI> url;
  nsresult rv = NS_NewURI(getter_AddRefs(url), [aURLSpec UTF8String]);
  if (NS_FAILED(rv))
    return;
  
  [self saveInternal: url.get()
        withDocument: nsnull
   suggestedFilename: (([aFilename length] > 0) ? [aFilename fileSystemRepresentation] : "")
         bypassCache: YES
          filterView: aFilterView
          filterList: aFilterList];
}

Here is the call graph for this function:

- (IBAction) selectAll: (id aSender

Definition at line 682 of file CHBrowserView.mm.

                    :(id)aSender
{
  nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
  if ( clipboard )
    clipboard->SelectAll();
}

Here is the call graph for this function:

- (void) setActive: (BOOL aIsActive

Definition at line 738 of file CHBrowserView.mm.

                 : (BOOL)aIsActive
{
  nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
  if (wbf) {
    if (aIsActive)
      wbf->Activate();
    else
      wbf->Deactivate();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) setContainer: (id <CHBrowserContainer>)  container

Definition at line 204 of file CHBrowserView.mm.

                    :(id <CHBrowserContainer>)container
{
  _listener->SetContainer(container);
}

Here is the caller graph for this function:

- (void) setFrame: (NSRect)  frameRect

Definition at line 183 of file CHBrowserView.mm.

                :(NSRect)frameRect 
{
  [super setFrame:frameRect];
  if (_webBrowser) {
    nsCOMPtr<nsIBaseWindow> window = do_QueryInterface(_webBrowser);
    window->SetSize((PRInt32)frameRect.size.width, 
        (PRInt32)frameRect.size.height,
        PR_TRUE);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) setWebBrowser: (nsIWebBrowser*)  browser

Definition at line 375 of file CHBrowserView.mm.

                     :(nsIWebBrowser*)browser
{
  NS_IF_ADDREF(browser);                         // prevents destroying |browser| if |browser| == |_webBrowser|
  NS_IF_RELEASE(_webBrowser);
  _webBrowser = browser;

  if (_webBrowser) {
    // Set the container nsIWebBrowserChrome
    _webBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome *, 
               _listener));

    NSRect frame = [self frame];
 
    // Hook up the widget hierarchy with us as the parent
    nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(_webBrowser);
    baseWin->InitWindow((NSView*)self, nsnull, 0, 0, 
      frame.size.width, frame.size.height);
    baseWin->Create();
  }

}

Here is the call graph for this function:

- (BOOL) shouldAcceptDrag: (id <NSDraggingInfo>)  sender [implementation]

Definition at line 804 of file CHBrowserView.mm.

                        :(id <NSDraggingInfo>)sender
{
  if ([[self superview] conformsToProtocol:@protocol(CHBrowserContainer)])
  {
    id<CHBrowserContainer> browserContainer = [self superview];
    return [browserContainer shouldAcceptDragFromSource:[sender draggingSource]];
  }
  return YES;
}
- (void) stop: (unsigned int flags

Definition at line 330 of file CHBrowserView.mm.

            :(unsigned int)flags
{
  nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
  if ( !nav )
    return;

  nsresult rv = nav->Stop(flags);
  if (NS_FAILED(rv)) {
    // XXX need to throw
  }    
}

Here is the call graph for this function:

- (IBAction) undo: (id aSender

Definition at line 689 of file CHBrowserView.mm.

               :(id)aSender
{
  [self doCommand: "cmd_undo"];
}

Here is the call graph for this function:

- (BOOL) validateMenuItem: (NSMenuItem*)  aMenuItem

Definition at line 897 of file CHBrowserView.mm.

                       : (NSMenuItem*)aMenuItem
{
  // update first responder items based on the selection
  SEL action = [aMenuItem action];
  if (action == @selector(cut:))
    return [self canCut];    
  else if (action == @selector(copy:))
    return [self canCopy];
  else if (action == @selector(paste:))
    return [self canPaste];
  else if (action == @selector(delete:))
    return [self canDelete];
  else if (action == @selector(undo:))
    return [self canUndo];
  else if (action == @selector(redo:))
    return [self canRedo];
  else if (action == @selector(selectAll:))
    return YES;
  
  return NO;
}

Here is the call graph for this function:


Member Data Documentation

- (CHBrowserListener*) _listener [protected]

Definition at line 121 of file CHBrowserView.h.

- (nsIWebBrowser*) _webBrowser [protected]

Definition at line 120 of file CHBrowserView.h.

Definition at line 124 of file CHBrowserView.h.

- (NSPoint) mLastTrackedLocation [protected]

Definition at line 125 of file CHBrowserView.h.

- (NSWindow*) mLastTrackedWindow [protected]

Definition at line 126 of file CHBrowserView.h.

- (NSWindow*) mWindow [protected]

Definition at line 122 of file CHBrowserView.h.


The documentation for this class was generated from the following files: