File:  [mozdev] / chimera / BookmarksService.mm
Revision 1.17: download - view: text, annotated - select for diffs - revision graph
Sun Mar 10 08:14:36 2002 UTC (17 years ago) by macserv
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

    1: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
    2: /* ***** BEGIN LICENSE BLOCK *****
    3:  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
    4:  *
    5:  * The contents of this file are subject to the Netscape Public License
    6:  * Version 1.1 (the "License"); you may not use this file except in
    7:  * compliance with the License. You may obtain a copy of the License at
    8:  * http://www.mozilla.org/NPL/
    9:  *
   10:  * Software distributed under the License is distributed on an "AS IS" basis,
   11:  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   12:  * for the specific language governing rights and limitations under the
   13:  * License.
   14:  *
   15:  * The Original Code is mozilla.org code.
   16:  *
   17:  * The Initial Developer of the Original Code is 
   18:  * Netscape Communications Corporation.
   19:  * Portions created by the Initial Developer are Copyright (C) 2002
   20:  * the Initial Developer. All Rights Reserved.
   21:  *
   22:  * Contributor(s):
   23:  *
   24:  * Alternatively, the contents of this file may be used under the terms of
   25:  * either the GNU General Public License Version 2 or later (the "GPL"), or 
   26:  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   27:  * in which case the provisions of the GPL or the LGPL are applicable instead
   28:  * of those above. If you wish to allow use of your version of this file only
   29:  * under the terms of either the GPL or the LGPL, and not to allow others to
   30:  * use your version of this file under the terms of the NPL, indicate your
   31:  * decision by deleting the provisions above and replace them with the notice
   32:  * and other provisions required by the GPL or the LGPL. If you do not delete
   33:  * the provisions above, a recipient may use your version of this file under
   34:  * the terms of any one of the NPL, the GPL or the LGPL.
   35:  *
   36:  * ***** END LICENSE BLOCK ***** */
   37: 
   38: #import "NSBrowserView.h"
   39: #include "BookmarksService.h"
   40: #include "nsIDocument.h"
   41: #include "nsIContent.h"
   42: #include "nsIAtom.h"
   43: #include "nsITextContent.h"
   44: #include "nsIDOMWindow.h"
   45: #include "nsIDOMHTMLDocument.h"
   46: #include "nsIDOMElement.h"
   47: #include "nsString.h"
   48: #include "nsIFile.h"
   49: #include "nsAppDirectoryServiceDefs.h"
   50: #include "nsIXMLHttpRequest.h"
   51: #include "nsIDOMSerializer.h"
   52: #include "nsNetUtil.h"
   53: #include "nsINamespaceManager.h"
   54: #include "nsIXBLService.h"
   55: #include "nsIWebBrowser.h"
   56: 
   57: @implementation BookmarksDataSource
   58: 
   59: -(id) init
   60: {
   61:     [super init];
   62:     mBookmarks = nsnull;
   63:     return self;
   64: }
   65: 
   66: -(void) dealloc
   67: {
   68:     [super dealloc];
   69: }
   70: 
   71: -(void) windowClosing
   72: {
   73:     if (mBookmarks) {
   74:         mBookmarks->RemoveObserver();
   75:         delete mBookmarks;
   76:     }
   77: }
   78: 
   79: -(void) ensureBookmarks
   80: {
   81:     if (mBookmarks)
   82:         return;
   83:     
   84:     mBookmarks = new BookmarksService(self);
   85:     mBookmarks->AddObserver();
   86:     
   87:     [mOutlineView setTarget: self];
   88:     [mOutlineView setDoubleAction: @selector(openBookmark:)];
   89:     [mOutlineView reloadData];
   90: }
   91: 
   92: -(IBAction)addBookmark:(id)aSender
   93: {
   94:     if (!mBookmarks)
   95:         return;
   96:     
   97:     nsCOMPtr<nsIContent> content;
   98:     int index = [mOutlineView selectedRow];
   99:    
  100:     if (index >= 0) {
  101:         BookmarkItem* item = [mOutlineView itemAtRow: index];
  102:         if ([mOutlineView isExpandable: item]) 
  103:             content = [item contentNode];
  104:     }
  105:     
  106:     if (!content)
  107:         mBookmarks->GetRootContent(getter_AddRefs(content));
  108:         
  109:     nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
  110:     nsCOMPtr<nsIDOMElement> elt;
  111:     domDoc->CreateElementNS(NS_LITERAL_STRING("http://chimera.mozdev.org/bookmarks"), 
  112:                             NS_LITERAL_STRING("bookmark"), 
  113:                             getter_AddRefs(elt));
  114:     
  115:     // Fetch the title of the current page and the URL.
  116:     nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView] getBrowserView] getWebBrowser]);
  117:     nsCOMPtr<nsIDOMWindow> window;
  118:     webBrowser->GetContentDOMWindow(getter_AddRefs(window));
  119:     nsCOMPtr<nsIDOMDocument> htmlDoc;
  120:     window->GetDocument(getter_AddRefs(htmlDoc));
  121:     nsCOMPtr<nsIDocument> pageDoc(do_QueryInterface(htmlDoc));
  122:     
  123:     nsAutoString href; 
  124:     if (pageDoc) {
  125:         nsCOMPtr<nsIURI> url;
  126:         pageDoc->GetDocumentURL(getter_AddRefs(url));
  127:         nsCAutoString spec;
  128:         url->GetSpec(spec);
  129:         href.AssignWithConversion(spec.get());
  130:     }
  131:     
  132:     nsAutoString title;
  133:     nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));
  134:     if (htmlDocument)
  135:         htmlDocument->GetTitle(title);
  136:     if (title.IsEmpty())
  137:         title = href;
  138:         
  139:     elt->SetAttribute(NS_LITERAL_STRING("name"), title);
  140:     elt->SetAttribute(NS_LITERAL_STRING("href"), href);    
  141:     
  142:     nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(content));
  143:     nsCOMPtr<nsIDOMNode> dummy;
  144:     parent->AppendChild(elt, getter_AddRefs(dummy));
  145: 
  146:     mBookmarks->NotifyObservers(content, PR_TRUE);
  147: }
  148: 
  149: -(IBAction)deleteBookmark: (id)aSender
  150: {
  151:     if (!mBookmarks)
  152:         return;
  153:     
  154:     int index = [mOutlineView selectedRow];
  155:     if (index == -1)
  156:         return;
  157:         
  158:     BookmarkItem* item = [mOutlineView itemAtRow: index];
  159:     nsCOMPtr<nsIContent> content = [item contentNode];
  160:     nsCOMPtr<nsIDOMElement> child(do_QueryInterface(content));
  161:     nsCOMPtr<nsIDOMNode> parent;
  162:     child->GetParentNode(getter_AddRefs(parent));
  163:     nsCOMPtr<nsIDOMNode> dummy;
  164:     parent->RemoveChild(child, getter_AddRefs(dummy));
  165:     nsCOMPtr<nsIContent> parentContent(do_QueryInterface(parent));
  166:     mBookmarks->NotifyObservers(parentContent, PR_TRUE);
  167:     
  168:     int total = [mOutlineView numberOfRows];
  169:     if (index == total)
  170:         index--;
  171:         
  172:     [mOutlineView selectRow: index byExtendingSelection: NO];
  173: }
  174: 
  175: -(IBAction)openBookmark: (id)aSender
  176: {
  177:     int index = [mOutlineView selectedRow];
  178:     if (index == -1)
  179:         return;
  180:     
  181:     id item = [mOutlineView itemAtRow: index];
  182:     if (!item)
  183:         return;
  184:         
  185:     if ([mOutlineView isExpandable: item]) {
  186:         if ([mOutlineView isItemExpanded: item])
  187:             [mOutlineView collapseItem: item];
  188:         else
  189:             [mOutlineView expandItem: item];
  190:     }
  191:     else {
  192:         nsIContent* content = [item contentNode];
  193:         nsAutoString href;
  194:         content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
  195:         if (!href.IsEmpty()) {
  196:             nsCAutoString cstr; cstr.AssignWithConversion(href);
  197:             NSString* url = [NSString stringWithCString: cstr.get()];
  198:             [[[mBrowserWindowController getMyBrowserView] getBrowserView] loadURI:[NSURL URLWithString: url] flags:NSLoadFlagsNone];
  199:         }
  200:     } 
  201: }
  202: 
  203: - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
  204: {
  205:     return NO;
  206: }
  207: 
  208: - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
  209: {
  210:     if (!mBookmarks)
  211:         return nil;
  212:        
  213:     nsCOMPtr<nsIContent> content;
  214:     if (!item)
  215:         mBookmarks->GetRootContent(getter_AddRefs(content));
  216:     else
  217:         content = [item contentNode];
  218:     
  219:     nsCOMPtr<nsIContent> child;
  220:     content->ChildAt(index, *getter_AddRefs(child));
  221:     return mBookmarks->GetWrapperFor(child);
  222: }
  223: 
  224: - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
  225: {
  226:     if (!mBookmarks)
  227:         return NO;
  228:     
  229:     if (!item)
  230:         return YES; // The root node is always open.
  231:     
  232:     nsCOMPtr<nsIAtom> tagName;
  233:     nsIContent* content = [item contentNode];
  234:     content->GetTag(*getter_AddRefs(tagName));
  235:     
  236:     return (tagName == BookmarksService::gFolderAtom);
  237: }
  238: 
  239: - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
  240: {
  241:     if (!mBookmarks)
  242:         return 0;
  243:   
  244:     nsCOMPtr<nsIContent> content;
  245:     if (!item)
  246:         mBookmarks->GetRootContent(getter_AddRefs(content));
  247:     else 
  248:         content = [item contentNode];
  249:     
  250:     PRInt32 childCount;
  251:     content->ChildCount(childCount);
  252:     
  253:     return childCount;
  254: }
  255: 
  256: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
  257: {
  258:     NSString 					*columnName = [tableColumn identifier];
  259:     NSMutableAttributedString 	*cellValue = [[NSMutableAttributedString alloc] init];
  260:     NSFileWrapper				*fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil];
  261:     NSTextAttachment			*textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
  262:     NSMutableAttributedString   *attachmentAttrString = nil;
  263:     NSCell 						*attachmentAttrStringCell;
  264: 
  265:     if ([columnName isEqualToString: @"name"]) {
  266:         nsIContent* content = [item contentNode];
  267:         nsAutoString nameAttr;
  268:         content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
  269:         nsCAutoString cStr; cStr.AssignWithConversion(nameAttr);
  270:         
  271:         //Set cell's textual contents
  272:         [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length])
  273:                                  withString:[NSString stringWithCString: cStr.get()]];
  274:         
  275:         //Create an attributed string to hold the empty attachment, then release the components.
  276:         attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
  277:         [textAttachment release];
  278:         [fileWrapper release];
  279: 
  280:         //Get the cell of the text attachment.
  281:         attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute:NSAttachmentAttributeName
  282:                                                                                           atIndex:0
  283:                                                                                    effectiveRange:nil] attachmentCell];
  284:         //Figure out which image to add, and set the cell's image.
  285:         if ( [self outlineView:outlineView isItemExpandable:item] ) {
  286:             [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]];
  287:         } else {
  288:             [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallbookmark"]];
  289:         }
  290:         //Insert the image
  291:         [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString];
  292:         
  293:         //Tweak the baseline to vertically center the text.
  294:         [cellValue addAttribute:NSBaselineOffsetAttributeName
  295:                           value:[NSNumber numberWithFloat:-3.0]
  296:                           range:NSMakeRange(0, 1)];
  297:     }
  298:     return cellValue;
  299: }
  300: 
  301: - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
  302: {
  303: }
  304: 
  305: - (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren
  306: {
  307:     printf("Reloading?\n");
  308:     if (!item)
  309:         [mOutlineView reloadData];
  310:     else if ([mOutlineView isItemExpanded: item])
  311:         [mOutlineView reloadItem: item reloadChildren: aReloadChildren];
  312: }
  313: 
  314: @end
  315: 
  316: @implementation BookmarkItem
  317: -(nsIContent*)contentNode
  318: {
  319:     return mContentNode;
  320: }
  321: 
  322: -(void)setContentNode: (nsIContent*)aContentNode
  323: {
  324:     mContentNode = aContentNode;
  325: }
  326: 
  327: - (id)copyWithZone:(NSZone *)aZone
  328: {
  329:     BookmarkItem* copy = [[[self class] allocWithZone: aZone] init];
  330:     [copy setContentNode: mContentNode];
  331:     return copy;
  332: }
  333: 
  334: @end
  335: 
  336: // Helper for stripping whitespace
  337: static void
  338: StripWhitespaceNodes(nsIContent* aElement)
  339: {
  340:     PRInt32 childCount;
  341:     aElement->ChildCount(childCount);
  342:     for (PRInt32 i = 0; i < childCount; i++) {
  343:         nsCOMPtr<nsIContent> child;
  344:         aElement->ChildAt(i, *getter_AddRefs(child));
  345:         nsCOMPtr<nsITextContent> text = do_QueryInterface(child);
  346:         if (text) {
  347:             PRBool isEmpty;
  348:             text->IsOnlyWhitespace(&isEmpty);
  349:             if (isEmpty) {
  350:                 // This node contained nothing but whitespace.
  351:                 // Remove it from the content model.
  352:                 aElement->RemoveChildAt(i, PR_TRUE);
  353:                 i--; // Decrement our count, since we just removed this child.
  354:                 childCount--; // Also decrement our total count.
  355:             }
  356:         }
  357:         else StripWhitespaceNodes(child);
  358:     }
  359: }
  360: 
  361: PRUint32 BookmarksService::gRefCnt = 0;
  362: nsIDocument* BookmarksService::gBookmarks = nsnull;
  363: NSMutableDictionary* BookmarksService::gDictionary = nil;
  364: MainController* BookmarksService::gMainController = nil;
  365: nsIAtom* BookmarksService::gFolderAtom = nsnull;
  366: nsIAtom* BookmarksService::gBookmarkAtom = nsnull;
  367: nsIAtom* BookmarksService::gHrefAtom = nsnull;
  368: nsIAtom* BookmarksService::gNameAtom = nsnull;
  369: nsVoidArray* BookmarksService::gInstances = nsnull;
  370: 
  371: BookmarksService::BookmarksService(BookmarksDataSource* aDataSource)
  372: {
  373:     mDataSource = aDataSource;
  374: }
  375: 
  376: BookmarksService::~BookmarksService()
  377: {
  378: }
  379: 
  380: void
  381: BookmarksService::GetRootContent(nsIContent** aResult)
  382: {
  383:     *aResult = nsnull;
  384:     if (gBookmarks) {
  385:         nsCOMPtr<nsIDOMElement> elt;
  386:         nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(gBookmarks));
  387:         domDoc->GetDocumentElement(getter_AddRefs(elt));
  388:         elt->QueryInterface(NS_GET_IID(nsIContent), (void**)aResult); // Addref happens here.
  389:     }
  390: }
  391: 
  392: BookmarkItem*
  393: BookmarksService::GetWrapperFor(nsIContent* aContent)
  394: {
  395:     if (!gDictionary)
  396:         gDictionary = [[NSMutableDictionary alloc] initWithCapacity: 30];
  397:     
  398:     PRUint32 contentID;
  399:     aContent->GetContentID(&contentID);
  400:     
  401:     BookmarkItem* item = [gDictionary objectForKey: [NSNumber numberWithInt: contentID]];
  402:     if (item)
  403:         return item;
  404:     else {
  405:         // Create an item.
  406:         item = [[[BookmarkItem alloc] init] autorelease]; // The dictionary retains us.
  407:         [item setContentNode: aContent];
  408:         [gDictionary setObject: item forKey: [NSNumber numberWithInt: contentID]];
  409:     }
  410:     return item;
  411: }
  412: 
  413: void
  414: BookmarksService::NotifyObservers(nsIContent* aContainer, PRBool aReloadChildren)
  415: {
  416:     if (!gInstances)
  417:         return;
  418:     
  419:     PRInt32 count = gInstances->Count();
  420:     for (PRInt32 i = 0; i < count; i++) {
  421:         BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
  422:         instance->NotifyObserver(aContainer, aReloadChildren);
  423:     }
  424:     
  425:     FlushBookmarks();
  426: }
  427: 
  428: 
  429: void
  430: BookmarksService::NotifyObserver(nsIContent* aContainer, PRBool aReloadChildren)
  431: {
  432:     if (!gDictionary)
  433:         return;
  434:    
  435:     nsCOMPtr<nsIContent> parent;
  436:     aContainer->GetParent(*getter_AddRefs(parent));
  437:     
  438:     BookmarkItem* item = nil;
  439:     if (parent)
  440:         // We're not the root.
  441:         item = GetWrapperFor(aContainer);
  442:     
  443:     [mDataSource reloadDataForItem: item reloadChildren: aReloadChildren];
  444: }
  445: 
  446: void
  447: BookmarksService::AddObserver()
  448: {
  449:     gRefCnt++;
  450:     if (gRefCnt == 1) {
  451:         gBookmarkAtom = NS_NewAtom("bookmark");
  452:         gFolderAtom = NS_NewAtom("folder");
  453:         gNameAtom = NS_NewAtom("name");
  454:         gHrefAtom = NS_NewAtom("href");
  455:         gInstances = new nsVoidArray();
  456:                 
  457:         nsCOMPtr<nsIFile> profileDir;
  458:         NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
  459:         profileDir->Append("bookmarks.xml");
  460:     
  461:         nsCAutoString bookmarksFileURL;
  462:         NS_GetURLSpecFromFile(profileDir, bookmarksFileURL);
  463:         
  464:         nsCOMPtr<nsIURI> uri;
  465:         NS_NewURI(getter_AddRefs(uri), bookmarksFileURL.get());
  466:     
  467:         nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));    
  468:         xblService->FetchSyncXMLDocument(uri, &gBookmarks); // The addref is here.
  469:         
  470:         nsCOMPtr<nsIContent> rootNode;
  471:         GetRootContent(getter_AddRefs(rootNode));
  472:         StripWhitespaceNodes(rootNode);
  473:     }
  474:     
  475:     gInstances->AppendElement(this);
  476: }
  477: 
  478: void
  479: BookmarksService::RemoveObserver()
  480: {
  481:     if (gRefCnt == 0)
  482:         return;
  483:  
  484:     gInstances->RemoveElement(this);
  485:      
  486:     gRefCnt--;
  487:     if (gRefCnt == 0) {
  488:         NS_IF_RELEASE(gBookmarks);
  489:         NS_RELEASE(gBookmarkAtom);
  490:         NS_RELEASE(gFolderAtom);
  491:         NS_RELEASE(gNameAtom);
  492:         NS_RELEASE(gHrefAtom);
  493:         [gDictionary release];
  494:     }
  495: }
  496: 
  497: void
  498: BookmarksService::FlushBookmarks()
  499: {
  500:     nsCOMPtr<nsIFile> bookmarksFile;
  501:     NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(bookmarksFile));
  502:     bookmarksFile->Append("bookmarks.xml");
  503: 
  504:     nsCOMPtr<nsIOutputStream> outputStream;
  505:     NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), bookmarksFile);
  506: 
  507:     nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(gBookmarks));
  508:     
  509:     nsCOMPtr<nsIDOMSerializer> domSerializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));
  510:     domSerializer->SerializeToStream(domDoc, outputStream, nsnull);
  511: }
  512: 
  513: void
  514: BookmarksService::ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent)
  515: {
  516:     nsCOMPtr<nsIContent> content = aContent;
  517:     if (!content) {
  518:         GetRootContent(getter_AddRefs(content));
  519:         GetWrapperFor(content);
  520:     }
  521:     
  522:     // Now walk our children, and for folders also recur into them.
  523:     PRInt32 childCount;
  524:     content->ChildCount(childCount);
  525:     
  526:     for (PRInt32 i = 0; i < childCount; i++) {
  527:         nsCOMPtr<nsIContent> child;
  528:         content->ChildAt(i, *getter_AddRefs(child));
  529:         
  530:         // Obtain our name attribute.
  531:         nsAutoString name;
  532:         child->GetAttr(kNameSpaceID_None, gNameAtom, name);
  533:         nsCAutoString nameCStr; nameCStr.AssignWithConversion(name);
  534:         NSString* title = [NSString stringWithCString: nameCStr.get()];
  535:                 
  536:         // Create a menu or menu item for the child.
  537:         NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
  538:         GetWrapperFor(child);
  539:         [aMenu addItem: menuItem];
  540:         
  541:         nsCOMPtr<nsIAtom> tag;
  542:         child->GetTag(*getter_AddRefs(tag));
  543:         
  544:         if (tag == gFolderAtom) {
  545:             NSMenu* menu = [[[NSMenu alloc] initWithTitle: title] autorelease];
  546:             [aMenu setSubmenu: menu forItem: menuItem];
  547:             [menu setAutoenablesItems: NO];
  548:             ConstructBookmarksMenu(menu, child);
  549:         }
  550:         else {
  551:             [menuItem setTarget: gMainController];
  552:             [menuItem setAction: @selector(openMenuBookmark:)];
  553:         }
  554:         
  555:         PRUint32 contentID;
  556:         child->GetContentID(&contentID);
  557:         [menuItem setTag: contentID];
  558:     }
  559: }
  560: 
  561: void 
  562: BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem)
  563: {
  564:     // Get the corresponding bookmark item.
  565:     BookmarkItem* item = [gDictionary objectForKey: [NSNumber numberWithInt: [aMenuItem tag]]];
  566:         
  567:     // Get the content node.
  568:     nsIContent* content = [item contentNode];
  569:         
  570:     // Get the href attribute.  This is the URL we want to load.
  571:     nsAutoString href;
  572:     content->GetAttr(kNameSpaceID_None, gHrefAtom, href);
  573:     nsCAutoString cref; cref.AssignWithConversion(href);
  574:     if (cref.IsEmpty())
  575:         return;
  576:         
  577:     NSString* url = [NSString stringWithCString: cref.get()];
  578:     
  579:     // Now load the URL in the window.
  580:     [aController loadURL:[NSURL URLWithString: url]];
  581: }

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