1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UNDO_BOOKMARK_UNDO_SERVICE_H_
6 #define CHROME_BROWSER_UNDO_BOOKMARK_UNDO_SERVICE_H_
10 #include "chrome/browser/undo/bookmark_renumber_observer.h"
11 #include "chrome/browser/undo/undo_manager.h"
12 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
13 #include "components/bookmarks/browser/bookmark_node_data.h"
14 #include "components/keyed_service/core/keyed_service.h"
18 class BookmarkUndoOperation
;
21 // BookmarkUndoService --------------------------------------------------------
23 // BookmarkUndoService is owned by the profile, and is responsible for observing
24 // BookmarkModel changes in order to provide an undo for those changes.
25 class BookmarkUndoService
: public bookmarks::BaseBookmarkModelObserver
,
27 public BookmarkRenumberObserver
{
29 explicit BookmarkUndoService(Profile
* profile
);
30 ~BookmarkUndoService() override
;
32 UndoManager
* undo_manager() { return &undo_manager_
; }
35 // bookmarks::BaseBookmarkModelObserver:
36 void BookmarkModelChanged() override
{}
37 void BookmarkModelLoaded(bookmarks::BookmarkModel
* model
,
38 bool ids_reassigned
) override
;
39 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel
* model
) override
;
40 void BookmarkNodeMoved(bookmarks::BookmarkModel
* model
,
41 const bookmarks::BookmarkNode
* old_parent
,
43 const bookmarks::BookmarkNode
* new_parent
,
44 int new_index
) override
;
45 void BookmarkNodeAdded(bookmarks::BookmarkModel
* model
,
46 const bookmarks::BookmarkNode
* parent
,
48 void OnWillRemoveBookmarks(bookmarks::BookmarkModel
* model
,
49 const bookmarks::BookmarkNode
* parent
,
51 const bookmarks::BookmarkNode
* node
) override
;
52 void OnWillRemoveAllUserBookmarks(bookmarks::BookmarkModel
* model
) override
;
53 void OnWillChangeBookmarkNode(bookmarks::BookmarkModel
* model
,
54 const bookmarks::BookmarkNode
* node
) override
;
55 void OnWillReorderBookmarkNode(bookmarks::BookmarkModel
* model
,
56 const bookmarks::BookmarkNode
* node
) override
;
57 void GroupedBookmarkChangesBeginning(
58 bookmarks::BookmarkModel
* model
) override
;
59 void GroupedBookmarkChangesEnded(bookmarks::BookmarkModel
* model
) override
;
61 // BookmarkRenumberObserver:
62 void OnBookmarkRenumbered(int64 old_id
, int64 new_id
) override
;
65 UndoManager undo_manager_
;
67 DISALLOW_COPY_AND_ASSIGN(BookmarkUndoService
);
70 #endif // CHROME_BROWSER_UNDO_BOOKMARK_UNDO_SERVICE_H_