Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1402)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/LayerTitleCache.java

Issue 2293573002: Add tinted static UI resource cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix text color when cache is full Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/LayerTitleCache.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/LayerTitleCache.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/LayerTitleCache.java
index 5a7fc237baec1a08bd8f6407f7669a0ef148f8c1..f45f27248e2e608e7c021d5714c0ed73b14017fd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/LayerTitleCache.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/LayerTitleCache.java
@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.favicon.FaviconHelper;
import org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.util.ColorUtils;
import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.resources.ResourceManager;
@@ -33,6 +34,8 @@ public class LayerTitleCache implements TitleCache {
private static int sNextResourceId = 1;
private final Context mContext;
+ private TabModelSelector mTabModelSelector;
+
private final SparseArray<Title> mTitles = new SparseArray<Title>();
private final int mFaviconSize;
@@ -83,36 +86,53 @@ public class LayerTitleCache implements TitleCache {
mNativeLayerTitleCache = 0;
}
+ public void setTabModelSelector(TabModelSelector tabModelSelector) {
+ mTabModelSelector = tabModelSelector;
+ }
+
@CalledByNative
private long getNativePtr() {
return mNativeLayerTitleCache;
}
+ @CalledByNative
+ private void buildUpdatedTitle(int tabId, int themeColor) {
+ if (mTabModelSelector == null) return;
+
+ Tab tab = mTabModelSelector.getTabById(tabId);
+ if (tab == null) return;
+ getUpdatedTitleWithThemeColor(tab, "", themeColor);
aelias_OOO_until_Jul13 2016/09/03 08:01:46 It's weird to override the tab's idea of its own t
mdjones 2016/09/06 16:21:25 The tab still needs to know its color for the tool
+ }
+
@Override
public String getUpdatedTitle(Tab tab, String defaultTitle) {
+ return getUpdatedTitleWithThemeColor(tab, defaultTitle, tab.getThemeColor());
+ }
+
+ private String getUpdatedTitleWithThemeColor(Tab tab, String defaultTitle, int themeColor) {
// If content view core is null, tab does not have direct access to the favicon, and we
// will initially show default favicon. But favicons are stored in the history database, so
// we will fetch favicons asynchronously from database.
boolean fetchFaviconFromHistory = tab.getContentViewCore() == null;
String titleString = getTitleForTab(tab, defaultTitle);
- getUpdatedTitleInternal(tab, titleString, fetchFaviconFromHistory);
+ getUpdatedTitleInternal(tab, titleString, fetchFaviconFromHistory, themeColor);
if (fetchFaviconFromHistory) fetchFaviconForTab(tab);
return titleString;
}
private String getUpdatedTitleInternal(Tab tab, String titleString,
- boolean fetchFaviconFromHistory) {
+ boolean fetchFaviconFromHistory, int themeColor) {
final int tabId = tab.getId();
Bitmap originalFavicon = tab.getFavicon();
boolean isDarkTheme = tab.isIncognito();
// The theme might require lighter text.
if (!DeviceFormFactor.isTablet(mContext)) {
- isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
+ isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(themeColor);
}
- ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
+ ColorUtils.shouldUseLightForegroundOnBackground(themeColor);
boolean isRtl = tab.isTitleDirectionRtl();
TitleBitmapFactory titleBitmapFactory = isDarkTheme
? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory;

Powered by Google App Engine
This is Rietveld 408576698