| 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 "components/undo/bookmark_undo_service.h" | 5 #include "components/undo/bookmark_undo_service.h" |
| 6 | 6 |
| 7 #include "components/bookmarks/browser/bookmark_model.h" | 7 #include "components/bookmarks/browser/bookmark_model.h" |
| 8 #include "components/bookmarks/browser/bookmark_node_data.h" | 8 #include "components/bookmarks/browser/bookmark_node_data.h" |
| 9 #include "components/bookmarks/browser/bookmark_utils.h" | 9 #include "components/bookmarks/browser/bookmark_utils.h" |
| 10 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h" | 10 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 for (size_t i = 0; i < ordered_bookmarks_.size(); ++i) { | 395 for (size_t i = 0; i < ordered_bookmarks_.size(); ++i) { |
| 396 if (ordered_bookmarks_[i] == old_id) | 396 if (ordered_bookmarks_[i] == old_id) |
| 397 ordered_bookmarks_[i] = new_id; | 397 ordered_bookmarks_[i] = new_id; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace | 401 } // namespace |
| 402 | 402 |
| 403 // BookmarkUndoService -------------------------------------------------------- | 403 // BookmarkUndoService -------------------------------------------------------- |
| 404 | 404 |
| 405 BookmarkUndoService::BookmarkUndoService() : scoped_observer_(this) { | 405 BookmarkUndoService::BookmarkUndoService() |
| 406 : model_(NULL), scoped_observer_(this) { |
| 406 } | 407 } |
| 407 | 408 |
| 408 BookmarkUndoService::~BookmarkUndoService() { | 409 BookmarkUndoService::~BookmarkUndoService() { |
| 409 } | 410 } |
| 410 | 411 |
| 411 void BookmarkUndoService::Start(BookmarkModel* model) { | 412 void BookmarkUndoService::Start(BookmarkModel* model) { |
| 413 DCHECK(!model_); |
| 414 model_ = model; |
| 412 scoped_observer_.Add(model); | 415 scoped_observer_.Add(model); |
| 413 } | 416 } |
| 414 | 417 |
| 415 void BookmarkUndoService::Shutdown() { | 418 void BookmarkUndoService::Shutdown() { |
| 419 model_ = NULL; |
| 416 scoped_observer_.RemoveAll(); | 420 scoped_observer_.RemoveAll(); |
| 417 } | 421 } |
| 418 | 422 |
| 419 void BookmarkUndoService::BookmarkModelLoaded(BookmarkModel* model, | 423 void BookmarkUndoService::BookmarkModelLoaded(BookmarkModel* model, |
| 420 bool ids_reassigned) { | 424 bool ids_reassigned) { |
| 421 undo_manager_.RemoveAllOperations(); | 425 undo_manager_.RemoveAllOperations(); |
| 422 } | 426 } |
| 423 | 427 |
| 424 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) { | 428 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) { |
| 425 undo_manager_.RemoveAllOperations(); | 429 undo_manager_.RemoveAllOperations(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 undo_manager()->EndGroupingActions(); | 489 undo_manager()->EndGroupingActions(); |
| 486 } | 490 } |
| 487 | 491 |
| 488 void BookmarkUndoService::OnBookmarkRenumbered(int64 old_id, int64 new_id) { | 492 void BookmarkUndoService::OnBookmarkRenumbered(int64 old_id, int64 new_id) { |
| 489 std::vector<UndoOperation*> all_operations = | 493 std::vector<UndoOperation*> all_operations = |
| 490 undo_manager()->GetAllUndoOperations(); | 494 undo_manager()->GetAllUndoOperations(); |
| 491 for (UndoOperation* op : all_operations) { | 495 for (UndoOperation* op : all_operations) { |
| 492 static_cast<BookmarkUndoOperation*>(op) | 496 static_cast<BookmarkUndoOperation*>(op) |
| 493 ->OnBookmarkRenumbered(old_id, new_id); | 497 ->OnBookmarkRenumbered(old_id, new_id); |
| 494 } | 498 } |
| 499 |
| 500 if (model_) |
| 501 model_->OnBookmarkRenumbered(old_id, new_id); |
| 495 } | 502 } |
| OLD | NEW |