diff --git a/mozilla/camino/src/browser/HistoryMenu.mm b/mozilla/camino/src/browser/HistoryMenu.mm index cae917e0f4a..582ccc7d852 100644 --- a/mozilla/camino/src/browser/HistoryMenu.mm +++ b/mozilla/camino/src/browser/HistoryMenu.mm @@ -418,6 +418,12 @@ static const unsigned int kMaxTitleLength = 50; selector:@selector(browserClosed:) name:kBrowserInstanceClosedNotification object:nil]; + + // Listen for history being cleared. + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(historyCleared:) + name:kNotificationNameHistoryDataSourceCleared + object:[HistoryMenuDataSourceOwner sharedHistoryDataSource]]; } - (void)appLaunchFinished:(NSNotification*)inNotification @@ -581,15 +587,6 @@ static const unsigned int kMaxTitleLength = 50; if (!rootChangedItem) { [mTodayItem release]; mTodayItem = nil; - // We can get here either when the history is being cleared (in which case - // we will already have an mRootItem) or when we are doing the lazy - // construction of the root item as the menu is shown (in which case - // mRootItem is still |nil|). If it's the former, clear the recently closed - // pages as well. - if (mRootItem) { - [mRecentlyClosedMenu release]; - mRecentlyClosedMenu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"RecentlyClosed", nil)]; - } } else if (mTodayItem == rootChangedItem || mTodayItem == [rootChangedItem parentItem]) @@ -600,4 +597,9 @@ static const unsigned int kMaxTitleLength = 50; [super historyChanged:inNotification]; } +- (void)historyCleared:(NSNotification*)inNotification { + [mRecentlyClosedMenu release]; + mRecentlyClosedMenu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"RecentlyClosed", nil)]; +} + @end diff --git a/mozilla/camino/src/history/HistoryDataSource.h b/mozilla/camino/src/history/HistoryDataSource.h index 6126bff22d1..8eb4b0b7b55 100644 --- a/mozilla/camino/src/history/HistoryDataSource.h +++ b/mozilla/camino/src/history/HistoryDataSource.h @@ -58,6 +58,9 @@ extern NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItem; // if true, this indicates that just the item changed, not its children (it's an NSNumber with bool) extern NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItemOnly; +// Sent when history is cleared. Notification object is the data source. +extern NSString* const kNotificationNameHistoryDataSourceCleared; + @class HistoryTreeBuilder; @interface HistoryDataSource : NSObject diff --git a/mozilla/camino/src/history/HistoryDataSource.mm b/mozilla/camino/src/history/HistoryDataSource.mm index c52b36b40dd..f8968124b3d 100644 --- a/mozilla/camino/src/history/HistoryDataSource.mm +++ b/mozilla/camino/src/history/HistoryDataSource.mm @@ -72,6 +72,7 @@ NSString* const kHistoryViewFlat = @"flat"; NSString* const kNotificationNameHistoryDataSourceChanged = @"history_changed"; NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItem = @"changed_item"; NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItemOnly = @"item_only"; +NSString* const kNotificationNameHistoryDataSourceCleared = @"history_cleared"; struct SortData { @@ -1146,6 +1147,11 @@ NS_IMPL_ISUPPORTS1(nsNavHistoryObserver, nsINavHistoryObserver); { [mHistoryItems removeAllObjects]; [mHistoryItemsDictionary removeAllObjects]; + + [[NSNotificationCenter defaultCenter] + postNotificationName:kNotificationNameHistoryDataSourceCleared + object:self + userInfo:nil]; } #pragma mark -