OLD | NEW |
1 // Copyright (c) 2011 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 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
(...skipping 22 matching lines...) Expand all Loading... |
34 | 34 |
35 // Converts |text| to a fixed-up URL and returns it. Attempts to make | 35 // Converts |text| to a fixed-up URL and returns it. Attempts to make |
36 // some "smart" adjustments to obviously-invalid input where possible. | 36 // some "smart" adjustments to obviously-invalid input where possible. |
37 // |text| may be an absolute path to a file, which will get converted to a | 37 // |text| may be an absolute path to a file, which will get converted to a |
38 // "file:" URL. | 38 // "file:" URL. |
39 // | 39 // |
40 // The result will be a "more" valid URL than the input. It may still not | 40 // The result will be a "more" valid URL than the input. It may still not |
41 // be valid, so check the return value's validity or use | 41 // be valid, so check the return value's validity or use |
42 // possibly_invalid_spec(). | 42 // possibly_invalid_spec(). |
43 // | 43 // |
44 // Schemes "about" and "chrome" are normalized to "chrome://", with slashes. | |
45 // "about:blank" is unaltered, as Webkit allows frames to access about:blank. | |
46 // Additionally, if a chrome URL does not have a valid host, as in "about:", | |
47 // the returned URL will have the host "version", as in "chrome://version". | |
48 // | |
49 // 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 |
50 // 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 |
51 // 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 |
52 // |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, |
53 // 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" |
54 // instead of ".com"). | 49 // instead of ".com"). |
55 GURL FixupURL(const std::string& text, const std::string& desired_tld); | 50 GURL FixupURL(const std::string& text, const std::string& desired_tld); |
56 | 51 |
57 // Converts |text| to a fixed-up URL, allowing it to be a relative path on | 52 // Converts |text| to a fixed-up URL, allowing it to be a relative path on |
58 // the local filesystem. Begin searching in |base_dir|; if empty, use the | 53 // the local filesystem. Begin searching in |base_dir|; if empty, use the |
(...skipping 14 matching lines...) Expand all Loading... |
73 // Does nothing if |part| is invalid. | 68 // Does nothing if |part| is invalid. |
74 void OffsetComponent(int offset, url_parse::Component* part); | 69 void OffsetComponent(int offset, url_parse::Component* part); |
75 | 70 |
76 // For paths like ~, we use $HOME for the current user's home | 71 // For paths like ~, we use $HOME for the current user's home |
77 // directory. For tests, we allow our idea of $HOME to be overriden | 72 // directory. For tests, we allow our idea of $HOME to be overriden |
78 // by this variable. | 73 // by this variable. |
79 extern const char* home_directory_override; | 74 extern const char* home_directory_override; |
80 }; | 75 }; |
81 | 76 |
82 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ | 77 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ |
OLD | NEW |