OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ | 5 #ifndef CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ |
6 #define CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ | 6 #define CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 // possibly_invalid_spec(). | 42 // possibly_invalid_spec(). |
43 // | 43 // |
44 // If |desired_tld| is non-empty, it represents the TLD the user wishes to | 44 // If |desired_tld| is non-empty, it represents the TLD the user wishes to |
45 // append in the case of an incomplete domain. We check that this is not a | 45 // append in the case of an incomplete domain. We check that this is not a |
46 // file path and there does not appear to be a valid TLD already, then append | 46 // file path and there does not appear to be a valid TLD already, then append |
47 // |desired_tld| to the domain and prepend "www." (unless it, or a scheme, | 47 // |desired_tld| to the domain and prepend "www." (unless it, or a scheme, |
48 // are already present.) This TLD should not have a leading '.' (use "com" | 48 // are already present.) This TLD should not have a leading '.' (use "com" |
49 // instead of ".com"). | 49 // instead of ".com"). |
50 GURL FixupURL(const std::string& text, const std::string& desired_tld); | 50 GURL FixupURL(const std::string& text, const std::string& desired_tld); |
51 | 51 |
52 // Normalizes about:foo, about://foo, and chrome:foo to chrome://foo. | |
53 // The host "version" is added if the url does not contain a host ("about:"); | |
54 // otherwise GURL considers the result invalid. | |
55 GURL FixupChromeURL(const GURL& url); | |
abarth-chromium
2011/05/31 19:27:54
This description doesn't seem quite right. This f
msw
2011/05/31 20:58:25
Done.
| |
56 | |
52 // Converts |text| to a fixed-up URL, allowing it to be a relative path on | 57 // Converts |text| to a fixed-up URL, allowing it to be a relative path on |
53 // the local filesystem. Begin searching in |base_dir|; if empty, use the | 58 // the local filesystem. Begin searching in |base_dir|; if empty, use the |
54 // current working directory. If this resolves to a file on disk, convert it | 59 // current working directory. If this resolves to a file on disk, convert it |
55 // to a "file:" URL in |fixed_up_url|; otherwise, fall back to the behavior | 60 // to a "file:" URL in |fixed_up_url|; otherwise, fall back to the behavior |
56 // of FixupURL(). | 61 // of FixupURL(). |
57 // | 62 // |
58 // For "regular" input, even if it is possibly a file with a full path, you | 63 // For "regular" input, even if it is possibly a file with a full path, you |
59 // should use FixupURL() directly. This function should only be used when | 64 // should use FixupURL() directly. This function should only be used when |
60 // relative path handling is desired, as for command line processing. | 65 // relative path handling is desired, as for command line processing. |
61 GURL FixupRelativeFile(const FilePath& base_dir, const FilePath& text); | 66 GURL FixupRelativeFile(const FilePath& base_dir, const FilePath& text); |
62 | 67 |
63 // Offsets the beginning index of |part| by |offset|, which is allowed to be | 68 // Offsets the beginning index of |part| by |offset|, which is allowed to be |
64 // negative. In some cases, the desired component does not exist at the given | 69 // negative. In some cases, the desired component does not exist at the given |
65 // offset. For example, when converting from "http://foo" to "foo", the | 70 // offset. For example, when converting from "http://foo" to "foo", the |
66 // scheme component no longer exists. In such a case, the beginning index is | 71 // scheme component no longer exists. In such a case, the beginning index is |
67 // set to 0. | 72 // set to 0. |
68 // Does nothing if |part| is invalid. | 73 // Does nothing if |part| is invalid. |
69 void OffsetComponent(int offset, url_parse::Component* part); | 74 void OffsetComponent(int offset, url_parse::Component* part); |
70 | 75 |
71 // For paths like ~, we use $HOME for the current user's home | 76 // For paths like ~, we use $HOME for the current user's home |
72 // directory. For tests, we allow our idea of $HOME to be overriden | 77 // directory. For tests, we allow our idea of $HOME to be overriden |
73 // by this variable. | 78 // by this variable. |
74 extern const char* home_directory_override; | 79 extern const char* home_directory_override; |
75 }; | 80 }; |
76 | 81 |
77 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ | 82 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ |
OLD | NEW |