| OLD | NEW |
| 1 | 1 |
| 2 // Copyright 2016 The Chromium Authors. All rights reserved. | 2 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ | 6 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ |
| 7 #define COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ | 7 #define COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ |
| 8 | 8 |
| 9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/reading_list/ios/reading_list_model_observer.h" | 12 #include "components/reading_list/ios/reading_list_model_observer.h" |
| 13 | 13 |
| 14 // Protocol duplicating all Reading List Model Observer methods in Objective-C. | 14 // Protocol duplicating all Reading List Model Observer methods in Objective-C. |
| 15 @protocol ReadingListModelBridgeObserver<NSObject> | 15 @protocol ReadingListModelBridgeObserver<NSObject> |
| 16 | 16 |
| 17 @required | 17 @required |
| 18 |
| 18 - (void)readingListModelLoaded:(const ReadingListModel*)model; | 19 - (void)readingListModelLoaded:(const ReadingListModel*)model; |
| 19 - (void)readingListModelDidApplyChanges:(const ReadingListModel*)model; | 20 - (void)readingListModelDidApplyChanges:(const ReadingListModel*)model; |
| 20 | 21 |
| 21 @optional | 22 @optional |
| 22 - (void)readingListModel:(const ReadingListModel*)model | 23 - (void)readingListModel:(const ReadingListModel*)model |
| 23 willRemoveUnreadEntryAtIndex:(size_t)index; | 24 willRemoveEntry:(const GURL&)url; |
| 24 - (void)readingListModel:(const ReadingListModel*)model | |
| 25 willRemoveReadEntryAtIndex:(size_t)index; | |
| 26 | 25 |
| 27 - (void)readingListModel:(const ReadingListModel*)model | 26 - (void)readingListModel:(const ReadingListModel*)model |
| 28 willMoveEntry:(size_t)unreadIndex | 27 willMoveEntry:(const GURL&)url; |
| 29 isRead:(BOOL)read; | |
| 30 | 28 |
| 31 - (void)readingListModel:(const ReadingListModel*)model | 29 - (void)readingListModel:(const ReadingListModel*)model |
| 32 willAddUnreadEntry:(const ReadingListEntry&)entry; | 30 willAddEntry:(const ReadingListEntry&)entry; |
| 31 |
| 33 - (void)readingListModel:(const ReadingListModel*)model | 32 - (void)readingListModel:(const ReadingListModel*)model |
| 34 willAddReadEntry:(const ReadingListEntry&)entry; | 33 didAddEntry:(const GURL&)url; |
| 35 | 34 |
| 36 - (void)readingListModelBeganBatchUpdates:(const ReadingListModel*)model; | 35 - (void)readingListModelBeganBatchUpdates:(const ReadingListModel*)model; |
| 37 - (void)readingListModelCompletedBatchUpdates:(const ReadingListModel*)model; | 36 - (void)readingListModelCompletedBatchUpdates:(const ReadingListModel*)model; |
| 38 | 37 |
| 39 - (void)readingListModelBeingDeleted:(const ReadingListModel*)model; | 38 - (void)readingListModelBeingDeleted:(const ReadingListModel*)model; |
| 40 | 39 |
| 41 - (void)readingListModel:(const ReadingListModel*)model | 40 - (void)readingListModel:(const ReadingListModel*)model |
| 42 willUpdateUnreadEntryAtIndex:(size_t)index; | 41 willUpdateEntry:(const GURL&)url; |
| 43 - (void)readingListModel:(const ReadingListModel*)model | |
| 44 willUpdateReadEntryAtIndex:(size_t)index; | |
| 45 | 42 |
| 46 @end | 43 @end |
| 47 | 44 |
| 48 // Observer for the Reading List model that translates all the callbacks to | 45 // Observer for the Reading List model that translates all the callbacks to |
| 49 // Objective-C calls. | 46 // Objective-C calls. |
| 50 class ReadingListModelBridge : public ReadingListModelObserver { | 47 class ReadingListModelBridge : public ReadingListModelObserver { |
| 51 public: | 48 public: |
| 52 explicit ReadingListModelBridge(id<ReadingListModelBridgeObserver> observer, | 49 explicit ReadingListModelBridge(id<ReadingListModelBridgeObserver> observer, |
| 53 ReadingListModel* model); | 50 ReadingListModel* model); |
| 54 ~ReadingListModelBridge() override; | 51 ~ReadingListModelBridge() override; |
| 55 | 52 |
| 56 private: | 53 private: |
| 57 void ReadingListModelBeganBatchUpdates( | 54 void ReadingListModelBeganBatchUpdates( |
| 58 const ReadingListModel* model) override; | 55 const ReadingListModel* model) override; |
| 59 | 56 |
| 60 void ReadingListModelCompletedBatchUpdates( | 57 void ReadingListModelCompletedBatchUpdates( |
| 61 const ReadingListModel* model) override; | 58 const ReadingListModel* model) override; |
| 62 void ReadingListModelLoaded(const ReadingListModel* model) override; | 59 void ReadingListModelLoaded(const ReadingListModel* model) override; |
| 63 void ReadingListModelBeingDeleted(const ReadingListModel* model) override; | 60 void ReadingListModelBeingDeleted(const ReadingListModel* model) override; |
| 64 void ReadingListWillRemoveUnreadEntry(const ReadingListModel* model, | 61 void ReadingListWillRemoveEntry(const ReadingListModel* model, |
| 65 size_t index) override; | 62 const GURL& url) override; |
| 66 void ReadingListWillRemoveReadEntry(const ReadingListModel* model, | |
| 67 size_t index) override; | |
| 68 void ReadingListWillMoveEntry(const ReadingListModel* model, | 63 void ReadingListWillMoveEntry(const ReadingListModel* model, |
| 69 size_t index, | 64 const GURL& url) override; |
| 70 bool read) override; | 65 void ReadingListWillAddEntry(const ReadingListModel* model, |
| 71 void ReadingListWillAddUnreadEntry(const ReadingListModel* model, | 66 const ReadingListEntry& entry) override; |
| 72 const ReadingListEntry& entry) override; | 67 void ReadingListDidAddEntry(const ReadingListModel* model, |
| 73 void ReadingListWillAddReadEntry(const ReadingListModel* model, | 68 const GURL& url) override; |
| 74 const ReadingListEntry& entry) override; | |
| 75 void ReadingListDidApplyChanges(ReadingListModel* model) override; | 69 void ReadingListDidApplyChanges(ReadingListModel* model) override; |
| 76 void ReadingListWillUpdateUnreadEntry(const ReadingListModel* model, | 70 void ReadingListWillUpdateEntry(const ReadingListModel* model, |
| 77 size_t index) override; | 71 const GURL& url) override; |
| 78 void ReadingListWillUpdateReadEntry(const ReadingListModel* model, | |
| 79 size_t index) override; | |
| 80 | 72 |
| 81 __unsafe_unretained id<ReadingListModelBridgeObserver> observer_; | 73 __unsafe_unretained id<ReadingListModelBridgeObserver> observer_; |
| 82 ReadingListModel* model_; // weak | 74 ReadingListModel* model_; // weak |
| 83 | 75 |
| 84 DISALLOW_COPY_AND_ASSIGN(ReadingListModelBridge); | 76 DISALLOW_COPY_AND_ASSIGN(ReadingListModelBridge); |
| 85 }; | 77 }; |
| 86 | 78 |
| 87 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ | 79 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_BRIDGE_OBSERVER_H_ |
| OLD | NEW |