| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
|
| index 84872fcf4ec01b9a661a400814bad22e4f7178b5..84760a1c2d5a3a04e30a1ad0c3729c198c831949 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
|
| @@ -28,6 +28,12 @@ public class FakeSuggestionsSource implements SuggestionsSource {
|
| private final Map<Integer, SuggestionsCategoryInfo> mCategoryInfo = new HashMap<>();
|
| private final Map<String, Bitmap> mThumbnails = new HashMap<>();
|
|
|
| + private final List<Integer> mDismissedCategories = new ArrayList<>();
|
| + private final Map<Integer, List<SnippetArticle>> mDismissedCategorySuggestions =
|
| + new HashMap<>();
|
| + private final Map<Integer, Integer> mDismissedCategoryStatus = new LinkedHashMap<>();
|
| + private final Map<Integer, SuggestionsCategoryInfo> mDismissedCategoryInfo = new HashMap<>();
|
| +
|
| /**
|
| * Sets the status to be returned for a given category.
|
| */
|
| @@ -60,7 +66,7 @@ public class FakeSuggestionsSource implements SuggestionsSource {
|
| }
|
|
|
| /**
|
| - * Set's the bitmap to be returned when the Thumbnail is requested for a snippet with that id.
|
| + * Sets the bitmap to be returned when the thumbnail is requested for a snippet with that id.
|
| */
|
| public void setThumbnailForId(String id, Bitmap bitmap) {
|
| mThumbnails.put(id, bitmap);
|
| @@ -92,17 +98,29 @@ public class FakeSuggestionsSource implements SuggestionsSource {
|
|
|
| @Override
|
| public void dismissSuggestion(SnippetArticle suggestion) {
|
| - throw new UnsupportedOperationException();
|
| + for (List<SnippetArticle> suggestions : mSuggestions.values()) {
|
| + suggestions.remove(suggestion);
|
| + }
|
| }
|
|
|
| @Override
|
| public void dismissCategory(@CategoryInt int category) {
|
| + mDismissedCategorySuggestions.put(category, mSuggestions.get(category));
|
| + mDismissedCategoryStatus.put(category, mCategoryStatus.get(category));
|
| + mDismissedCategoryInfo.put(category, mCategoryInfo.get(category));
|
| + mDismissedCategories.add(category);
|
| silentlyRemoveCategory(category);
|
| }
|
|
|
| @Override
|
| public void restoreDismissedCategories() {
|
| - throw new UnsupportedOperationException();
|
| + for (int category : mDismissedCategories) {
|
| + mSuggestions.put(category, mDismissedCategorySuggestions.remove(category));
|
| + mCategoryStatus.put(category, mDismissedCategoryStatus.remove(category));
|
| + mCategoryInfo.put(category, mDismissedCategoryInfo.remove(category));
|
| + mCategories.add(category);
|
| + }
|
| + mDismissedCategories.clear();
|
| }
|
|
|
| @Override
|
|
|