Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chrome/browser/undo/bookmark_undo_service.cc

Issue 176563002: Revert r252832: Eliminate Bookmarks dependence to bookmark_undo_utils.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/undo/bookmark_undo_service.h ('k') | chrome/browser/undo/bookmark_undo_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/browser/bookmarks/scoped_group_bookmark_actions.h"
12 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/undo/bookmark_renumber_observer.h" 12 #include "chrome/browser/undo/bookmark_renumber_observer.h"
14 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 13 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
14 #include "chrome/browser/undo/bookmark_undo_utils.h"
15 #include "chrome/browser/undo/undo_operation.h" 15 #include "chrome/browser/undo/undo_operation.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 18
19 namespace { 19 namespace {
20 20
21 // BookmarkUndoOperation ------------------------------------------------------ 21 // BookmarkUndoOperation ------------------------------------------------------
22 22
23 // Base class for all bookmark related UndoOperations that facilitates access to 23 // Base class for all bookmark related UndoOperations that facilitates access to
24 // the BookmarkUndoService. 24 // the BookmarkUndoService.
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
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
394 void BookmarkUndoService::BookmarkModelLoaded(BookmarkModel* model, 404 void BookmarkUndoService::BookmarkModelLoaded(BookmarkModel* model,
395 bool ids_reassigned) { 405 bool ids_reassigned) {
396 undo_manager_.RemoveAllOperations(); 406 undo_manager_.RemoveAllOperations();
397 } 407 }
398 408
399 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) { 409 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) {
400 undo_manager_.RemoveAllOperations(); 410 undo_manager_.RemoveAllOperations();
401 } 411 }
402 412
403 void BookmarkUndoService::BookmarkNodeMoved(BookmarkModel* model, 413 void BookmarkUndoService::BookmarkNodeMoved(BookmarkModel* model,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 const BookmarkNode* node) { 459 const BookmarkNode* node) {
450 scoped_ptr<UndoOperation> op(new BookmarkEditOperation(profile_, node)); 460 scoped_ptr<UndoOperation> op(new BookmarkEditOperation(profile_, node));
451 undo_manager()->AddUndoOperation(op.Pass()); 461 undo_manager()->AddUndoOperation(op.Pass());
452 } 462 }
453 463
454 void BookmarkUndoService::OnWillReorderBookmarkNode(BookmarkModel* model, 464 void BookmarkUndoService::OnWillReorderBookmarkNode(BookmarkModel* model,
455 const BookmarkNode* node) { 465 const BookmarkNode* node) {
456 scoped_ptr<UndoOperation> op(new BookmarkReorderOperation(profile_, node)); 466 scoped_ptr<UndoOperation> op(new BookmarkReorderOperation(profile_, node));
457 undo_manager()->AddUndoOperation(op.Pass()); 467 undo_manager()->AddUndoOperation(op.Pass());
458 } 468 }
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
OLDNEW
« no previous file with comments | « chrome/browser/undo/bookmark_undo_service.h ('k') | chrome/browser/undo/bookmark_undo_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698