| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.h" | 5 #include "ios/chrome/browser/ui/bookmarks/undo_manager_wrapper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "components/undo/bookmark_undo_service.h" | 9 #include "components/undo/bookmark_undo_service.h" |
| 10 #include "components/undo/undo_manager.h" | 10 #include "components/undo/undo_manager.h" |
| 11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 12 #include "ios/chrome/browser/ui/bookmarks/undo_manager_bridge_observer.h" | 12 #include "ios/chrome/browser/ui/bookmarks/undo_manager_bridge_observer.h" |
| 13 #include "ios/chrome/browser/undo/bookmark_undo_service_factory.h" | 13 #include "ios/chrome/browser/undo/bookmark_undo_service_factory.h" |
| 14 | 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." |
| 17 #endif |
| 18 |
| 15 @interface UndoManagerWrapper ()<UndoManagerBridgeObserver> { | 19 @interface UndoManagerWrapper ()<UndoManagerBridgeObserver> { |
| 16 std::unique_ptr<bookmarks::UndoManagerBridge> _bridge; | 20 std::unique_ptr<bookmarks::UndoManagerBridge> _bridge; |
| 17 } | 21 } |
| 18 @property(nonatomic, assign) UndoManager* undoManager; | 22 @property(nonatomic, assign) UndoManager* undoManager; |
| 19 @property(nonatomic, assign) BOOL hasUndoManagerChanged; | 23 @property(nonatomic, assign) BOOL hasUndoManagerChanged; |
| 20 @end | 24 @end |
| 21 | 25 |
| 22 @implementation UndoManagerWrapper | 26 @implementation UndoManagerWrapper |
| 23 @synthesize hasUndoManagerChanged = _hasUndoManagerChanged; | 27 @synthesize hasUndoManagerChanged = _hasUndoManagerChanged; |
| 24 @synthesize undoManager = _undoManager; | 28 @synthesize undoManager = _undoManager; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 ios::BookmarkUndoServiceFactory::GetForBrowserState(browserState) | 39 ios::BookmarkUndoServiceFactory::GetForBrowserState(browserState) |
| 36 ->undo_manager(); | 40 ->undo_manager(); |
| 37 _bridge.reset(new bookmarks::UndoManagerBridge(self)); | 41 _bridge.reset(new bookmarks::UndoManagerBridge(self)); |
| 38 _undoManager->AddObserver(_bridge.get()); | 42 _undoManager->AddObserver(_bridge.get()); |
| 39 } | 43 } |
| 40 return self; | 44 return self; |
| 41 } | 45 } |
| 42 | 46 |
| 43 - (void)dealloc { | 47 - (void)dealloc { |
| 44 _undoManager->RemoveObserver(_bridge.get()); | 48 _undoManager->RemoveObserver(_bridge.get()); |
| 45 [super dealloc]; | |
| 46 } | 49 } |
| 47 | 50 |
| 48 #pragma mark - Public Methods | 51 #pragma mark - Public Methods |
| 49 | 52 |
| 50 - (void)startGroupingActions { | 53 - (void)startGroupingActions { |
| 51 self.undoManager->StartGroupingActions(); | 54 self.undoManager->StartGroupingActions(); |
| 52 } | 55 } |
| 53 | 56 |
| 54 - (void)stopGroupingActions { | 57 - (void)stopGroupingActions { |
| 55 self.undoManager->EndGroupingActions(); | 58 self.undoManager->EndGroupingActions(); |
| 56 } | 59 } |
| 57 | 60 |
| 58 - (void)resetUndoManagerChanged { | 61 - (void)resetUndoManagerChanged { |
| 59 self.hasUndoManagerChanged = NO; | 62 self.hasUndoManagerChanged = NO; |
| 60 } | 63 } |
| 61 | 64 |
| 62 - (void)undo { | 65 - (void)undo { |
| 63 self.undoManager->Undo(); | 66 self.undoManager->Undo(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 #pragma mark - UndoManagerBridgeObserver | 69 #pragma mark - UndoManagerBridgeObserver |
| 67 | 70 |
| 68 - (void)undoManagerChanged { | 71 - (void)undoManagerChanged { |
| 69 self.hasUndoManagerChanged = YES; | 72 self.hasUndoManagerChanged = YES; |
| 70 } | 73 } |
| 71 | 74 |
| 72 @end | 75 @end |
| OLD | NEW |