Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.mm

Issue 2638413006: Add ContentSuggestionsMediator (Closed)
Patch Set: Format Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.mm
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.mm b/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.mm
new file mode 100644
index 0000000000000000000000000000000000000000..90d3d7c99f47538dc48cff94348607532cf8e09b
--- /dev/null
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.mm
@@ -0,0 +1,49 @@
+// 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.
+
+#import "ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+ContentSuggestionsServiceBridge::ContentSuggestionsServiceBridge(
+ id<ContentSuggestionsServiceObserver> observer,
+ ntp_snippets::ContentSuggestionsService* service) {
+ observer_ = observer;
+ service_ = service;
+ service->AddObserver(this);
+}
+
+ContentSuggestionsServiceBridge::~ContentSuggestionsServiceBridge() {
+ service_->RemoveObserver(this);
+}
+
+void ContentSuggestionsServiceBridge::OnNewSuggestions(
+ ntp_snippets::Category category) {
+ [observer_ contentSuggestionsService:service_
+ newSuggestionsInCategory:category];
+}
+
+void ContentSuggestionsServiceBridge::OnCategoryStatusChanged(
+ ntp_snippets::Category category,
+ ntp_snippets::CategoryStatus new_status) {
+ [observer_ contentSuggestionsService:service_
+ category:category
+ statusChangedTo:new_status];
+}
+
+void ContentSuggestionsServiceBridge::OnSuggestionInvalidated(
+ const ntp_snippets::ContentSuggestion::ID& suggestion_id) {
+ [observer_ contentSuggestionsService:service_
+ SuggestionInvalidated:suggestion_id];
+}
+
+void ContentSuggestionsServiceBridge::OnFullRefreshRequired() {
+ [observer_ contentSuggestionsServiceFullRefreshRequired:service_];
+}
+
+void ContentSuggestionsServiceBridge::ContentSuggestionsServiceShutdown() {
+ [observer_ contentSuggestionsServiceShutdown:service_];
+}

Powered by Google App Engine
This is Rietveld 408576698