summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 03:35:33 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 03:35:33 +0000
commitc919469b3dfc6ea110fdc2218c014599babfd6e9 (patch)
tree648bd6033dc8bd83c69f1275bae3e0da4b893051 /chrome/browser/views
parent023b66d1d8e7fcb99a6ae7dfbed1ce998d3c6882 (diff)
downloadchromium_src-c919469b3dfc6ea110fdc2218c014599babfd6e9.zip
chromium_src-c919469b3dfc6ea110fdc2218c014599babfd6e9.tar.gz
chromium_src-c919469b3dfc6ea110fdc2218c014599babfd6e9.tar.bz2
Fixes crash in BookmarkBarView. If the HistoryService fails to load it
was possible for BookmarkBarView to deref NULL (the model_ field). There is no point in having the BookmarkBarView wait for history to load now though, so I've taken this out which makes it impossible to get in this situation. BUG=1356168 TEST=make sure bookmarks still work correctly Review URL: http://codereview.chromium.org/426 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc60
-rw-r--r--chrome/browser/views/bookmark_bar_view.h7
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.