0

Remove the legacy/fallback chrome-devtools: scheme from the codebase.

This CL stops rewriting chrome-devtools: scheme URLs into
devtools: scheme URLs, by tweaking
//components/url_formatter/url_fixer.cc.

This CL also stops special-casing chrome-devtools: scheme
in //components/policy/core/browser/url_util.cc.

The CL then also proceeds to remove all other mentions of the
chrome-devtools: scheme from the codebase.  This part of the
change was initially done with the following command:
    $ git grep -l 'chrome-devtools[^-]' | xargs -n 1 \
        sed -i -e 's/chrome-devtools/devtools/g'
and then manually reviewing and tweaking the edited files.

Bug: 1055524
Change-Id: Ie9d51332e4c28fd6201f4b5590bbba5c79fc09d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088335
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Sergey Poromov <poromov@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748242}
This commit is contained in:
Lukasz Anforowicz
2020-03-09 16:20:47 +00:00
committed by Commit Bot
parent 2c695fe87c
commit 6700d12448
14 changed files with 28 additions and 106 deletions
chrome
android
java
src
org
chromium
chrome
javatests
src
org
chromium
chrome
browser
components
embedder_support
android
java
src
org
chromium
components
embedder_support
omnibox
policy
url_formatter
docs/ui/ui_devtools
third_party/blink/renderer/core/layout

