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 "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 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 531 |
532 // We handle the filesystem scheme separately. | 532 // We handle the filesystem scheme separately. |
533 if (scheme == url::kFileSystemScheme) { | 533 if (scheme == url::kFileSystemScheme) { |
534 if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) | 534 if (parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) |
535 return GURL(text); | 535 return GURL(text); |
536 return GURL(); | 536 return GURL(); |
537 } | 537 } |
538 | 538 |
539 // Parse and rebuild about: and chrome: URLs, except about:blank. | 539 // Parse and rebuild about: and chrome: URLs, except about:blank. |
540 bool chrome_url = | 540 bool chrome_url = |
541 !base::LowerCaseEqualsASCII(trimmed, url::kAboutBlankURL) && | 541 !LowerCaseEqualsASCII(trimmed, url::kAboutBlankURL) && |
542 ((scheme == url::kAboutScheme) || (scheme == kChromeUIScheme)); | 542 ((scheme == url::kAboutScheme) || (scheme == kChromeUIScheme)); |
543 | 543 |
544 // For some schemes whose layouts we understand, we rebuild it. | 544 // For some schemes whose layouts we understand, we rebuild it. |
545 if (chrome_url || | 545 if (chrome_url || |
546 url::IsStandard(scheme.c_str(), | 546 url::IsStandard(scheme.c_str(), |
547 url::Component(0, static_cast<int>(scheme.length())))) { | 547 url::Component(0, static_cast<int>(scheme.length())))) { |
548 // Replace the about: scheme with the chrome: scheme. | 548 // Replace the about: scheme with the chrome: scheme. |
549 std::string url(chrome_url ? kChromeUIScheme : scheme); | 549 std::string url(chrome_url ? kChromeUIScheme : scheme); |
550 url.append(url::kStandardSchemeSeparator); | 550 url.append(url::kStandardSchemeSeparator); |
551 | 551 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 part->reset(); | 660 part->reset(); |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 bool url_fixer::IsEquivalentScheme(const std::string& scheme1, | 664 bool url_fixer::IsEquivalentScheme(const std::string& scheme1, |
665 const std::string& scheme2) { | 665 const std::string& scheme2) { |
666 return scheme1 == scheme2 || | 666 return scheme1 == scheme2 || |
667 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || | 667 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || |
668 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); | 668 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); |
669 } | 669 } |
OLD | NEW |