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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SuggestionsSource.java

Issue 2230473002: Refactor and extend SnippetsBridge for multi-section support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@categoryinfo
Patch Set: Michael's comments Created 4 years, 4 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: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SuggestionsSource.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SuggestionsSource.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SuggestionsSource.java
new file mode 100644
index 0000000000000000000000000000000000000000..2d691206d79fe62217503b4716ed832416d539af
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SuggestionsSource.java
@@ -0,0 +1,74 @@
+// Copyright 2016 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.
+
+package org.chromium.chrome.browser.ntp.snippets;
dgn 2016/08/10 10:31:22 should this be in a ntp.suggestions package, and s
Philipp Keck 2016/08/10 12:36:12 This should just all be named suggestions. The Sni
Bernhard Bauer 2016/08/10 14:42:26 (Who is on leave ☺️)
+
+import android.graphics.Bitmap;
+
+import org.chromium.base.Callback;
+import org.chromium.chrome.browser.ntp.cards.SuggestionsCategoryInfo;
+import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnum;
+
+import java.util.List;
+
+/**
+ * An interface for classes that provide content suggestions.
+ */
+public interface SuggestionsSource {
+ /**
+ * An observer for events in the content suggestions service.
+ */
+ interface Observer {
+ /** Called when a category has a new list of content suggestions. */
+ void onNewSuggestions(int category);
+
+ /** Called when a category changed its status. */
+ void onCategoryStatusChanged(int category, @CategoryStatusEnum int newStatus);
+ }
+
+ /**
+ * Gets the categories in the order in which they should be displayed.
+ * @return The categories.
+ */
+ int[] getCategories();
+
+ /**
+ * Gets the status of a category, possibly indicating the reason why it is disabled.
+ */
+ @CategoryStatusEnum
+ int getCategoryStatus(int category);
+
+ /**
+ * Gets the meta information of a category.
+ */
+ SuggestionsCategoryInfo getCategoryInfo(int category);
+
+ /**
+ * Gets the current content suggestions for a category, in the order in which they should be
+ * displayed.
+ */
+ List<SnippetArticleListItem> getSuggestionsForCategory(int category);
+
+ /**
+ * Fetches the thumbnail image for a content suggestion. A null Bitmap is returned if no image
+ * is available. The callback is never called synchronously.
+ */
+ void fetchSuggestionImage(SnippetArticleListItem suggestion, Callback<Bitmap> callback);
+
+ /**
+ * Tells the source to dismiss the content suggestion.
+ */
+ void dismissSuggestion(SnippetArticleListItem suggestion);
+
+ /**
+ * Checks whether a content suggestion has been visited. The callback is never called
+ * synchronously.
+ */
+ void getSuggestionVisited(SnippetArticleListItem suggestion, Callback<Boolean> callback);
+
+ /**
+ * Sets the recipient for update events from the source.
+ */
+ void setObserver(Observer observer);
+}

Powered by Google App Engine
This is Rietveld 408576698