Apply edits when closing the bookmarks bubble
Fixes regression where the dialog had to be explicitly accepted to apply
pending updates.
(cherry picked from commit 417603ce00e6dc879b85400d833e26f82fd867d6)
Bug: 1137491
Change-Id: I9c8166aa013714b08280eaf1d51c7831dcd6b9a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476719
Commit-Queue: Peter Boström <[email protected]>
Commit-Queue: Elly Fong-Jones <[email protected]>
Auto-Submit: Peter Boström <[email protected]>
Reviewed-by: Elly Fong-Jones <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#817628}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485836
Reviewed-by: Peter Boström <[email protected]>
Cr-Commit-Position: refs/branch-heads/4280@{#500}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
index 10a65bc..b942c4b 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -55,7 +55,7 @@
void RemoveBookmark() {
base::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"));
- can_apply_edits_ = false;
+ should_apply_edits_ = false;
bookmarks::BookmarkModel* model =
BookmarkModelFactory::GetForBrowserContext(profile_);
const bookmarks::BookmarkNode* node =
@@ -65,6 +65,8 @@
}
void OnWindowClosing() {
+ if (should_apply_edits_)
+ ApplyEdits();
bookmark_bubble_ = nullptr;
if (observer_)
observer_->OnBookmarkBubbleHidden();
@@ -86,7 +88,8 @@
DCHECK(native_parent);
Profile* const profile = profile_;
- ApplyEdits();
+ // Note that closing the dialog with |should_apply_edits_| still true will
+ // synchronously save any pending changes.
dialog_model()->host()->Close();
if (node && native_parent) {
@@ -108,9 +111,9 @@
}
void ApplyEdits() {
- DCHECK(can_apply_edits_);
+ DCHECK(should_apply_edits_);
// Set this to make sure we don't attempt to apply edits again.
- can_apply_edits_ = false;
+ should_apply_edits_ = false;
bookmarks::BookmarkModel* const model =
BookmarkModelFactory::GetForBrowserContext(profile_);
@@ -148,7 +151,7 @@
Profile* const profile_;
const GURL url_;
- bool can_apply_edits_ = true;
+ bool should_apply_edits_ = true;
};
// static