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

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: Address comments and add extra crash URL checks. Created 9 years, 7 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
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..370de2bdff7f10ae78cedb952481aee25289ffc0 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -407,9 +407,9 @@ std::string URLFixerUpper::SegmentURL(const std::string& text,
}
// 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()))))
+ 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());
@@ -482,7 +482,7 @@ GURL URLFixerUpper::FixupURL(const std::string& text,
if (url_util::IsStandard(scheme.c_str(),
url_parse::Component(0, static_cast<int>(scheme.length())))) {
std::string url(scheme);
- url.append("://");
+ 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
@@ -505,13 +505,43 @@ 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);
}
return GURL(trimmed);
}
+GURL URLFixerUpper::FixupChromeURL(const GURL& url) {
+ DCHECK(url.SchemeIs(chrome::kAboutScheme) ||
+ url.SchemeIs(chrome::kChromeUIScheme));
+
+ // Segment the URL.
+ url_parse::Parsed parts;
+ SegmentURL(url.spec(), &parts);
+ std::string new_url(chrome::kChromeUIScheme);
+ new_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
+ // the host portion of the URL.
+ if (parts.username.is_valid()) {
+ FixupUsername(url.spec(), parts.username, &new_url);
+ FixupPassword(url.spec(), parts.password, &new_url);
+ new_url.append("@");
+ }
+
+ if (parts.host.is_valid())
+ FixupHost(url.spec(), parts.host, true, std::string(), &new_url);
+ else
+ new_url.append(chrome::kChromeUIVersionHost);
+ FixupPort(url.spec(), parts.port, &new_url);
+ FixupPath(url.spec(), parts.path, &new_url);
+ FixupQuery(url.spec(), parts.query, &new_url);
+ FixupRef(url.spec(), parts.ref, &new_url);
+ return GURL(new_url);
+}
+
// The rules are different here than for regular fixup, since we need to handle
// input like "hello.html" and know to look in the current directory. Regular
// fixup will look for cues that it is actually a file path before trying to

Powered by Google App Engine
This is Rietveld 408576698