Commit ce9fcbf6 authored by Fei Ling's avatar Fei Ling Committed by Commit Bot

Fix DCHECK() failure when invoking Translate on about:blank page.

"about:blank" should not be a translatable URL.

Bug: 960369
Change-Id: Ife979fd641a793d8e4442309c436c6c0dd07c876
Fixed: 960369
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946870Reviewed-by: default avatarJohn Wu <jzw@chromium.org>
Commit-Queue: Fei Ling <feiling@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721188}
parent 075c43d9
...@@ -133,11 +133,12 @@ bool TranslateService::IsTranslatableURL(const GURL& url) { ...@@ -133,11 +133,12 @@ bool TranslateService::IsTranslatableURL(const GURL& url) {
// - empty (can happen for popups created with window.open("")) // - empty (can happen for popups created with window.open(""))
// - an internal URL (chrome:// and others) // - an internal URL (chrome:// and others)
// - the devtools (which is considered UI) // - the devtools (which is considered UI)
// - about:blank
// - Chrome OS file manager extension // - Chrome OS file manager extension
// - an FTP page (as FTP pages tend to have long lists of filenames that may // - an FTP page (as FTP pages tend to have long lists of filenames that may
// confuse the CLD) // confuse the CLD)
return !url.is_empty() && !url.SchemeIs(content::kChromeUIScheme) && return !url.is_empty() && !url.SchemeIs(content::kChromeUIScheme) &&
!url.SchemeIs(content::kChromeDevToolsScheme) && !url.SchemeIs(content::kChromeDevToolsScheme) && !url.IsAboutBlank() &&
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
!(url.SchemeIs(extensions::kExtensionScheme) && !(url.SchemeIs(extensions::kExtensionScheme) &&
url.DomainIs(file_manager::kFileManagerAppId)) && url.DomainIs(file_manager::kFileManagerAppId)) &&
......
...@@ -24,6 +24,9 @@ TEST(TranslateServiceTest, CheckTranslatableURL) { ...@@ -24,6 +24,9 @@ TEST(TranslateServiceTest, CheckTranslatableURL) {
GURL empty_url = GURL(std::string()); GURL empty_url = GURL(std::string());
EXPECT_FALSE(TranslateService::IsTranslatableURL(empty_url)); EXPECT_FALSE(TranslateService::IsTranslatableURL(empty_url));
GURL about_blank_url = GURL("about:blank");
EXPECT_FALSE(TranslateService::IsTranslatableURL(about_blank_url));
std::string chrome = std::string(content::kChromeUIScheme) + "://flags"; std::string chrome = std::string(content::kChromeUIScheme) + "://flags";
GURL chrome_url = GURL(chrome); GURL chrome_url = GURL(chrome);
EXPECT_FALSE(TranslateService::IsTranslatableURL(chrome_url)); EXPECT_FALSE(TranslateService::IsTranslatableURL(chrome_url));
......
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