| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "components/reading_list/reading_list_model_bridge_observer.h" | |
| 6 | |
| 7 #import "components/reading_list/reading_list_entry.h" | |
| 8 #import "components/reading_list/reading_list_model.h" | |
| 9 | |
| 10 ReadingListModelBridge::ReadingListModelBridge( | |
| 11 id<ReadingListModelBridgeObserver> observer, | |
| 12 ReadingListModel* model) | |
| 13 : observer_(observer), model_(model) { | |
| 14 DCHECK(model); | |
| 15 model_->AddObserver(this); | |
| 16 } | |
| 17 | |
| 18 ReadingListModelBridge::~ReadingListModelBridge() { | |
| 19 if (model_) { | |
| 20 model_->RemoveObserver(this); | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 void ReadingListModelBridge::ReadingListModelLoaded( | |
| 25 const ReadingListModel* model) { | |
| 26 [observer_ readingListModelLoaded:model]; | |
| 27 } | |
| 28 | |
| 29 void ReadingListModelBridge::ReadingListModelBeingDeleted( | |
| 30 const ReadingListModel* model) { | |
| 31 if ([observer_ respondsToSelector:@selector(readingListModelBeingDeleted:)]) { | |
| 32 [observer_ readingListModelBeingDeleted:model]; | |
| 33 } | |
| 34 model_ = nullptr; | |
| 35 } | |
| 36 | |
| 37 void ReadingListModelBridge::ReadingListWillRemoveUnreadEntry( | |
| 38 const ReadingListModel* model, | |
| 39 size_t index) { | |
| 40 if ([observer_ respondsToSelector:@selector(readingListModel: | |
| 41 willRemoveUnreadEntryAtIndex:)]) { | |
| 42 [observer_ readingListModel:model willRemoveUnreadEntryAtIndex:index]; | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 void ReadingListModelBridge::ReadingListWillRemoveReadEntry( | |
| 47 const ReadingListModel* model, | |
| 48 size_t index) { | |
| 49 if ([observer_ respondsToSelector:@selector(readingListModel: | |
| 50 willRemoveReadEntryAtIndex:)]) { | |
| 51 [observer_ readingListModel:model willRemoveReadEntryAtIndex:index]; | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 void ReadingListModelBridge::ReadingListWillAddReadEntry( | |
| 56 const ReadingListModel* model, | |
| 57 const ReadingListEntry& entry) { | |
| 58 if ([observer_ | |
| 59 respondsToSelector:@selector(readingListModel:willAddReadEntry:)]) { | |
| 60 [observer_ readingListModel:model willAddReadEntry:entry]; | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 void ReadingListModelBridge::ReadingListWillAddUnreadEntry( | |
| 65 const ReadingListModel* model, | |
| 66 const ReadingListEntry& entry) { | |
| 67 if ([observer_ | |
| 68 respondsToSelector:@selector(readingListModel:willAddUnreadEntry:)]) { | |
| 69 [observer_ readingListModel:model willAddUnreadEntry:entry]; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 void ReadingListModelBridge::ReadingListDidApplyChanges( | |
| 74 ReadingListModel* model) { | |
| 75 [observer_ readingListModelDidApplyChanges:model]; | |
| 76 } | |
| 77 | |
| 78 void ReadingListModelBridge::ReadingListModelBeganBatchUpdates( | |
| 79 const ReadingListModel* model) { | |
| 80 if ([observer_ | |
| 81 respondsToSelector:@selector(readingListModelBeganBatchUpdates:)]) { | |
| 82 [observer_ readingListModelBeganBatchUpdates:model]; | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 void ReadingListModelBridge::ReadingListModelCompletedBatchUpdates( | |
| 87 const ReadingListModel* model) { | |
| 88 if ([observer_ | |
| 89 respondsToSelector:@selector( | |
| 90 readingListModelCompletedBatchUpdates:)]) { | |
| 91 [observer_ readingListModelCompletedBatchUpdates:model]; | |
| 92 } | |
| 93 } | |
| 94 | |
| 95 void ReadingListModelBridge::ReadingListWillMoveEntry( | |
| 96 const ReadingListModel* model, | |
| 97 size_t index, | |
| 98 bool read) { | |
| 99 if ([observer_ respondsToSelector:@selector(readingListModel: | |
| 100 willMoveEntry: | |
| 101 isRead:)]) { | |
| 102 [observer_ readingListModel:model willMoveEntry:index isRead:read]; | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 void ReadingListModelBridge::ReadingListWillUpdateUnreadEntry( | |
| 107 const ReadingListModel* model, | |
| 108 size_t index) { | |
| 109 if ([observer_ respondsToSelector:@selector(readingListModel: | |
| 110 willUpdateUnreadEntryAtIndex:)]) { | |
| 111 [observer_ readingListModel:model willUpdateUnreadEntryAtIndex:index]; | |
| 112 } | |
| 113 } | |
| 114 | |
| 115 void ReadingListModelBridge::ReadingListWillUpdateReadEntry( | |
| 116 const ReadingListModel* model, | |
| 117 size_t index) { | |
| 118 if ([observer_ respondsToSelector:@selector(readingListModel: | |
| 119 willUpdateReadEntryAtIndex:)]) { | |
| 120 [observer_ readingListModel:model willUpdateReadEntryAtIndex:index]; | |
| 121 } | |
| 122 } | |
| OLD | NEW |