diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 17:18:31 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 17:18:31 +0000 |
commit | 0b97342d07fd3ef047432b52809d31d10432ee85 (patch) | |
tree | 3189d76afdbef54f9fb7ee0033d2d87ab2324cb2 /chrome/browser/cocoa | |
parent | 3a7415688299593d2ac3b8fd9578753161d03687 (diff) | |
download | chromium_src-0b97342d07fd3ef047432b52809d31d10432ee85.zip chromium_src-0b97342d07fd3ef047432b52809d31d10432ee85.tar.gz chromium_src-0b97342d07fd3ef047432b52809d31d10432ee85.tar.bz2 |
Popuplate bookmark menus on 1st launch.
BUG=13794
TEST=launch Chrome. Before doing anything (e.g. changing focus or
creating new windows), make sure the bookmark menu is populated. If
you have no bookmarks you'll need to add them ('star' some URLs) then
restart Chrome.
Review URL: http://codereview.chromium.org/125094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/bookmark_menu_bridge.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_menu_bridge.mm | 22 |
2 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.h b/chrome/browser/cocoa/bookmark_menu_bridge.h index 2516b4f..b350fd5 100644 --- a/chrome/browser/cocoa/bookmark_menu_bridge.h +++ b/chrome/browser/cocoa/bookmark_menu_bridge.h @@ -72,6 +72,9 @@ class BookmarkMenuBridge : public BookmarkModelObserver, // Return the Bookmark menu. NSMenu* BookmarkMenu(); + // Start watching the bookmarks for changes. + void ObserveBookmarkModel(); + private: friend class BookmarkMenuBridgeTest; diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.mm b/chrome/browser/cocoa/bookmark_menu_bridge.mm index eea9b413..fc29548 100644 --- a/chrome/browser/cocoa/bookmark_menu_bridge.mm +++ b/chrome/browser/cocoa/bookmark_menu_bridge.mm @@ -14,9 +14,20 @@ #include "chrome/browser/profile_manager.h" BookmarkMenuBridge::BookmarkMenuBridge() - : controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]), - observing_(true) { - BrowserList::AddObserver(this); + : controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]) { + // Depending on when this is constructed, we may or may not have a + // browser yet. If we do, start watching the bookmarks. If we do + // not, delay watching until we see a SetLastActive(). At this time + // (6/12/09), the BookmarkMenuBridge object is constructed AFTER the + // first SetLastActive in -[AppController applicationDidFinishLaunching:]. + Browser* browser = BrowserList::GetLastActive(); + if (browser) { + observing_ = false; // not observing browser activation + ObserveBookmarkModel(); + } else { + observing_ = true; + BrowserList::AddObserver(this); + } } BookmarkMenuBridge::~BookmarkMenuBridge() { @@ -104,6 +115,11 @@ void BookmarkMenuBridge::OnBrowserRemoving(const Browser* browser) { void BookmarkMenuBridge::OnBrowserSetLastActive(const Browser* browser) { BrowserList::RemoveObserver(this); observing_ = false; + ObserveBookmarkModel(); +} + +// Watch for changes. +void BookmarkMenuBridge::ObserveBookmarkModel() { BookmarkModel* model = GetBookmarkModel(); model->AddObserver(this); if (model->IsLoaded()) |