| 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();
|
| }
|
|
|