| Index: chrome/browser/views/bookmark_bar_view.cc
|
| diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
|
| index 9ca4ec519057da11e5423d40cb870fdbb1d920b6..1723f9fa89a75a94a4bce68f8833dabebdb4a249 100644
|
| --- a/chrome/browser/views/bookmark_bar_view.cc
|
| +++ b/chrome/browser/views/bookmark_bar_view.cc
|
| @@ -444,13 +444,16 @@ void BookmarkBarView::SetProfile(Profile* profile) {
|
| registrar_.Add(this, NotificationType::BOOKMARK_BUBBLE_SHOWN, ns_source);
|
| registrar_.Add(this, NotificationType::BOOKMARK_BUBBLE_HIDDEN, ns_source);
|
| registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
|
| - NotificationService::AllSources());
|
| + NotificationService::AllSources());
|
| +
|
| + // Remove any existing bookmark buttons.
|
| + while (GetBookmarkButtonCount())
|
| + delete GetChildViewAt(0);
|
|
|
| model_ = profile_->GetBookmarkModel();
|
| model_->AddObserver(this);
|
| if (model_->IsLoaded())
|
| Loaded(model_);
|
| -
|
| // else case: we'll receive notification back from the BookmarkModel when done
|
| // loading, then we'll populate the bar.
|
| }
|
| @@ -948,14 +951,11 @@ MenuButton* BookmarkBarView::CreateOverflowButton() {
|
| return button;
|
| }
|
|
|
| -int BookmarkBarView::GetBookmarkButtonCount() {
|
| - // We contain at least four non-bookmark button views: other bookmarks,
|
| - // bookmarks separator, chevrons (for overflow), the instruction label and
|
| - // the sync error button.
|
| - return GetChildViewCount() - 5;
|
| -}
|
| -
|
| void BookmarkBarView::Loaded(BookmarkModel* model) {
|
| + volatile int button_count = GetBookmarkButtonCount();
|
| + CHECK(button_count == 0); // If non-zero it means Load was invoked more than
|
| + // once, or we didn't properly clear things. Either
|
| + // of which shouldn't happen
|
| const BookmarkNode* node = model_->GetBookmarkBarNode();
|
| DCHECK(node && model_->other_node());
|
| // Create a button for each of the children on the bookmark bar.
|
| @@ -966,6 +966,8 @@ void BookmarkBarView::Loaded(BookmarkModel* model) {
|
|
|
| Layout();
|
| SchedulePaint();
|
| +
|
| + CheckIntegrity();
|
| }
|
|
|
| void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) {
|
| @@ -1557,6 +1559,13 @@ void BookmarkBarView::StartThrobbing(const BookmarkNode* node,
|
| throbbing_view_->StartThrobbing(std::numeric_limits<int>::max());
|
| }
|
|
|
| +int BookmarkBarView::GetBookmarkButtonCount() {
|
| + // We contain at least four non-bookmark button views: other bookmarks,
|
| + // bookmarks separator, chevrons (for overflow), the instruction label and
|
| + // the sync error button.
|
| + return GetChildViewCount() - 5;
|
| +}
|
| +
|
| void BookmarkBarView::StopThrobbing(bool immediate) {
|
| if (!throbbing_view_)
|
| return;
|
|
|