Skip to content

Commit

Permalink
[Android]: Webshare: Adjust URL formatting in header.
Browse files Browse the repository at this point in the history
Use formatUrlForSecurityDisplay() in share dialog.
Fix tests to use same URL formatting method as share dialog code, and
change test input URL to a URL with path, query, and hash components
to ensure these are handled properly (i.e. removed).

(cherry picked from commit 0e8f231)

Bug: 1367085
Change-Id: Ib04d3d8d16588d810c2ea916d218e7e058cf5a56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4670811
Reviewed-by: Wenyu Fu <wenyufu@chromium.org>
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: Sophey Dong <sophey@chromium.org>
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1168335}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4679174
Auto-Submit: Finnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Wenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/branch-heads/5845@{#447}
Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
  • Loading branch information
Alesandro Ortiz authored and Chromium LUCI CQ committed Jul 12, 2023
1 parent d2acf1c commit fcae350
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.chromium.components.feature_engagement.EventConstants;
import org.chromium.components.feature_engagement.FeatureConstants;
import org.chromium.components.feature_engagement.Tracker;
import org.chromium.components.url_formatter.SchemeDisplay;
import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.ui.base.ViewUtils;
import org.chromium.ui.modelutil.LayoutViewBuilder;
Expand Down Expand Up @@ -245,8 +246,8 @@ private void createPreview(Set<Integer> contentTypes, String fileContentType,
ShareSheetLinkToggleCoordinator shareSheetLinkToggleCoordinator) {
// Default preview is to show title + url.
String title = mParams.getTitle();
String subtitle =
UrlFormatter.formatUrlForDisplayOmitSchemeOmitTrivialSubdomains(mParams.getUrl());
String subtitle = UrlFormatter.formatUrlForSecurityDisplay(
mParams.getUrl(), SchemeDisplay.OMIT_HTTP_AND_HTTPS);

if (contentTypes.contains(ContentType.IMAGE)
|| contentTypes.contains(ContentType.IMAGE_AND_LINK)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.chromium.components.favicon.LargeIconBridge;
import org.chromium.components.feature_engagement.FeatureConstants;
import org.chromium.components.feature_engagement.Tracker;
import org.chromium.components.url_formatter.SchemeDisplay;
import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.test.NativeLibraryTestUtils;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
Expand Down Expand Up @@ -85,7 +86,7 @@ public final class ShareSheetBottomSheetContentTest {
private static final Uri sImageUri = Uri.parse("content://testImage.png");
private static final String sText = "Text";
private static final String sTitle = "Title";
private static final String sUrl = "https://www.example.com";
private static final String sUrl = "https://www.example.com/path?query#hash";
private String mPreviewUrl;

private Activity mActivity;
Expand All @@ -99,7 +100,8 @@ public void setUp() {
mActivityTestRule.launchActivity(null);
mActivity = mActivityTestRule.getActivity();

mPreviewUrl = UrlFormatter.formatUrlForDisplayOmitSchemeOmitTrivialSubdomains(sUrl);
mPreviewUrl = UrlFormatter.formatUrlForSecurityDisplay(
sUrl, SchemeDisplay.OMIT_HTTP_AND_HTTPS);
mShareParams = new ShareParams.Builder(/*window=*/null, sTitle, sUrl)
.setText(sText)
.setSingleImageUri(sImageUri)
Expand Down

0 comments on commit fcae350

Please sign in to comment.