| Index: ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h
|
| diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h b/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f6b29437b25d865310b796136bae928735f42356
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h
|
| @@ -0,0 +1,50 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#ifndef IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDGE_OBSERVER_H_
|
| +#define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDGE_OBSERVER_H_
|
| +
|
| +#include "components/ntp_snippets/content_suggestions_service.h"
|
| +
|
| +// Protocol duplicating all ContentSuggestionsService Observer methods in
|
| +// Objective-C.
|
| +@protocol ContentSuggestionsServiceBridgeObserver
|
| +
|
| +- (void)onNewSuggestions:(ntp_snippets::Category)category;
|
| +- (void)onCategory:(ntp_snippets::Category)category
|
| + statusChanged:(ntp_snippets::CategoryStatus)status;
|
| +- (void)onSuggestionInvalidated:
|
| + (const ntp_snippets::ContentSuggestion::ID&)suggestion_id;
|
| +- (void)onFullRefreshRequired;
|
| +- (void)contentSuggestionsServiceShutdown;
|
| +
|
| +@end
|
| +
|
| +// Observer for the ContentSuggestionsService that translates all the callbacks
|
| +// to Objective-C calls.
|
| +class ContentSuggestionsServiceBridge
|
| + : public ntp_snippets::ContentSuggestionsService::Observer {
|
| + public:
|
| + ContentSuggestionsServiceBridge(
|
| + id<ContentSuggestionsServiceBridgeObserver> observer,
|
| + ntp_snippets::ContentSuggestionsService* service);
|
| + ~ContentSuggestionsServiceBridge() override;
|
| +
|
| + private:
|
| + void OnNewSuggestions(ntp_snippets::Category category) override;
|
| + void OnCategoryStatusChanged(
|
| + ntp_snippets::Category category,
|
| + ntp_snippets::CategoryStatus new_status) override;
|
| + void OnSuggestionInvalidated(
|
| + const ntp_snippets::ContentSuggestion::ID& suggestion_id) override;
|
| + void OnFullRefreshRequired() override;
|
| + void ContentSuggestionsServiceShutdown() override;
|
| +
|
| + __unsafe_unretained id<ContentSuggestionsServiceBridgeObserver> observer_;
|
| + ntp_snippets::ContentSuggestionsService* service_; // weak
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsServiceBridge);
|
| +};
|
| +
|
| +#endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDGE_OBSERVER_H_
|
|
|