Commit 5e15fd87 authored by Xi Han's avatar Xi Han Committed by Commit Bot

[Instant Start] Create TabAttributeCache for single tab card.

This CL fixes the issue of "Tab title is missing on the single Tab when
Instant Start is enabled". When missing the creation of
TabAttributeCache, SingleTabSwitcherCoordinator won't have a
TabModelSelectorTabObserver, thus will miss the
TabModelSelectorTabObserver#onTitleUpdated(Tab tab) etc. events.

Bug: 1097789
Change-Id: If7037519e4f48292828c390a89cc4cb79fd966a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363715
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799606}
parent 8c70e048
......@@ -15,7 +15,10 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tasks.pseudotab.TabAttributeCache;
import org.chromium.chrome.browser.tasks.tab_management.TabListFaviconProvider;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
......@@ -42,6 +45,9 @@ class SingleTabSwitcherCoordinator implements TabSwitcher {
mTabListFaviconProvider = new TabListFaviconProvider(activity, false);
mMediator = new SingleTabSwitcherMediator(
propertyModel, activity.getTabModelSelector(), mTabListFaviconProvider);
if (CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START)) {
new TabAttributeCache(activity.getTabModelSelector());
}
// Most of these interfaces should be unused. They are invalid implementations.
mTabListDelegate = new TabSwitcher.TabListDelegate() {
......
......@@ -58,6 +58,8 @@ public class TabAttributeCache {
* @param tabModelSelector The {@link TabModelSelector} to observe.
*/
public TabAttributeCache(TabModelSelector tabModelSelector) {
// TODO(hanxi): makes TabAttributeCache a singleton. The TabAttributeCache should be
// instantiated and exactly once before it is used.
mTabModelSelector = tabModelSelector;
mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
@Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment