Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6454)

Unified Diff: chrome/browser/net/url_fixer_upper.cc

Issue 7068007: Revise about: and chrome: url handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update special_tabs.py from Nirnimesh's codereview.chromium.org/6995057/. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/url_fixer_upper.h ('k') | chrome/browser/net/url_fixer_upper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/url_fixer_upper.cc
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index 10d930b0fa6c2aeb71860d435f874d0b544d4326..37125d02cd4176fa394c8ef3e03da2f2e9b58964 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -406,10 +406,10 @@ std::string URLFixerUpper::SegmentURL(const std::string& text,
chrome::kFtpScheme : chrome::kHttpScheme);
}
- // Not segmenting file schemes or nonstandard schemes.
- if ((scheme == chrome::kFileScheme) ||
- !url_util::IsStandard(scheme.c_str(),
- url_parse::Component(0, static_cast<int>(scheme.length()))))
+ // Proceed with about and chrome schemes, but not file or nonstandard schemes.
+ if ((scheme != chrome::kAboutScheme) && (scheme != chrome::kChromeUIScheme) &&
+ ((scheme == chrome::kFileScheme) || !url_util::IsStandard(scheme.c_str(),
+ url_parse::Component(0, static_cast<int>(scheme.length())))))
return scheme;
if (parts->scheme.is_valid()) {
@@ -427,7 +427,7 @@ std::string URLFixerUpper::SegmentURL(const std::string& text,
// Construct the text to parse by inserting the scheme.
std::string inserted_text(scheme);
- inserted_text.append("://");
+ inserted_text.append(chrome::kStandardSchemeSeparator);
std::string text_to_parse(text.begin(), first_nonwhite);
text_to_parse.append(inserted_text);
text_to_parse.append(first_nonwhite, text.end());
@@ -478,11 +478,16 @@ GURL URLFixerUpper::FixupURL(const std::string& text,
if (scheme == chrome::kFileScheme)
return GURL(parts.scheme.is_valid() ? text : FixupPath(text));
+ // Parse and rebuild about: and chrome: URLs, except about:blank.
+ bool chrome_url = !LowerCaseEqualsASCII(trimmed, chrome::kAboutBlankURL) &&
+ ((scheme == chrome::kAboutScheme) || (scheme == chrome::kChromeUIScheme));
+
// For some schemes whose layouts we understand, we rebuild it.
- if (url_util::IsStandard(scheme.c_str(),
+ if (chrome_url || url_util::IsStandard(scheme.c_str(),
url_parse::Component(0, static_cast<int>(scheme.length())))) {
- std::string url(scheme);
- url.append("://");
+ // Replace the about: scheme with the chrome: scheme.
+ std::string url(chrome_url ? chrome::kChromeUIScheme : scheme);
+ url.append(chrome::kStandardSchemeSeparator);
// We need to check whether the |username| is valid because it is our
// responsibility to append the '@' to delineate the user information from
@@ -494,6 +499,8 @@ GURL URLFixerUpper::FixupURL(const std::string& text,
}
FixupHost(trimmed, parts.host, parts.scheme.is_valid(), desired_tld, &url);
+ if (chrome_url && !parts.host.is_valid())
+ url.append(chrome::kChromeUIDefaultHost);
FixupPort(trimmed, parts.port, &url);
FixupPath(trimmed, parts.path, &url);
FixupQuery(trimmed, parts.query, &url);
@@ -505,7 +512,7 @@ GURL URLFixerUpper::FixupURL(const std::string& text,
// In the worst-case, we insert a scheme if the URL lacks one.
if (!parts.scheme.is_valid()) {
std::string fixed_scheme(scheme);
- fixed_scheme.append("://");
+ fixed_scheme.append(chrome::kStandardSchemeSeparator);
trimmed.insert(0, fixed_scheme);
}
« no previous file with comments | « chrome/browser/net/url_fixer_upper.h ('k') | chrome/browser/net/url_fixer_upper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698