@ -437,7 +437,7 @@ public class ExternalNavigationHandler {
}
/**
* The "about:", "chrome:", "chrome-native:", "chrome-devtools:", and "devtools:" schemes
* The "about:", "chrome:", "chrome-native:", and "devtools:" schemes
* are internal to the browser; don't want these to be dispatched to other apps.
*/
private boolean hasInternalScheme(
@ -454,8 +454,7 @@ public class ExternalNavigationHandler {
if (url.startsWith(ContentUrlConstants.ABOUT_SCHEME)
|| url.startsWith(UrlConstants.CHROME_URL_SHORT_PREFIX)
|| url.startsWith(UrlConstants.CHROME_NATIVE_URL_SHORT_PREFIX)
|| url.startsWith(UrlConstants.DEVTOOLS_URL_SHORT_PREFIX)
|| url.startsWith(UrlConstants.DEVTOOLS_FALLBACK_URL_SHORT_PREFIX)) {
|| url.startsWith(UrlConstants.DEVTOOLS_URL_SHORT_PREFIX)) {
if (DEBUG) Log.i(TAG, "Navigating to a chrome-internal page");
return true;
}

@ -313,7 +313,6 @@ public class ExternalNavigationHandlerTest {
"chrome://history",
"chrome-native://newtab",
"devtools://foo",
"chrome-devtools://foo",
"intent:chrome-urls#Intent;package=com.android.chrome;scheme=about;end;",
"intent:chrome-urls#Intent;package=com.android.chrome;scheme=chrome;end;",
"intent://com.android.chrome.FileProvider/foo.html#Intent;scheme=content;end;",

@ -52,5 +52,12 @@ TEST_F(ChromeAutocompleteSchemeClassifierTest, BlockedScheme) {
metrics::OmniboxInputType::QUERY);
}
TEST_F(ChromeAutocompleteSchemeClassifierTest, DevToolsUrl) {
GURL url("devtools://foo");
// An internal scheme should also be recognized as a URL.
EXPECT_EQ(scheme_classifier_->GetInputTypeForScheme(url.scheme()),
metrics::OmniboxInputType::URL);
}
// Can't test registered apps handling with mocking of shell_integration
// because shell_integration is implemented via namespace shell_integration.

@ -2415,7 +2415,7 @@ class DevToolsPolicyTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(DevToolsPolicyTest, OpenBlackListedDevTools) {
base::ListValue blacklist;
blacklist.AppendString("chrome-devtools://*");
blacklist.AppendString("devtools://*");
policy::PolicyMap policies;
policies.Set(policy::key::kURLBlacklist, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,

@ -29,7 +29,6 @@ public class UrlConstants {
public static final String CHROME_NATIVE_URL_SHORT_PREFIX = "chrome-native:";
public static final String FILE_URL_SHORT_PREFIX = "file:";
public static final String DEVTOOLS_URL_SHORT_PREFIX = "devtools:";
public static final String DEVTOOLS_FALLBACK_URL_SHORT_PREFIX = "chrome-devtools:";
public static final String INTENT_URL_SHORT_PREFIX = "intent:";
public static final String APP_INTENT_URL_SHORT_PREFIX = "android-app:";

@ -26,7 +26,6 @@ namespace {
// Hardcode constant to avoid any dependencies on content/.
const char kViewSourceScheme[] = "view-source";
const char kDevToolsScheme[] = "devtools";
void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed,
size_t* cursor_position) {
@ -206,14 +205,6 @@ metrics::OmniboxInputType AutocompleteInput::Parse(
return metrics::OmniboxInputType::URL;
}
if (base::LowerCaseEqualsASCII(parsed_scheme_utf8, kDevToolsScheme)) {
// A user might type in the fallback url when using devtools. In
// this case, |parsed_scheme_utf8| will tell us that this is a devtools URL,
// but |parts->scheme| might be empty.e.g. if the user typed
// "chrome-devtools://".
return metrics::OmniboxInputType::URL;
}
// Treat javascript: scheme queries followed by things that are unlikely to
// be code as UNKNOWN, rather than script to execute (URL).
if (RE2::FullMatch(base::UTF16ToUTF8(text), "(?i)javascript:([^;=().\"]*)")) {

@ -178,8 +178,12 @@ TEST(AutocompleteInputTest, InputType) {
{ASCIIToUTF16("filesystem:http"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("filesystem:"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("chrome-search://"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("chrome-devtools:"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("chrome-devtools:"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16("chrome-devtools://"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16("chrome-devtools://x"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16("devtools:"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("devtools://"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("devtools://x"), metrics::OmniboxInputType::URL},
{ASCIIToUTF16("about://f;"), metrics::OmniboxInputType::QUERY},
{ASCIIToUTF16("://w"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16(":w"), metrics::OmniboxInputType::UNKNOWN},
@ -199,6 +203,7 @@ TEST(AutocompleteInputTest, InputType) {
{ASCIIToUTF16("example."), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16(".example"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16(".example."), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16("example:"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16("example:80/ "), metrics::OmniboxInputType::URL},
{ASCIIToUTF16("http://foo.invalid"), metrics::OmniboxInputType::UNKNOWN},
{ASCIIToUTF16("foo.invalid/"), metrics::OmniboxInputType::QUERY},
@ -369,24 +374,3 @@ TEST(AutocompleteInputTest, InputTypeWithCursorPosition) {
input.cursor_position());
}
}
TEST(AutocompleteInputTest, InputParsedToFallback) {
struct test_data {
const base::string16 input;
const std::string parsed_input;
} input_cases[] = {
{ASCIIToUTF16("devtools://bundled/devtools/inspector.html"),
std::string("devtools://bundled/devtools/inspector.html")},
{ASCIIToUTF16("chrome-devtools://bundled/devtools/inspector.html"),
std::string("devtools://bundled/devtools/inspector.html")},
};
for (size_t i = 0; i < base::size(input_cases); ++i) {
SCOPED_TRACE(input_cases[i].input);
AutocompleteInput input(input_cases[i].input,
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
input.set_prevent_inline_autocomplete(true);
EXPECT_EQ(input_cases[i].parsed_input, input.canonicalized_url().spec());
}
}

@ -26,7 +26,7 @@ metrics::OmniboxInputType TestSchemeClassifier::GetInputTypeForScheme(
url::kWssScheme, url::kFileScheme, url::kAboutScheme,
url::kFtpScheme, url::kBlobScheme, url::kFileSystemScheme,
"view-source", "javascript", "chrome",
"chrome-ui",
"chrome-ui", "devtools",
};
for (const char* known_scheme : kKnownURLSchemes) {
if (scheme == known_scheme)

@ -288,16 +288,7 @@ TEST_F(URLBlacklistManagerTest, Filtering) {
blacklist.Allow(allowed.get());
EXPECT_FALSE(blacklist.IsURLBlocked(GURL("http://example.com")));
// Treats chrome-devtools and devtools schemes the same way.
blocked.reset(new base::ListValue);
blocked->AppendString("*");
blacklist.Block(blocked.get());
allowed.reset(new base::ListValue);
allowed->AppendString("chrome-devtools://*");
blacklist.Allow(allowed.get());
EXPECT_FALSE(blacklist.IsURLBlocked(GURL("devtools://something.com")));
EXPECT_TRUE(blacklist.IsURLBlocked(GURL("https://something.com")));
// Devtools should not be blocked.
blocked.reset(new base::ListValue);
blocked->AppendString("*");
blacklist.Block(blocked.get());

@ -51,9 +51,6 @@ const char kGoogleWebCacheQueryPattern[] =
const char kGoogleTranslateSubdomain[] = "translate.";
const char kAlternateGoogleTranslateHost[] = "translate.googleusercontent.com";
const char kDevToolsLegacyScheme[] = "chrome-devtools";
const char kDevToolsScheme[] = "devtools";
// Maximum filters per policy. Filters over this index are ignored.
const size_t kMaxFiltersPerPolicy = 1000;
@ -299,16 +296,6 @@ bool FilterToComponents(const std::string& filter,
std::string lc_filter = base::ToLowerASCII(filter);
const std::string url_scheme = url_formatter::SegmentURL(filter, &parsed);
// This is for backward compatibility between 'chrome-devtools' and 'devtools'
// schemes. url_formatter::SegmentURL will return 'devtools' if the filter's
// scheme is the deprecated 'chrome-devtools'. To comply with that
// transformation, since both schemes are equivalent, if the filter's scheme
// was 'chrome-devtools', it should be replaced by 'devtools'.
if (url_scheme == kDevToolsScheme &&
lc_filter.find(kDevToolsLegacyScheme) == 0) {
lc_filter.replace(0, 15, kDevToolsScheme);
}
// Check if it's a scheme wildcard pattern. We support both versions
// (scheme:* and scheme://*) the later being consistent with old filter
// definitions.

@ -37,7 +37,6 @@ namespace {
// Hardcode these constants to avoid dependences on //chrome and //content.
const char kChromeUIScheme[] = "chrome";
const char kDevToolsScheme[] = "devtools";
const char kDevToolsFallbackScheme[] = "chrome-devtools";
const char kChromeUIDefaultHost[] = "version";
const char kViewSourceScheme[] = "view-source";
@ -461,7 +460,7 @@ std::string SegmentURLInternal(std::string* text, url::Parsed* parts) {
// Proceed with about, chrome, and devtools schemes,
// but not file or nonstandard schemes.
if ((scheme != url::kAboutScheme) && (scheme != kChromeUIScheme) &&
(scheme != kDevToolsScheme) && (scheme != kDevToolsFallbackScheme) &&
(scheme != kDevToolsScheme) &&
!url::IsStandard(scheme.c_str(),
url::Component(0, static_cast<int>(scheme.length())))) {
return scheme;
@ -479,14 +478,6 @@ std::string SegmentURLInternal(std::string* text, url::Parsed* parts) {
return scheme;
}
if (scheme == kDevToolsFallbackScheme) {
// Have the GURL parser do the heavy lifting for us.
url::ParseStandardURL(text->data(), text_length, parts);
// Now replace the fallback scheme alias with the real one
parts->scheme.reset();
return kDevToolsScheme;
}
if (parts->scheme.is_valid()) {
// Have the GURL parser do the heavy lifting for us.
url::ParseStandardURL(text->data(), text_length, parts);
@ -585,22 +576,15 @@ GURL FixupURL(const std::string& text, const std::string& desired_tld) {
return about_url;
}
// Parse and rebuild about: and chrome: URLs.
// For some schemes whose layouts we understand, we rebuild the URL.
bool chrome_url =
(scheme == url::kAboutScheme) || (scheme == kChromeUIScheme);
// Parse and rebuild devtools: and the fallback chrome-devtools: URLs.
bool devtools_url =
(scheme == kDevToolsScheme) || (scheme == kDevToolsFallbackScheme);
// For some schemes whose layouts we understand, we rebuild it.
bool devtools_url = (scheme == kDevToolsScheme);
if (chrome_url || devtools_url ||
url::IsStandard(scheme.c_str(),
url::Component(0, static_cast<int>(scheme.length())))) {
// Replace the about: scheme with the chrome: scheme, or
// chrome-devtoools: scheme with the devtools: scheme.
std::string url(chrome_url ? kChromeUIScheme
: devtools_url ? kDevToolsScheme : scheme);
// Replace the about: scheme with the chrome: scheme.
std::string url(scheme == url::kAboutScheme ? kChromeUIScheme : scheme);
url.append(url::kStandardSchemeSeparator);
// We need to check whether the |username| is valid because it is our
@ -716,9 +700,7 @@ bool IsEquivalentScheme(const std::string& scheme1,
const std::string& scheme2) {
return scheme1 == scheme2 ||
(scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) ||
(scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme) ||
(scheme1 == kDevToolsScheme && scheme2 == kDevToolsFallbackScheme) ||
(scheme1 == kDevToolsFallbackScheme && scheme2 == kDevToolsScheme);
(scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme);
}
} // namespace url_formatter

@ -260,18 +260,6 @@ static const SegmentCase segment_cases[] = {
url::Component(43, 17), // query
url::Component(), // ref
},
{
"chrome-devtools://bundled/devtools/inspector.html?ws=localhost:9221",
"devtools",
url::Component(), // scheme
url::Component(), // username
url::Component(), // password
url::Component(18, 7), // host
url::Component(), // port
url::Component(25, 24), // path
url::Component(50, 17), // query
url::Component(), // ref
},
};
typedef testing::Test URLFixerTest;
@ -282,6 +270,8 @@ TEST(URLFixerTest, SegmentURL) {
for (size_t i = 0; i < base::size(segment_cases); ++i) {
SegmentCase value = segment_cases[i];
SCOPED_TRACE(testing::Message() << "test #" << i << ": " << value.input);
result = url_formatter::SegmentURL(value.input, &parts);
EXPECT_EQ(value.result, result);
EXPECT_EQ(value.scheme, parts.scheme);
@ -395,16 +385,9 @@ struct FixupCase {
// Devtools scheme.
{"devtools://bundled/devtools/node.html",
"devtools://bundled/devtools/node.html"},
// Devtools fallback scheme.
{"chrome-devtools://bundled/devtools/toolbox.html",
"devtools://bundled/devtools/toolbox.html"},
// Devtools scheme with websocket query.
{"devtools://bundled/devtools/inspector.html?ws=ws://localhost:9222/guid",
"devtools://bundled/devtools/inspector.html?ws=ws://localhost:9222/guid"},
// Devtools fallback scheme with websocket query.
{"chrome-devtools://bundled/devtools/inspector.html?ws=ws://localhost:9222/"
"guid",
"devtools://bundled/devtools/inspector.html?ws=ws://localhost:9222/guid"},
// host:123 should be rewritten to http://host:123/, but only if the port
// number is valid - in particular telephone numbers are not port numbers
// (see also SendTabToSelfUtilTest.ShouldNotOfferFeatureForTelephoneLink).

@ -15,7 +15,7 @@ currently supported on Linux, Windows, Mac, and ChromeOS.
* If you want to use different port, add port in the flag `--enable-ui-devtools=<port>`.
2. In the Chrome Omnibox, go to chrome://inspect#other and click `inspect` under UIDevToolsClient.
* Direct link is chrome-devtools://devtools/bundled/inspector.html?ws=localhost:9223/0.
* Direct link is devtools://devtools/bundled/inspector.html?ws=localhost:9223/0.
## How to Use

@ -105,7 +105,7 @@ void RegionToTracedValue(const LayoutShiftRegion& region, TracedValue& value) {
#if DCHECK_IS_ON()
bool ShouldLog(const LocalFrame& frame) {
const String& url = frame.GetDocument()->Url().GetString();
return !url.StartsWith("chrome-devtools:") && !url.StartsWith("devtools:");
return !url.StartsWith("devtools:");
}
#endif