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

Unified Diff: components/bookmarks/browser/bookmark_model.h

Issue 1379983002: Supporting undoing bookmark deletion without creating new ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
Index: components/bookmarks/browser/bookmark_model.h
diff --git a/components/bookmarks/browser/bookmark_model.h b/components/bookmarks/browser/bookmark_model.h
index 27837703d0adc6719ef330fb483cd6afe1d1bcb7..de4690055a3cb830d5f62d0d2fbfc6da9e1a534f 100644
--- a/components/bookmarks/browser/bookmark_model.h
+++ b/components/bookmarks/browser/bookmark_model.h
@@ -308,6 +308,18 @@ class BookmarkModel : public KeyedService {
// Returns the client used by this BookmarkModel.
BookmarkClient* client() const { return client_; }
+ // Turns on/off the capability to undo removing nodes.
+ void EnableUndoableRemove();
sky 2015/10/02 15:40:30 I think all the bookkeeping of undo should be kept
jianli 2015/10/06 22:08:24 Done.
+ void DisableUndoableRemove();
+
+ // Undo deleting the node with |node_id| by putting it back to its original
+ // position.
+ void UndoRemove(int64_t node_id);
+
+ // Throws aways the undo info for the deleted node. After this, the deleted
+ // node can no longer be restored.
+ void DiscardUndoableRemovedNode(int64_t node_id);
+
private:
friend class BookmarkCodecTest;
friend class BookmarkModelFaviconTest;
@@ -323,6 +335,13 @@ class BookmarkModel : public KeyedService {
}
};
+ // Used to track all the info necessary to bring back a deleted node.
+ struct RestorableDeletedNodeInfo {
+ int64_t parent_node_id;
+ int index;
+ BookmarkNode* node;
+ };
+
// Implementation of IsBookmarked. Before calling this the caller must obtain
// a lock on |url_lock_|.
bool IsBookmarkedNoLock(const GURL& url);
@@ -405,6 +424,9 @@ class BookmarkModel : public KeyedService {
scoped_ptr<BookmarkLoadDetails> CreateLoadDetails(
const std::string& accept_languages);
+ // Discards all removed nodes that are tracked for restoring.
+ void DiscardAllUndoableRemovedNodes();
+
BookmarkClient* const client_;
// Whether the initial set of data has been loaded.
@@ -449,6 +471,12 @@ class BookmarkModel : public KeyedService {
std::set<std::string> non_cloned_keys_;
+ // Whether or not to support undoing node removal.
+ bool undoable_remove_enabled_;
+
+ // Tracks those deleted nodes that can be restored by the undo operations.
+ std::map<int64_t, RestorableDeletedNodeInfo> undoable_deleted_nodes_;
+
DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
};
« no previous file with comments | « no previous file | components/bookmarks/browser/bookmark_model.cc » ('j') | components/bookmarks/browser/bookmark_model.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698