Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8790)

Unified Diff: chrome/browser/views/bookmark_bar_view.cc

Issue 2822010: Fixes bug in bookmark bar view if profile changed. If the profile (Closed)
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/bookmark_bar_view.h ('k') | chrome/browser/views/bookmark_bar_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/browser/views/bookmark_bar_view.h ('k') | chrome/browser/views/bookmark_bar_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698