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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/ntp/FakeMostVisitedSites.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.ntp;
6
7 import org.chromium.base.ThreadUtils;
8 import org.chromium.chrome.browser.profiles.MostVisitedSites;
9 import org.chromium.chrome.browser.profiles.Profile;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 /**
15 * A fake implementation of MostVisitedSites that returns a fixed list of most v isited sites.
16 */
17 public class FakeMostVisitedSites extends MostVisitedSites {
18
19 private final String[] mMostVisitedTitles;
20 private final String[] mMostVisitedUrls;
21
22 private final List<String> mBlacklistedUrls = new ArrayList<String>();
23
24 /**
25 * @param p The profile to associated most visited with.
26 * @param mostVisitedTitles The titles of the fixed list of most visited sit es.
27 * @param mostVisitedUrls The URLs of the fixed list of most visited sites.
28 */
29 public FakeMostVisitedSites(Profile p, String[] mostVisitedTitles, String[] mostVisitedUrls) {
30 super(p);
31 assert mostVisitedTitles.length == mostVisitedUrls.length;
32 mMostVisitedTitles = mostVisitedTitles.clone();
33 mMostVisitedUrls = mostVisitedUrls.clone();
34 }
35
36 @Override
37 public void setMostVisitedURLsObserver(final MostVisitedURLsObserver observe r, int numResults) {
38 ThreadUtils.postOnUiThread(new Runnable() {
39 @Override
40 public void run() {
41 observer.onMostVisitedURLsAvailable(mMostVisitedTitles.clone(),
42 mMostVisitedUrls.clone());
43 }
44 });
45 }
46
47 @Override
48 public void getURLThumbnail(String url, final ThumbnailCallback callback) {
49 ThreadUtils.postOnUiThread(new Runnable() {
50 @Override
51 public void run() {
52 callback.onMostVisitedURLsThumbnailAvailable(null);
53 }
54 });
55 }
56
57 @Override
58 public void blacklistUrl(String url) {
59 mBlacklistedUrls.add(url);
60 }
61
62 /**
63 * @return Whether blacklistUrl() has been called on the given url.
64 */
65 public boolean isUrlBlacklisted(String url) {
66 return mBlacklistedUrls.contains(url);
67 }
68
69 @Override
70 public void recordOpenedMostVisitedItem(int index) {
71 // Metrics are stubbed out.
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698