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" |
11 #endif | 11 #endif |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
18 #include "net/base/filename_util.h" | 18 #include "net/base/filename_util.h" |
19 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 21 #include "net/base/url_constants.h" |
21 #include "url/url_file.h" | 22 #include "url/url_file.h" |
22 #include "url/url_parse.h" | 23 #include "url/url_parse.h" |
23 #include "url/url_util.h" | 24 #include "url/url_util.h" |
24 | 25 |
25 const char* URLFixerUpper::home_directory_override = NULL; | 26 const char* URLFixerUpper::home_directory_override = NULL; |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 // TODO(estade): Remove these ugly, ugly functions. They are only used in | 30 // TODO(estade): Remove these ugly, ugly functions. They are only used in |
30 // SegmentURL. A url_parse::Parsed object keeps track of a bunch of indices into | 31 // SegmentURL. A url_parse::Parsed object keeps track of a bunch of indices into |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 if (semicolon != 0 && semicolon != std::string::npos) { | 417 if (semicolon != 0 && semicolon != std::string::npos) { |
417 (*text)[semicolon] = ':'; | 418 (*text)[semicolon] = ':'; |
418 if (GetValidScheme(*text, &parts->scheme, &scheme)) | 419 if (GetValidScheme(*text, &parts->scheme, &scheme)) |
419 found_scheme = true; | 420 found_scheme = true; |
420 else | 421 else |
421 (*text)[semicolon] = ';'; | 422 (*text)[semicolon] = ';'; |
422 } | 423 } |
423 if (!found_scheme) { | 424 if (!found_scheme) { |
424 // Couldn't determine the scheme, so just pick one. | 425 // Couldn't determine the scheme, so just pick one. |
425 parts->scheme.reset(); | 426 parts->scheme.reset(); |
426 scheme = StartsWithASCII(*text, "ftp.", false) ? | 427 scheme = StartsWithASCII(*text, "ftp.", false) ? content::kFtpScheme |
427 content::kFtpScheme : content::kHttpScheme; | 428 : net::kHttpScheme; |
428 } | 429 } |
429 } | 430 } |
430 | 431 |
431 // Proceed with about and chrome schemes, but not file or nonstandard schemes. | 432 // Proceed with about and chrome schemes, but not file or nonstandard schemes. |
432 if ((scheme != content::kAboutScheme) && | 433 if ((scheme != content::kAboutScheme) && |
433 (scheme != content::kChromeUIScheme) && | 434 (scheme != content::kChromeUIScheme) && |
434 ((scheme == content::kFileScheme) || | 435 ((scheme == content::kFileScheme) || |
435 !url_util::IsStandard( | 436 !url_util::IsStandard( |
436 scheme.c_str(), | 437 scheme.c_str(), |
437 url_parse::Component(0, static_cast<int>(scheme.length()))))) | 438 url_parse::Component(0, static_cast<int>(scheme.length()))))) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 646 |
646 if (part->is_valid()) { | 647 if (part->is_valid()) { |
647 // Offset the location of this component. | 648 // Offset the location of this component. |
648 part->begin += offset; | 649 part->begin += offset; |
649 | 650 |
650 // This part might not have existed in the original text. | 651 // This part might not have existed in the original text. |
651 if (part->begin < 0) | 652 if (part->begin < 0) |
652 part->reset(); | 653 part->reset(); |
653 } | 654 } |
654 } | 655 } |
OLD | NEW |