| Index: ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.mm
|
| diff --git a/ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.mm b/ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2dbe79f6d227f536e1b441fde063dc10e903e2c3
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.mm
|
| @@ -0,0 +1,72 @@
|
| +// 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.
|
| +
|
| +#include "ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.h"
|
| +
|
| +#include <memory>
|
| +
|
| +#include "components/undo/bookmark_undo_service.h"
|
| +#include "components/undo/undo_manager.h"
|
| +#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
|
| +#include "ios/chrome/browser/ui/bookmarks/undo_manager_bridge_observer.h"
|
| +#include "ios/chrome/browser/undo/bookmark_undo_service_factory.h"
|
| +
|
| +@interface UndoManagerWrapper ()<UndoManagerBridgeObserver> {
|
| + std::unique_ptr<bookmarks::UndoManagerBridge> _bridge;
|
| +}
|
| +@property(nonatomic, assign) UndoManager* undoManager;
|
| +@property(nonatomic, assign) BOOL hasUndoManagerChanged;
|
| +@end
|
| +
|
| +@implementation UndoManagerWrapper
|
| +@synthesize hasUndoManagerChanged = _hasUndoManagerChanged;
|
| +@synthesize undoManager = _undoManager;
|
| +
|
| +- (id)init {
|
| + NOTREACHED();
|
| + return nil;
|
| +}
|
| +
|
| +- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState {
|
| + self = [super init];
|
| + if (self) {
|
| + _undoManager =
|
| + ios::BookmarkUndoServiceFactory::GetForBrowserState(browserState)
|
| + ->undo_manager();
|
| + _bridge.reset(new bookmarks::UndoManagerBridge(self));
|
| + _undoManager->AddObserver(_bridge.get());
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (void)dealloc {
|
| + _undoManager->RemoveObserver(_bridge.get());
|
| + [super dealloc];
|
| +}
|
| +
|
| +#pragma mark - Public Methods
|
| +
|
| +- (void)startGroupingActions {
|
| + self.undoManager->StartGroupingActions();
|
| +}
|
| +
|
| +- (void)stopGroupingActions {
|
| + self.undoManager->EndGroupingActions();
|
| +}
|
| +
|
| +- (void)resetUndoManagerChanged {
|
| + self.hasUndoManagerChanged = NO;
|
| +}
|
| +
|
| +- (void)undo {
|
| + self.undoManager->Undo();
|
| +}
|
| +
|
| +#pragma mark - UndoManagerBridgeObserver
|
| +
|
| +- (void)undoManagerChanged {
|
| + self.hasUndoManagerChanged = YES;
|
| +}
|
| +
|
| +@end
|
|
|