OLD | NEW |
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 content::kFtpScheme : content::kHttpScheme); | 423 content::kFtpScheme : content::kHttpScheme); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 // Proceed with about and chrome schemes, but not file or nonstandard schemes. | 427 // Proceed with about and chrome schemes, but not file or nonstandard schemes. |
428 if ((scheme != chrome::kAboutScheme) && (scheme != chrome::kChromeUIScheme) && | 428 if ((scheme != chrome::kAboutScheme) && (scheme != chrome::kChromeUIScheme) && |
429 ((scheme == chrome::kFileScheme) || !url_util::IsStandard(scheme.c_str(), | 429 ((scheme == chrome::kFileScheme) || !url_util::IsStandard(scheme.c_str(), |
430 url_parse::Component(0, static_cast<int>(scheme.length()))))) | 430 url_parse::Component(0, static_cast<int>(scheme.length()))))) |
431 return scheme; | 431 return scheme; |
432 | 432 |
433 if (scheme == chrome::kFileSystemScheme) { | 433 if (scheme == content::kFileSystemScheme) { |
434 // Have the GURL parser do the heavy lifting for us. | 434 // Have the GURL parser do the heavy lifting for us. |
435 url_parse::ParseFileSystemURL(text->data(), | 435 url_parse::ParseFileSystemURL(text->data(), |
436 static_cast<int>(text->length()), parts); | 436 static_cast<int>(text->length()), parts); |
437 return scheme; | 437 return scheme; |
438 } | 438 } |
439 | 439 |
440 if (parts->scheme.is_valid()) { | 440 if (parts->scheme.is_valid()) { |
441 // Have the GURL parser do the heavy lifting for us. | 441 // Have the GURL parser do the heavy lifting for us. |
442 url_parse::ParseStandardURL(text->data(), static_cast<int>(text->length()), | 442 url_parse::ParseStandardURL(text->data(), static_cast<int>(text->length()), |
443 parts); | 443 parts); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 FixupURL(trimmed.substr(scheme.length() + 1), | 514 FixupURL(trimmed.substr(scheme.length() + 1), |
515 desired_tld).possibly_invalid_spec()); | 515 desired_tld).possibly_invalid_spec()); |
516 } | 516 } |
517 } | 517 } |
518 | 518 |
519 // We handle the file scheme separately. | 519 // We handle the file scheme separately. |
520 if (scheme == chrome::kFileScheme) | 520 if (scheme == chrome::kFileScheme) |
521 return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); | 521 return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); |
522 | 522 |
523 // We handle the filesystem scheme separately. | 523 // We handle the filesystem scheme separately. |
524 if (scheme == chrome::kFileSystemScheme) { | 524 if (scheme == content::kFileSystemScheme) { |
525 if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) | 525 if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) |
526 return GURL(text); | 526 return GURL(text); |
527 return GURL(); | 527 return GURL(); |
528 } | 528 } |
529 | 529 |
530 // Parse and rebuild about: and chrome: URLs, except about:blank. | 530 // Parse and rebuild about: and chrome: URLs, except about:blank. |
531 bool chrome_url = !LowerCaseEqualsASCII(trimmed, content::kAboutBlankURL) && | 531 bool chrome_url = !LowerCaseEqualsASCII(trimmed, content::kAboutBlankURL) && |
532 ((scheme == chrome::kAboutScheme) || (scheme == chrome::kChromeUIScheme)); | 532 ((scheme == chrome::kAboutScheme) || (scheme == chrome::kChromeUIScheme)); |
533 | 533 |
534 // For some schemes whose layouts we understand, we rebuild it. | 534 // For some schemes whose layouts we understand, we rebuild it. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 | 637 |
638 if (part->is_valid()) { | 638 if (part->is_valid()) { |
639 // Offset the location of this component. | 639 // Offset the location of this component. |
640 part->begin += offset; | 640 part->begin += offset; |
641 | 641 |
642 // This part might not have existed in the original text. | 642 // This part might not have existed in the original text. |
643 if (part->begin < 0) | 643 if (part->begin < 0) |
644 part->reset(); | 644 part->reset(); |
645 } | 645 } |
646 } | 646 } |
OLD | NEW |