| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.suggestions; | 5 package org.chromium.chrome.browser.suggestions; |
| 6 | 6 |
| 7 import org.chromium.base.ThreadUtils; | 7 import org.chromium.base.ThreadUtils; |
| 8 import org.chromium.chrome.browser.ntp.NTPTileSource; | |
| 9 | 8 |
| 10 import java.util.ArrayList; | 9 import java.util.ArrayList; |
| 11 import java.util.Arrays; | 10 import java.util.Arrays; |
| 12 import java.util.List; | 11 import java.util.List; |
| 13 | 12 |
| 14 /** | 13 /** |
| 15 * A fake implementation of MostVisitedSites that returns a fixed list of most v
isited sites. | 14 * A fake implementation of MostVisitedSites that returns a fixed list of most v
isited sites. |
| 16 */ | 15 */ |
| 17 public class FakeMostVisitedSites implements MostVisitedSites { | 16 public class FakeMostVisitedSites implements MostVisitedSites { |
| 18 private final List<String> mBlacklistedUrls = new ArrayList<>(); | 17 private final List<String> mBlacklistedUrls = new ArrayList<>(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 * If there is an observer it is notified. | 81 * If there is an observer it is notified. |
| 83 * | 82 * |
| 84 * @param urls The URLs of the site suggestions. | 83 * @param urls The URLs of the site suggestions. |
| 85 * @see #setTileSuggestions(String[], String[], String[], int[]) | 84 * @see #setTileSuggestions(String[], String[], String[], int[]) |
| 86 */ | 85 */ |
| 87 public void setTileSuggestions(String... urls) { | 86 public void setTileSuggestions(String... urls) { |
| 88 String[] whitelistIconPaths = new String[urls.length]; | 87 String[] whitelistIconPaths = new String[urls.length]; |
| 89 Arrays.fill(whitelistIconPaths, ""); | 88 Arrays.fill(whitelistIconPaths, ""); |
| 90 | 89 |
| 91 int[] sources = new int[urls.length]; | 90 int[] sources = new int[urls.length]; |
| 92 Arrays.fill(sources, NTPTileSource.TOP_SITES); | 91 Arrays.fill(sources, TileSource.TOP_SITES); |
| 93 | 92 |
| 94 setTileSuggestions(urls, urls.clone(), whitelistIconPaths, sources); | 93 setTileSuggestions(urls, urls.clone(), whitelistIconPaths, sources); |
| 95 } | 94 } |
| 96 | 95 |
| 97 private void notifyTileSuggestionsAvailable() { | 96 private void notifyTileSuggestionsAvailable() { |
| 98 if (mObserver == null) return; | 97 if (mObserver == null) return; |
| 99 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 98 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 100 @Override | 99 @Override |
| 101 public void run() { | 100 public void run() { |
| 102 mObserver.onMostVisitedURLsAvailable(mTitles.clone(), mUrls.clon
e(), | 101 mObserver.onMostVisitedURLsAvailable(mTitles.clone(), mUrls.clon
e(), |
| 103 mWhitelistIconPaths.clone(), mSources.clone()); | 102 mWhitelistIconPaths.clone(), mSources.clone()); |
| 104 } | 103 } |
| 105 }); | 104 }); |
| 106 } | 105 } |
| 107 } | 106 } |
| OLD | NEW |