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

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

Issue 155913004: Eliminate Bookmarks dependence to bookmark_undo_utils.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
OLDNEW
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;
17 return undo_service ? undo_service->undo_manager() : NULL; 19 return undo_service ? undo_service->undo_manager() : NULL;
18 } 20 }
19 21
20 } // namespace 22 } // namespace
21 23
22 // ScopedSuspendBookmarkUndo -------------------------------------------------- 24 // ScopedSuspendBookmarkUndo --------------------------------------------------
23 25
24 ScopedSuspendBookmarkUndo::ScopedSuspendBookmarkUndo(Profile* profile) 26 ScopedSuspendBookmarkUndo::ScopedSuspendBookmarkUndo(Profile* profile)
25 : profile_(profile) { 27 : profile_(profile) {
26 UndoManager* undo_manager = GetUndoManager(profile_); 28 UndoManager* undo_manager = GetUndoManager(profile_);
27 if (undo_manager) 29 if (undo_manager)
28 undo_manager->SuspendUndoTracking(); 30 undo_manager->SuspendUndoTracking();
29 } 31 }
30 32
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
37 // ScopedGroupBookmarkActions -------------------------------------------------
38
39 ScopedGroupBookmarkActions::ScopedGroupBookmarkActions(Profile* profile)
40 : profile_(profile) {
41 UndoManager *undo_manager = GetUndoManager(profile_);
42 if (undo_manager)
43 undo_manager->StartGroupingActions();
44 }
45
46 ScopedGroupBookmarkActions::~ScopedGroupBookmarkActions() {
47 UndoManager *undo_manager = GetUndoManager(profile_);
48 if (undo_manager)
49 undo_manager->EndGroupingActions();
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698