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

Unified Diff: chrome/browser/undo/undo_manager.cc

Issue 19287013: Bookmark Undo service for multiple level undo/redo of bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/undo/undo_manager.cc
diff --git a/chrome/browser/undo/undo_manager.cc b/chrome/browser/undo/undo_manager.cc
index 6b1c3de33df11abea08858ab16a2aaa185c2b14c..d6543eb14d2e0325c3766440d047d437ecb30f9d 100644
--- a/chrome/browser/undo/undo_manager.cc
+++ b/chrome/browser/undo/undo_manager.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/undo/undo_manager.h"
+#include <algorithm>
+
#include "base/auto_reset.h"
#include "base/logging.h"
#include "chrome/browser/undo/undo_operation.h"
@@ -53,7 +55,7 @@ void UndoManager::Redo() {
void UndoManager::AddUndoOperation(scoped_ptr<UndoOperation> operation) {
if (IsUndoTrakingSuspended()) {
- RemoveAllActions();
+ Reset();
operation.reset();
return;
}
@@ -63,10 +65,11 @@ void UndoManager::AddUndoOperation(scoped_ptr<UndoOperation> operation) {
} else {
UndoGroup* new_action = new UndoGroup();
new_action->AddOperation(operation.Pass());
- GetActiveUndoGroup()->insert(GetActiveUndoGroup()->end(), new_action);
+ GetActiveUndoGroup()->push_back(new_action);
- // A new user action invalidates any available redo actions.
- RemoveAllRedoActions();
+ // User actions invalidate any available redo actions.
+ if (is_user_action())
+ RemoveAllRedoActions();
}
}
@@ -84,11 +87,11 @@ void UndoManager::EndGroupingActions() {
// Check that StartGroupingActions and EndGroupingActions are paired.
DCHECK_GE(group_actions_count_, 0);
- bool is_user_action = !performing_undo_ && !performing_redo_;
if (pending_grouped_action_->has_operations()) {
GetActiveUndoGroup()->push_back(pending_grouped_action_.release());
+
// User actions invalidate any available redo actions.
- if (is_user_action)
+ if (is_user_action())
RemoveAllRedoActions();
} else {
// No changes were executed since we started grouping actions, so the
@@ -97,7 +100,7 @@ void UndoManager::EndGroupingActions() {
// This situation is only expected when it is a user initiated action.
// Undo/Redo should have at least one operation performed.
- DCHECK(is_user_action);
+ DCHECK(is_user_action());
}
}
@@ -132,7 +135,7 @@ void UndoManager::Undo(bool* performing_indicator,
EndGroupingActions();
}
-void UndoManager::RemoveAllActions() {
+void UndoManager::Reset() {
undo_actions_.clear();
RemoveAllRedoActions();
}

Powered by Google App Engine
This is Rietveld 408576698