| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.ntp.snippets; | 5 package org.chromium.chrome.browser.ntp.snippets; |
| 6 | 6 |
| 7 import android.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
| 8 | 8 |
| 9 import org.chromium.base.Callback; | 9 import org.chromium.base.Callback; |
| 10 import org.chromium.chrome.browser.ntp.cards.SuggestionsCategoryInfo; | 10 import org.chromium.chrome.browser.ntp.cards.SuggestionsCategoryInfo; |
| 11 import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnu
m; | 11 import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnu
m; |
| 12 import org.chromium.chrome.browser.suggestions.SuggestionsUma; |
| 12 | 13 |
| 13 import java.util.ArrayList; | 14 import java.util.ArrayList; |
| 14 import java.util.Collections; | 15 import java.util.Collections; |
| 15 import java.util.HashMap; | 16 import java.util.HashMap; |
| 16 import java.util.LinkedHashMap; | 17 import java.util.LinkedHashMap; |
| 17 import java.util.List; | 18 import java.util.List; |
| 18 import java.util.Map; | 19 import java.util.Map; |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * A fake Suggestions source for use in unit and instrumentation tests. | 22 * A fake Suggestions source for use in unit and instrumentation tests. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 callback.onResult(mThumbnails.get(suggestion.mIdWithinCategory)); | 133 callback.onResult(mThumbnails.get(suggestion.mIdWithinCategory)); |
| 133 } | 134 } |
| 134 } | 135 } |
| 135 | 136 |
| 136 @Override | 137 @Override |
| 137 public void fetchSuggestions(@CategoryInt int category, String[] displayedSu
ggestionIds) { | 138 public void fetchSuggestions(@CategoryInt int category, String[] displayedSu
ggestionIds) { |
| 138 throw new UnsupportedOperationException(); | 139 throw new UnsupportedOperationException(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 @Override | 142 @Override |
| 142 public void setObserver(Observer observer) { | 143 public void init(Observer observer, SuggestionsUma umaHelper) { |
| 143 mObserver = observer; | 144 mObserver = observer; |
| 144 } | 145 } |
| 145 | 146 |
| 146 @Override | 147 @Override |
| 147 public int[] getCategories() { | 148 public int[] getCategories() { |
| 148 int[] result = new int[mCategories.size()]; | 149 int[] result = new int[mCategories.size()]; |
| 149 int index = 0; | 150 int index = 0; |
| 150 for (int id : mCategories) result[index++] = id; | 151 for (int id : mCategories) result[index++] = id; |
| 151 return result; | 152 return result; |
| 152 } | 153 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 164 | 165 |
| 165 @Override | 166 @Override |
| 166 public List<SnippetArticle> getSuggestionsForCategory(int category) { | 167 public List<SnippetArticle> getSuggestionsForCategory(int category) { |
| 167 if (!SnippetsBridge.isCategoryStatusAvailable(mCategoryStatus.get(catego
ry))) { | 168 if (!SnippetsBridge.isCategoryStatusAvailable(mCategoryStatus.get(catego
ry))) { |
| 168 return Collections.emptyList(); | 169 return Collections.emptyList(); |
| 169 } | 170 } |
| 170 List<SnippetArticle> result = mSuggestions.get(category); | 171 List<SnippetArticle> result = mSuggestions.get(category); |
| 171 return result == null ? Collections.<SnippetArticle>emptyList() : result
; | 172 return result == null ? Collections.<SnippetArticle>emptyList() : result
; |
| 172 } | 173 } |
| 173 } | 174 } |
| OLD | NEW |