blob: 4725ea1731a8c03c1d34ce8c4b27f978462dfb34 [file] [log] [blame]
// Copyright 2014 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.
#import <Foundation/Foundation.h>
class ChromeBrowserState;
// This object is a convenience ObjC wrapper around UndoManager.
// On construction, it registers itself as an observer of the UndoManager.
// On destruction, it unregisters itself as an observer of the UndoManager.
// Provides a convenient interface to the UndoManager.
// The general usage of this class should be:
// - startGroupingActions
// - *make changes to BookmarkModel*
// - stopGroupingActions
// - resetUndoManagerChanged
// At a later point in time, an undo should only be attempted if
// hasUndoManagerChanged returns NO.
@interface UndoManagerWrapper : NSObject
// Designated initializer.
- (instancetype)initWithBrowserState:(ChromeBrowserState*)browserState;
// Subsequent changes to the BookmarkModel are grouped together so that a single
// undo will revert all changes.
- (void)startGroupingActions;
// Stops grouping changes to the BookmarkModel. Calls to this method must mirror
// calls to startGroupingActions.
- (void)stopGroupingActions;
// Resets the internal state for whether the UndoManager has changed to NO.
- (void)resetUndoManagerChanged;
// Returns YES if the UndoManager has changed since the last call to
// resetUndoManagerChanged.
- (BOOL)hasUndoManagerChanged;
// Reverts the last change made to the BookmarkModel.
- (void)undo;