Skip to content

Commit

Permalink
Remove old sharing flags
Browse files Browse the repository at this point in the history
Remove ChromeSharingHubV15, and ChromeShareQRCode flags,
these are all enabled by default on M90, which is already
on stable. Keep ChromeSharingHub as it's used to parse the
finch param for share targets, but remove checks for if it
is enabled.

Change-Id: Ib7597c0554539aadb14fa0e8c60aa6fd2103807c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2844711
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Reviewed-by: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880004}
  • Loading branch information
Kyle Milka authored and Chromium LUCI CQ committed May 6, 2021
1 parent ae33227 commit 66f304f
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 554 deletions.
Expand Up @@ -393,8 +393,7 @@ public void testDialogToolbarMenuShareGroup() {
@Test
@MediumTest
// clang-format off
@Features.EnableFeatures({ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID,
ChromeFeatureList.CHROME_SHARING_HUB})
@Features.EnableFeatures({ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID})
public void testDialogToolbarMenuShareGroup_WithSharingHub() {
// clang-format on
final ChromeTabbedActivity cta = mActivityTestRule.getActivity();
Expand Down
Expand Up @@ -169,7 +169,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
AppHooks.get().getLocaleManager().showSearchEnginePromoIfNeeded(
TabUtils.getActivity(mTab), callback);
mHelper.finishActionMode();
} else if (mShareDelegateSupplier.get().isSharingHubV15Enabled()
} else if (mShareDelegateSupplier.get().isSharingHubEnabled()
&& item.getItemId() == R.id.select_action_menu_share) {
RecordUserAction.record(SelectionPopupController.UMA_MOBILE_ACTION_MODE_SHARE);
RecordHistogram.recordMediumTimesHistogram("ContextMenu.TimeToSelectShare",
Expand Down
Expand Up @@ -818,7 +818,7 @@ private void copyImageToClipboard() {
*/
private void shareImage() {
mNativeDelegate.retrieveImageForShare(ContextMenuImageFormat.ORIGINAL, (Uri imageUri) -> {
if (!mShareDelegateSupplier.get().isSharingHubV15Enabled()) {
if (!mShareDelegateSupplier.get().isSharingHubEnabled()) {
ShareHelper.shareImage(getWindow(), null, imageUri);
return;
}
Expand Down
Expand Up @@ -18,7 +18,6 @@
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.feature_engagement.ScreenshotTabObserver;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.history_clusters.HistoryClustersTabHelper;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
Expand Down Expand Up @@ -96,7 +95,7 @@ public void share(
ProfileSyncService.get() != null && ProfileSyncService.get().isSyncRequested();
mDelegate.share(params, chromeShareExtras, mBottomSheetController, mLifecycleDispatcher,
mTabProvider, this::printTab, shareOrigin, isSyncEnabled, mShareStartTime,
isSharingHubV1Enabled());
isSharingHubEnabled());
mShareStartTime = 0;
}

Expand Down Expand Up @@ -286,14 +285,8 @@ private void printTab(Tab tab) {
}

@Override
public boolean isSharingHubV1Enabled() {
return !mIsCustomTab && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB);
}

@Override
public boolean isSharingHubV15Enabled() {
return isSharingHubV1Enabled()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARING_HUB_V15);
public boolean isSharingHubEnabled() {
return !mIsCustomTab;
}

/**
Expand Down
Expand Up @@ -4,13 +4,10 @@

package org.chromium.chrome.browser.webshare;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.support.test.InstrumentationRegistry;

import androidx.appcompat.app.AlertDialog;
import androidx.test.filters.MediumTest;

import org.junit.After;
Expand All @@ -23,15 +20,12 @@
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.share.ShareHelper;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.test.NativeLibraryTestUtils;
import org.chromium.content_public.browser.test.util.TouchCommon;
import org.chromium.net.test.EmbeddedTestServer;
Expand Down Expand Up @@ -126,107 +120,6 @@ public void testWebShareNoUserGesture() throws Exception {
mUpdateWaiter.waitForUpdate());
}

/**
* Verify WebShare fails if share is called from a user gesture, and canceled.
* This test tests functionality that is only available post Lollipop MR1.
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP_MR1)
public void testWebShareDoubleRequest() throws Exception {
// Set up ShareHelper to ignore the intent (without showing a picker),
// and request another share.
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPostLMR1(false));

mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Fail: InvalidStateError: Failed to execute 'share' on 'Navigator': "
+ "A earlier share had not yet completed.",
mUpdateWaiter.waitForUpdate());
}

/**
* Verify WebShare succeeds if share is called from a user gesture, and app chosen.
* This test tests functionality that is only available post Lollipop MR1.
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP_MR1)
public void testWebShareSuccess() throws Exception {
// Set up ShareHelper to immediately succeed (without showing a picker).
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPostLMR1(true));

mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());

// The actual intent to be delivered to the target is in the EXTRA_INTENT of the chooser
// intent.
Assert.assertNotNull(mReceivedIntent);
Assert.assertTrue(mReceivedIntent.hasExtra(Intent.EXTRA_INTENT));
verifyDeliveredIntent(mReceivedIntent.getParcelableExtra(Intent.EXTRA_INTENT));
}

/**
* Verify WebShare of .ogg file succeeds if share is called from a user gesture, and app chosen.
* This test tests functionality that is only available post Lollipop MR1.
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP_MR1)
public void testWebShareOgg() throws Exception {
// Set up ShareHelper to immediately succeed (without showing a picker).
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPostLMR1(true));

mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE_OGG));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());

// The actual intent to be delivered to the target is in the EXTRA_INTENT of the chooser
// intent.
Assert.assertNotNull(mReceivedIntent);
Assert.assertTrue(mReceivedIntent.hasExtra(Intent.EXTRA_INTENT));
verifyDeliveredOggIntent(mReceivedIntent.getParcelableExtra(Intent.EXTRA_INTENT));
}

/**
* Verify WebShare of .bmp files succeeds if share is called from a user gesture, and app
* chosen. This test tests functionality that is only available post Lollipop MR1.
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP_MR1)
public void testWebShareBmp() throws Exception {
// Set up ShareHelper to immediately succeed (without showing a picker).
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPostLMR1(true));

mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE_BMP));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());

// The actual intent to be delivered to the target is in the EXTRA_INTENT of the chooser
// intent.
Assert.assertNotNull(mReceivedIntent);
Assert.assertTrue(mReceivedIntent.hasExtra(Intent.EXTRA_INTENT));
verifyDeliveredBmpIntent(mReceivedIntent.getParcelableExtra(Intent.EXTRA_INTENT));
}

/**
* Verify WebShare fails if share of .apk is called from a user gesture.
* @throws Exception
Expand Down Expand Up @@ -305,95 +198,6 @@ public void testWebShareLongText() throws Exception {
mUpdateWaiter.waitForUpdate());
}

/**
* Verify WebShare fails if share is called from a user gesture, and canceled.
*
* Simulates pre-Lollipop-LMR1 system (different intent picker).
*
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
public void testWebShareCancelPreLMR1() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPreLMR1(false));

ShareHelper.setForceCustomChooserForTesting(true);

mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Fail: AbortError: Share canceled", mUpdateWaiter.waitForUpdate());
}

/**
* Verify WebShare succeeds if share is called from a user gesture, and app chosen.
*
* Simulates pre-Lollipop-LMR1 system (different intent picker).
*
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
public void testWebShareSuccessPreLMR1() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPreLMR1(true));

ShareHelper.setForceCustomChooserForTesting(true);
mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());
verifyDeliveredIntent(mReceivedIntent);
}

/**
* Verify WebShare of .ogg succeeds if share is called from a user gesture, and app chosen.
*
* Simulates pre-Lollipop-LMR1 system (different intent picker).
*
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
public void testWebShareOggPreLMR1() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPreLMR1(true));

ShareHelper.setForceCustomChooserForTesting(true);
mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE_OGG));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());
verifyDeliveredOggIntent(mReceivedIntent);
}

/**
* Verify WebShare of .csv files succeeds if share is called from a user gesture, and app
* chosen.
*
* Simulates pre-Lollipop-LMR1 system (different intent picker).
*
* @throws Exception
*/
@Test
@MediumTest
@Feature({"WebShare"})
@Features.DisableFeatures(ChromeFeatureList.CHROME_SHARING_HUB)
public void testWebShareCsvPreLMR1() throws Exception {
ShareHelper.setFakeIntentReceiverForTesting(new FakeIntentReceiverPreLMR1(true));

ShareHelper.setForceCustomChooserForTesting(true);
mActivityTestRule.loadUrl(mTestServer.getURL(TEST_FILE_CSV));
// Click (instead of directly calling the JavaScript function) to simulate a user gesture.
TouchCommon.singleClickView(mTab.getView());
Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate());
verifyDeliveredCsvIntent(mReceivedIntent);
}

private static void verifyDeliveredIntent(Intent intent) {
Assert.assertNotNull(intent);
Assert.assertEquals(Intent.ACTION_SEND, intent.getAction());
Expand Down Expand Up @@ -451,73 +255,4 @@ private static void verifyDeliveredOggIntent(Intent intent) throws Exception {
Uri fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
Assert.assertEquals("contents", getFileContents(fileUri));
}

// Uses intent picker functionality that is only available since Lollipop MR1.
private class FakeIntentReceiverPostLMR1 implements ShareHelper.FakeIntentReceiver {
private final boolean mProceed;
private Intent mIntentToSendBack;

FakeIntentReceiverPostLMR1(boolean proceed) {
Assert.assertTrue(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1);
mProceed = proceed;
}

@Override
public void setIntentToSendBack(Intent intent) {
mIntentToSendBack = intent;
}

@Override
public void onCustomChooserShown(AlertDialog dialog) {}

@Override
public void fireIntent(Context context, Intent intent) {
mReceivedIntent = intent;

if (!mProceed) {
// Click again to start another share, which fails as a share is already in
// progress.
TouchCommon.singleClickView(mTab.getView());
return;
}

if (context == null) return;

// Send the intent back, which indicates that the user made a choice. (Normally,
// this would have EXTRA_CHOSEN_COMPONENT set, but for the test, we do not set any
// chosen target app.)
context.sendBroadcast(mIntentToSendBack);
}
}

// Uses intent picker functionality that is available before Lollipop MR1.
private class FakeIntentReceiverPreLMR1 implements ShareHelper.FakeIntentReceiver {
private final boolean mProceed;

FakeIntentReceiverPreLMR1(boolean proceed) {
mProceed = proceed;
}

@Override
public void setIntentToSendBack(Intent intent) {}

@Override
public void onCustomChooserShown(AlertDialog dialog) {
if (!mProceed) {
// Cancel the chooser dialog.
dialog.dismiss();
return;
}

// Click on an app (it doesn't matter which, because we will hook the intent).
Assert.assertTrue(dialog.getListView().getCount() > 0);
dialog.getListView().performItemClick(
null, 0, dialog.getListView().getItemIdAtPosition(0));
}

@Override
public void fireIntent(Context context, Intent intent) {
mReceivedIntent = intent;
}
}
}
6 changes: 0 additions & 6 deletions chrome/browser/about_flags.cc
Expand Up @@ -3266,18 +3266,12 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kChromeShareLongScreenshotName,
flag_descriptions::kChromeShareLongScreenshotDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kChromeShareLongScreenshot)},
{"chrome-share-qr-code", flag_descriptions::kChromeShareQRCodeName,
flag_descriptions::kChromeShareQRCodeDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kChromeShareQRCode)},
{"chrome-share-screenshot", flag_descriptions::kChromeShareScreenshotName,
flag_descriptions::kChromeShareScreenshotDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kChromeShareScreenshot)},
{"chrome-sharing-hub", flag_descriptions::kChromeSharingHubName,
flag_descriptions::kChromeSharingHubDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kChromeSharingHub)},
{"chrome-sharing-hub-v1-5", flag_descriptions::kChromeSharingHubV15Name,
flag_descriptions::kChromeSharingHubV15Description, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kChromeSharingHubV15)},
{"webnotes-stylize", flag_descriptions::kWebNotesStylizeName,
flag_descriptions::kWebNotesStylizeDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kWebNotesStylize)},
Expand Down

0 comments on commit 66f304f

Please sign in to comment.