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.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 9 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
10 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 | 384 |
385 // BookmarkUndoService -------------------------------------------------------- | 385 // BookmarkUndoService -------------------------------------------------------- |
386 | 386 |
387 BookmarkUndoService::BookmarkUndoService(Profile* profile) : profile_(profile) { | 387 BookmarkUndoService::BookmarkUndoService(Profile* profile) : profile_(profile) { |
388 } | 388 } |
389 | 389 |
390 BookmarkUndoService::~BookmarkUndoService() { | 390 BookmarkUndoService::~BookmarkUndoService() { |
391 BookmarkModelFactory::GetForProfile(profile_)->RemoveObserver(this); | 391 BookmarkModelFactory::GetForProfile(profile_)->RemoveObserver(this); |
392 } | 392 } |
393 | 393 |
394 void BookmarkUndoService::OnBookmarkRenumbered(int64 old_id, int64 new_id) { | |
Tom Cassiotis
2014/02/05 20:06:08
This function was not in the same order as in the
| |
395 std::vector<UndoOperation*> all_operations = | |
396 undo_manager()->GetAllUndoOperations(); | |
397 for (std::vector<UndoOperation*>::iterator it = all_operations.begin(); | |
398 it != all_operations.end(); ++it) { | |
399 static_cast<BookmarkUndoOperation*>(*it)->OnBookmarkRenumbered(old_id, | |
400 new_id); | |
401 } | |
402 } | |
403 | |
404 void BookmarkUndoService::BookmarkModelLoaded(BookmarkModel* model, | 394 void BookmarkUndoService::BookmarkModelLoaded(BookmarkModel* model, |
405 bool ids_reassigned) { | 395 bool ids_reassigned) { |
406 undo_manager_.RemoveAllOperations(); | 396 undo_manager_.RemoveAllOperations(); |
407 } | 397 } |
408 | 398 |
409 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) { | 399 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) { |
410 undo_manager_.RemoveAllOperations(); | 400 undo_manager_.RemoveAllOperations(); |
411 } | 401 } |
412 | 402 |
413 void BookmarkUndoService::BookmarkNodeMoved(BookmarkModel* model, | 403 void BookmarkUndoService::BookmarkNodeMoved(BookmarkModel* model, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 const BookmarkNode* node) { | 449 const BookmarkNode* node) { |
460 scoped_ptr<UndoOperation> op(new BookmarkEditOperation(profile_, node)); | 450 scoped_ptr<UndoOperation> op(new BookmarkEditOperation(profile_, node)); |
461 undo_manager()->AddUndoOperation(op.Pass()); | 451 undo_manager()->AddUndoOperation(op.Pass()); |
462 } | 452 } |
463 | 453 |
464 void BookmarkUndoService::OnWillReorderBookmarkNode(BookmarkModel* model, | 454 void BookmarkUndoService::OnWillReorderBookmarkNode(BookmarkModel* model, |
465 const BookmarkNode* node) { | 455 const BookmarkNode* node) { |
466 scoped_ptr<UndoOperation> op(new BookmarkReorderOperation(profile_, node)); | 456 scoped_ptr<UndoOperation> op(new BookmarkReorderOperation(profile_, node)); |
467 undo_manager()->AddUndoOperation(op.Pass()); | 457 undo_manager()->AddUndoOperation(op.Pass()); |
468 } | 458 } |
459 | |
460 void BookmarkUndoService::GroupedBookmarkChangesBeginning( | |
461 BookmarkModel* model) { | |
462 undo_manager()->StartGroupingActions(); | |
463 } | |
464 | |
465 void BookmarkUndoService::GroupedBookmarkChangesEnded(BookmarkModel* model) { | |
466 undo_manager()->EndGroupingActions(); | |
467 } | |
468 | |
469 void BookmarkUndoService::OnBookmarkRenumbered(int64 old_id, int64 new_id) { | |
470 std::vector<UndoOperation*> all_operations = | |
471 undo_manager()->GetAllUndoOperations(); | |
472 for (std::vector<UndoOperation*>::iterator it = all_operations.begin(); | |
473 it != all_operations.end(); ++it) { | |
474 static_cast<BookmarkUndoOperation*>(*it)->OnBookmarkRenumbered(old_id, | |
475 new_id); | |
476 } | |
477 } | |
478 | |
OLD | NEW |