diff options
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 60 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.h | 7 |
2 files changed, 27 insertions, 40 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 64e4489..b5a952f 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -672,20 +672,17 @@ void BookmarkBarView::SetProfile(Profile* profile) { NotificationService* ns = NotificationService::current(); Source<Profile> ns_source(profile_->GetOriginalProfile()); - ns->AddObserver(this, NOTIFY_HISTORY_CREATED, ns_source); ns->AddObserver(this, NOTIFY_BOOKMARK_BUBBLE_SHOWN, ns_source); ns->AddObserver(this, NOTIFY_BOOKMARK_BUBBLE_HIDDEN, ns_source); ns->AddObserver(this, NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, NotificationService::AllSources()); - if (!profile->HasHistoryService()) { - // The history service hasn't been loaded yet. We don't want to trigger - // loading it. Instead we install an observer that is notified when the - // history service has loaded. - model_ = NULL; - } else { - ProfileHasValidHistoryService(); - } + model_ = profile_->GetBookmarkBarModel(); + model_->AddObserver(this); + if (model_->IsLoaded()) + Loaded(model_); + // else case: we'll receive notification back from the BookmarkBarModel when + // done loading, then we'll populate the bar. } void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) { @@ -1121,6 +1118,7 @@ void BookmarkBarView::Init() { SetContextMenuController(this); size_animation_.reset(new SlideAnimation(this)); + size_animation_->SetSlideDuration(4000); } MenuButton* BookmarkBarView::CreateOtherBookmarkedButton() { @@ -1439,37 +1437,31 @@ void BookmarkBarView::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(profile_); - if (type == NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) { - if (IsAlwaysShown()) { - size_animation_->Show(); - } else { - size_animation_->Hide(); - } - } else if (type == NOTIFY_HISTORY_CREATED) { - ProfileHasValidHistoryService(); - } else if (type == NOTIFY_BOOKMARK_BUBBLE_SHOWN) { - StopThrobbing(true); - bubble_url_ = *(Details<GURL>(details).ptr()); - StartThrobbing(); - } else if (type == NOTIFY_BOOKMARK_BUBBLE_HIDDEN) { - StopThrobbing(false); - bubble_url_ = GURL(); - } -} + switch (type) { + case NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: + if (IsAlwaysShown()) { + size_animation_->Show(); + } else { + size_animation_->Hide(); + } + break; -void BookmarkBarView::ProfileHasValidHistoryService() { - DCHECK(profile_); - model_ = profile_->GetBookmarkBarModel(); - DCHECK(model_); - model_->AddObserver(this); - if (model_->IsLoaded()) - Loaded(model_); + case NOTIFY_BOOKMARK_BUBBLE_SHOWN: + StopThrobbing(true); + bubble_url_ = *(Details<GURL>(details).ptr()); + StartThrobbing(); + break; + + case NOTIFY_BOOKMARK_BUBBLE_HIDDEN: + StopThrobbing(false); + bubble_url_ = GURL(); + break; + } } void BookmarkBarView::RemoveNotificationObservers() { NotificationService* ns = NotificationService::current(); Source<Profile> ns_source(profile_->GetOriginalProfile()); - ns->RemoveObserver(this, NOTIFY_HISTORY_CREATED, ns_source); ns->RemoveObserver(this, NOTIFY_BOOKMARK_BUBBLE_SHOWN, ns_source); ns->RemoveObserver(this, NOTIFY_BOOKMARK_BUBBLE_HIDDEN, ns_source); ns->RemoveObserver(this, NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h index 1f3e124..507da5d 100644 --- a/chrome/browser/views/bookmark_bar_view.h +++ b/chrome/browser/views/bookmark_bar_view.h @@ -309,16 +309,11 @@ class BookmarkBarView : public ChromeViews::View, // visible. Updates the preferences to match the users choice as appropriate. virtual void ExecuteCommand(int id); - // Notification that the HistoryService is up an running. Removes us as - // a listener on the notification service and invokes - // ProfileHasValidHistoryService. + // NotificationService method. virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); - // Invoked when the profile has a history service. Recreates the models. - void ProfileHasValidHistoryService(); - // If we have registered an observer on the notification service, this // unregisters it. This does nothing if we have not installed ourself as an // observer. |