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); |
}; |