Diff for /chimera/NSBrowserView.mm between versions 1.32 and 1.35

version 1.32, 2002/04/12 19:45:37 version 1.35, 2002/04/20 00:44:56
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];    if ( (self = [super initWithFrame:frame]) ) {
   
  nsresult rv = nsCocoaBrowserService::InitEmbedding();        nsresult rv = nsCocoaBrowserService::InitEmbedding();
  if (NS_FAILED(rv)) {        if (NS_FAILED(rv)) {
     // XXX need to throw      // XXX need to throw
  }        }
   
  _listener = new nsCocoaBrowserListener(self); 
  NS_ADDREF(_listener); 
   
           _listener = new nsCocoaBrowserListener(self);
           NS_ADDREF(_listener);
           
   // Create the web browser instance    // Create the web browser instance
  nsCOMPtr<nsIWebBrowser> browser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);        nsCOMPtr<nsIWebBrowser> browser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {        if (NS_FAILED(rv)) {
     // XXX need to throw      // XXX need to throw
  }        }
 
  _webBrowser = browser; 
  NS_ADDREF(_webBrowser); 
   
           _webBrowser = browser;
           NS_ADDREF(_webBrowser);
           
   // Set the container nsIWebBrowserChrome    // Set the container nsIWebBrowserChrome
  _webBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome *,         _webBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome *,
                                                 _listener));                                                       _listener));
          
   // Register as a listener for web progress    // Register as a listener for web progress
  nsCOMPtr<nsIWeakReference> weak = do_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, _listener));        nsCOMPtr<nsIWeakReference> weak = do_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, _listener));
  _webBrowser->AddWebBrowserListener(weak, NS_GET_IID(nsIWebProgressListener));        _webBrowser->AddWebBrowserListener(weak, NS_GET_IID(nsIWebProgressListener));
        
   // Hook up the widget hierarchy with us as the parent    // Hook up the widget hierarchy with us as the parent
  nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(_webBrowser);        nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(_webBrowser);
  baseWin->InitWindow((NSView*)self, nsnull, 0, 0,         baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
                      frame.size.width, frame.size.height);                            frame.size.width, frame.size.height);
  baseWin->Create();        baseWin->Create();
    }
   return self;    return self;
 }  }
   
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 1252  nsHeaderSniffer::OnSecurityChange(nsIWeb Line 1265  nsHeaderSniffer::OnSecurityChange(nsIWeb
     return found;      return found;
 }  }
   
   - (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 1281  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 1372  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.32  
changed lines
  Added in v.1.35


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