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/browser/net/url_fixer_upper.h" | 5 #include "chrome/browser/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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 TrimWhitespaceUTF8(text, TRIM_ALL, &trimmed); | 498 TrimWhitespaceUTF8(text, TRIM_ALL, &trimmed); |
499 if (trimmed.empty()) | 499 if (trimmed.empty()) |
500 return GURL(); // Nothing here. | 500 return GURL(); // Nothing here. |
501 | 501 |
502 // Segment the URL. | 502 // Segment the URL. |
503 url_parse::Parsed parts; | 503 url_parse::Parsed parts; |
504 std::string scheme(SegmentURLInternal(&trimmed, &parts)); | 504 std::string scheme(SegmentURLInternal(&trimmed, &parts)); |
505 | 505 |
506 // For view-source: URLs, we strip "view-source:", do fixup, and stick it back | 506 // For view-source: URLs, we strip "view-source:", do fixup, and stick it back |
507 // on. This allows us to handle things like "view-source:google.com". | 507 // on. This allows us to handle things like "view-source:google.com". |
508 if (scheme == chrome::kViewSourceScheme) { | 508 if (scheme == content::kViewSourceScheme) { |
509 // Reject "view-source:view-source:..." to avoid deep recursion. | 509 // Reject "view-source:view-source:..." to avoid deep recursion. |
510 std::string view_source(chrome::kViewSourceScheme + std::string(":")); | 510 std::string view_source(content::kViewSourceScheme + std::string(":")); |
511 if (!StartsWithASCII(text, view_source + view_source, false)) { | 511 if (!StartsWithASCII(text, view_source + view_source, false)) { |
512 return GURL(chrome::kViewSourceScheme + std::string(":") + | 512 return GURL(content::kViewSourceScheme + std::string(":") + |
513 FixupURL(trimmed.substr(scheme.length() + 1), | 513 FixupURL(trimmed.substr(scheme.length() + 1), |
514 desired_tld).possibly_invalid_spec()); | 514 desired_tld).possibly_invalid_spec()); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 // We handle the file scheme separately. | 518 // We handle the file scheme separately. |
519 if (scheme == chrome::kFileScheme) | 519 if (scheme == chrome::kFileScheme) |
520 return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); | 520 return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); |
521 | 521 |
522 // We handle the filesystem scheme separately. | 522 // We handle the filesystem scheme separately. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 636 |
637 if (part->is_valid()) { | 637 if (part->is_valid()) { |
638 // Offset the location of this component. | 638 // Offset the location of this component. |
639 part->begin += offset; | 639 part->begin += offset; |
640 | 640 |
641 // This part might not have existed in the original text. | 641 // This part might not have existed in the original text. |
642 if (part->begin < 0) | 642 if (part->begin < 0) |
643 part->reset(); | 643 part->reset(); |
644 } | 644 } |
645 } | 645 } |
OLD | NEW |