Diff for /chimera/NSBrowserView.mm between versions 1.31 and 1.34

version 1.31, 2002/04/12 09:56:34 version 1.34, 2002/04/20 00:02:55
Line 659  class nsHeaderSniffer :  public nsIWebPr Line 659  class nsHeaderSniffer :  public nsIWebPr
 {  {
 public:  public:
     nsHeaderSniffer(nsIWebBrowserPersist* aPersist, nsIFile* aFile, nsIURI* aURL,      nsHeaderSniffer(nsIWebBrowserPersist* aPersist, nsIFile* aFile, nsIURI* aURL,
                    nsIDOMDocument* aDocument, nsIInputStream* aPostData, PRBool aBypassCache,                    nsIDOMDocument* aDocument, nsIInputStream* aPostData,
                     const nsCString& aSuggestedFilename, PRBool aBypassCache,
                     NSView* aFilterView, NSPopUpButton* aFilterList)                      NSView* aFilterView, NSPopUpButton* aFilterList)
     {      {
         NS_INIT_REFCNT();          NS_INIT_REFCNT();
Line 668  public: Line 669  public:
         mURL = aURL;          mURL = aURL;
         mDocument = aDocument;          mDocument = aDocument;
         mPostData = aPostData;          mPostData = aPostData;
           mDefaultFilename = aSuggestedFilename;
         mBypassCache = aBypassCache;          mBypassCache = aBypassCache;
         mFilterView = aFilterView;          mFilterView = aFilterView;
         mFilterList = aFilterList;          mFilterList = aFilterList;
Line 689  private: Line 691  private:
     nsCOMPtr<nsIURI> mURL;      nsCOMPtr<nsIURI> mURL;
     nsCOMPtr<nsIDOMDocument> mDocument;      nsCOMPtr<nsIDOMDocument> mDocument;
     nsCOMPtr<nsIInputStream> mPostData;      nsCOMPtr<nsIInputStream> mPostData;
       nsCString mDefaultFilename;
     PRBool mBypassCache;      PRBool mBypassCache;
     nsCString mContentType;      nsCString mContentType;
     nsCString mContentDisposition;      nsCString mContentDisposition;
Line 751  void nsHeaderSniffer::PerformSave() Line 754  void nsHeaderSniffer::PerformSave()
                   
     // We need to figure out what file name to use.      // We need to figure out what file name to use.
     nsCAutoString defaultFileName;      nsCAutoString defaultFileName;
       
     if (!mContentDisposition.IsEmpty()) {      if (!mContentDisposition.IsEmpty()) {
         // (1) Use the HTTP header suggestion.          // (1) Use the HTTP header suggestion.
         PRInt32 index = mContentDisposition.Find("filename=");          PRInt32 index = mContentDisposition.Find("filename=");
Line 779  void nsHeaderSniffer::PerformSave() Line 781  void nsHeaderSniffer::PerformSave()
     }      }
           
     if (defaultFileName.IsEmpty()) {      if (defaultFileName.IsEmpty()) {
        // (4) Use the caller provided name. XXXdwh        // (4) Use the caller provided name.
         defaultFileName = mDefaultFilename;
     }      }
   
     if (defaultFileName.IsEmpty())      if (defaultFileName.IsEmpty())
Line 916  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 919  nsHeaderSniffer::OnSecurityChange(nsIWeb
   
 @implementation NSBrowserView  @implementation NSBrowserView
   
   - (id)initWithFrame:(NSRect)frame andWindow:(NSWindow*)aWindow
   {
     mWindow = aWindow;
     return [self initWithFrame:frame];
   }
   
 - (id)initWithFrame:(NSRect)frame  - (id)initWithFrame:(NSRect)frame
 {  {
   [super initWithFrame:frame];    [super initWithFrame:frame];
Line 1167  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1176  nsHeaderSniffer::OnSecurityChange(nsIWeb
   
 -(void) saveInternal: (nsIURI*)aURI  -(void) saveInternal: (nsIURI*)aURI
         withDocument: (nsIDOMDocument*)aDocument          withDocument: (nsIDOMDocument*)aDocument
           suggestedFilename: (const char*)aFilename
         bypassCache: (BOOL)aBypassCache          bypassCache: (BOOL)aBypassCache
         filterView: (NSView*)aFilterView          filterView: (NSView*)aFilterView
         filterList: (NSPopUpButton*)aFilterList          filterList: (NSPopUpButton*)aFilterList
Line 1192  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1202  nsHeaderSniffer::OnSecurityChange(nsIWeb
     tmpFile->Append(saveFile.get());       tmpFile->Append(saveFile.get()); 
           
     // Get the post data if we're an HTML doc.      // Get the post data if we're an HTML doc.
     nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(_webBrowser));  
     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));  
     nsCOMPtr<nsIInputStream> postData;      nsCOMPtr<nsIInputStream> postData;
    if (shEntry)    if (aDocument) {
        shEntry->GetPostData(getter_AddRefs(postData));      nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(_webBrowser));
          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));
     }
 
     nsCAutoString fileName(aFilename);
     nsHeaderSniffer* sniffer = new nsHeaderSniffer(webPersist, tmpFile, aURI,       nsHeaderSniffer* sniffer = new nsHeaderSniffer(webPersist, tmpFile, aURI, 
                                                   aDocument, postData, aBypassCache,                                                   aDocument, postData, fileName, aBypassCache,
                                                    aFilterView, aFilterList);                                                     aFilterView, aFilterList);
     if (!sniffer)      if (!sniffer)
         return;          return;
Line 1223  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1236  nsHeaderSniffer::OnSecurityChange(nsIWeb
     print->Print(nsnull, nsnull);      print->Print(nsnull, nsnull);
 }  }
   
-(void)findInPage:(NSString*)inText-(BOOL)findInPage:(NSString*)inText
 {  {
       PRBool found =  PR_FALSE;
       
     nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));      nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
     nsCOMPtr<nsIDOMWindow> rootWindow;      nsCOMPtr<nsIDOMWindow> rootWindow;
     nsCOMPtr<nsIDOMWindow> focusedWindow;      nsCOMPtr<nsIDOMWindow> focusedWindow;
Line 1233  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1248  nsHeaderSniffer::OnSecurityChange(nsIWeb
     if (!focusedWindow)      if (!focusedWindow)
         focusedWindow = rootWindow;          focusedWindow = rootWindow;
     nsCOMPtr<nsIWebBrowserFind> webFind(do_GetInterface(_webBrowser));      nsCOMPtr<nsIWebBrowserFind> webFind(do_GetInterface(_webBrowser));
    nsCOMPtr<nsIWebBrowserFindInFrames> framesFind(do_QueryInterface(webFind));    if ( webFind ) {
    framesFind->SetRootSearchFrame(rootWindow);      nsCOMPtr<nsIWebBrowserFindInFrames> framesFind(do_QueryInterface(webFind));
    framesFind->SetCurrentSearchFrame(focusedWindow);      framesFind->SetRootSearchFrame(rootWindow);
          framesFind->SetCurrentSearchFrame(focusedWindow);
    PRUnichar* text = (PRUnichar*)nsMemory::Alloc(([inText length]+1)*sizeof(PRUnichar));      
    if ( text ) {      PRUnichar* text = (PRUnichar*)nsMemory::Alloc(([inText length]+1)*sizeof(PRUnichar));
      [inText getCharacters:text];      if ( text ) {
      text[[inText length]] = 0;        [inText getCharacters:text];
      webFind->SetSearchString(text);        text[[inText length]] = 0;
      PRBool found;        webFind->SetSearchString(text);
      webFind->FindNext(&found);        webFind->FindNext(&found);
      nsMemory::Free(text);        nsMemory::Free(text);
    }      }
}    }
    return found;
-(void)findAgain}
{
 - (void)saveURL: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
             url: (NSURL*)aURL suggestedFilename: (NSString*)aFilename
 {
   nsCOMPtr<nsIURI> url;
   nsresult rv = NS_NewURI(getter_AddRefs(url), [[aURL absoluteString] cString]);
   if (NS_FAILED(rv))
     return;
   
   [self saveInternal: url.get()
         withDocument: nsnull
    suggestedFilename: [aFilename cString]
          bypassCache: YES
           filterView: aFilterView
           filterList: aFilterList];
 }  }
   
-(void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList- (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
 {  {
     nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));      nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
     nsCOMPtr<nsIDOMWindow> domWindow;      nsCOMPtr<nsIDOMWindow> domWindow;
Line 1280  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1309  nsHeaderSniffer::OnSecurityChange(nsIWeb
     nsresult rv = NS_NewURI(getter_AddRefs(url), urlCStr.get());      nsresult rv = NS_NewURI(getter_AddRefs(url), urlCStr.get());
     if (NS_FAILED(rv))      if (NS_FAILED(rv))
         return;          return;
            
#if 0 
    nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument)); 
    if (!doc) 
        return; 
    nsCOMPtr<nsIURI> url; 
    doc->GetDocumentURL(getter_AddRefs(url)); 
#endif 
      
     [self saveInternal: url.get()      [self saveInternal: url.get()
           withDocument: domDocument            withDocument: domDocument
             suggestedFilename: ""
           bypassCache: NO            bypassCache: NO
           filterView: aFilterView            filterView: aFilterView
           filterList: aFilterList];            filterList: aFilterList];
Line 1371  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1393  nsHeaderSniffer::OnSecurityChange(nsIWeb
 {  {
   return [[self superview] getContextMenu];    return [[self superview] getContextMenu];
 }  }
   
   -(NSWindow*)getNativeWindow
   {
     NSWindow* result = [self window];
     if (result)
       return result; // We're visible.  Just hand the window back.
     else {
       // 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.
       return [[self superview] getNativeWindow];
     }
   }
   
 @end  @end
   

Removed from v.1.31  
changed lines
  Added in v.1.34


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