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

Side by Side Diff: components/url_fixer/url_fixer.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/url_fixer/url_fixer.h" 5 #include "components/url_fixer/url_fixer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 if (semicolon != 0 && semicolon != std::string::npos) { 429 if (semicolon != 0 && semicolon != std::string::npos) {
430 (*text)[semicolon] = ':'; 430 (*text)[semicolon] = ':';
431 if (GetValidScheme(*text, &parts->scheme, &scheme)) 431 if (GetValidScheme(*text, &parts->scheme, &scheme))
432 found_scheme = true; 432 found_scheme = true;
433 else 433 else
434 (*text)[semicolon] = ';'; 434 (*text)[semicolon] = ';';
435 } 435 }
436 if (!found_scheme) { 436 if (!found_scheme) {
437 // Couldn't determine the scheme, so just pick one. 437 // Couldn't determine the scheme, so just pick one.
438 parts->scheme.reset(); 438 parts->scheme.reset();
439 scheme = StartsWithASCII(*text, "ftp.", false) ? url::kFtpScheme 439 scheme = base::StartsWithASCII(*text, "ftp.", false) ? url::kFtpScheme
440 : url::kHttpScheme; 440 : url::kHttpScheme;
441 } 441 }
442 } 442 }
443 443
444 // Proceed with about and chrome schemes, but not file or nonstandard schemes. 444 // Proceed with about and chrome schemes, but not file or nonstandard schemes.
445 if ((scheme != url::kAboutScheme) && (scheme != kChromeUIScheme) && 445 if ((scheme != url::kAboutScheme) && (scheme != kChromeUIScheme) &&
446 ((scheme == url::kFileScheme) || 446 ((scheme == url::kFileScheme) ||
447 !url::IsStandard( 447 !url::IsStandard(
448 scheme.c_str(), 448 scheme.c_str(),
449 url::Component(0, static_cast<int>(scheme.length()))))) { 449 url::Component(0, static_cast<int>(scheme.length()))))) {
450 return scheme; 450 return scheme;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 // Segment the URL. 521 // Segment the URL.
522 url::Parsed parts; 522 url::Parsed parts;
523 std::string scheme(SegmentURLInternal(&trimmed, &parts)); 523 std::string scheme(SegmentURLInternal(&trimmed, &parts));
524 524
525 // For view-source: URLs, we strip "view-source:", do fixup, and stick it back 525 // For view-source: URLs, we strip "view-source:", do fixup, and stick it back
526 // on. This allows us to handle things like "view-source:google.com". 526 // on. This allows us to handle things like "view-source:google.com".
527 if (scheme == kViewSourceScheme) { 527 if (scheme == kViewSourceScheme) {
528 // Reject "view-source:view-source:..." to avoid deep recursion. 528 // Reject "view-source:view-source:..." to avoid deep recursion.
529 std::string view_source(kViewSourceScheme + std::string(":")); 529 std::string view_source(kViewSourceScheme + std::string(":"));
530 if (!StartsWithASCII(text, view_source + view_source, false)) { 530 if (!base::StartsWithASCII(text, view_source + view_source, false)) {
531 return GURL(kViewSourceScheme + std::string(":") + 531 return GURL(kViewSourceScheme + std::string(":") +
532 FixupURL(trimmed.substr(scheme.length() + 1), desired_tld) 532 FixupURL(trimmed.substr(scheme.length() + 1), desired_tld)
533 .possibly_invalid_spec()); 533 .possibly_invalid_spec());
534 } 534 }
535 } 535 }
536 536
537 // We handle the file scheme separately. 537 // We handle the file scheme separately.
538 if (scheme == url::kFileScheme) 538 if (scheme == url::kFileScheme)
539 return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); 539 return GURL(parts.scheme.is_valid() ? text : FixupPath(text));
540 540
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 part->reset(); 669 part->reset();
670 } 670 }
671 } 671 }
672 672
673 bool url_fixer::IsEquivalentScheme(const std::string& scheme1, 673 bool url_fixer::IsEquivalentScheme(const std::string& scheme1,
674 const std::string& scheme2) { 674 const std::string& scheme2) {
675 return scheme1 == scheme2 || 675 return scheme1 == scheme2 ||
676 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || 676 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) ||
677 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); 677 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme);
678 } 678 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698