OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.profiles; | 5 package org.chromium.chrome.browser.profiles; |
6 | 6 |
7 import android.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
8 | 8 |
9 import org.chromium.base.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 | 44 |
45 /** | 45 /** |
46 * Interface for receiving a thumbnail for a most visited site. | 46 * Interface for receiving a thumbnail for a most visited site. |
47 */ | 47 */ |
48 public interface ThumbnailCallback { | 48 public interface ThumbnailCallback { |
49 /** | 49 /** |
50 * Callback method for fetching thumbnail of a most visited URL. | 50 * Callback method for fetching thumbnail of a most visited URL. |
51 * Parameter may be null. | 51 * Parameter may be null. |
52 * | 52 * |
53 * @param thumbnail The bitmap thumbnail for the requested URL. | 53 * @param thumbnail The bitmap thumbnail for the requested URL. |
54 * @param isLocalThumbnail Whether the thumbnail was locally captured, a s opposed to | |
55 * server-provided. | |
Ted C
2015/09/28 23:08:45
indenting is off
| |
54 */ | 56 */ |
55 @CalledByNative("ThumbnailCallback") | 57 @CalledByNative("ThumbnailCallback") |
56 public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail); | 58 public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail, boolea n isLocalThumbnail); |
57 } | 59 } |
58 | 60 |
59 /** | 61 /** |
60 * MostVisitedSites constructor requires a valid user profile object. | 62 * MostVisitedSites constructor requires a valid user profile object. |
61 * | 63 * |
62 * @param profile The profile for which to fetch most visited sites. | 64 * @param profile The profile for which to fetch most visited sites. |
63 */ | 65 */ |
64 public MostVisitedSites(Profile profile) { | 66 public MostVisitedSites(Profile profile) { |
65 mNativeMostVisitedSites = nativeInit(profile); | 67 mNativeMostVisitedSites = nativeInit(profile); |
66 } | 68 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 | 106 |
105 /** | 107 /** |
106 * Fetches thumbnail bitmap for a url returned by getMostVisitedURLs. | 108 * Fetches thumbnail bitmap for a url returned by getMostVisitedURLs. |
107 * | 109 * |
108 * @param url String representation of url. | 110 * @param url String representation of url. |
109 * @param callback Instance of a callback object. | 111 * @param callback Instance of a callback object. |
110 */ | 112 */ |
111 public void getURLThumbnail(String url, final ThumbnailCallback callback) { | 113 public void getURLThumbnail(String url, final ThumbnailCallback callback) { |
112 ThumbnailCallback wrappedCallback = new ThumbnailCallback() { | 114 ThumbnailCallback wrappedCallback = new ThumbnailCallback() { |
113 @Override | 115 @Override |
114 public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail) { | 116 public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail, |
117 boolean isLocalThumbnail) { | |
115 // Don't notify callback if we've already been destroyed. | 118 // Don't notify callback if we've already been destroyed. |
116 if (mNativeMostVisitedSites != 0) { | 119 if (mNativeMostVisitedSites != 0) { |
117 callback.onMostVisitedURLsThumbnailAvailable(thumbnail); | 120 callback.onMostVisitedURLsThumbnailAvailable(thumbnail, isLo calThumbnail); |
118 } | 121 } |
119 } | 122 } |
120 }; | 123 }; |
121 nativeGetURLThumbnail(mNativeMostVisitedSites, url, wrappedCallback); | 124 nativeGetURLThumbnail(mNativeMostVisitedSites, url, wrappedCallback); |
122 } | 125 } |
123 | 126 |
124 /** | 127 /** |
125 * Blacklist a URL from the most visited URLs list. | 128 * Blacklists a URL from the most visited URLs list. |
126 * @param url The URL to be blacklisted. | 129 * @param url The URL to be blacklisted. |
127 */ | 130 */ |
128 public void blacklistUrl(String url) { | 131 public void blacklistUrl(String url) { |
129 nativeBlacklistUrl(mNativeMostVisitedSites, url); | 132 nativeBlacklistUrl(mNativeMostVisitedSites, url); |
130 } | 133 } |
131 | 134 |
132 /** | 135 /** |
133 * Called when the loading of the Most Visited page is complete. | 136 * Records metrics about which types of tiles are displayed. |
137 * @param tileTypes An array of values from MostVisitedTileType indicating t he type of each | |
138 * tile that's currently showing. | |
Ted C
2015/09/28 23:08:45
same indenting thing...should either be 8 for alig
| |
139 * @paral isIconMode Whether the icon-based version of the NTP is showing (a s opposed to the | |
140 * thumbnail-based version). | |
134 */ | 141 */ |
135 public void onLoadingComplete() { | 142 public void recordTileTypeMetrics(int[] tileTypes, boolean isIconMode) { |
newt (away)
2015/09/28 22:34:21
This was only every used for metrics recording, so
| |
136 nativeOnLoadingComplete(mNativeMostVisitedSites); | 143 nativeRecordTileTypeMetrics(mNativeMostVisitedSites, tileTypes, isIconMo de); |
137 } | 144 } |
138 | 145 |
139 /** | 146 /** |
140 * Record the opening of a Most Visited Item. | 147 * Records the opening of a Most Visited Item. |
141 * @param index The index of the item that was opened. | 148 * @param index The index of the item that was opened. |
149 * @param tileType The visual type of the item. Valid values are listed in M ostVisitedTileType. | |
142 */ | 150 */ |
143 public void recordOpenedMostVisitedItem(int index) { | 151 public void recordOpenedMostVisitedItem(int index, int tileType) { |
144 nativeRecordOpenedMostVisitedItem(mNativeMostVisitedSites, index); | 152 nativeRecordOpenedMostVisitedItem(mNativeMostVisitedSites, index, tileTy pe); |
145 } | 153 } |
146 | 154 |
147 private native long nativeInit(Profile profile); | 155 private native long nativeInit(Profile profile); |
148 private native void nativeDestroy(long nativeMostVisitedSites); | 156 private native void nativeDestroy(long nativeMostVisitedSites); |
149 private native void nativeOnLoadingComplete(long nativeMostVisitedSites); | |
150 private native void nativeSetMostVisitedURLsObserver(long nativeMostVisitedS ites, | 157 private native void nativeSetMostVisitedURLsObserver(long nativeMostVisitedS ites, |
151 MostVisitedURLsObserver observer, int numSites); | 158 MostVisitedURLsObserver observer, int numSites); |
152 private native void nativeGetURLThumbnail(long nativeMostVisitedSites, Strin g url, | 159 private native void nativeGetURLThumbnail(long nativeMostVisitedSites, Strin g url, |
153 ThumbnailCallback callback); | 160 ThumbnailCallback callback); |
154 private native void nativeBlacklistUrl(long nativeMostVisitedSites, String u rl); | 161 private native void nativeBlacklistUrl(long nativeMostVisitedSites, String u rl); |
155 private native void nativeRecordOpenedMostVisitedItem(long nativeMostVisited Sites, int index); | 162 private native void nativeRecordTileTypeMetrics(long nativeMostVisitedSites, int[] tileTypes, |
163 boolean isIconMode); | |
164 private native void nativeRecordOpenedMostVisitedItem(long nativeMostVisited Sites, int index, | |
165 int tileType); | |
156 | 166 |
157 } | 167 } |
OLD | NEW |