| 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; |
| 11 import android.graphics.Rect; | 11 import android.graphics.Rect; |
| 12 import android.os.Build; | 12 import android.os.Build; |
| 13 import android.support.v4.view.ViewCompat; | 13 import android.support.v4.view.ViewCompat; |
| 14 import android.support.v7.widget.RecyclerView; | 14 import android.support.v7.widget.RecyclerView; |
| 15 import android.text.TextUtils; | 15 import android.text.TextUtils; |
| 16 import android.view.LayoutInflater; | 16 import android.view.LayoutInflater; |
| 17 import android.view.View; | 17 import android.view.View; |
| 18 | 18 |
| 19 import org.chromium.base.ApiCompatibilityUtils; | 19 import org.chromium.base.ApiCompatibilityUtils; |
| 20 import org.chromium.base.CommandLine; | 20 import org.chromium.base.CommandLine; |
| 21 import org.chromium.base.ContextUtils; | 21 import org.chromium.base.ContextUtils; |
| 22 import org.chromium.base.Log; | 22 import org.chromium.base.Log; |
| 23 import org.chromium.base.TraceEvent; |
| 23 import org.chromium.base.VisibleForTesting; | 24 import org.chromium.base.VisibleForTesting; |
| 24 import org.chromium.base.metrics.RecordHistogram; | 25 import org.chromium.base.metrics.RecordHistogram; |
| 25 import org.chromium.base.metrics.RecordUserAction; | 26 import org.chromium.base.metrics.RecordUserAction; |
| 26 import org.chromium.chrome.R; | 27 import org.chromium.chrome.R; |
| 27 import org.chromium.chrome.browser.ChromeActivity; | 28 import org.chromium.chrome.browser.ChromeActivity; |
| 28 import org.chromium.chrome.browser.ChromeFeatureList; | 29 import org.chromium.chrome.browser.ChromeFeatureList; |
| 29 import org.chromium.chrome.browser.ChromeSwitches; | 30 import org.chromium.chrome.browser.ChromeSwitches; |
| 30 import org.chromium.chrome.browser.NativePage; | 31 import org.chromium.chrome.browser.NativePage; |
| 31 import org.chromium.chrome.browser.UrlConstants; | 32 import org.chromium.chrome.browser.UrlConstants; |
| 32 import org.chromium.chrome.browser.compositor.layouts.content.InvalidationAwareT
humbnailProvider; | 33 import org.chromium.chrome.browser.compositor.layouts.content.InvalidationAwareT
humbnailProvider; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 412 } |
| 412 | 413 |
| 413 /** | 414 /** |
| 414 * Constructs a NewTabPage. | 415 * Constructs a NewTabPage. |
| 415 * @param activity The activity used for context to create the new tab page'
s View. | 416 * @param activity The activity used for context to create the new tab page'
s View. |
| 416 * @param tab The Tab that is showing this new tab page. | 417 * @param tab The Tab that is showing this new tab page. |
| 417 * @param tabModelSelector The TabModelSelector used to open tabs. | 418 * @param tabModelSelector The TabModelSelector used to open tabs. |
| 418 */ | 419 */ |
| 419 public NewTabPage(ChromeActivity activity, Tab tab, TabModelSelector tabMode
lSelector) { | 420 public NewTabPage(ChromeActivity activity, Tab tab, TabModelSelector tabMode
lSelector) { |
| 420 mConstructedTimeNs = System.nanoTime(); | 421 mConstructedTimeNs = System.nanoTime(); |
| 422 TraceEvent.begin(TAG); |
| 421 | 423 |
| 422 mTab = tab; | 424 mTab = tab; |
| 423 mTabModelSelector = tabModelSelector; | 425 mTabModelSelector = tabModelSelector; |
| 424 Profile profile = tab.getProfile(); | 426 Profile profile = tab.getProfile(); |
| 425 | 427 |
| 426 mSnippetsBridge = new SnippetsBridge(profile); | 428 mSnippetsBridge = new SnippetsBridge(profile); |
| 427 | 429 |
| 428 SuggestionsNavigationDelegateImpl navigationDelegate = | 430 SuggestionsNavigationDelegateImpl navigationDelegate = |
| 429 new SuggestionsNavigationDelegateImpl(activity, profile, tab, ta
bModelSelector); | 431 new SuggestionsNavigationDelegateImpl(activity, profile, tab, ta
bModelSelector); |
| 430 mNewTabPageManager = new NewTabPageManagerImpl( | 432 mNewTabPageManager = new NewTabPageManagerImpl( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 if (mSnippetsBridge != null) { | 486 if (mSnippetsBridge != null) { |
| 485 mSnippetsBridge.onNtpInitialized(); | 487 mSnippetsBridge.onNtpInitialized(); |
| 486 } | 488 } |
| 487 | 489 |
| 488 DownloadManagerService.getDownloadManagerService(ContextUtils.getApplica
tionContext()) | 490 DownloadManagerService.getDownloadManagerService(ContextUtils.getApplica
tionContext()) |
| 489 .checkForExternallyRemovedDownloads(/*isOffRecord=*/false); | 491 .checkForExternallyRemovedDownloads(/*isOffRecord=*/false); |
| 490 | 492 |
| 491 RecordHistogram.recordBooleanHistogram( | 493 RecordHistogram.recordBooleanHistogram( |
| 492 "NewTabPage.MobileIsUserOnline", NetworkChangeNotifier.isOnline(
)); | 494 "NewTabPage.MobileIsUserOnline", NetworkChangeNotifier.isOnline(
)); |
| 493 NewTabPageUma.recordLoadType(activity); | 495 NewTabPageUma.recordLoadType(activity); |
| 496 TraceEvent.end(TAG); |
| 494 } | 497 } |
| 495 | 498 |
| 496 private static MostVisitedSites buildMostVisitedSites(Profile profile) { | 499 private static MostVisitedSites buildMostVisitedSites(Profile profile) { |
| 497 if (sMostVisitedSitesForTests != null) { | 500 if (sMostVisitedSitesForTests != null) { |
| 498 return sMostVisitedSitesForTests; | 501 return sMostVisitedSitesForTests; |
| 499 } else { | 502 } else { |
| 500 return new MostVisitedSites(profile); | 503 return new MostVisitedSites(profile); |
| 501 } | 504 } |
| 502 } | 505 } |
| 503 | 506 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 @Override | 756 @Override |
| 754 public boolean shouldCaptureThumbnail() { | 757 public boolean shouldCaptureThumbnail() { |
| 755 return mNewTabPageView.shouldCaptureThumbnail(); | 758 return mNewTabPageView.shouldCaptureThumbnail(); |
| 756 } | 759 } |
| 757 | 760 |
| 758 @Override | 761 @Override |
| 759 public void captureThumbnail(Canvas canvas) { | 762 public void captureThumbnail(Canvas canvas) { |
| 760 mNewTabPageView.captureThumbnail(canvas); | 763 mNewTabPageView.captureThumbnail(canvas); |
| 761 } | 764 } |
| 762 } | 765 } |
| OLD | NEW |