| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_utils.h" | 5 #include "chrome/browser/undo/bookmark_undo_utils.h" |
| 6 | 6 |
| 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 7 #include "chrome/browser/undo/bookmark_undo_service.h" | 9 #include "chrome/browser/undo/bookmark_undo_service.h" |
| 8 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 10 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 9 #include "chrome/browser/undo/undo_manager.h" | 11 #include "chrome/browser/undo/undo_manager.h" |
| 10 | 12 |
| 11 namespace { | 13 namespace { |
| 12 | 14 |
| 13 // Utility funciton to safely return an UndoManager if available. | 15 // Utility funciton to safely return an UndoManager if available. |
| 14 UndoManager* GetUndoManager(Profile* profile) { | 16 UndoManager* GetUndoManager(Profile* profile) { |
| 15 BookmarkUndoService* undo_service = profile ? | 17 BookmarkUndoService* undo_service = profile ? |
| 16 BookmarkUndoServiceFactory::GetForProfile(profile) : NULL; | 18 BookmarkUndoServiceFactory::GetForProfile(profile) : NULL; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 ScopedSuspendBookmarkUndo::~ScopedSuspendBookmarkUndo() { | 33 ScopedSuspendBookmarkUndo::~ScopedSuspendBookmarkUndo() { |
| 32 UndoManager *undo_manager = GetUndoManager(profile_); | 34 UndoManager *undo_manager = GetUndoManager(profile_); |
| 33 if (undo_manager) | 35 if (undo_manager) |
| 34 undo_manager->ResumeUndoTracking(); | 36 undo_manager->ResumeUndoTracking(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 // ScopedGroupBookmarkActions ------------------------------------------------- | 39 // ScopedGroupBookmarkActions ------------------------------------------------- |
| 38 | 40 |
| 39 ScopedGroupBookmarkActions::ScopedGroupBookmarkActions(Profile* profile) | 41 ScopedGroupBookmarkActions::ScopedGroupBookmarkActions(Profile* profile) |
| 40 : profile_(profile) { | 42 : profile_(profile) { |
| 41 UndoManager *undo_manager = GetUndoManager(profile_); | 43 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); |
| 42 if (undo_manager) | 44 if (model) |
| 43 undo_manager->StartGroupingActions(); | 45 model->BeginGroupedChanges(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 ScopedGroupBookmarkActions::~ScopedGroupBookmarkActions() { | 48 ScopedGroupBookmarkActions::~ScopedGroupBookmarkActions() { |
| 47 UndoManager *undo_manager = GetUndoManager(profile_); | 49 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); |
| 48 if (undo_manager) | 50 if (model) |
| 49 undo_manager->EndGroupingActions(); | 51 model->EndGroupedChanges(); |
| 50 } | 52 } |
| OLD | NEW |