summaryrefslogtreecommitdiffstats
path: root/chrome/browser/undo
diff options
context:
space:
mode:
authortom.cassiotis@gmail.com <tom.cassiotis@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-30 23:02:07 +0000
committertom.cassiotis@gmail.com <tom.cassiotis@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-30 23:02:07 +0000
commite8325ac9da150a03aef94f966da08eaf916378d1 (patch)
tree3b1a7752e15dd63ee25df10cd2367829f6a04ec4 /chrome/browser/undo
parentc6141c6f1e9ea94a792396deb5b97fe6f2358e51 (diff)
downloadchromium_src-e8325ac9da150a03aef94f966da08eaf916378d1.zip
chromium_src-e8325ac9da150a03aef94f966da08eaf916378d1.tar.gz
chromium_src-e8325ac9da150a03aef94f966da08eaf916378d1.tar.bz2
Helper classes to scope undo action.
Added 2 helper classes that allow scoping of the suspension of undo tracking and grouping actions for undo. BUG=126092 R=sky Review URL: https://chromiumcodereview.appspot.com/20571004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/undo')
-rw-r--r--chrome/browser/undo/undo_manager_utils.cc29
-rw-r--r--chrome/browser/undo/undo_manager_utils.h41
2 files changed, 70 insertions, 0 deletions
diff --git a/chrome/browser/undo/undo_manager_utils.cc b/chrome/browser/undo/undo_manager_utils.cc
new file mode 100644
index 0000000..48c1d0e
--- /dev/null
+++ b/chrome/browser/undo/undo_manager_utils.cc
@@ -0,0 +1,29 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/undo/undo_manager_utils.h"
+
+#include "chrome/browser/undo/undo_manager.h"
+
+// ScopedSuspendUndoTracking --------------------------------------------------
+
+ScopedSuspendUndoTracking::ScopedSuspendUndoTracking(UndoManager* undo_manager)
+ : undo_manager_(undo_manager) {
+ undo_manager_->SuspendUndoTracking();
+}
+
+ScopedSuspendUndoTracking::~ScopedSuspendUndoTracking() {
+ undo_manager_->ResumeUndoTracking();
+}
+
+// ScopedGroupingAction -------------------------------------------------------
+
+ScopedGroupingAction::ScopedGroupingAction(UndoManager* undo_manager)
+ : undo_manager_(undo_manager) {
+ undo_manager_->StartGroupingActions();
+}
+
+ScopedGroupingAction::~ScopedGroupingAction() {
+ undo_manager_->EndGroupingActions();
+}
diff --git a/chrome/browser/undo/undo_manager_utils.h b/chrome/browser/undo/undo_manager_utils.h
new file mode 100644
index 0000000..b99817a
--- /dev/null
+++ b/chrome/browser/undo/undo_manager_utils.h
@@ -0,0 +1,41 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UNDO_UNDO_MANAGER_UTILS_H_
+#define CHROME_BROWSER_UNDO_UNDO_MANAGER_UTILS_H_
+
+#include "base/basictypes.h"
+
+class UndoManager;
+
+// ScopedSuspendUndoTracking ---------------------------------------------------
+
+// Scopes the suspension of the undo tracking for non-user initiated changes
+// such as those occuring during profile synchronization.
+class ScopedSuspendUndoTracking {
+ public:
+ explicit ScopedSuspendUndoTracking(UndoManager* undo_manager);
+ ~ScopedSuspendUndoTracking();
+
+ private:
+ UndoManager* undo_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedSuspendUndoTracking);
+};
+
+// ScopedGroupingAction --------------------------------------------------------
+
+// Scopes the grouping of a set of changes into one undoable action.
+class ScopedGroupingAction {
+ public:
+ explicit ScopedGroupingAction(UndoManager* undo_manager);
+ ~ScopedGroupingAction();
+
+ private:
+ UndoManager* undo_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedGroupingAction);
+};
+
+#endif // CHROME_BROWSER_UNDO_UNDO_MANAGER_UTILS_H_