Commit 3e9e98cf authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS] Adjust display URL formatting on iOS.

Makes blob: URLs just show the domain name, like all other URLs, and
formats by clipping the head.

Bug: 1080395
Change-Id: If9bf4921044dfd94bcd8cb79c53083ac49266f5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310430
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791841}
parent b2ff43e3
......@@ -30,6 +30,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/text_elider.h"
#include "ui/gfx/vector_icon_types.h"
#include "url/origin.h"
#if (!defined(OS_ANDROID) || BUILDFLAG(ENABLE_VR)) && !defined(OS_IOS)
#include "components/omnibox/browser/vector_icons.h" // nogncheck
......@@ -105,6 +106,16 @@ base::string16 LocationBarModelImpl::GetFormattedURL(
}
GURL url(GetURL());
#if defined(OS_IOS)
// On iOS, the blob: display URLs should be simply the domain name. However,
// url_formatter parses everything past blob: as path, not domain, so swap
// the url here to be just origin.
if (url.SchemeIsBlob()) {
url = url::Origin::Create(url).GetURL();
}
#endif // defined(OS_IOS)
// Special handling for dom-distiller:. Instead of showing internal reader
// mode URLs, show the original article URL in the omnibox.
// Note that this does not disallow the user from seeing the distilled page
......
......@@ -334,4 +334,16 @@ TEST_F(LocationBarModelImplTest, GetVectorIcon_DangerWarning) {
}
#endif // !defined(OS_IOS)
#if defined(OS_IOS)
// Test that blob:http://example.test/foobar is displayed as "example.test" on
// iOS.
TEST_F(LocationBarModelImplTest, BlobDisplayURLIOS) {
delegate()->SetURL(GURL("blob:http://example.test/foo"));
EXPECT_EQ(base::ASCIIToUTF16("example.test/TestSuffix"),
model()->GetURLForDisplay());
}
#endif // defined(OS_IOS)
} // namespace
......@@ -295,13 +295,13 @@
return base::SysUTF16ToNSString(string);
}
// Some URLs (data://) should have their tail clipped when presented; while for
// Data URLs (data://) should have their tail clipped when presented; while for
// others (http://) it would be more appropriate to clip the head.
- (BOOL)locationShouldClipTail {
if (self.webContentAreaShowingHTTPAuthDialog)
return YES;
GURL url = self.locationBarModel->GetURL();
return url.SchemeIs(url::kDataScheme) || url.SchemeIs(url::kBlobScheme);
return url.SchemeIs(url::kDataScheme);
}
#pragma mark Security status icon helpers
......
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