Commit 005f5ddd authored by John Lin's avatar John Lin Committed by Commit Bot

Add a check to make sure the module is successfully loaded before header

customization on module-managed URLs.

Bug: 882404
Change-Id: I8b25e6d50e6ed93d426d387746e11b1d2970ca6e
Reviewed-on: https://chromium-review.googlesource.com/c/1350926
Commit-Queue: John Lin <chuanl@google.com>
Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611654}
parent 8e7c6ca6
......@@ -383,29 +383,31 @@ public class CustomTabActivity extends ChromeActivity<CustomTabActivityComponent
if (entryPoint == null) {
unregisterModuleNavigationEventObserver();
return;
}
mModuleEntryPoint = entryPoint;
} else {
mModuleEntryPoint = entryPoint;
long createActivityDelegateStartTime = ModuleMetrics.now();
mModuleActivityDelegate = entryPoint.createActivityDelegate(
new ActivityHostImpl(CustomTabActivity.this));
ModuleMetrics.recordCreateActivityDelegateTime(createActivityDelegateStartTime);
mModuleActivityDelegate.onCreate(getSavedInstanceState());
long createActivityDelegateStartTime = ModuleMetrics.now();
mModuleActivityDelegate = entryPoint.createActivityDelegate(
new ActivityHostImpl(CustomTabActivity.this));
ModuleMetrics.recordCreateActivityDelegateTime(createActivityDelegateStartTime);
mModuleActivityDelegate.onCreate(getSavedInstanceState());
if (mModuleOnStartPending) startModule();
if (mModuleOnResumePending) resumeModule();
if (mModuleOnStartPending) startModule();
if (mModuleOnResumePending) resumeModule();
if (mModuleEntryPoint.getModuleVersion() >=
DynamicModuleConstants.ON_NAVIGATION_EVENT_MODULE_API_VERSION) {
mModuleNavigationEventObserver.setActivityDelegate(mModuleActivityDelegate);
} else {
unregisterModuleNavigationEventObserver();
}
if (mModuleEntryPoint.getModuleVersion()
>= DynamicModuleConstants.ON_NAVIGATION_EVENT_MODULE_API_VERSION) {
mModuleNavigationEventObserver.setActivityDelegate(mModuleActivityDelegate);
} else {
unregisterModuleNavigationEventObserver();
}
// Initialise the PostMessageHandler for the current web contents.
maybeInitialiseDynamicModulePostMessageHandler(
new ActivityDelegatePostMessageBackend());
// Initialise the PostMessageHandler for the current web contents.
maybeInitialiseDynamicModulePostMessageHandler(
new ActivityDelegatePostMessageBackend());
}
// Show CCT header (or top bar) if module fails (or succeeds) to load.
maybeUpdateCctHeaderVisibility(mIntentDataProvider.getUrlToLoad());
}
}
......@@ -1690,12 +1692,12 @@ public class CustomTabActivity extends ChromeActivity<CustomTabActivityComponent
}
private void maybeUpdateCctHeaderVisibility(String url) {
// TODO(crbug.com/882404) Show CCT top bar if module fails to load.
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_MODULE) || !isModuleLoaded()) {
return;
}
boolean isModuleManagedUrl = isModuleManagedUrl(url);
mTopBarDelegate.showTopBarIfNecessary(isModuleManagedUrl);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_MODULE)
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_MODULE_CUSTOM_HEADER)
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_MODULE_CUSTOM_HEADER)
&& mIntentDataProvider.shouldHideCctHeaderOnModuleManagedUrls()) {
getToolbarManager().setToolbarVisibility(
isModuleManagedUrl ? View.GONE : mDefaultToolbarVisibility);
......
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