| 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.ntp; | 5 package org.chromium.chrome.browser.ntp; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.res.Configuration; | 9 import android.content.res.Configuration; |
| 10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; | 52 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener; |
| 53 import org.chromium.chrome.browser.ntp.cards.CardsVariationParameters; | 53 import org.chromium.chrome.browser.ntp.cards.CardsVariationParameters; |
| 54 import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; | 54 import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; |
| 55 import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView; | 55 import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView; |
| 56 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; | 56 import org.chromium.chrome.browser.ntp.snippets.SnippetArticle; |
| 57 import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig; | 57 import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig; |
| 58 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; | 58 import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource; |
| 59 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; | 59 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; |
| 60 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse
rver; | 60 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse
rver; |
| 61 import org.chromium.chrome.browser.profiles.Profile; | 61 import org.chromium.chrome.browser.profiles.Profile; |
| 62 import org.chromium.chrome.browser.suggestions.SuggestionsMetricsReporter; |
| 62 import org.chromium.chrome.browser.tab.Tab; | 63 import org.chromium.chrome.browser.tab.Tab; |
| 63 import org.chromium.chrome.browser.util.MathUtils; | 64 import org.chromium.chrome.browser.util.MathUtils; |
| 64 import org.chromium.chrome.browser.util.ViewUtils; | 65 import org.chromium.chrome.browser.util.ViewUtils; |
| 65 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 66 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| 66 import org.chromium.ui.base.DeviceFormFactor; | 67 import org.chromium.ui.base.DeviceFormFactor; |
| 67 | 68 |
| 68 import java.util.Arrays; | 69 import java.util.Arrays; |
| 69 import java.util.HashSet; | 70 import java.util.HashSet; |
| 70 import java.util.Set; | 71 import java.util.Set; |
| 71 | 72 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 /** Opens the bookmarks page in the current tab. */ | 158 /** Opens the bookmarks page in the current tab. */ |
| 158 void navigateToBookmarks(); | 159 void navigateToBookmarks(); |
| 159 | 160 |
| 160 /** Opens the recent tabs page in the current tab. */ | 161 /** Opens the recent tabs page in the current tab. */ |
| 161 void navigateToRecentTabs(); | 162 void navigateToRecentTabs(); |
| 162 | 163 |
| 163 /** Opens the Download Manager UI in the current tab. */ | 164 /** Opens the Download Manager UI in the current tab. */ |
| 164 void navigateToDownloadManager(); | 165 void navigateToDownloadManager(); |
| 165 | 166 |
| 166 /** | 167 /** |
| 167 * Tracks per-page-load metrics for content suggestions. | |
| 168 * @param categories The categories of content suggestions. | |
| 169 * @param suggestionsPerCategory The number of content suggestions in ea
ch category. | |
| 170 */ | |
| 171 void trackSnippetsPageImpression(int[] categories, int[] suggestionsPerC
ategory); | |
| 172 | |
| 173 /** | |
| 174 * Tracks impression metrics for a content suggestion. | |
| 175 * @param article The content suggestion that was shown to the user. | |
| 176 */ | |
| 177 void trackSnippetImpression(SnippetArticle article); | |
| 178 | |
| 179 /** | |
| 180 * Tracks impression metrics for the long-press menu for a content sugge
stion. | |
| 181 * @param article The content suggestion for which the long-press menu w
as opened. | |
| 182 */ | |
| 183 void trackSnippetMenuOpened(SnippetArticle article); | |
| 184 | |
| 185 /** | |
| 186 * Tracks impression metrics for a category's action button ("More"). | |
| 187 * @param category The category for which the action button was shown. | |
| 188 * @param position The position of the action button within the category
. | |
| 189 */ | |
| 190 void trackSnippetCategoryActionImpression(int category, int position); | |
| 191 | |
| 192 /** | |
| 193 * Tracks click metrics for a category's action button ("More"). | |
| 194 * @param category The category for which the action button was clicked. | |
| 195 * @param position The position of the action button within the category
. | |
| 196 */ | |
| 197 void trackSnippetCategoryActionClick(int category, int position); | |
| 198 | |
| 199 /** | |
| 200 * Opens a content suggestion and records related metrics. | 168 * Opens a content suggestion and records related metrics. |
| 201 * @param windowOpenDisposition How to open (current tab, new tab, new w
indow etc). | 169 * @param windowOpenDisposition How to open (current tab, new tab, new w
indow etc). |
| 202 * @param article The content suggestion to open. | 170 * @param article The content suggestion to open. |
| 203 * @param categoryIndex The index of the category |article| belongs to. | |
| 204 */ | 171 */ |
| 205 void openSnippet(int windowOpenDisposition, SnippetArticle article, int
categoryIndex); | 172 void openSnippet(int windowOpenDisposition, SnippetArticle article); |
| 206 | 173 |
| 207 /** | 174 /** |
| 208 * Animates the search box up into the omnibox and bring up the keyboard
. | 175 * Animates the search box up into the omnibox and bring up the keyboard
. |
| 209 * @param beginVoiceSearch Whether to begin a voice search. | 176 * @param beginVoiceSearch Whether to begin a voice search. |
| 210 * @param pastedText Text to paste in the omnibox after it's been focuse
d. May be null. | 177 * @param pastedText Text to paste in the omnibox after it's been focuse
d. May be null. |
| 211 */ | 178 */ |
| 212 void focusSearchBox(boolean beginVoiceSearch, String pastedText); | 179 void focusSearchBox(boolean beginVoiceSearch, String pastedText); |
| 213 | 180 |
| 214 /** | 181 /** |
| 215 * Gets the list of most visited sites. | 182 * Gets the list of most visited sites. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 * displayed to the user. | 261 * displayed to the user. |
| 295 */ | 262 */ |
| 296 boolean isCurrentPage(); | 263 boolean isCurrentPage(); |
| 297 | 264 |
| 298 /** | 265 /** |
| 299 * @return The context menu manager. Will be {@code null} if the {@link
NewTabPageView} is | 266 * @return The context menu manager. Will be {@code null} if the {@link
NewTabPageView} is |
| 300 * not done initialising. | 267 * not done initialising. |
| 301 */ | 268 */ |
| 302 @Nullable | 269 @Nullable |
| 303 ContextMenuManager getContextMenuManager(); | 270 ContextMenuManager getContextMenuManager(); |
| 271 |
| 272 /** |
| 273 * @return The suggestion metrics reporter. Will be {@code null} if the |
| 274 * {@link NewTabPageView} is not done initialising. |
| 275 */ |
| 276 @Nullable |
| 277 SuggestionsMetricsReporter getSuggestionsMetricsReporter(); |
| 304 } | 278 } |
| 305 | 279 |
| 306 /** | 280 /** |
| 307 * Default constructor required for XML inflation. | 281 * Default constructor required for XML inflation. |
| 308 */ | 282 */ |
| 309 public NewTabPageView(Context context, AttributeSet attrs) { | 283 public NewTabPageView(Context context, AttributeSet attrs) { |
| 310 super(context, attrs); | 284 super(context, attrs); |
| 311 } | 285 } |
| 312 | 286 |
| 313 /** | 287 /** |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 public int getScrollPosition() { | 1219 public int getScrollPosition() { |
| 1246 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); | 1220 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); |
| 1247 return RecyclerView.NO_POSITION; | 1221 return RecyclerView.NO_POSITION; |
| 1248 } | 1222 } |
| 1249 | 1223 |
| 1250 /** @return the context menu manager. */ | 1224 /** @return the context menu manager. */ |
| 1251 public ContextMenuManager getContextMenuManager() { | 1225 public ContextMenuManager getContextMenuManager() { |
| 1252 return mContextMenuManager; | 1226 return mContextMenuManager; |
| 1253 } | 1227 } |
| 1254 } | 1228 } |
| OLD | NEW |