summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 19:36:46 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 19:36:46 +0000
commitd1ba5b511c94fb02b79ceae67a172d6bdb716e98 (patch)
tree23288e2b27f8513e76e5f22750f3166c92edaae5 /chrome/browser/bookmarks
parentd3038bf0175f75df75385a17298134a2ee39b8a1 (diff)
downloadchromium_src-d1ba5b511c94fb02b79ceae67a172d6bdb716e98.zip
chromium_src-d1ba5b511c94fb02b79ceae67a172d6bdb716e98.tar.gz
chromium_src-d1ba5b511c94fb02b79ceae67a172d6bdb716e98.tar.bz2
Makes it so deleting a bookmark from the context menu doesn't close
the bookmark menu. BUG=2469 TEST=click on a bookmark folder on the bookmark bar, right click on an item and chose delete. Make sure the folder stays up and still works correctly (and the item you deleted isn't there). Review URL: http://codereview.chromium.org/551178 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu_controller.cc20
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu_controller.h7
2 files changed, 20 insertions, 7 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc
index a46110b..0ce5386 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc
@@ -278,6 +278,8 @@ void BookmarkContextMenuController::BuildMenu() {
}
void BookmarkContextMenuController::ExecuteCommand(int id) {
+ BookmarkModel* model = RemoveModelObserver();
+
switch (id) {
case IDS_BOOMARK_BAR_OPEN_ALL:
case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO:
@@ -327,12 +329,13 @@ void BookmarkContextMenuController::ExecuteCommand(int id) {
case IDS_BOOKMARK_BAR_REMOVE: {
UserMetrics::RecordAction("BookmarkBar_ContextMenu_Remove", profile_);
- BookmarkModel* model = RemoveModelObserver();
+ delegate_->WillRemoveBookmarks(selection_);
for (size_t i = 0; i < selection_.size(); ++i) {
model->Remove(selection_[i]->GetParent(),
selection_[i]->GetParent()->IndexOfChild(selection_[i]));
}
+ delegate_->DidRemoveBookmarks();
selection_.clear();
break;
}
@@ -387,13 +390,17 @@ void BookmarkContextMenuController::ExecuteCommand(int id) {
case IDS_BOOKMARK_MANAGER_SORT:
UserMetrics::RecordAction("BookmarkManager_Sort", profile_);
- model_->SortChildren(parent_);
+ model->SortChildren(parent_);
break;
- case IDS_COPY:
case IDS_CUT:
- bookmark_utils::CopyToClipboard(profile_->GetBookmarkModel(),
- selection_, id == IDS_CUT);
+ delegate_->WillRemoveBookmarks(selection_);
+ bookmark_utils::CopyToClipboard(model, selection_, false);
+ delegate_->DidRemoveBookmarks();
+ break;
+
+ case IDS_COPY:
+ bookmark_utils::CopyToClipboard(model, selection_, false);
break;
case IDS_PASTE: {
@@ -405,8 +412,7 @@ void BookmarkContextMenuController::ExecuteCommand(int id) {
parent_->IndexOfChild(selection_[0]) : -1;
if (index != -1)
index++;
- bookmark_utils::PasteFromClipboard(profile_->GetBookmarkModel(),
- parent_, index);
+ bookmark_utils::PasteFromClipboard(model, parent_, index);
break;
}
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.h b/chrome/browser/bookmarks/bookmark_context_menu_controller.h
index 0934b70..3812e28 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu_controller.h
+++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.h
@@ -29,6 +29,13 @@ class BookmarkContextMenuControllerDelegate {
virtual void AddItemWithStringId(int command_id, int string_id) = 0;
virtual void AddSeparator() = 0;
virtual void AddCheckboxItem(int command_id) = 0;
+
+ // Sent before bookmarks are removed.
+ virtual void WillRemoveBookmarks(
+ const std::vector<const BookmarkNode*>& bookmarks) {}
+
+ // Sent after bookmarks have been removed.
+ virtual void DidRemoveBookmarks() {}
};
// BookmarkContextMenuController creates and manages state for the context menu