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

Side by Side Diff: chrome/common/net/url_fixer_upper.cc

Issue 273193004: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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 "chrome/common/net/url_fixer_upper.h" 5 #include "chrome/common/net/url_fixer_upper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 (*text)[semicolon] = ':'; 417 (*text)[semicolon] = ':';
418 if (GetValidScheme(*text, &parts->scheme, &scheme)) 418 if (GetValidScheme(*text, &parts->scheme, &scheme))
419 found_scheme = true; 419 found_scheme = true;
420 else 420 else
421 (*text)[semicolon] = ';'; 421 (*text)[semicolon] = ';';
422 } 422 }
423 if (!found_scheme) { 423 if (!found_scheme) {
424 // Couldn't determine the scheme, so just pick one. 424 // Couldn't determine the scheme, so just pick one.
425 parts->scheme.reset(); 425 parts->scheme.reset();
426 scheme = StartsWithASCII(*text, "ftp.", false) ? 426 scheme = StartsWithASCII(*text, "ftp.", false) ?
427 content::kFtpScheme : url::kHttpScheme; 427 url::kFtpScheme : url::kHttpScheme;
428 } 428 }
429 } 429 }
430 430
431 // Proceed with about and chrome schemes, but not file or nonstandard schemes. 431 // Proceed with about and chrome schemes, but not file or nonstandard schemes.
432 if ((scheme != content::kAboutScheme) && 432 if ((scheme != content::kAboutScheme) &&
433 (scheme != content::kChromeUIScheme) && 433 (scheme != content::kChromeUIScheme) &&
434 ((scheme == content::kFileScheme) || 434 ((scheme == url::kFileScheme) ||
435 !url::IsStandard(scheme.c_str(), 435 !url::IsStandard(scheme.c_str(),
436 url::Component(0, 436 url::Component(0,
437 static_cast<int>(scheme.length()))))) { 437 static_cast<int>(scheme.length()))))) {
438 return scheme; 438 return scheme;
439 } 439 }
440 440
441 if (scheme == content::kFileSystemScheme) { 441 if (scheme == url::kFileSystemScheme) {
442 // Have the GURL parser do the heavy lifting for us. 442 // Have the GURL parser do the heavy lifting for us.
443 url::ParseFileSystemURL(text->data(), static_cast<int>(text->length()), 443 url::ParseFileSystemURL(text->data(), static_cast<int>(text->length()),
444 parts); 444 parts);
445 return scheme; 445 return scheme;
446 } 446 }
447 447
448 if (parts->scheme.is_valid()) { 448 if (parts->scheme.is_valid()) {
449 // Have the GURL parser do the heavy lifting for us. 449 // Have the GURL parser do the heavy lifting for us.
450 url::ParseStandardURL(text->data(), static_cast<int>(text->length()), 450 url::ParseStandardURL(text->data(), static_cast<int>(text->length()),
451 parts); 451 parts);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // Reject "view-source:view-source:..." to avoid deep recursion. 517 // Reject "view-source:view-source:..." to avoid deep recursion.
518 std::string view_source(content::kViewSourceScheme + std::string(":")); 518 std::string view_source(content::kViewSourceScheme + std::string(":"));
519 if (!StartsWithASCII(text, view_source + view_source, false)) { 519 if (!StartsWithASCII(text, view_source + view_source, false)) {
520 return GURL(content::kViewSourceScheme + std::string(":") + 520 return GURL(content::kViewSourceScheme + std::string(":") +
521 FixupURL(trimmed.substr(scheme.length() + 1), 521 FixupURL(trimmed.substr(scheme.length() + 1),
522 desired_tld).possibly_invalid_spec()); 522 desired_tld).possibly_invalid_spec());
523 } 523 }
524 } 524 }
525 525
526 // We handle the file scheme separately. 526 // We handle the file scheme separately.
527 if (scheme == content::kFileScheme) 527 if (scheme == url::kFileScheme)
528 return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); 528 return GURL(parts.scheme.is_valid() ? text : FixupPath(text));
529 529
530 // We handle the filesystem scheme separately. 530 // We handle the filesystem scheme separately.
531 if (scheme == content::kFileSystemScheme) { 531 if (scheme == url::kFileSystemScheme) {
532 if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) 532 if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid())
533 return GURL(text); 533 return GURL(text);
534 return GURL(); 534 return GURL();
535 } 535 }
536 536
537 // Parse and rebuild about: and chrome: URLs, except about:blank. 537 // Parse and rebuild about: and chrome: URLs, except about:blank.
538 bool chrome_url = !LowerCaseEqualsASCII(trimmed, content::kAboutBlankURL) && 538 bool chrome_url = !LowerCaseEqualsASCII(trimmed, content::kAboutBlankURL) &&
539 ((scheme == content::kAboutScheme) || 539 ((scheme == content::kAboutScheme) ||
540 (scheme == content::kChromeUIScheme)); 540 (scheme == content::kChromeUIScheme));
541 541
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 646
647 if (part->is_valid()) { 647 if (part->is_valid()) {
648 // Offset the location of this component. 648 // Offset the location of this component.
649 part->begin += offset; 649 part->begin += offset;
650 650
651 // This part might not have existed in the original text. 651 // This part might not have existed in the original text.
652 if (part->begin < 0) 652 if (part->begin < 0)
653 part->reset(); 653 part->reset();
654 } 654 }
655 } 655 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698