| 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.Log; | 21 import org.chromium.base.Log; |
| 22 import org.chromium.base.ReferencePool; |
| 22 import org.chromium.base.TraceEvent; | 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.NativePageHost; | 32 import org.chromium.chrome.browser.NativePageHost; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 @VisibleForTesting | 171 @VisibleForTesting |
| 171 public static void setSuggestionsSourceForTests(SuggestionsSource suggestion
sSource) { | 172 public static void setSuggestionsSourceForTests(SuggestionsSource suggestion
sSource) { |
| 172 sSuggestionsSourceForTests = suggestionsSource; | 173 sSuggestionsSourceForTests = suggestionsSource; |
| 173 } | 174 } |
| 174 | 175 |
| 175 private class NewTabPageManagerImpl | 176 private class NewTabPageManagerImpl |
| 176 extends SuggestionsUiDelegateImpl implements NewTabPageManager { | 177 extends SuggestionsUiDelegateImpl implements NewTabPageManager { |
| 177 public NewTabPageManagerImpl(SuggestionsSource suggestionsSource, | 178 public NewTabPageManagerImpl(SuggestionsSource suggestionsSource, |
| 178 SuggestionsEventReporter eventReporter, | 179 SuggestionsEventReporter eventReporter, |
| 179 SuggestionsNavigationDelegate navigationDelegate, Profile profil
e, | 180 SuggestionsNavigationDelegate navigationDelegate, Profile profil
e, |
| 180 NativePageHost nativePageHost) { | 181 NativePageHost nativePageHost, ReferencePool referencePool) { |
| 181 super(suggestionsSource, eventReporter, navigationDelegate, profile,
nativePageHost); | 182 super(suggestionsSource, eventReporter, navigationDelegate, profile,
nativePageHost, |
| 183 referencePool); |
| 182 } | 184 } |
| 183 | 185 |
| 184 @Override | 186 @Override |
| 185 public boolean isLocationBarShownInNTP() { | 187 public boolean isLocationBarShownInNTP() { |
| 186 if (mIsDestroyed) return false; | 188 if (mIsDestroyed) return false; |
| 187 Context context = mNewTabPageView.getContext(); | 189 Context context = mNewTabPageView.getContext(); |
| 188 return isInSingleUrlBarMode(context) | 190 return isInSingleUrlBarMode(context) |
| 189 && !mNewTabPageView.urlFocusAnimationsDisabled(); | 191 && !mNewTabPageView.urlFocusAnimationsDisabled(); |
| 190 } | 192 } |
| 191 | 193 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 mTab = nativePageHost.getActiveTab(); | 316 mTab = nativePageHost.getActiveTab(); |
| 315 mTabModelSelector = tabModelSelector; | 317 mTabModelSelector = tabModelSelector; |
| 316 Profile profile = mTab.getProfile(); | 318 Profile profile = mTab.getProfile(); |
| 317 | 319 |
| 318 mSnippetsBridge = new SnippetsBridge(profile); | 320 mSnippetsBridge = new SnippetsBridge(profile); |
| 319 SuggestionsEventReporter eventReporter = new SuggestionsEventReporterBri
dge(); | 321 SuggestionsEventReporter eventReporter = new SuggestionsEventReporterBri
dge(); |
| 320 | 322 |
| 321 SuggestionsNavigationDelegateImpl navigationDelegate = | 323 SuggestionsNavigationDelegateImpl navigationDelegate = |
| 322 new SuggestionsNavigationDelegateImpl( | 324 new SuggestionsNavigationDelegateImpl( |
| 323 activity, profile, nativePageHost, tabModelSelector); | 325 activity, profile, nativePageHost, tabModelSelector); |
| 324 mNewTabPageManager = new NewTabPageManagerImpl( | 326 mNewTabPageManager = new NewTabPageManagerImpl(mSnippetsBridge, eventRep
orter, |
| 325 mSnippetsBridge, eventReporter, navigationDelegate, profile, nat
ivePageHost); | 327 navigationDelegate, profile, nativePageHost, activity.getReferen
cePool()); |
| 326 mTileGroupDelegate = new NewTabPageTileGroupDelegate( | 328 mTileGroupDelegate = new NewTabPageTileGroupDelegate( |
| 327 activity, profile, tabModelSelector, navigationDelegate); | 329 activity, profile, tabModelSelector, navigationDelegate); |
| 328 | 330 |
| 329 mTitle = activity.getResources().getString(R.string.button_new_tab); | 331 mTitle = activity.getResources().getString(R.string.button_new_tab); |
| 330 mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(
), R.color.ntp_bg); | 332 mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(
), R.color.ntp_bg); |
| 331 mThemeColor = ApiCompatibilityUtils.getColor( | 333 mThemeColor = ApiCompatibilityUtils.getColor( |
| 332 activity.getResources(), R.color.default_primary_color); | 334 activity.getResources(), R.color.default_primary_color); |
| 333 TemplateUrlService.getInstance().addObserver(this); | 335 TemplateUrlService.getInstance().addObserver(this); |
| 334 | 336 |
| 335 mTabObserver = new EmptyTabObserver() { | 337 mTabObserver = new EmptyTabObserver() { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 @Override | 608 @Override |
| 607 public boolean shouldCaptureThumbnail() { | 609 public boolean shouldCaptureThumbnail() { |
| 608 return mNewTabPageView.shouldCaptureThumbnail(); | 610 return mNewTabPageView.shouldCaptureThumbnail(); |
| 609 } | 611 } |
| 610 | 612 |
| 611 @Override | 613 @Override |
| 612 public void captureThumbnail(Canvas canvas) { | 614 public void captureThumbnail(Canvas canvas) { |
| 613 mNewTabPageView.captureThumbnail(canvas); | 615 mNewTabPageView.captureThumbnail(canvas); |
| 614 } | 616 } |
| 615 } | 617 } |
| OLD | NEW |