| Index: chrome/android/java/src/org/chromium/chrome/browser/suggestions/MostVisitedSites.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/MostVisitedSites.java b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/MostVisitedSites.java
|
| index 53362f0082ae47e69ef165910af02383ad21831a..0e392dd048fa7ed5e5371e96c717c5acd4bf321b 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/MostVisitedSites.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/MostVisitedSites.java
|
| @@ -1,24 +1,21 @@
|
| -// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Copyright 2017 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.suggestions;
|
|
|
| import org.chromium.base.annotations.CalledByNative;
|
| -import org.chromium.chrome.browser.ntp.MostVisitedTileType.MostVisitedTileTypeEnum;
|
| -import org.chromium.chrome.browser.ntp.NTPTileSource.NTPTileSourceEnum;
|
| -import org.chromium.chrome.browser.profiles.Profile;
|
| +import org.chromium.chrome.browser.ntp.MostVisitedTileType;
|
| +import org.chromium.chrome.browser.ntp.NTPTileSource;
|
|
|
| /**
|
| - * Methods to bridge into native history to provide most recent urls, titles and thumbnails.
|
| + * Methods to provide most recent urls, titles and thumbnails.
|
| */
|
| -public class MostVisitedSites {
|
| - private long mNativeMostVisitedSitesBridge;
|
| -
|
| +interface MostVisitedSites {
|
| /**
|
| * An interface for handling events in {@link MostVisitedSites}.
|
| */
|
| - public interface Observer {
|
| + interface Observer {
|
| /**
|
| * This is called when the list of most visited URLs is initially available or updated.
|
| * Parameters guaranteed to be non-null.
|
| @@ -46,22 +43,9 @@ void onMostVisitedURLsAvailable(
|
| }
|
|
|
| /**
|
| - * MostVisitedSites constructor requires a valid user profile object.
|
| - *
|
| - * @param profile The profile for which to fetch most visited sites.
|
| - */
|
| - public MostVisitedSites(Profile profile) {
|
| - mNativeMostVisitedSitesBridge = nativeInit(profile);
|
| - }
|
| -
|
| - /**
|
| - * Cleans up the C++ side of this class. This instance must not be used after calling destroy().
|
| + * This instance must not be used after calling destroy().
|
| */
|
| - public void destroy() {
|
| - assert mNativeMostVisitedSitesBridge != 0;
|
| - nativeDestroy(mNativeMostVisitedSitesBridge);
|
| - mNativeMostVisitedSitesBridge = 0;
|
| - }
|
| + void destroy();
|
|
|
| /**
|
| * Sets the recipient for events from {@link MostVisitedSites}. The observer may be notified
|
| @@ -69,40 +53,17 @@ public void destroy() {
|
| * @param observer The observer to be notified.
|
| * @param numSites The maximum number of sites to return.
|
| */
|
| - public void setObserver(final Observer observer, int numSites) {
|
| - Observer wrappedObserver = new Observer() {
|
| - @Override
|
| - public void onMostVisitedURLsAvailable(
|
| - String[] titles, String[] urls, String[] whitelistIconPaths, int[] sources) {
|
| - // Don't notify observer if we've already been destroyed.
|
| - if (mNativeMostVisitedSitesBridge != 0) {
|
| - observer.onMostVisitedURLsAvailable(titles, urls, whitelistIconPaths, sources);
|
| - }
|
| - }
|
| - @Override
|
| - public void onIconMadeAvailable(String siteUrl) {
|
| - // Don't notify observer if we've already been destroyed.
|
| - if (mNativeMostVisitedSitesBridge != 0) {
|
| - observer.onIconMadeAvailable(siteUrl);
|
| - }
|
| - }
|
| - };
|
| - nativeSetObserver(mNativeMostVisitedSitesBridge, wrappedObserver, numSites);
|
| - }
|
| + void setObserver(Observer observer, int numSites);
|
|
|
| /**
|
| * Blacklists a URL from the most visited URLs list.
|
| */
|
| - public void addBlacklistedUrl(String url) {
|
| - nativeAddOrRemoveBlacklistedUrl(mNativeMostVisitedSitesBridge, url, true);
|
| - }
|
| + void addBlacklistedUrl(String url);
|
|
|
| /**
|
| * Removes a URL from the most visited URLs blacklist.
|
| */
|
| - public void removeBlacklistedUrl(String url) {
|
| - nativeAddOrRemoveBlacklistedUrl(mNativeMostVisitedSitesBridge, url, false);
|
| - }
|
| + void removeBlacklistedUrl(String url);
|
|
|
| /**
|
| * Records metrics about an impression, including the sources (local, server, ...) and visual
|
| @@ -113,9 +74,7 @@ public void removeBlacklistedUrl(String url) {
|
| * that's currently showing.
|
| * @param tileUrls An array of strings indicating the URL of each tile.
|
| */
|
| - public void recordPageImpression(int[] tileTypes, int[] sources, String[] tileUrls) {
|
| - nativeRecordPageImpression(mNativeMostVisitedSitesBridge, tileTypes, sources, tileUrls);
|
| - }
|
| + void recordPageImpression(int[] tileTypes, int[] sources, String[] tileUrls);
|
|
|
| /**
|
| * Records the opening of a Most Visited Item.
|
| @@ -123,19 +82,7 @@ public void recordPageImpression(int[] tileTypes, int[] sources, String[] tileUr
|
| * @param type The visual type of the item as defined in {@code MostVisitedTileType}.
|
| * @param source The {@code NTPTileSource} that generated this item.
|
| */
|
| - public void recordOpenedMostVisitedItem(
|
| - int index, @MostVisitedTileTypeEnum int type, @NTPTileSourceEnum int source) {
|
| - nativeRecordOpenedMostVisitedItem(mNativeMostVisitedSitesBridge, index, type, source);
|
| - }
|
| -
|
| - private native long nativeInit(Profile profile);
|
| - private native void nativeDestroy(long nativeMostVisitedSitesBridge);
|
| - private native void nativeSetObserver(
|
| - long nativeMostVisitedSitesBridge, Observer observer, int numSites);
|
| - private native void nativeAddOrRemoveBlacklistedUrl(
|
| - long nativeMostVisitedSitesBridge, String url, boolean addUrl);
|
| - private native void nativeRecordPageImpression(
|
| - long nativeMostVisitedSitesBridge, int[] tileTypes, int[] sources, String[] tileUrls);
|
| - private native void nativeRecordOpenedMostVisitedItem(
|
| - long nativeMostVisitedSitesBridge, int index, int tileType, int source);
|
| + void recordOpenedMostVisitedItem(int index,
|
| + @MostVisitedTileType.MostVisitedTileTypeEnum int type,
|
| + @NTPTileSource.NTPTileSourceEnum int source);
|
| }
|
|
|