Commit 05e7ea4b authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[SharingHub] Don't show custom share sheet for custom tabs

For the initial launch we do not want to show the custom share sheet
for CCTs.

Bug: 1090470
Change-Id: I60ed2bae711adbe93db2e21866db0f7cb1b48c0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284363
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786096}
parent fb31b4cd
...@@ -19,7 +19,6 @@ import org.chromium.base.PackageManagerUtils; ...@@ -19,7 +19,6 @@ import org.chromium.base.PackageManagerUtils;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.Supplier; import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.firstrun.FirstRunStatus; import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.locale.LocaleManager; import org.chromium.chrome.browser.locale.LocaleManager;
import org.chromium.chrome.browser.share.ChromeShareExtras; import org.chromium.chrome.browser.share.ChromeShareExtras;
import org.chromium.chrome.browser.share.ShareDelegate; import org.chromium.chrome.browser.share.ShareDelegate;
...@@ -165,7 +164,7 @@ public class ChromeActionModeHandler { ...@@ -165,7 +164,7 @@ public class ChromeActionModeHandler {
LocaleManager.getInstance().showSearchEnginePromoIfNeeded( LocaleManager.getInstance().showSearchEnginePromoIfNeeded(
TabUtils.getActivity(mTab), callback); TabUtils.getActivity(mTab), callback);
mHelper.finishActionMode(); mHelper.finishActionMode();
} else if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB_V15) } else if (mShareDelegateSupplier.get().isSharingHubV15Enabled()
&& item.getItemId() == R.id.select_action_menu_share) { && item.getItemId() == R.id.select_action_menu_share) {
mShareDelegateSupplier.get().share( mShareDelegateSupplier.get().share(
new ShareParams.Builder(mTab.getWindowAndroid(), /*url=*/"", /*title=*/"") new ShareParams.Builder(mTab.getWindowAndroid(), /*url=*/"", /*title=*/"")
......
...@@ -450,9 +450,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent> ...@@ -450,9 +450,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
getLifecycleDispatcher().register(bottomContainer); getLifecycleDispatcher().register(bottomContainer);
// Should be called after TabModels are initialized. // Should be called after TabModels are initialized.
ShareDelegate shareDelegate = ShareDelegate shareDelegate = new ShareDelegateImpl(
new ShareDelegateImpl(mRootUiCoordinator.getBottomSheetController(), mRootUiCoordinator.getBottomSheetController(), getActivityTabProvider(),
getActivityTabProvider(), new ShareDelegateImpl.ShareSheetDelegate()); new ShareDelegateImpl.ShareSheetDelegate(), isCustomTab());
mShareDelegateSupplier.set(shareDelegate); mShareDelegateSupplier.set(shareDelegate);
// If onStart was called before postLayoutInflation (because inflation was done in a // If onStart was called before postLayoutInflation (because inflation was done in a
......
...@@ -815,7 +815,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator { ...@@ -815,7 +815,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
*/ */
private void shareImage(RenderFrameHost renderFrameHost, String srcUrl) { private void shareImage(RenderFrameHost renderFrameHost, String srcUrl) {
retrieveImage(renderFrameHost, ContextMenuImageFormat.ORIGINAL, (Uri imageUri) -> { retrieveImage(renderFrameHost, ContextMenuImageFormat.ORIGINAL, (Uri imageUri) -> {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB_V15)) { if (!mShareDelegateSupplier.get().isSharingHubV15Enabled()) {
ShareHelper.shareImage(getWindow(), null, imageUri); ShareHelper.shareImage(getWindow(), null, imageUri);
return; return;
} }
......
...@@ -26,4 +26,14 @@ public interface ShareDelegate { ...@@ -26,4 +26,14 @@ public interface ShareDelegate {
* @param shareDirectly If this share should be sent directly to the last used share target. * @param shareDirectly If this share should be sent directly to the last used share target.
*/ */
void share(Tab currentTab, boolean shareDirectly); void share(Tab currentTab, boolean shareDirectly);
/**
* Check if the custom share sheet is enabled.
*/
boolean isSharingHubV1Enabled();
/**
* Check if v1.5 of the custom share sheet is enabled.
*/
boolean isSharingHubV15Enabled();
} }
...@@ -52,6 +52,7 @@ public class ShareDelegateImpl implements ShareDelegate { ...@@ -52,6 +52,7 @@ public class ShareDelegateImpl implements ShareDelegate {
private final ShareSheetDelegate mDelegate; private final ShareSheetDelegate mDelegate;
private final Supplier<Tab> mTabProvider; private final Supplier<Tab> mTabProvider;
private long mShareStartTime; private long mShareStartTime;
private boolean mIsCustomTab;
private static boolean sScreenshotCaptureSkippedForTesting; private static boolean sScreenshotCaptureSkippedForTesting;
...@@ -61,12 +62,14 @@ public class ShareDelegateImpl implements ShareDelegate { ...@@ -61,12 +62,14 @@ public class ShareDelegateImpl implements ShareDelegate {
* @param controller The BottomSheetController for the current activity. * @param controller The BottomSheetController for the current activity.
* @param tabProvider Supplier for the current activity tab. * @param tabProvider Supplier for the current activity tab.
* @param delegate The ShareSheetDelegate for the current activity. * @param delegate The ShareSheetDelegate for the current activity.
* @param isCustomTab This share delegate is associated with a CCT.
*/ */
public ShareDelegateImpl(BottomSheetController controller, Supplier<Tab> tabProvider, public ShareDelegateImpl(BottomSheetController controller, Supplier<Tab> tabProvider,
ShareSheetDelegate delegate) { ShareSheetDelegate delegate, boolean isCustomTab) {
mBottomSheetController = controller; mBottomSheetController = controller;
mDelegate = delegate; mDelegate = delegate;
mTabProvider = tabProvider; mTabProvider = tabProvider;
mIsCustomTab = isCustomTab;
} }
// ShareDelegate implementation. // ShareDelegate implementation.
...@@ -76,7 +79,7 @@ public class ShareDelegateImpl implements ShareDelegate { ...@@ -76,7 +79,7 @@ public class ShareDelegateImpl implements ShareDelegate {
mShareStartTime = System.currentTimeMillis(); mShareStartTime = System.currentTimeMillis();
} }
mDelegate.share(params, chromeShareExtras, mBottomSheetController, mTabProvider, mDelegate.share(params, chromeShareExtras, mBottomSheetController, mTabProvider,
this::printTab, mShareStartTime); this::printTab, mShareStartTime, isSharingHubV1Enabled());
mShareStartTime = 0; mShareStartTime = 0;
} }
...@@ -265,6 +268,17 @@ public class ShareDelegateImpl implements ShareDelegate { ...@@ -265,6 +268,17 @@ public class ShareDelegateImpl implements ShareDelegate {
} }
} }
@Override
public boolean isSharingHubV1Enabled() {
return !mIsCustomTab && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB);
}
@Override
public boolean isSharingHubV15Enabled() {
return isSharingHubV1Enabled()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB);
}
/** /**
* Delegate for share handling. * Delegate for share handling.
*/ */
...@@ -274,10 +288,10 @@ public class ShareDelegateImpl implements ShareDelegate { ...@@ -274,10 +288,10 @@ public class ShareDelegateImpl implements ShareDelegate {
*/ */
void share(ShareParams params, ChromeShareExtras chromeShareExtras, void share(ShareParams params, ChromeShareExtras chromeShareExtras,
BottomSheetController controller, Supplier<Tab> tabProvider, BottomSheetController controller, Supplier<Tab> tabProvider,
Callback<Tab> printCallback, long shareStartTime) { Callback<Tab> printCallback, long shareStartTime, boolean sharingHubEnabled) {
if (chromeShareExtras.shareDirectly()) { if (chromeShareExtras.shareDirectly()) {
ShareHelper.shareWithLastUsedComponent(params); ShareHelper.shareWithLastUsedComponent(params);
} else if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB)) { } else if (sharingHubEnabled) {
ShareSheetCoordinator coordinator = ShareSheetCoordinator coordinator =
new ShareSheetCoordinator(controller, tabProvider, new ShareSheetCoordinator(controller, tabProvider,
new ShareSheetPropertyModelBuilder(controller, new ShareSheetPropertyModelBuilder(controller,
......
...@@ -119,14 +119,15 @@ public class ShareDelegateImplIntegrationTest { ...@@ -119,14 +119,15 @@ public class ShareDelegateImplIntegrationTest {
@Override @Override
void share(ShareParams params, ChromeShareExtras chromeShareParams, void share(ShareParams params, ChromeShareExtras chromeShareParams,
BottomSheetController controller, Supplier<Tab> tabProvider, BottomSheetController controller, Supplier<Tab> tabProvider,
Callback<Tab> printCallback, long shareStartTime) { Callback<Tab> printCallback, long shareStartTime,
boolean sharingHubEnabled) {
paramsRef.set(params); paramsRef.set(params);
helper.notifyCalled(); helper.notifyCalled();
} }
}; };
new ShareDelegateImpl(mActivityTestRule.getActivity().getBottomSheetController(), new ShareDelegateImpl(mActivityTestRule.getActivity().getBottomSheetController(),
mActivityTestRule.getActivity().getActivityTabProvider(), delegate) mActivityTestRule.getActivity().getActivityTabProvider(), delegate, false)
.share(mActivityTestRule.getActivity().getActivityTab(), false); .share(mActivityTestRule.getActivity().getActivityTab(), false);
}); });
helper.waitForCallback(0); helper.waitForCallback(0);
......
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