--- chimera/NSBrowserView.mm 2002/02/25 08:44:17 1.22 +++ chimera/NSBrowserView.mm 2002/04/08 22:30:20 1.29 @@ -179,6 +179,8 @@ nsCocoaBrowserListener::CreateChromeWind return NS_ERROR_FAILURE; } + printf("made a chrome window.\n"); + *_retval = listener; NS_IF_ADDREF(*_retval); return NS_OK; @@ -569,13 +571,11 @@ nsCocoaBrowserListener::OnLocationChange nsIRequest *aRequest, nsIURI *location) { - nsXPIDLCString spec; - - location->GetSpec(getter_Copies(spec)); - if (!spec) { + if (!location) return NS_ERROR_FAILURE; - } - + + nsCAutoString spec; + location->GetSpec(spec); const char* cstr = spec.get(); NSString* str = [NSString stringWithCString:cstr]; NSURL* url = [NSURL URLWithString:str]; @@ -696,17 +696,12 @@ nsHeaderSniffer::OnStateChange(nsIWebPro { if (aStateFlags & nsIWebProgressListener::STATE_START) { nsCOMPtr channel(do_QueryInterface(aRequest)); - nsXPIDLCString contentType; - channel->GetContentType(getter_Copies(contentType)); - mContentType = contentType; - + channel->GetContentType(mContentType); + // Get the content-disposition if we're an HTTP channel. nsCOMPtr httpChannel(do_QueryInterface(channel)); - if (httpChannel) { - nsXPIDLCString disp; - httpChannel->GetResponseHeader("content-disposition", getter_Copies(disp)); - mContentDisposition = disp; - } + if (httpChannel) + httpChannel->GetResponseHeader(nsCAutoString("content-disposition"), mContentDisposition); mPersist->CancelSave(); PRBool exists; @@ -759,11 +754,8 @@ void nsHeaderSniffer::PerformSave() if (defaultFileName.IsEmpty()) { nsCOMPtr url(do_QueryInterface(mURL)); - if (url) { - nsXPIDLCString fileName; - url->GetFileName(getter_Copies(fileName)); - defaultFileName = fileName; // (2) For file URLs, use the file name. - } + if (url) + url->GetFileName(defaultFileName); // (2) For file URLs, use the file name. } if (defaultFileName.IsEmpty() && mDocument && isHTML) { @@ -778,12 +770,9 @@ void nsHeaderSniffer::PerformSave() // (4) Use the caller provided name. XXXdwh } - if (defaultFileName.IsEmpty()) { + if (defaultFileName.IsEmpty()) // (5) Use the host. - nsXPIDLCString host; - mURL->GetHost(getter_Copies(host)); - defaultFileName = host; - } + mURL->GetHost(defaultFileName); // One last case to handle about:blank and other fruity untitled pages. if (defaultFileName.IsEmpty()) @@ -799,11 +788,10 @@ void nsHeaderSniffer::PerformSave() nsCOMPtr fileURL(do_QueryInterface(fileURI)); if (!fileURL) return; - fileURL->SetFilePath(defaultFileName.get()); + fileURL->SetFilePath(defaultFileName); - nsXPIDLCString fileEx; - fileURL->GetFileExtension(getter_Copies(fileEx)); - nsDependentCString fileExtension(fileEx.get()); + nsCAutoString fileExtension; + fileURL->GetFileExtension(fileExtension); PRBool setExtension = PR_FALSE; if (mContentType.Equals("text/html")) { @@ -962,14 +950,14 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb - (void)dealloc { + [super dealloc]; + NS_RELEASE(_listener); NS_IF_RELEASE(_webBrowser); nsCocoaBrowserService::BrowserClosed(); printf("NSBrowserView died.\n"); - - [super dealloc]; } - (void)setFrame:(NSRect)frameRect @@ -1124,8 +1112,8 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb return nsnull; } - nsXPIDLCString spec; - uri->GetSpec(getter_Copies(spec)); + nsCAutoString spec; + uri->GetSpec(spec); const char* cstr = spec.get(); NSString* str = [NSString stringWithCString:cstr]; @@ -1185,7 +1173,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb nsCOMPtr tmpFile; dirService->Get("TmpD", NS_GET_IID(nsIFile), getter_AddRefs(tmpFile)); static short unsigned int tmpRandom = 0; - nsCAutoString tmpNo; tmpNo.AssignWithConversion(tmpRandom++); + nsCAutoString tmpNo; tmpNo.AppendInt(tmpRandom++); nsCAutoString saveFile("-sav"); saveFile += tmpNo; saveFile += "tmp"; @@ -1223,9 +1211,8 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb print->Print(nsnull, nsnull); } --(void)findInPage +-(void)findInPage:(NSString*)inText { - FindDlgController* findDialog = [[FindDlgController alloc] initWithWindowNibName: @"FindDialog"]; nsCOMPtr wbf(do_QueryInterface(_webBrowser)); nsCOMPtr rootWindow; nsCOMPtr focusedWindow; @@ -1238,8 +1225,15 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb framesFind->SetRootSearchFrame(rootWindow); framesFind->SetCurrentSearchFrame(focusedWindow); - [findDialog setFind: webFind]; - [findDialog showWindow: findDialog]; + PRUnichar* text = (PRUnichar*)nsMemory::Alloc(([inText length]+1)*sizeof(PRUnichar)); + if ( text ) { + [inText getCharacters:text]; + text[[inText length]] = 0; + webFind->SetSearchString(text); + PRBool found; + webFind->FindNext(&found); + nsMemory::Free(text); + } } -(void)findAgain @@ -1321,6 +1315,11 @@ nsHeaderSniffer::OnSecurityChange(nsIWeb clipboard->SelectAll(); } +-(IBAction)undo:(id)aSender +{ + NSLog(@"Undo not yet implemented"); +} + -(NSString*)getCurrentURLSpec { NSString* empty = @"";