| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 #ifndef IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDG
E_OBSERVER_H_ |
| 6 #define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDG
E_OBSERVER_H_ |
| 7 |
| 8 #include "components/ntp_snippets/content_suggestions_service.h" |
| 9 |
| 10 // Protocol duplicating all ContentSuggestionsService Observer methods in |
| 11 // Objective-C. |
| 12 @protocol ContentSuggestionsServiceBridgeObserver |
| 13 |
| 14 - (void)onNewSuggestions:(ntp_snippets::Category)category; |
| 15 - (void)onCategory:(ntp_snippets::Category)category |
| 16 statusChanged:(ntp_snippets::CategoryStatus)status; |
| 17 - (void)onSuggestionInvalidated: |
| 18 (const ntp_snippets::ContentSuggestion::ID&)suggestion_id; |
| 19 - (void)onFullRefreshRequired; |
| 20 - (void)contentSuggestionsServiceShutdown; |
| 21 |
| 22 @end |
| 23 |
| 24 // Observer for the ContentSuggestionsService that translates all the callbacks |
| 25 // to Objective-C calls. |
| 26 class ContentSuggestionsServiceBridge |
| 27 : public ntp_snippets::ContentSuggestionsService::Observer { |
| 28 public: |
| 29 ContentSuggestionsServiceBridge( |
| 30 id<ContentSuggestionsServiceBridgeObserver> observer, |
| 31 ntp_snippets::ContentSuggestionsService* service); |
| 32 ~ContentSuggestionsServiceBridge() override; |
| 33 |
| 34 private: |
| 35 void OnNewSuggestions(ntp_snippets::Category category) override; |
| 36 void OnCategoryStatusChanged( |
| 37 ntp_snippets::Category category, |
| 38 ntp_snippets::CategoryStatus new_status) override; |
| 39 void OnSuggestionInvalidated( |
| 40 const ntp_snippets::ContentSuggestion::ID& suggestion_id) override; |
| 41 void OnFullRefreshRequired() override; |
| 42 void ContentSuggestionsServiceShutdown() override; |
| 43 |
| 44 __unsafe_unretained id<ContentSuggestionsServiceBridgeObserver> observer_; |
| 45 ntp_snippets::ContentSuggestionsService* service_; // weak |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsServiceBridge); |
| 48 }; |
| 49 |
| 50 #endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BR
IDGE_OBSERVER_H_ |
| OLD | NEW |