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. 4 5 #ifndef CHROME_BROWSER_UNDO_BOOKMARK_UNDO_SERVICE_H_ 6 #define CHROME_BROWSER_UNDO_BOOKMARK_UNDO_SERVICE_H_ 7 8 #include <map> 9 10 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" 11 #include "chrome/browser/bookmarks/bookmark_node_data.h" 12 #include "chrome/browser/undo/bookmark_renumber_observer.h" 13 #include "chrome/browser/undo/undo_manager.h" 14 #include "components/browser_context_keyed_service/browser_context_keyed_service.h" 15 16 class Profile; 17 namespace { 18 class BookmarkUndoOperation; 19 } // namespace 20 21 // BookmarkUndoService -------------------------------------------------------- 22 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 BaseBookmarkModelObserver, 26 public BrowserContextKeyedService, 27 public BookmarkRenumberObserver { 28 public: 29 explicit BookmarkUndoService(Profile* profile); 30 virtual ~BookmarkUndoService(); 31 32 UndoManager* undo_manager() { return &undo_manager_; } 33 34 private: 35 // BaseBookmarkModelObserver: 36 virtual void BookmarkModelChanged() OVERRIDE {} 37 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; 38 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; 39 virtual void BookmarkNodeMoved(BookmarkModel* model, 40 const BookmarkNode* old_parent, 41 int old_index, 42 const BookmarkNode* new_parent, 43 int new_index) OVERRIDE; 44 virtual void BookmarkNodeAdded(BookmarkModel* model, 45 const BookmarkNode* parent, 46 int index) OVERRIDE; 47 virtual void OnWillRemoveBookmarks(BookmarkModel* model, 48 const BookmarkNode* parent, 49 int old_index, 50 const BookmarkNode* node) OVERRIDE; 51 virtual void OnWillRemoveAllBookmarks(BookmarkModel* model) OVERRIDE; 52 virtual void OnWillChangeBookmarkNode(BookmarkModel* model, 53 const BookmarkNode* node) OVERRIDE; 54 virtual void OnWillReorderBookmarkNode(BookmarkModel* model, 55 const BookmarkNode* node) OVERRIDE; 56 57 // BookmarkRenumberObserver: 58 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) OVERRIDE; 59 60 Profile* profile_; 61 UndoManager undo_manager_; 62 63 DISALLOW_COPY_AND_ASSIGN(BookmarkUndoService); 64 }; 65 66 #endif // CHROME_BROWSER_UNDO_BOOKMARK_UNDO_SERVICE_H_ 67