diff --git a/mozilla/camino/Camino.xcode/project.pbxproj b/mozilla/camino/Camino.xcode/project.pbxproj index d460e5c6c71..1b66450a959 100644 --- a/mozilla/camino/Camino.xcode/project.pbxproj +++ b/mozilla/camino/Camino.xcode/project.pbxproj @@ -1379,6 +1379,26 @@ settings = { }; }; + 0FB6D99A089B276100414498 = { + isa = PBXFileReference; + lastKnownFileType = image.tiff; + name = bm_favicon.tiff; + path = chrome/bm_favicon.tiff; + refType = 4; + sourceTree = ""; + }; + 0FB6D99B089B276100414498 = { + fileRef = 0FB6D99A089B276100414498; + isa = PBXBuildFile; + settings = { + }; + }; + 0FB6D99C089B276100414498 = { + fileRef = 0FB6D99A089B276100414498; + isa = PBXBuildFile; + settings = { + }; + }; 0FBC0EC90798F92600E8E0E2 = { children = ( 0FBC0ECA0798F92600E8E0E2, @@ -3214,6 +3234,7 @@ 3FBDC8E00827C44B00D7F8E0, 3FFE23530847CB0D00D6CAFC, 0F5187C408858E620091F3FB, + 0FB6D99B089B276100414498, ); isa = PBXResourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -7064,6 +7085,7 @@ 3FBDC86208253C8C00D7F8E0, 3FBDC8E10827C44B00D7F8E0, 3FFE23540847CB0D00D6CAFC, + 0FB6D99C089B276100414498, ); isa = PBXResourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -12763,6 +12785,7 @@ 0FFE0A7E079B147F00966027, 0FFE0A7F079B147F00966027, 0FFE0A80079B147F00966027, + 0FB6D99A089B276100414498, ); isa = PBXGroup; name = images; diff --git a/mozilla/camino/resources/images/chrome/bm_favicon.tiff b/mozilla/camino/resources/images/chrome/bm_favicon.tiff new file mode 100644 index 00000000000..c5b01056765 Binary files /dev/null and b/mozilla/camino/resources/images/chrome/bm_favicon.tiff differ diff --git a/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/classes.nib b/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/classes.nib index 2606c3809ef..3cca3143bce 100644 --- a/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/classes.nib +++ b/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/classes.nib @@ -10,11 +10,16 @@ addBookmarkFolder = id; addBookmarkSeparator = id; addCollection = id; + copy = id; + cut = id; + delete = id; deleteBookmarks = id; locateBookmark = id; openBookmark = id; openBookmarkInNewTab = id; openBookmarkInNewWindow = id; + openBookmarksInTabsInNewWindow = id; + paste = id; quicksearchPopupChanged = id; setAsDockMenuFolder = id; showBookmarkInfo = id; @@ -27,7 +32,7 @@ mActionMenuHistory = NSMenu; mAddButton = NSButton; mAddCollectionButton = NSButton; - mBookmarksEditingView = NSView; + mBookmarksEditingView = BookmarksEditingView; mBookmarksHostView = NSView; mBookmarksOutlineView = BookmarkOutlineView; mContainersSplit = NSSplitView; diff --git a/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/info.nib b/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/info.nib index 418454f4772..95401ec5253 100644 --- a/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/info.nib +++ b/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/info.nib @@ -17,7 +17,7 @@ 18 476 439 606 458 0 0 1600 1002 253 - 555 448 454 439 0 0 1600 1002 + 552 448 454 439 0 0 1600 1002 261 551 476 457 383 0 0 1600 1002 302 @@ -30,8 +30,8 @@ 206 320 138 68 0 0 1600 1002 IBFramework Version - 364.0 + 437.0 IBSystem Version - 7W98 + 8C46 diff --git a/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/keyedobjects.nib b/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/keyedobjects.nib index 0538ba18f97..eb56cfd7f64 100644 Binary files a/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/keyedobjects.nib and b/mozilla/camino/resources/localized/English.lproj/BookmarksEditing.nib/keyedobjects.nib differ diff --git a/mozilla/camino/resources/localized/English.lproj/Localizable.strings b/mozilla/camino/resources/localized/English.lproj/Localizable.strings index 18347a09de5..dac8a102325 100644 Binary files a/mozilla/camino/resources/localized/English.lproj/Localizable.strings and b/mozilla/camino/resources/localized/English.lproj/Localizable.strings differ diff --git a/mozilla/camino/src/application/AppComponents.mm b/mozilla/camino/src/application/AppComponents.mm index f305b053b9f..5437afaf15b 100644 --- a/mozilla/camino/src/application/AppComponents.mm +++ b/mozilla/camino/src/application/AppComponents.mm @@ -186,13 +186,13 @@ static const nsModuleComponentInfo gAppComponents[] = { "About Bookmarks Module", NS_ABOUT_BOOKMARKS_MODULE_CID, NS_ABOUT_MODULE_CONTRACTID_PREFIX "bookmarks", - nsAboutBookmarks::Create, + nsAboutBookmarks::CreateBookmarks, }, { "About Bookmarks Module", NS_ABOUT_BOOKMARKS_MODULE_CID, NS_ABOUT_MODULE_CONTRACTID_PREFIX "history", - nsAboutBookmarks::Create, + nsAboutBookmarks::CreateHistory, } }; diff --git a/mozilla/camino/src/application/MainController.mm b/mozilla/camino/src/application/MainController.mm index b578d0faa68..bcc611847c4 100644 --- a/mozilla/camino/src/application/MainController.mm +++ b/mozilla/camino/src/application/MainController.mm @@ -66,6 +66,7 @@ #import "FindDlgController.h" #import "PreferenceManager.h" #import "SharedMenusObj.h" +#import "SiteIconProvider.h" #include "nsBuildID.h" #include "nsCOMPtr.h" @@ -284,6 +285,11 @@ const int kReuseWindowOnAE = 2; // and fire up bookmarks (they will be loaded on a thread) [[BookmarkManager sharedBookmarkManager] loadBookmarksLoadingSynchronously:NO]; + // register some special favicon images + [[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"smallDocument"] forPageURI:@"about:blank"]; + [[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"bm_favicon"] forPageURI:@"about:bookmarks"]; + [[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"bm_favicon"] forPageURI:@"about:history"]; + [self setupStartpage]; // Initialize offline mode. @@ -1367,9 +1373,7 @@ Otherwise, we return the URL we originally got. Right now this supports .url and if (action == @selector(sendURL:)) { - NSString* titleString = nil; - NSString* urlString = nil; - [[[self getMainWindowBrowserController] getBrowserWrapper] getTitle:&titleString andHref:&urlString]; + NSString* urlString = [[[self getMainWindowBrowserController] getBrowserWrapper] location]; return ![MainController isBlankURL:urlString]; } diff --git a/mozilla/camino/src/bookmarks/AddBookmarkDialogController.mm b/mozilla/camino/src/bookmarks/AddBookmarkDialogController.mm index b7b29e09c56..f0b9f2704de 100644 --- a/mozilla/camino/src/bookmarks/AddBookmarkDialogController.mm +++ b/mozilla/camino/src/bookmarks/AddBookmarkDialogController.mm @@ -213,7 +213,7 @@ NSString* const kAddBookmarkItemPrimaryTabKey = @"primary"; if (initialItemIndex != -1) [mParentFolderPopup selectItemAtIndex:initialItemIndex]; } - else + else if ([mParentFolderPopup numberOfItems] > 0) { [mParentFolderPopup selectItemAtIndex:0]; } diff --git a/mozilla/camino/src/bookmarks/Bookmark.h b/mozilla/camino/src/bookmarks/Bookmark.h index 5970f1006e1..959dacf222c 100644 --- a/mozilla/camino/src/bookmarks/Bookmark.h +++ b/mozilla/camino/src/bookmarks/Bookmark.h @@ -63,4 +63,10 @@ -(void) setIsSeparator:(BOOL)aSeparatorFlag; -(void) setNumberOfVisits:(unsigned)aNumber; +// methods used for saving to files; are guaranteed never to return nil +- (id)savedURL; +- (id)savedLastVisit; +- (id)savedStatus; +- (id)savedNumberOfVisits; + @end diff --git a/mozilla/camino/src/bookmarks/Bookmark.mm b/mozilla/camino/src/bookmarks/Bookmark.mm index 7806da57f66..b9613b85fd5 100644 --- a/mozilla/camino/src/bookmarks/Bookmark.mm +++ b/mozilla/camino/src/bookmarks/Bookmark.mm @@ -47,8 +47,10 @@ #import "SiteIconProvider.h" @interface Bookmark (Private) --(void) siteIconCheck:(NSNotification *)aNote; --(void) urlLoadCheck:(NSNotification *)aNote; + +- (void)siteIconCheck:(NSNotification *)aNote; +- (void)urlLoadCheck:(NSNotification *)aNote; + @end // Notification of URL load @@ -61,8 +63,8 @@ NSString* const URLLoadSuccessKey = @"url_bool"; { if ((self = [super init])) { mURL = [[NSString alloc] init]; - mStatus = [[NSNumber alloc] initWithUnsignedInt:0]; // retain count +1 - mNumberOfVisits = [mStatus retain]; // retain count +2 + mStatus = [[NSNumber alloc] initWithUnsignedInt:kBookmarkOKStatus]; // retain count +1 + mNumberOfVisits = [[NSNumber alloc] initWithUnsignedInt:0]; // retain count +1 mLastVisit = [[NSDate date] retain]; mIcon = [[NSImage imageNamed:@"smallbookmark"] retain]; // register for notifications @@ -242,6 +244,29 @@ NSString* const URLLoadSuccessKey = @"url_bool"; return [super matchesString:searchString inFieldWithTag:tag]; } +#pragma mark - + +- (id)savedURL +{ + return mURL ? mURL : @""; +} + +- (id)savedLastVisit +{ + return mLastVisit ? mLastVisit : [NSDate distantPast]; +} + +- (id)savedStatus +{ + return mStatus ? mStatus : [NSNumber numberWithUnsignedInt:kBookmarkOKStatus]; +} + +- (id)savedNumberOfVisits +{ + return mNumberOfVisits ? mNumberOfVisits : [NSNumber numberWithUnsignedInt:0]; +} + + #pragma mark - // @@ -257,6 +282,7 @@ NSString* const URLLoadSuccessKey = @"url_bool"; [self setItemDescription:[aDict objectForKey:BMDescKey]]; [self setKeyword:[aDict objectForKey:BMKeywordKey]]; [self setUrl:[aDict objectForKey:BMURLKey]]; + [self setUUID:[aDict objectForKey:BMUUIDKey]]; [self setLastVisit:[aDict objectForKey:BMLastVisitKey]]; [self setNumberOfVisits:[[aDict objectForKey:BMNumberVisitsKey] unsignedIntValue]]; [self setStatus:[[aDict objectForKey:BMStatusKey] unsignedIntValue]]; @@ -324,9 +350,9 @@ NSString* const URLLoadSuccessKey = @"url_bool"; -(void)writeBookmarksMetadataToPath:(NSString*)inPath { NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys: - mTitle, @"Name", - mURL, @"URL", - nil]; + [self savedTitle], @"Name", + [self savedURL], @"URL", + nil]; NSString* file = [self UUID]; NSString* path = [NSString stringWithFormat:@"%@/%@.webbookmark", inPath, file]; [dict writeToFile:path atomically:YES]; @@ -351,18 +377,19 @@ NSString* const URLLoadSuccessKey = @"url_bool"; NSDictionary* dict; if (![self isSeparator]) { dict = [NSDictionary dictionaryWithObjectsAndKeys: - mTitle,BMTitleKey, - mKeyword,BMKeywordKey, - mURL,BMURLKey, - mDescription,BMDescKey , - mLastVisit,BMLastVisitKey, - mNumberOfVisits,BMNumberVisitsKey, - mStatus,BMStatusKey, - nil]; + [self savedTitle], BMTitleKey, + [self savedKeyword], BMKeywordKey, + [self savedURL], BMURLKey, + [self savedUUID], BMUUIDKey, + [self savedItemDescription], BMDescKey, + [self savedLastVisit], BMLastVisitKey, + [self savedNumberOfVisits], BMNumberVisitsKey, + [self savedStatus], BMStatusKey, + nil]; } else { dict = [NSDictionary dictionaryWithObjectsAndKeys: - mStatus,BMStatusKey, - nil]; + [self savedStatus], BMStatusKey, + nil]; } return dict; } @@ -372,19 +399,19 @@ NSString* const URLLoadSuccessKey = @"url_bool"; NSDictionary* dict = nil; if (![self isSeparator]) { NSDictionary *uriDict = [NSDictionary dictionaryWithObjectsAndKeys: - mTitle,SafariBookmarkTitleKey, - mURL,[NSString string], - nil]; + [self savedTitle], SafariBookmarkTitleKey, + [self savedURL], @"", + nil]; if (!uriDict) { - return nil; + return nil; // when would this happen? } dict = [NSDictionary dictionaryWithObjectsAndKeys: - uriDict,SafariURIDictKey, - mURL,SafariURLStringKey, - SafariLeaf,SafariTypeKey, - [self UUID],SafariUUIDKey, - nil]; + uriDict, SafariURIDictKey, + [self savedURL], SafariURLStringKey, + SafariLeaf, SafariTypeKey, + [self UUID], SafariUUIDKey, + nil]; } return dict; } diff --git a/mozilla/camino/src/bookmarks/BookmarkFolder.h b/mozilla/camino/src/bookmarks/BookmarkFolder.h index e0821bccf3a..b1acfa1134c 100644 --- a/mozilla/camino/src/bookmarks/BookmarkFolder.h +++ b/mozilla/camino/src/bookmarks/BookmarkFolder.h @@ -83,6 +83,9 @@ enum { -(unsigned)indexOfObject:(id)object; -(unsigned)indexOfObjectIdenticalTo:(id)object; +// methods used for saving to files; are guaranteed never to return nil +- (id)savedSpecialFlag; + // ways to add a new bookmark -(Bookmark *) addBookmark; //adds to end -(Bookmark *) addBookmark:(NSString *)aTitle url:(NSString *)aURL inPosition:(unsigned)aIndex isSeparator:(BOOL)aBool; @@ -123,6 +126,4 @@ enum { -(NSArray *) indicesOfObjectsByEvaluatingRelativeSpecifier:(NSRelativeSpecifier *)relSpec; -(NSArray *) indicesOfObjectsByEvaluatingRangeSpecifier:(NSRangeSpecifier *)rangeSpec; - - @end diff --git a/mozilla/camino/src/bookmarks/BookmarkFolder.mm b/mozilla/camino/src/bookmarks/BookmarkFolder.mm index 90e8063d265..159ecc5f41c 100644 --- a/mozilla/camino/src/bookmarks/BookmarkFolder.mm +++ b/mozilla/camino/src/bookmarks/BookmarkFolder.mm @@ -655,6 +655,11 @@ NSString* const BookmarkFolderDockMenuChangeNotificaton = @"bf_dmc"; return [mChildArray indexOfObjectIdenticalTo:object]; } +- (id)savedSpecialFlag +{ + return mSpecialFlag ? mSpecialFlag : [NSNumber numberWithUnsignedInt:kBookmarkFolder]; +} + // // build submenu // @@ -828,6 +833,7 @@ NSString* const BookmarkFolderDockMenuChangeNotificaton = @"bf_dmc"; [self setTitle:[aDict objectForKey:BMTitleKey]]; [self setItemDescription:[aDict objectForKey:BMFolderDescKey]]; [self setKeyword:[aDict objectForKey:BMFolderKeywordKey]]; + [self setUUID:[aDict objectForKey:BMUUIDKey]]; unsigned int flag = [[aDict objectForKey:BMFolderTypeKey] unsignedIntValue]; // on the off chance we've imported somebody else's bookmarks after startup, // we need to clear any super special flags on it. if we have a shared bookmark manager, @@ -965,11 +971,13 @@ NSString* const BookmarkFolderDockMenuChangeNotificaton = @"bf_dmc"; [children addObject:aDict]; } return [NSDictionary dictionaryWithObjectsAndKeys: - mTitle,BMTitleKey, - mDescription,BMFolderDescKey, - mKeyword,BMFolderKeywordKey, - mSpecialFlag,BMFolderTypeKey, - children,BMChildrenKey, nil]; + [self savedTitle], BMTitleKey, + [self savedItemDescription], BMFolderDescKey, + [self savedKeyword], BMFolderKeywordKey, + [self savedUUID], BMUUIDKey, + [self savedSpecialFlag], BMFolderTypeKey, + children, BMChildrenKey, + nil]; } return nil; } diff --git a/mozilla/camino/src/bookmarks/BookmarkItem.h b/mozilla/camino/src/bookmarks/BookmarkItem.h index 184151587f0..cae434ce8ec 100644 --- a/mozilla/camino/src/bookmarks/BookmarkItem.h +++ b/mozilla/camino/src/bookmarks/BookmarkItem.h @@ -65,6 +65,7 @@ -(void) setItemDescription:(NSString *)aString; -(void) setKeyword:(NSString *)aKeyword; -(void) setIcon:(NSImage *)aIcon; +-(void) setUUID:(NSString*)aUUID; // Status checks - (BOOL)isChildOfItem:(BookmarkItem *)anItem; @@ -104,6 +105,12 @@ enum -(NSDictionary *)writeSafariDictionary; -(NSString *)writeHTML:(unsigned)aPad; +// methods used for saving to files; are guaranteed never to return nil +- (id)savedTitle; +- (id)savedItemDescription; // don't use "description" +- (id)savedKeyword; +- (id)savedUUID; // does not generate a new UUID if UUID is not set + @end // Bunch of Keys for reading/writing dictionaries. @@ -119,6 +126,7 @@ extern NSString* const BMFolderKeywordKey; extern NSString* const BMDescKey; extern NSString* const BMStatusKey; extern NSString* const BMURLKey; +extern NSString* const BMUUIDKey; extern NSString* const BMKeywordKey; extern NSString* const BMLastVisitKey; extern NSString* const BMNumberVisitsKey; diff --git a/mozilla/camino/src/bookmarks/BookmarkItem.m b/mozilla/camino/src/bookmarks/BookmarkItem.m deleted file mode 100644 index a19d0487081..00000000000 --- a/mozilla/camino/src/bookmarks/BookmarkItem.m +++ /dev/null @@ -1,331 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * David Haas - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#import "BookmarkItem.h" - -// Notifications -NSString* const BookmarkItemChangedNotification = @"bi_cg"; -NSString* const BookmarkIconChangedNotification = @"bicon_cg"; - -// all our saving/loading keys -// Safari & Camino plist keys -NSString* const BMTitleKey = @"Title"; -NSString* const BMChildrenKey = @"Children"; - -// Camino plist keys -NSString* const BMFolderDescKey = @"FolderDescription"; -NSString* const BMFolderTypeKey = @"FolderType"; -NSString* const BMFolderKeywordKey = @"FolderKeyword"; -NSString* const BMDescKey = @"Description"; -NSString* const BMStatusKey = @"Status"; -NSString* const BMURLKey = @"URL"; -NSString* const BMKeywordKey = @"Keyword"; -NSString* const BMLastVisitKey = @"LastVisitedDate"; -NSString* const BMNumberVisitsKey = @"VisitCount"; - -// safari keys -NSString* const SafariTypeKey = @"WebBookmarkType"; -NSString* const SafariLeaf = @"WebBookmarkTypeLeaf"; -NSString* const SafariList = @"WebBookmarkTypeList"; -NSString* const SafariAutoTab = @"WebBookmarkAutoTab"; -NSString* const SafariUUIDKey = @"WebBookmarkUUID"; -NSString* const SafariURIDictKey = @"URIDictionary"; -NSString* const SafariBookmarkTitleKey = @"title"; -NSString* const SafariURLStringKey = @"URLString"; - -// camino XML keys -NSString* const CaminoNameKey = @"name"; -NSString* const CaminoDescKey = @"description"; -NSString* const CaminoTypeKey = @"type"; -NSString* const CaminoKeywordKey = @"id"; -NSString* const CaminoURLKey = @"href"; -NSString* const CaminoToolbarKey = @"toolbar"; -NSString* const CaminoDockMenuKey = @"dockmenu"; -NSString* const CaminoGroupKey = @"group"; -NSString* const CaminoBookmarkKey = @"bookmark"; -NSString* const CaminoFolderKey = @"folder"; -NSString* const CaminoTrueKey = @"true"; - - -@implementation BookmarkItem - -static BOOL gSuppressAllUpdates = NO; - -//Initialization --(id) init -{ - if ((self = [super init])) - { - mParent = NULL; - mTitle = [[NSString alloc] init]; //retain count +1 - mKeyword = [mTitle retain]; //retain count +2 - mDescription = [mTitle retain]; //retain count +3! and just 1 allocation. - mUUID = nil; - // if we set the icon here, we will get a memory leak. so don't. - // subclass will provide icon. - mIcon = NULL; - mAccumulateItemChangeUpdates = NO; - } - return self; -} - --(id) copyWithZone:(NSZone *)zone -{ - //descend from NSObject - so don't call super - id doppleganger = [[[self class] allocWithZone:zone] init]; - [doppleganger setTitle:[self title]]; - [doppleganger setDescription:[self description]]; - [doppleganger setKeyword:[self keyword]]; - [doppleganger setParent:[self parent]]; - [doppleganger setIcon:[self icon]]; - // do NOT copy the UUID. It wouldn't be "U" then, would it? - return doppleganger; -} - --(void)dealloc -{ - [mTitle release]; - [mDescription release]; - [mKeyword release]; - [mIcon release]; - [mUUID release]; - [super dealloc]; -} - - -// Basic properties --(id) parent -{ - return mParent; -} - --(NSString *) title -{ - return mTitle; -} - --(NSString *) description -{ - return mDescription; -} - --(NSString *) keyword -{ - return mKeyword; -} - -// if we ask for a UUID, it means we need -// one. So generate it if it doesn't exist. --(NSString *) UUID -{ - if (!mUUID) { - CFUUIDRef aUUID = CFUUIDCreate(kCFAllocatorDefault); - if (aUUID) { - mUUID =(NSString *)CFUUIDCreateString(kCFAllocatorDefault, aUUID); - CFRelease (aUUID); - } - } - return mUUID; -} - --(NSImage *)icon -{ - return mIcon; -} - --(BOOL) isChildOfItem:(BookmarkItem *)anItem -{ - if (![[self parent] isKindOfClass:[BookmarkItem class]]) - return NO; - if ([self parent] == anItem) - return YES; - return [[self parent] isChildOfItem:anItem]; -} - --(void) setParent:(id) aParent -{ - mParent = aParent; // no reference on the parent, so it better not disappear on us. -} - --(void) setTitle:(NSString *)aTitle -{ - if (!aTitle) - return; - [aTitle retain]; - [mTitle release]; - mTitle = aTitle; - [self itemUpdatedNote]; -} - --(void) setDescription:(NSString *)aDescription -{ - if (!aDescription) - return; - [aDescription retain]; - [mDescription release]; - mDescription = aDescription; -} - -- (void) setKeyword:(NSString *)aKeyword -{ - if (!aKeyword) - return; - [aKeyword retain]; - [mKeyword release]; - mKeyword = aKeyword; -} - --(void) setUUID:(NSString *)aUUID -{ - [aUUID retain]; - [mUUID release]; - mUUID = aUUID; -} - --(void) setIcon:(NSImage *)aIcon -{ - if (!aIcon) - return; - [aIcon retain]; - [mIcon release]; - mIcon = aIcon; - - if (![BookmarkItem allowNotifications]) return; - NSNotification *note = [NSNotification notificationWithName:BookmarkIconChangedNotification - object:self userInfo:nil]; - [[NSNotificationCenter defaultCenter] postNotification:note]; -} - --(BOOL)matchesString:(NSString*)searchString inFieldWithTag:(int)tag -{ - switch (tag) - { - case eBookmarksSearchFieldAll: - return (([[self title] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound) || - ([[self keyword] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound) || - ([[self description] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound)); - - case eBookmarksSearchFieldTitle: - return ([[self title] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound); - - // case eBookmarksSearchFieldURL: // Bookmark subclass has to check this - case eBookmarksSearchFieldKeyword: - return ([[self keyword] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound); - - case eBookmarksSearchFieldDescription: - return ([[self description] rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound); - } - - return NO; -} - - -// Prevents all NSNotification posting from any BookmarkItem. -// Useful for suppressing all the pointless notifications during load. -+(void) setSuppressAllUpdateNotifications:(BOOL)suppressUpdates -{ - gSuppressAllUpdates = suppressUpdates; -} - -+(BOOL) allowNotifications -{ - return !gSuppressAllUpdates; -} - -// Helps prevent spamming from itemUpdatedNote: -// calling with YES will prevent itemUpdatedNote from doing anything -// and calling with NO will restore itemUpdatedNote and then call it. --(void) setAccumulateUpdateNotifications:(BOOL)accumulateUpdates -{ - mAccumulateItemChangeUpdates = accumulateUpdates; - if (!mAccumulateItemChangeUpdates) - [self itemUpdatedNote]; //fire an update to cover the updates that weren't sent -} - --(void) itemUpdatedNote -{ - if (gSuppressAllUpdates || mAccumulateItemChangeUpdates) return; - - NSNotification *note = [NSNotification notificationWithName:BookmarkItemChangedNotification object:self userInfo:nil]; - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc postNotification:note]; -} - -// stub functions to avoid warning - --(void) refreshIcon -{ -} - -//Reading/writing to & from disk - all just stubs. - --(BOOL) readNativeDictionary:(NSDictionary *)aDict -{ - return NO; -} - --(BOOL) readSafariDictionary:(NSDictionary *)aDict -{ - return NO; -} - --(BOOL) readCaminoXML:(CFXMLTreeRef)aTreeRef -{ - return NO; -} - --(NSDictionary *)writeNativeDictionary -{ - return [NSDictionary dictionary]; -} - --(NSDictionary *)writeSafariDictionary -{ - return [NSDictionary dictionary]; -} - --(NSString *)writeHTML:(unsigned)aPad -{ - return [NSString string]; -} - - -@end - - - diff --git a/mozilla/camino/src/bookmarks/BookmarkItem.mm b/mozilla/camino/src/bookmarks/BookmarkItem.mm index 249542b920e..3ee4bc9cec2 100644 --- a/mozilla/camino/src/bookmarks/BookmarkItem.mm +++ b/mozilla/camino/src/bookmarks/BookmarkItem.mm @@ -57,6 +57,7 @@ NSString* const BMFolderKeywordKey = @"FolderKeyword"; NSString* const BMDescKey = @"Description"; NSString* const BMStatusKey = @"Status"; NSString* const BMURLKey = @"URL"; +NSString* const BMUUIDKey = @"UUID"; NSString* const BMKeywordKey = @"Keyword"; NSString* const BMLastVisitKey = @"LastVisitedDate"; NSString* const BMNumberVisitsKey = @"VisitCount"; @@ -94,14 +95,14 @@ static BOOL gSuppressAllUpdates = NO; { if ((self = [super init])) { - mParent = NULL; + mParent = nil; mTitle = [[NSString alloc] init]; //retain count +1 mKeyword = [mTitle retain]; //retain count +2 mDescription = [mTitle retain]; //retain count +3! and just 1 allocation. mUUID = nil; // if we set the icon here, we will get a memory leak. so don't. // subclass will provide icon. - mIcon = NULL; + mIcon = nil; mAccumulateItemChangeUpdates = NO; } return self; @@ -159,6 +160,8 @@ static BOOL gSuppressAllUpdates = NO; { if (!mUUID) mUUID = [[NSString stringWithUUID] retain]; + + NSAssert([mUUID length] > 0, @"Empty UUID"); return mUUID; } @@ -237,6 +240,17 @@ static BOOL gSuppressAllUpdates = NO; [[NSNotificationCenter defaultCenter] postNotification:note]; } +-(void) setUUID:(NSString*)aUUID +{ + // ignore nil or empty strings + if (!aUUID || [aUUID length] == 0) + return; + + [aUUID retain]; + [mUUID release]; + mUUID = aUUID; +} + -(BOOL)matchesString:(NSString*)searchString inFieldWithTag:(int)tag { switch (tag) @@ -340,6 +354,25 @@ static BOOL gSuppressAllUpdates = NO; return [NSString string]; } +- (id)savedTitle +{ + return mTitle ? mTitle : @""; +} + +- (id)savedItemDescription +{ + return mDescription ? mDescription : @""; +} + +- (id)savedKeyword +{ + return mKeyword ? mKeyword : @""; +} + +- (id)savedUUID +{ + return mUUID ? mUUID : @""; +} @end diff --git a/mozilla/camino/src/bookmarks/BookmarkManager.mm b/mozilla/camino/src/bookmarks/BookmarkManager.mm index e0b30f4bdce..85c6516c6d1 100644 --- a/mozilla/camino/src/bookmarks/BookmarkManager.mm +++ b/mozilla/camino/src/bookmarks/BookmarkManager.mm @@ -259,13 +259,14 @@ static unsigned gFirstUserCollection = 0; [nc addObserver:self selector:@selector(bookmarkChanged:) name:BookmarkItemChangedNotification object:nil]; [nc addObserver:self selector:@selector(writeBookmarks:) name:kWriteBookmarkNotification object:nil]; + // broadcast to everyone interested that we're loaded and ready for public consumption + [[NSNotificationCenter defaultCenter] postNotificationName:kBookmarkManagerStartedNotification object:nil]; + // pitch everything in the metadata cache and start over. Changes made from here will be incremental. It's // easier this way in case someone changed the bm plist directly, we know at startup we always have // the most up-to-date cache. [self writeBookmarksMetadataForSpotlight]; - // broadcast to everyone interested that we're loaded and ready for public consumption - [[NSNotificationCenter defaultCenter] postNotificationName:kBookmarkManagerStartedNotification object:nil]; } - (void)shutdown diff --git a/mozilla/camino/src/bookmarks/BookmarkViewController.h b/mozilla/camino/src/bookmarks/BookmarkViewController.h index 281716c4a52..0e772e3e61c 100644 --- a/mozilla/camino/src/bookmarks/BookmarkViewController.h +++ b/mozilla/camino/src/bookmarks/BookmarkViewController.h @@ -59,9 +59,21 @@ @class SearchTextField; + +// a simple view subclass that allows us to override viewDidMoveToWindow +@interface BookmarksEditingView : NSView +{ + id mDelegate; +} + +- (id)delegate; +- (void)setDelegate:(id)inDelegate; + +@end + @interface BookmarkViewController : NSObject { - IBOutlet NSView* mBookmarksEditingView; + IBOutlet BookmarksEditingView* mBookmarksEditingView; IBOutlet NSButton* mAddCollectionButton; diff --git a/mozilla/camino/src/bookmarks/BookmarkViewController.mm b/mozilla/camino/src/bookmarks/BookmarkViewController.mm index a9ba5d998f9..6458b83eb24 100644 --- a/mozilla/camino/src/bookmarks/BookmarkViewController.mm +++ b/mozilla/camino/src/bookmarks/BookmarkViewController.mm @@ -172,14 +172,11 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; - (void)dealloc { - // save the splitter width of the container view - float width = [mContainersSplit leftWidth]; - [[NSUserDefaults standardUserDefaults] setFloat: width forKey:USER_DEFAULTS_CONTAINER_SPLITTER_WIDTH]; + // we know this is still alive, because we release the last ref below + [mBookmarksEditingView setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; - [self saveExpandedStateDictionary]; - // balance the extra retains [mBookmarksHostView release]; [mHistoryHostView release]; @@ -217,6 +214,8 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; // called when our nib has loaded - (void)awakeFromNib { + [mBookmarksEditingView setDelegate:self]; + // retain views that we remove from the hierarchy [mBookmarksHostView retain]; [mHistoryHostView retain]; @@ -352,8 +351,6 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; [mBookmarksOutlineView setDoubleAction: @selector(openBookmark:)]; [mBookmarksOutlineView setDeleteAction: @selector(deleteBookmarks:)]; [mBookmarksOutlineView reloadData]; - - [self restoreFolderExpandedStates]; } } @@ -735,6 +732,11 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; float savedWidth = [[NSUserDefaults standardUserDefaults] floatForKey:USER_DEFAULTS_CONTAINER_SPLITTER_WIDTH]; if (savedWidth < kDefaultSplitWidth) savedWidth = kDefaultSplitWidth; + + float maxWidth = NSWidth([mBookmarksEditingView frame]) - 100; + if (savedWidth > maxWidth) + savedWidth = maxWidth; + [mContainersSplit setLeftWidth:savedWidth]; mSplittersRestored = YES; // needed first time only } @@ -872,9 +874,9 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; if ([item isKindOfClass:[BookmarkFolder class]]) { if ([self hasExpandedState:item]) - [mBookmarksOutlineView expandItem: item]; + [mBookmarksOutlineView expandItem:item]; else - [mBookmarksOutlineView collapseItem: item]; + [mBookmarksOutlineView collapseItem:item]; } curRow ++; } @@ -884,19 +886,17 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; { if (!mExpandedStates) { - // We can't save BM expanded states to user defaults, because we don't have a persisent per-bookmark ID. - // mExpandedStates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:kExpandedBookmarksStatesDefaultsKey] mutableCopy]; - // if (!mExpandedStates) - mExpandedStates = [[NSMutableDictionary alloc] initWithCapacity:20]; + mExpandedStates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:kExpandedBookmarksStatesDefaultsKey] mutableCopy]; + if (!mExpandedStates) + mExpandedStates = [[NSMutableDictionary alloc] initWithCapacity:20]; } return mExpandedStates; } - (void)saveExpandedStateDictionary { - // We can't save BM expanded states to user defaults, because we don't have a persisent per-bookmark ID. - // if (mExpandedStates) - // [[NSUserDefaults standardUserDefaults] setObject:mExpandedStates forKey:kExpandedBookmarksStatesDefaultsKey]; + if (mExpandedStates) + [[NSUserDefaults standardUserDefaults] setObject:mExpandedStates forKey:kExpandedBookmarksStatesDefaultsKey]; } -(void)pasteBookmarks:(NSPasteboard*)aPasteboard intoFolder:(BookmarkFolder *)dropFolder index:(int)index copying:(BOOL)isCopy @@ -1077,6 +1077,8 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; [mSortButton setMenu:mSortMenuHistory]; [mSearchField setPopupMenu:mQuickSearchMenuHistory]; [mSearchField selectPopupMenuItem:[[mSearchField popupMenu] itemWithTag:1]]; // select the "all" item + + [[mBookmarksEditingView window] setTitle:NSLocalizedString(@"HistoryWindowTitle", @"")]; } else { @@ -1105,6 +1107,8 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; [mSearchField setPopupMenu:mQuickSearchMenuBookmarks]; [mSearchField selectPopupMenuItem:[[mSearchField popupMenu] itemWithTag:1]]; // select the "all" item + [[mBookmarksEditingView window] setTitle:NSLocalizedString(@"BookmarksWindowTitle", @"")]; + // this reload ensures that we display the newly selected activeCollection [mBookmarksOutlineView reloadData]; } @@ -1801,6 +1805,21 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; [self reloadDataForItem:[note object] reloadChildren:NO]; } +- (void)bookmarksViewDidMoveToWindow:(NSWindow*)inWindow +{ + // we're leaving the window, so... + if (!inWindow) + { + // save the splitter width + float containerWidth = [mContainersSplit leftWidth]; + [[NSUserDefaults standardUserDefaults] setFloat:containerWidth forKey:USER_DEFAULTS_CONTAINER_SPLITTER_WIDTH]; + + // save the expanded state + [self saveExpandedStateDictionary]; + } + +} + #pragma mark - // @@ -1822,6 +1841,10 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; return proposedCoord; } +- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification +{ +} + #pragma mark - @@ -1846,5 +1869,35 @@ static const int kDisabledQuicksearchPopupItemTag = 9999; return mBookmarksEditingView; } +- (void)contentView:(NSView*)inView usedForURL:(NSString*)inURL +{ + if (inView == mBookmarksEditingView) + { + [self focus]; + } +} + +@end + +#pragma mark - + +@implementation BookmarksEditingView + +- (id)delegate +{ + return mDelegate; +} + +- (void)setDelegate:(id)inDelegate +{ + mDelegate = inDelegate; +} + +- (void)viewDidMoveToWindow +{ + if ([mDelegate respondsToSelector:@selector(bookmarksViewDidMoveToWindow:)]) + [mDelegate bookmarksViewDidMoveToWindow:[self window]]; +} + @end diff --git a/mozilla/camino/src/bookmarks/nsAboutBookmarks.h b/mozilla/camino/src/bookmarks/nsAboutBookmarks.h index 8cc4a9b4efa..5d315f19985 100644 --- a/mozilla/camino/src/bookmarks/nsAboutBookmarks.h +++ b/mozilla/camino/src/bookmarks/nsAboutBookmarks.h @@ -47,13 +47,15 @@ public: NS_DECL_NSIABOUTMODULE - nsAboutBookmarks() {} + nsAboutBookmarks(PRBool inIsBookmarks); virtual ~nsAboutBookmarks() {} - static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); + static NS_METHOD CreateBookmarks(nsISupports *aOuter, REFNSIID aIID, void **aResult); + static NS_METHOD CreateHistory(nsISupports *aOuter, REFNSIID aIID, void **aResult); protected: + PRBool mIsBookmarks; // or history }; #define NS_ABOUT_BOOKMARKS_MODULE_CID \ diff --git a/mozilla/camino/src/bookmarks/nsAboutBookmarks.mm b/mozilla/camino/src/bookmarks/nsAboutBookmarks.mm index b0fa9515138..1c8c3d7ce76 100644 --- a/mozilla/camino/src/bookmarks/nsAboutBookmarks.mm +++ b/mozilla/camino/src/bookmarks/nsAboutBookmarks.mm @@ -43,8 +43,15 @@ #include "nsIStringStream.h" #include "nsNetUtil.h" +#import "NSString+Utils.h" + NS_IMPL_ISUPPORTS1(nsAboutBookmarks, nsIAboutModule) +nsAboutBookmarks::nsAboutBookmarks(PRBool inIsBookmarks) +: mIsBookmarks(inIsBookmarks) +{ +} + NS_IMETHODIMP nsAboutBookmarks::NewChannel(nsIURI *aURI, nsIChannel **result) { @@ -53,13 +60,18 @@ nsAboutBookmarks::NewChannel(nsIURI *aURI, nsIChannel **result) nsresult rv; nsIChannel* channel; + NSString* windowTitle = mIsBookmarks ? NSLocalizedString(@"BookmarksWindowTitle", @"") + : NSLocalizedString(@"HistoryWindowTitle", @""); + + NSString* sourceString = [NSString stringWithFormat:kBlankPageHTML, windowTitle]; + nsAutoString pageSource; + [sourceString assignTo_nsAString:pageSource]; + nsCOMPtr in; - NSString* localizedBlank = [NSString stringWithFormat:kBlankPageHTML, NSLocalizedString(@"Bookmarks",nil)]; - rv = NS_NewCStringInputStream(getter_AddRefs(in), nsDependentCString([localizedBlank UTF8String])); + rv = NS_NewStringInputStream(getter_AddRefs(in), pageSource); if (NS_FAILED(rv)) return rv; - rv = NS_NewInputStreamChannel(&channel, aURI, in, - NS_LITERAL_CSTRING("text/html")); + rv = NS_NewInputStreamChannel(&channel, aURI, in, NS_LITERAL_CSTRING("text/html")); if (NS_FAILED(rv)) return rv; *result = channel; @@ -67,9 +79,21 @@ nsAboutBookmarks::NewChannel(nsIURI *aURI, nsIChannel **result) } NS_METHOD -nsAboutBookmarks::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) +nsAboutBookmarks::CreateBookmarks(nsISupports *aOuter, REFNSIID aIID, void **aResult) { - nsAboutBookmarks* about = new nsAboutBookmarks(); + nsAboutBookmarks* about = new nsAboutBookmarks(PR_TRUE); + if (about == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(about); + nsresult rv = about->QueryInterface(aIID, aResult); + NS_RELEASE(about); + return rv; +} + +NS_METHOD +nsAboutBookmarks::CreateHistory(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + nsAboutBookmarks* about = new nsAboutBookmarks(PR_FALSE); if (about == nsnull) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(about); diff --git a/mozilla/camino/src/browser/AutoCompleteTextField.mm b/mozilla/camino/src/browser/AutoCompleteTextField.mm index bf99b5e1c36..0e56d2345df 100644 --- a/mozilla/camino/src/browser/AutoCompleteTextField.mm +++ b/mozilla/camino/src/browser/AutoCompleteTextField.mm @@ -602,7 +602,7 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) - (void) revertText { BrowserWindowController *controller = (BrowserWindowController *)[[self window] windowController]; - NSString *url = [[controller getBrowserWrapper] getCurrentURLSpec]; + NSString *url = [[controller getBrowserWrapper] getCurrentURI]; if (url) { [self clearResults]; NSTextView *fieldEditor = [self fieldEditor]; diff --git a/mozilla/camino/src/browser/BrowserTabViewItem.mm b/mozilla/camino/src/browser/BrowserTabViewItem.mm index ef0b03b41f1..83c92ddd671 100644 --- a/mozilla/camino/src/browser/BrowserTabViewItem.mm +++ b/mozilla/camino/src/browser/BrowserTabViewItem.mm @@ -271,7 +271,7 @@ const int kMenuTruncationChars = 60; CHBrowserView* browserView = (CHBrowserView*)[mTabViewItem view]; - NSString *url = [browserView getCurrentURLSpec]; + NSString *url = [browserView getCurrentURI]; NSString *title = [mLabelCell stringValue]; NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "]; diff --git a/mozilla/camino/src/browser/BrowserWindowController.mm b/mozilla/camino/src/browser/BrowserWindowController.mm index 4eb1df47be4..49e8e825a7e 100644 --- a/mozilla/camino/src/browser/BrowserWindowController.mm +++ b/mozilla/camino/src/browser/BrowserWindowController.mm @@ -1207,7 +1207,7 @@ enum BWCOpenDest { return ([mTabBrowser numberOfTabViewItems] > 1); else if (action == @selector(sendURL:)) { - NSString* curURL = [[self getBrowserWrapper] getCurrentURLSpec]; + NSString* curURL = [[self getBrowserWrapper] getCurrentURI]; return ![MainController isBlankURL:curURL]; } else if (action == @selector(viewSource:)) @@ -1659,7 +1659,7 @@ enum BWCOpenDest { - (IBAction)viewPageSource:(id)aSender { - NSString* urlStr = [[mBrowserView getBrowserView] getCurrentURLSpec]; + NSString* urlStr = [[mBrowserView getBrowserView] getCurrentURI]; [self loadSourceOfURL:urlStr]; } @@ -1692,7 +1692,7 @@ enum BWCOpenDest { NSMutableString *searchURL = [NSMutableString stringWithString: [[BrowserWindowController searchURLDictionary] objectForKey: [inSearchField titleOfSelectedPopUpItem]]]; - NSString *currentURL = [[self getBrowserWrapper] getCurrentURLSpec]; + NSString *currentURL = [[self getBrowserWrapper] getCurrentURI]; NSString *searchString = [inSearchField stringValue]; const char *aURLSpec = [currentURL lossyCString]; @@ -1733,7 +1733,7 @@ enum BWCOpenDest { } } else { - aURLSpec = [[[self getBrowserWrapper] getCurrentURLSpec] lossyCString]; + aURLSpec = [[[self getBrowserWrapper] getCurrentURI] UTF8String]; // Get the domain so that we can replace %d in our searchURL if (NS_NewURI(&aURI, aURLSpec, nsnull, nsnull) == NS_OK) { @@ -1911,7 +1911,7 @@ enum BWCOpenDest { - (BOOL)bookmarkManagerIsVisible { - NSString* currentURL = [[[self getBrowserWrapper] getCurrentURLSpec] lowercaseString]; + NSString* currentURL = [[[self getBrowserWrapper] getCurrentURI] lowercaseString]; return [currentURL isEqualToString:@"about:bookmarks"] || [currentURL isEqualToString:@"about:history"]; } @@ -2486,7 +2486,7 @@ enum BWCOpenDest { BrowserTabViewItem* tabViewItem = [mTabBrowser itemWithTag:[sender tag]]; if (tabViewItem) { - NSString* url = [[tabViewItem view] getCurrentURLSpec]; + NSString* url = [[tabViewItem view] getCurrentURI]; BOOL backgroundLoad = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL]; [self openNewWindowWithURL:url referrer:nil loadInBackground:backgroundLoad allowPopups:NO]; @@ -3343,7 +3343,7 @@ enum BWCOpenDest { // kill any autocomplete that was in progress [mURLBar revertText]; // set the text in the URL bar back to the current URL - [self updateLocationFields:[mBrowserView getCurrentURLSpec] ignoreTyping:YES]; + [self updateLocationFields:[mBrowserView getCurrentURI] ignoreTyping:YES]; // see if command-return came in the search field } else if ([mSearchBar isFirstResponder]) { diff --git a/mozilla/camino/src/browser/BrowserWrapper.h b/mozilla/camino/src/browser/BrowserWrapper.h index 826a52f7b07..b3d3ff3e613 100644 --- a/mozilla/camino/src/browser/BrowserWrapper.h +++ b/mozilla/camino/src/browser/BrowserWrapper.h @@ -81,7 +81,11 @@ class nsISupportsArray; // @protocol ContentViewProvider +// supply a view for the given url, or return nil to ignore this request - (NSView*)provideContentViewForURL:(NSString*)inURL; +// notification that the given view from this provider has been inserted +// for the given url +- (void)contentView:(NSView*)inView usedForURL:(NSString*)inURL; @end @@ -160,6 +164,7 @@ class nsISupportsArray; - (BOOL)isEmpty; // is about:blank loaded? - (NSString*)windowTitle; +- (NSString*)pageTitle; - (NSImage*)siteIcon; - (NSString*)location; - (NSString*)statusString; @@ -167,7 +172,7 @@ class nsISupportsArray; - (BOOL)popupsBlocked; - (unsigned long)securityState; -- (NSString*)getCurrentURLSpec; +- (NSString*)getCurrentURI; - (void)getBlockedSites:(nsISupportsArray**)outSites; diff --git a/mozilla/camino/src/browser/BrowserWrapper.mm b/mozilla/camino/src/browser/BrowserWrapper.mm index 125fbb92061..5c50e029fcf 100644 --- a/mozilla/camino/src/browser/BrowserWrapper.mm +++ b/mozilla/camino/src/browser/BrowserWrapper.mm @@ -87,7 +87,6 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; - (void)updateOfflineStatus; -- (NSView*)contentProviderViewForURL:(NSString*)inURL; - (void)checkForCustomViewOnLoad:(NSString*)inURL; @end @@ -218,9 +217,9 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; return mTabItem; } --(NSString*)getCurrentURLSpec +-(NSString*)getCurrentURI { - return [mBrowserView getCurrentURLSpec]; + return [mBrowserView getCurrentURI]; } - (void)setFrame:(NSRect)frameRect @@ -260,6 +259,24 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; return mTitle; } +- (NSString*)pageTitle +{ + nsCOMPtr window = getter_AddRefs([mBrowserView getContentWindow]); + if (!window) + return @""; + + nsCOMPtr htmlDoc; + window->GetDocument(getter_AddRefs(htmlDoc)); + + nsCOMPtr htmlDocument(do_QueryInterface(htmlDoc)); + if (!htmlDocument) + return @""; + + nsAutoString titleString; + htmlDocument->GetTitle(titleString); + return [NSString stringWith_nsAString:titleString]; +} + - (NSImage*)siteIcon { return mSiteIconImage; @@ -267,7 +284,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; - (NSString*)location { - return [mBrowserView getCurrentURLSpec]; + return [mBrowserView getCurrentURI]; } - (NSString*)statusString @@ -378,22 +395,21 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; return [mContentViewProviders objectForKey:[inURL lowercaseString]]; } -- (NSView*)contentProviderViewForURL:(NSString*)inURL -{ - id provider = [mContentViewProviders objectForKey:[inURL lowercaseString]]; - return [provider provideContentViewForURL:inURL]; // ok with nil provider -} - - (void)checkForCustomViewOnLoad:(NSString*)inURL { - NSView* newContentView = [self contentProviderViewForURL:inURL]; - if (!newContentView) - newContentView = mBrowserView; // put the browser view back + id provider = [mContentViewProviders objectForKey:[inURL lowercaseString]]; + NSView* providedView = [provider provideContentViewForURL:inURL]; // ok with nil provider + + NSView* newContentView = providedView ? providedView : mBrowserView; if ([self firstSubview] != newContentView) { [self swapFirstSubview:newContentView]; [mDelegate contentViewChangedTo:newContentView forURL:inURL]; + + // tell the provider that we swapped in its view + if (providedView) + [provider contentView:providedView usedForURL:inURL]; } } @@ -480,48 +496,45 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; - (void)onLocationChange:(NSString*)urlSpec isNewPage:(BOOL)newPage requestSucceeded:(BOOL)requestOK { - if (newPage) + BOOL useSiteIcons = [[PreferenceManager sharedInstance] getBooleanPref:"browser.chrome.favicons" withSuccess:NULL]; + + NSString* faviconURI = [SiteIconProvider faviconLocationStringFromURI:urlSpec]; + if (requestOK && useSiteIcons && [faviconURI length] > 0) { - BOOL useSiteIcons = [[PreferenceManager sharedInstance] getBooleanPref:"browser.chrome.favicons" withSuccess:NULL]; - - NSString* faviconURI = [SiteIconProvider faviconLocationStringFromURI:urlSpec]; - if (requestOK && useSiteIcons && [faviconURI length] > 0) + SiteIconProvider* faviconProvider = [SiteIconProvider sharedFavoriteIconProvider]; + + // if the favicon uri has changed, fire off favicon load. When it completes, our + // imageLoadedNotification selector gets called. + if (![faviconURI isEqualToString:mSiteIconURI]) { - SiteIconProvider* faviconProvider = [SiteIconProvider sharedFavoriteIconProvider]; + // first get a cached image for this site, if we have one. we'll go ahead + // and request the load anyway, in case the site updated their icon. + NSImage* cachedImage = [faviconProvider favoriteIconForPage:urlSpec]; + NSString* cachedImageURI = nil; - // if the favicon uri has changed, fire off favicon load. When it completes, our - // imageLoadedNotification selector gets called. - if (![faviconURI isEqualToString:mSiteIconURI]) - { - // first get a cached image for this site, if we have one. we'll go ahead - // and request the load anyway, in case the site updated their icon. - NSImage* cachedImage = [faviconProvider favoriteIconForPage:urlSpec]; - NSString* cachedImageURI = nil; + if (cachedImage) + cachedImageURI = faviconURI; + + // immediately update the site icon (to the cached one, or the default) + [self updateSiteIconImage:cachedImage withURI:cachedImageURI loadError:NO]; - if (cachedImage) - cachedImageURI = faviconURI; - - // immediately update the site icon (to the cached one, or the default) - [self updateSiteIconImage:cachedImage withURI:cachedImageURI loadError:NO]; - - // note that this is the only time we hit the network for site icons. - // note also that we may get a site icon from a link element later, - // which will replace any we get from the default location. - [faviconProvider fetchFavoriteIconForPage:urlSpec - withIconLocation:nil - allowNetwork:YES - notifyingClient:self]; - } + // note that this is the only time we hit the network for site icons. + // note also that we may get a site icon from a link element later, + // which will replace any we get from the default location. + [faviconProvider fetchFavoriteIconForPage:urlSpec + withIconLocation:nil + allowNetwork:YES + notifyingClient:self]; } + } + else + { + if ([urlSpec hasPrefix:@"about:"]) + faviconURI = urlSpec; else - { - if ([urlSpec isEqualToString:@"about:blank"]) - faviconURI = urlSpec; - else - faviconURI = @""; + faviconURI = @""; - [self updateSiteIconImage:nil withURI:faviconURI loadError:!requestOK]; - } + [self updateSiteIconImage:nil withURI:faviconURI loadError:!requestOK]; } [mDelegate updateLocationFields:urlSpec ignoreTyping:NO]; @@ -583,7 +596,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; - (void)setTabTitle:(NSString*)tabTitle windowTitle:(NSString*)windowTitle { - NSString* curURL = [self getCurrentURLSpec]; + NSString* curURL = [self getCurrentURI]; [mTabTitle autorelease]; mTabTitle = [[self displayTitleForPageURL:curURL title:tabTitle] retain]; @@ -682,7 +695,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; // imageLoadedNotification selector gets called. if (![inIconURI isEqualToString:mSiteIconURI]) { - [[SiteIconProvider sharedFavoriteIconProvider] fetchFavoriteIconForPage:[self getCurrentURLSpec] + [[SiteIconProvider sharedFavoriteIconProvider] fetchFavoriteIconForPage:[self getCurrentURI] withIconLocation:inIconURI allowNetwork:YES notifyingClient:self]; @@ -759,31 +772,8 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; - (void)getTitle:(NSString **)outTitle andHref:(NSString**)outHrefString { - *outTitle = *outHrefString = nil; - - nsCOMPtr window = getter_AddRefs([mBrowserView getContentWindow]); - if (!window) return; - - nsCOMPtr htmlDoc; - window->GetDocument(getter_AddRefs(htmlDoc)); - nsCOMPtr pageDoc(do_QueryInterface(htmlDoc)); - if (pageDoc) - { - nsIURI* url = pageDoc->GetDocumentURI(); - if (url) - { - nsCAutoString spec; - url->GetSpec(spec); - *outHrefString = [NSString stringWithUTF8String:spec.get()]; - } - } - - nsAutoString titleString; - nsCOMPtr htmlDocument(do_QueryInterface(htmlDoc)); - if (htmlDocument) - htmlDocument->GetTitle(titleString); - if (!titleString.IsEmpty()) - *outTitle = [NSString stringWith_nsAString:titleString]; + *outTitle = [self pageTitle]; + *outHrefString = [self getCurrentURI]; } - (void)offlineModeChanged:(NSNotification*)aNotification @@ -884,7 +874,6 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; } // A nil inSiteIcon image indicates that we should use the default icon -// If inSiteIconURI is "about:blank", we don't show any icon - (void)updateSiteIconImage:(NSImage*)inSiteIcon withURI:(NSString *)inSiteIconURI loadError:(BOOL)inLoadError { BOOL resetTabIcon = NO; @@ -895,19 +884,15 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; { if (!siteIcon) { - if ([inSiteIconURI isEqualToString:@"about:blank"]) - { - siteIcon = [NSImage imageNamed:@"smallDocument"]; - tabIconDraggable = NO; - } - else if (inLoadError) - { + if (inLoadError) siteIcon = [NSImage imageNamed:@"brokenbookmark_icon"]; // it should have its own image - } else siteIcon = [NSImage imageNamed:@"globe_ico"]; } + if ([inSiteIconURI isEqualToString:@"about:blank"]) + tabIconDraggable = NO; + [self setSiteIconImage:siteIcon]; [self setSiteIconURI:inSiteIconURI]; @@ -943,12 +928,13 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged"; { NSImage* iconImage = [userInfo objectForKey:SiteIconLoadImageKey]; NSString* siteIconURI = [userInfo objectForKey:SiteIconLoadURIKey]; + NSString* pageURI = [userInfo objectForKey:SiteIconLoadUserDataKey]; - // NSLog(@"BrowserWrapper imageLoadedNotification got image %@ and uri %@", iconImage, proxyImageURI); if (iconImage == nil) siteIconURI = @""; // go back to default image - - [self updateSiteIconImage:iconImage withURI:siteIconURI loadError:NO]; + + if ([pageURI isEqualToString:[[self getBrowserView] getCurrentURI]]) // make sure it's for the current page + [self updateSiteIconImage:iconImage withURI:siteIconURI loadError:NO]; } } diff --git a/mozilla/camino/src/browser/KeychainService.mm b/mozilla/camino/src/browser/KeychainService.mm index b000f9c6f3f..a5c9a8021b2 100644 --- a/mozilla/camino/src/browser/KeychainService.mm +++ b/mozilla/camino/src/browser/KeychainService.mm @@ -213,9 +213,9 @@ int KeychainPrefChangedCallback(const char* inPref, void* unused) char buffer[kBufferLen]; UInt32 actualSize; - if ( inPort == -1 ) + if (inPort == -1) inPort = kAnyPort; - if(kcfindinternetpassword([realm UTF8String], 0, 0, inPort, kKCProtocolTypeHTTP, kKCAuthTypeHTTPDigest, + if (kcfindinternetpassword([realm UTF8String], 0, 0, inPort, kKCProtocolTypeHTTP, kKCAuthTypeHTTPDigest, kBufferLen, buffer, &actualSize, outItemRef) != noErr) return false; diff --git a/mozilla/camino/src/browser/SiteIconProvider.h b/mozilla/camino/src/browser/SiteIconProvider.h index abc33143b45..19807332f5d 100644 --- a/mozilla/camino/src/browser/SiteIconProvider.h +++ b/mozilla/camino/src/browser/SiteIconProvider.h @@ -93,4 +93,8 @@ class NeckoCacheHelper; // then this will take that into account. - (NSImage*)favoriteIconForPage:(NSString*)inPageURI; +// to register a specific image for a given uri, can all this method. This will +// add an entry to the cache. It's used for "special" uris like "about:bookmarks". +- (void)registerFaviconImage:(NSImage*)inImage forPageURI:(NSString*)inURI; + @end diff --git a/mozilla/camino/src/browser/SiteIconProvider.mm b/mozilla/camino/src/browser/SiteIconProvider.mm index 4427ea8f1e4..c34bf3e1d1c 100644 --- a/mozilla/camino/src/browser/SiteIconProvider.mm +++ b/mozilla/camino/src/browser/SiteIconProvider.mm @@ -476,6 +476,14 @@ MakeFaviconURIFromURI(const nsAString& inURIString, nsAString& outFaviconURI) return siteIcon; } +- (void)registerFaviconImage:(NSImage*)inImage forPageURI:(NSString*)inURI +{ + if (inImage == nil || [inURI length] == 0) + return; + + [mIconDictionary setObject:inImage forKey:inURI]; +} + - (BOOL)fetchFavoriteIconForPage:(NSString*)inPageURI withIconLocation:(NSString*)inIconURI allowNetwork:(BOOL)inAllowNetwork @@ -561,6 +569,10 @@ MakeFaviconURIFromURI(const nsAString& inURIString, nsAString& outFaviconURI) + (NSString*)faviconLocationStringFromURI:(NSString*)inURI { + // about: urls are special + if ([inURI hasPrefix:@"about:"]) + return inURI; + nsAutoString uriString; [inURI assignTo_nsAString:uriString]; diff --git a/mozilla/camino/src/embedding/CHBrowserView.h b/mozilla/camino/src/embedding/CHBrowserView.h index 94b28e3a5f6..436ee10668a 100644 --- a/mozilla/camino/src/embedding/CHBrowserView.h +++ b/mozilla/camino/src/embedding/CHBrowserView.h @@ -224,8 +224,6 @@ enum { - (void)doBeforePromptDisplay; - (void)doAfterPromptDismissal; --(NSString*)getCurrentURLSpec; - - (void)setActive: (BOOL)aIsActive; - (NSMenu*)getContextMenu; diff --git a/mozilla/camino/src/embedding/CHBrowserView.mm b/mozilla/camino/src/embedding/CHBrowserView.mm index f7b3f695556..1c9eab020d1 100644 --- a/mozilla/camino/src/embedding/CHBrowserView.mm +++ b/mozilla/camino/src/embedding/CHBrowserView.mm @@ -481,17 +481,16 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1"; browserSetup->SetProperty(property, value); } -// how does this differ from getCurrentURLSpec? - (NSString*)getCurrentURI { nsCOMPtr nav = do_QueryInterface(_webBrowser); if (!nav) - return nil; + return @""; nsCOMPtr uri; nav->GetCurrentURI(getter_AddRefs(uri)); if (!uri) - return nil; + return @""; nsCAutoString spec; uri->GetSpec(spec); @@ -959,6 +958,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1"; [[self getBrowserContainer] didDismissPrompt]; } +#if 0 // how does this differ from getCurrentURI? -(NSString*)getCurrentURLSpec { @@ -988,6 +988,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1"; location->GetHref(urlStr); return [NSString stringWith_nsAString: urlStr]; } +#endif - (void)setActive: (BOOL)aIsActive {