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.app.Activity; | 8 import android.app.Activity; |
9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
10 import android.app.Dialog; | 10 import android.app.Dialog; |
11 import android.content.Context; | 11 import android.content.Context; |
12 import android.content.Intent; | 12 import android.content.Intent; |
13 import android.graphics.Canvas; | 13 import android.graphics.Canvas; |
| 14 import android.graphics.Color; |
14 import android.graphics.Rect; | 15 import android.graphics.Rect; |
15 import android.net.Uri; | 16 import android.net.Uri; |
16 import android.os.Build; | 17 import android.os.Build; |
17 import android.view.ContextMenu; | 18 import android.view.ContextMenu; |
18 import android.view.LayoutInflater; | 19 import android.view.LayoutInflater; |
19 import android.view.Menu; | 20 import android.view.Menu; |
20 import android.view.MenuItem.OnMenuItemClickListener; | 21 import android.view.MenuItem.OnMenuItemClickListener; |
21 import android.view.View; | 22 import android.view.View; |
22 | 23 |
23 import org.chromium.base.ApiCompatibilityUtils; | 24 import org.chromium.base.ApiCompatibilityUtils; |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 */ | 575 */ |
575 public NewTabPage(Activity activity, Tab tab, TabModelSelector tabModelSelec
tor) { | 576 public NewTabPage(Activity activity, Tab tab, TabModelSelector tabModelSelec
tor) { |
576 mConstructedTimeNs = System.nanoTime(); | 577 mConstructedTimeNs = System.nanoTime(); |
577 | 578 |
578 mTab = tab; | 579 mTab = tab; |
579 mActivity = activity; | 580 mActivity = activity; |
580 mTabModelSelector = tabModelSelector; | 581 mTabModelSelector = tabModelSelector; |
581 mProfile = tab.getProfile(); | 582 mProfile = tab.getProfile(); |
582 | 583 |
583 mTitle = activity.getResources().getString(R.string.button_new_tab); | 584 mTitle = activity.getResources().getString(R.string.button_new_tab); |
584 mBackgroundColor = NtpColorUtils.getBackgroundColorResource(activity.get
Resources()); | 585 mBackgroundColor = ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_SNI
PPETS) |
| 586 ? ApiCompatibilityUtils.getColor(activity.getResources(), R.colo
r.ntp_with_cards_bg) |
| 587 : ApiCompatibilityUtils.getColor(activity.getResources(), R.colo
r.ntp_bg); |
585 mThemeColor = ApiCompatibilityUtils.getColor( | 588 mThemeColor = ApiCompatibilityUtils.getColor( |
586 activity.getResources(), R.color.default_primary_color); | 589 activity.getResources(), R.color.default_primary_color); |
587 TemplateUrlService.getInstance().addObserver(this); | 590 TemplateUrlService.getInstance().addObserver(this); |
588 | 591 |
589 mTabObserver = new EmptyTabObserver() { | 592 mTabObserver = new EmptyTabObserver() { |
590 @Override | 593 @Override |
591 public void onShown(Tab tab) { | 594 public void onShown(Tab tab) { |
592 // Showing the NTP is only meaningful when the page has been loa
ded already. | 595 // Showing the NTP is only meaningful when the page has been loa
ded already. |
593 if (mIsLoaded) recordNTPShown(); | 596 if (mIsLoaded) recordNTPShown(); |
594 mIsVisible = true; | 597 mIsVisible = true; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 return mTitle; | 808 return mTitle; |
806 } | 809 } |
807 | 810 |
808 @Override | 811 @Override |
809 public int getBackgroundColor() { | 812 public int getBackgroundColor() { |
810 return mBackgroundColor; | 813 return mBackgroundColor; |
811 } | 814 } |
812 | 815 |
813 @Override | 816 @Override |
814 public int getThemeColor() { | 817 public int getThemeColor() { |
815 return isLocationBarShownInNTP() | 818 return isLocationBarShownInNTP() ? Color.WHITE : mThemeColor; |
816 ? NtpColorUtils.getBackgroundColorResource(mActivity.getResource
s()) | |
817 : mThemeColor; | |
818 } | 819 } |
819 | 820 |
820 @Override | 821 @Override |
821 public View getView() { | 822 public View getView() { |
822 return mNewTabPageView; | 823 return mNewTabPageView; |
823 } | 824 } |
824 | 825 |
825 @Override | 826 @Override |
826 public String getHost() { | 827 public String getHost() { |
827 return UrlConstants.NTP_HOST; | 828 return UrlConstants.NTP_HOST; |
828 } | 829 } |
829 | 830 |
830 @Override | 831 @Override |
831 public void updateForUrl(String url) { | 832 public void updateForUrl(String url) { |
832 } | 833 } |
833 | 834 |
834 // InvalidationAwareThumbnailProvider | 835 // InvalidationAwareThumbnailProvider |
835 | 836 |
836 @Override | 837 @Override |
837 public boolean shouldCaptureThumbnail() { | 838 public boolean shouldCaptureThumbnail() { |
838 return mNewTabPageView.shouldCaptureThumbnail(); | 839 return mNewTabPageView.shouldCaptureThumbnail(); |
839 } | 840 } |
840 | 841 |
841 @Override | 842 @Override |
842 public void captureThumbnail(Canvas canvas) { | 843 public void captureThumbnail(Canvas canvas) { |
843 mNewTabPageView.captureThumbnail(canvas); | 844 mNewTabPageView.captureThumbnail(canvas); |
844 } | 845 } |
845 } | 846 } |
OLD | NEW |