OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/undo/bookmark_undo_service.h" | 5 #include "chrome/browser/undo/bookmark_undo_service.h" |
6 | 6 |
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/undo/bookmark_renumber_observer.h" | 9 #include "chrome/browser/undo/bookmark_renumber_observer.h" |
10 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 10 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 // BookmarkAddOperation ------------------------------------------------------- | 52 // BookmarkAddOperation ------------------------------------------------------- |
53 | 53 |
54 // Handles the undo of the insertion of a bookmark or folder. | 54 // Handles the undo of the insertion of a bookmark or folder. |
55 class BookmarkAddOperation : public BookmarkUndoOperation { | 55 class BookmarkAddOperation : public BookmarkUndoOperation { |
56 public: | 56 public: |
57 BookmarkAddOperation(Profile* profile, const BookmarkNode* parent, int index); | 57 BookmarkAddOperation(Profile* profile, const BookmarkNode* parent, int index); |
58 virtual ~BookmarkAddOperation() {} | 58 virtual ~BookmarkAddOperation() {} |
59 | 59 |
60 // UndoOperation: | 60 // UndoOperation: |
61 virtual void Undo() OVERRIDE; | 61 virtual void Undo() override; |
62 virtual int GetUndoLabelId() const OVERRIDE; | 62 virtual int GetUndoLabelId() const override; |
63 virtual int GetRedoLabelId() const OVERRIDE; | 63 virtual int GetRedoLabelId() const override; |
64 | 64 |
65 // BookmarkRenumberObserver: | 65 // BookmarkRenumberObserver: |
66 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) OVERRIDE; | 66 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) override; |
67 | 67 |
68 private: | 68 private: |
69 int64 parent_id_; | 69 int64 parent_id_; |
70 const int index_; | 70 const int index_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(BookmarkAddOperation); | 72 DISALLOW_COPY_AND_ASSIGN(BookmarkAddOperation); |
73 }; | 73 }; |
74 | 74 |
75 BookmarkAddOperation::BookmarkAddOperation(Profile* profile, | 75 BookmarkAddOperation::BookmarkAddOperation(Profile* profile, |
76 const BookmarkNode* parent, | 76 const BookmarkNode* parent, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // The BookmarkModel allows only single bookmark node to be removed. | 110 // The BookmarkModel allows only single bookmark node to be removed. |
111 class BookmarkRemoveOperation : public BookmarkUndoOperation { | 111 class BookmarkRemoveOperation : public BookmarkUndoOperation { |
112 public: | 112 public: |
113 BookmarkRemoveOperation(Profile* profile, | 113 BookmarkRemoveOperation(Profile* profile, |
114 const BookmarkNode* parent, | 114 const BookmarkNode* parent, |
115 int old_index, | 115 int old_index, |
116 const BookmarkNode* node); | 116 const BookmarkNode* node); |
117 virtual ~BookmarkRemoveOperation() {} | 117 virtual ~BookmarkRemoveOperation() {} |
118 | 118 |
119 // UndoOperation: | 119 // UndoOperation: |
120 virtual void Undo() OVERRIDE; | 120 virtual void Undo() override; |
121 virtual int GetUndoLabelId() const OVERRIDE; | 121 virtual int GetUndoLabelId() const override; |
122 virtual int GetRedoLabelId() const OVERRIDE; | 122 virtual int GetRedoLabelId() const override; |
123 | 123 |
124 // BookmarkRenumberObserver: | 124 // BookmarkRenumberObserver: |
125 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) OVERRIDE; | 125 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) override; |
126 | 126 |
127 private: | 127 private: |
128 void UpdateBookmarkIds(const BookmarkNodeData::Element& element, | 128 void UpdateBookmarkIds(const BookmarkNodeData::Element& element, |
129 const BookmarkNode* parent, | 129 const BookmarkNode* parent, |
130 int index_added_at) const; | 130 int index_added_at) const; |
131 | 131 |
132 int64 parent_id_; | 132 int64 parent_id_; |
133 const int old_index_; | 133 const int old_index_; |
134 BookmarkNodeData removed_node_; | 134 BookmarkNodeData removed_node_; |
135 | 135 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // BookmarkEditOperation ------------------------------------------------------ | 187 // BookmarkEditOperation ------------------------------------------------------ |
188 | 188 |
189 // Handles the undo of the modification of a bookmark node. | 189 // Handles the undo of the modification of a bookmark node. |
190 class BookmarkEditOperation : public BookmarkUndoOperation { | 190 class BookmarkEditOperation : public BookmarkUndoOperation { |
191 public: | 191 public: |
192 BookmarkEditOperation(Profile* profile, | 192 BookmarkEditOperation(Profile* profile, |
193 const BookmarkNode* node); | 193 const BookmarkNode* node); |
194 virtual ~BookmarkEditOperation() {} | 194 virtual ~BookmarkEditOperation() {} |
195 | 195 |
196 // UndoOperation: | 196 // UndoOperation: |
197 virtual void Undo() OVERRIDE; | 197 virtual void Undo() override; |
198 virtual int GetUndoLabelId() const OVERRIDE; | 198 virtual int GetUndoLabelId() const override; |
199 virtual int GetRedoLabelId() const OVERRIDE; | 199 virtual int GetRedoLabelId() const override; |
200 | 200 |
201 // BookmarkRenumberObserver: | 201 // BookmarkRenumberObserver: |
202 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) OVERRIDE; | 202 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) override; |
203 | 203 |
204 private: | 204 private: |
205 int64 node_id_; | 205 int64 node_id_; |
206 BookmarkNodeData original_bookmark_; | 206 BookmarkNodeData original_bookmark_; |
207 | 207 |
208 DISALLOW_COPY_AND_ASSIGN(BookmarkEditOperation); | 208 DISALLOW_COPY_AND_ASSIGN(BookmarkEditOperation); |
209 }; | 209 }; |
210 | 210 |
211 BookmarkEditOperation::BookmarkEditOperation(Profile* profile, | 211 BookmarkEditOperation::BookmarkEditOperation(Profile* profile, |
212 const BookmarkNode* node) | 212 const BookmarkNode* node) |
(...skipping 30 matching lines...) Expand all Loading... |
243 | 243 |
244 // Handles the undo of a bookmark being moved to a new location. | 244 // Handles the undo of a bookmark being moved to a new location. |
245 class BookmarkMoveOperation : public BookmarkUndoOperation { | 245 class BookmarkMoveOperation : public BookmarkUndoOperation { |
246 public: | 246 public: |
247 BookmarkMoveOperation(Profile* profile, | 247 BookmarkMoveOperation(Profile* profile, |
248 const BookmarkNode* old_parent, | 248 const BookmarkNode* old_parent, |
249 int old_index, | 249 int old_index, |
250 const BookmarkNode* new_parent, | 250 const BookmarkNode* new_parent, |
251 int new_index); | 251 int new_index); |
252 virtual ~BookmarkMoveOperation() {} | 252 virtual ~BookmarkMoveOperation() {} |
253 virtual int GetUndoLabelId() const OVERRIDE; | 253 virtual int GetUndoLabelId() const override; |
254 virtual int GetRedoLabelId() const OVERRIDE; | 254 virtual int GetRedoLabelId() const override; |
255 | 255 |
256 // UndoOperation: | 256 // UndoOperation: |
257 virtual void Undo() OVERRIDE; | 257 virtual void Undo() override; |
258 | 258 |
259 // BookmarkRenumberObserver: | 259 // BookmarkRenumberObserver: |
260 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) OVERRIDE; | 260 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) override; |
261 | 261 |
262 private: | 262 private: |
263 int64 old_parent_id_; | 263 int64 old_parent_id_; |
264 int64 new_parent_id_; | 264 int64 new_parent_id_; |
265 int old_index_; | 265 int old_index_; |
266 int new_index_; | 266 int new_index_; |
267 | 267 |
268 DISALLOW_COPY_AND_ASSIGN(BookmarkMoveOperation); | 268 DISALLOW_COPY_AND_ASSIGN(BookmarkMoveOperation); |
269 }; | 269 }; |
270 | 270 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // sorting a bookmark folder by name or the undo of that operation. The change | 322 // sorting a bookmark folder by name or the undo of that operation. The change |
323 // of order is not recursive so only the order of the immediate children of the | 323 // of order is not recursive so only the order of the immediate children of the |
324 // folder need to be restored. | 324 // folder need to be restored. |
325 class BookmarkReorderOperation : public BookmarkUndoOperation { | 325 class BookmarkReorderOperation : public BookmarkUndoOperation { |
326 public: | 326 public: |
327 BookmarkReorderOperation(Profile* profile, | 327 BookmarkReorderOperation(Profile* profile, |
328 const BookmarkNode* parent); | 328 const BookmarkNode* parent); |
329 virtual ~BookmarkReorderOperation(); | 329 virtual ~BookmarkReorderOperation(); |
330 | 330 |
331 // UndoOperation: | 331 // UndoOperation: |
332 virtual void Undo() OVERRIDE; | 332 virtual void Undo() override; |
333 virtual int GetUndoLabelId() const OVERRIDE; | 333 virtual int GetUndoLabelId() const override; |
334 virtual int GetRedoLabelId() const OVERRIDE; | 334 virtual int GetRedoLabelId() const override; |
335 | 335 |
336 // BookmarkRenumberObserver: | 336 // BookmarkRenumberObserver: |
337 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) OVERRIDE; | 337 virtual void OnBookmarkRenumbered(int64 old_id, int64 new_id) override; |
338 | 338 |
339 private: | 339 private: |
340 int64 parent_id_; | 340 int64 parent_id_; |
341 std::vector<int64> ordered_bookmarks_; | 341 std::vector<int64> ordered_bookmarks_; |
342 | 342 |
343 DISALLOW_COPY_AND_ASSIGN(BookmarkReorderOperation); | 343 DISALLOW_COPY_AND_ASSIGN(BookmarkReorderOperation); |
344 }; | 344 }; |
345 | 345 |
346 BookmarkReorderOperation::BookmarkReorderOperation(Profile* profile, | 346 BookmarkReorderOperation::BookmarkReorderOperation(Profile* profile, |
347 const BookmarkNode* parent) | 347 const BookmarkNode* parent) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 476 |
477 void BookmarkUndoService::OnBookmarkRenumbered(int64 old_id, int64 new_id) { | 477 void BookmarkUndoService::OnBookmarkRenumbered(int64 old_id, int64 new_id) { |
478 std::vector<UndoOperation*> all_operations = | 478 std::vector<UndoOperation*> all_operations = |
479 undo_manager()->GetAllUndoOperations(); | 479 undo_manager()->GetAllUndoOperations(); |
480 for (std::vector<UndoOperation*>::iterator it = all_operations.begin(); | 480 for (std::vector<UndoOperation*>::iterator it = all_operations.begin(); |
481 it != all_operations.end(); ++it) { | 481 it != all_operations.end(); ++it) { |
482 static_cast<BookmarkUndoOperation*>(*it)->OnBookmarkRenumbered(old_id, | 482 static_cast<BookmarkUndoOperation*>(*it)->OnBookmarkRenumbered(old_id, |
483 new_id); | 483 new_id); |
484 } | 484 } |
485 } | 485 } |
OLD | NEW |