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.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
10 import android.graphics.Point; | 10 import android.graphics.Point; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 return false; | 322 return false; |
323 } | 323 } |
324 | 324 |
325 private boolean matchURLs(String url1, String url2, boolean matchByHost) { | 325 private boolean matchURLs(String url1, String url2, boolean matchByHost) { |
326 if (url1 == null || url2 == null) return false; | 326 if (url1 == null || url2 == null) return false; |
327 return matchByHost ? UrlUtilities.sameHost(url1, url2) : url1.equals (url2); | 327 return matchByHost ? UrlUtilities.sameHost(url1, url2) : url1.equals (url2); |
328 } | 328 } |
329 | 329 |
330 @Override | 330 @Override |
331 public void trackSnippetsPageImpression(int[] categories, int[] suggesti onsPerCategory) { | 331 public void trackSnippetsPageImpression(int[] categories, int[] suggesti onsPerCategory) { |
332 if (sSuggestionsSourceForTests != null) return; | |
Bernhard Bauer
2017/01/11 13:53:38
Could we instead move these tracking methods into
dgn
2017/01/12 14:29:58
Sure! I was thinking about doing that in another p
| |
332 mSnippetsBridge.onPageShown(categories, suggestionsPerCategory); | 333 mSnippetsBridge.onPageShown(categories, suggestionsPerCategory); |
333 } | 334 } |
334 | 335 |
335 @Override | 336 @Override |
336 public void trackSnippetImpression(SnippetArticle article) { | 337 public void trackSnippetImpression(SnippetArticle article) { |
338 if (sSuggestionsSourceForTests != null) return; | |
337 mSnippetsBridge.onSuggestionShown(article); | 339 mSnippetsBridge.onSuggestionShown(article); |
338 } | 340 } |
339 | 341 |
340 @Override | 342 @Override |
341 public void trackSnippetMenuOpened(SnippetArticle article) { | 343 public void trackSnippetMenuOpened(SnippetArticle article) { |
344 if (sSuggestionsSourceForTests != null) return; | |
342 mSnippetsBridge.onSuggestionMenuOpened(article); | 345 mSnippetsBridge.onSuggestionMenuOpened(article); |
343 } | 346 } |
344 | 347 |
345 @Override | 348 @Override |
346 public void trackSnippetCategoryActionImpression(int category, int posit ion) { | 349 public void trackSnippetCategoryActionImpression(int category, int posit ion) { |
350 if (sSuggestionsSourceForTests != null) return; | |
347 mSnippetsBridge.onMoreButtonShown(category, position); | 351 mSnippetsBridge.onMoreButtonShown(category, position); |
348 } | 352 } |
349 | 353 |
350 @Override | 354 @Override |
351 public void trackSnippetCategoryActionClick(int category, int position) { | 355 public void trackSnippetCategoryActionClick(int category, int position) { |
356 if (sSuggestionsSourceForTests != null) return; | |
352 mSnippetsBridge.onMoreButtonClicked(category, position); | 357 mSnippetsBridge.onMoreButtonClicked(category, position); |
353 switch (category) { | 358 switch (category) { |
354 case KnownCategories.BOOKMARKS: | 359 case KnownCategories.BOOKMARKS: |
355 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKM ARKS_MANAGER); | 360 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKM ARKS_MANAGER); |
356 break; | 361 break; |
357 // MORE button in both categories leads to the recent tabs manag er | 362 // MORE button in both categories leads to the recent tabs manag er |
358 case KnownCategories.FOREIGN_TABS: | 363 case KnownCategories.FOREIGN_TABS: |
359 case KnownCategories.RECENT_TABS: | 364 case KnownCategories.RECENT_TABS: |
360 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECEN T_TABS_MANAGER); | 365 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECEN T_TABS_MANAGER); |
361 break; | 366 break; |
362 case KnownCategories.DOWNLOADS: | 367 case KnownCategories.DOWNLOADS: |
363 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_DOWNL OADS_MANAGER); | 368 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_DOWNL OADS_MANAGER); |
364 break; | 369 break; |
365 default: | 370 default: |
366 // No action associated | 371 // No action associated |
367 break; | 372 break; |
368 } | 373 } |
369 } | 374 } |
370 | 375 |
371 @Override | 376 @Override |
372 public void openSnippet(int windowOpenDisposition, SnippetArticle articl e) { | 377 public void openSnippet(int windowOpenDisposition, SnippetArticle articl e) { |
373 mSnippetsBridge.onSuggestionOpened(article, windowOpenDisposition); | 378 if (sSuggestionsSourceForTests != null) { |
379 mSnippetsBridge.onSuggestionOpened(article, windowOpenDispositio n); | |
380 } | |
374 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_SNIPPET); | 381 NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_SNIPPET); |
375 | 382 |
376 if (article.mIsAssetDownload) { | 383 if (article.mIsAssetDownload) { |
377 assert windowOpenDisposition == WindowOpenDisposition.CURRENT_TA B | 384 assert windowOpenDisposition == WindowOpenDisposition.CURRENT_TA B |
378 || windowOpenDisposition == WindowOpenDisposition.NEW_WI NDOW | 385 || windowOpenDisposition == WindowOpenDisposition.NEW_WI NDOW |
379 || windowOpenDisposition == WindowOpenDisposition.NEW_FO REGROUND_TAB; | 386 || windowOpenDisposition == WindowOpenDisposition.NEW_FO REGROUND_TAB; |
380 DownloadUtils.openFile( | 387 DownloadUtils.openFile( |
381 article.getAssetDownloadFile(), article.getAssetDownload MimeType(), false); | 388 article.getAssetDownloadFile(), article.getAssetDownload MimeType(), false); |
382 return; | 389 return; |
383 } | 390 } |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1057 @Override | 1064 @Override |
1058 public boolean shouldCaptureThumbnail() { | 1065 public boolean shouldCaptureThumbnail() { |
1059 return mNewTabPageView.shouldCaptureThumbnail(); | 1066 return mNewTabPageView.shouldCaptureThumbnail(); |
1060 } | 1067 } |
1061 | 1068 |
1062 @Override | 1069 @Override |
1063 public void captureThumbnail(Canvas canvas) { | 1070 public void captureThumbnail(Canvas canvas) { |
1064 mNewTabPageView.captureThumbnail(canvas); | 1071 mNewTabPageView.captureThumbnail(canvas); |
1065 } | 1072 } |
1066 } | 1073 } |
OLD | NEW |