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 |
| 11 #include "base/string16.h" |
11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
12 | 13 |
13 namespace url_parse { | 14 namespace url_parse { |
14 struct Component; | 15 struct Component; |
15 struct Parsed; | 16 struct Parsed; |
16 } | 17 } |
17 | 18 |
18 class FilePath; | 19 class FilePath; |
19 | 20 |
20 // This object is designed to convert various types of input into URLs that we | 21 // This object is designed to convert various types of input into URLs that we |
21 // know are valid. For example, user typing in the URL bar or command line | 22 // know are valid. For example, user typing in the URL bar or command line |
22 // options. This is NOT the place for converting between different types of | 23 // options. This is NOT the place for converting between different types of |
23 // URLs or parsing them, see net_util.h for that. | 24 // URLs or parsing them, see net_util.h for that. |
24 namespace URLFixerUpper { | 25 namespace URLFixerUpper { |
25 | 26 |
26 // Segments the given text string into parts of a URL. This is most useful | 27 // Segments the given text string into parts of a URL. This is most useful |
27 // for schemes such as http, https, and ftp where |SegmentURL| will find many | 28 // for schemes such as http, https, and ftp where |SegmentURL| will find many |
28 // segments. Currently does not segment "file" schemes. | 29 // segments. Currently does not segment "file" schemes. |
29 // Returns the canonicalized scheme, or the empty string when |text| is only | 30 // Returns the canonicalized scheme, or the empty string when |text| is only |
30 // whitespace. | 31 // whitespace. |
31 std::string SegmentURL(const std::string& text, url_parse::Parsed* parts); | 32 std::string SegmentURL(const std::string& text, url_parse::Parsed* parts); |
32 // Deprecated temporary compatibility function. | 33 // Deprecated temporary compatibility functions. |
33 std::wstring SegmentURL(const std::wstring& text, url_parse::Parsed* parts); | 34 std::wstring SegmentURL(const std::wstring& text, url_parse::Parsed* parts); |
| 35 #if defined(WCHAR_T_IS_UTF32) |
| 36 string16 SegmentURL(const string16& text, url_parse::Parsed* parts); |
| 37 #endif |
34 | 38 |
35 // Converts |text| to a fixed-up URL and returns it. Attempts to make | 39 // Converts |text| to a fixed-up URL and returns it. Attempts to make |
36 // some "smart" adjustments to obviously-invalid input where possible. | 40 // 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 | 41 // |text| may be an absolute path to a file, which will get converted to a |
38 // "file:" URL. | 42 // "file:" URL. |
39 // | 43 // |
40 // The result will be a "more" valid URL than the input. It may still not | 44 // 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 | 45 // be valid, so check the return value's validity or use |
42 // possibly_invalid_spec(). | 46 // possibly_invalid_spec(). |
43 // | 47 // |
(...skipping 27 matching lines...) Expand all Loading... |
71 // Does nothing if |part| is invalid. | 75 // Does nothing if |part| is invalid. |
72 void OffsetComponent(int offset, url_parse::Component* part); | 76 void OffsetComponent(int offset, url_parse::Component* part); |
73 | 77 |
74 // For paths like ~, we use $HOME for the current user's home | 78 // For paths like ~, we use $HOME for the current user's home |
75 // directory. For tests, we allow our idea of $HOME to be overriden | 79 // directory. For tests, we allow our idea of $HOME to be overriden |
76 // by this variable. | 80 // by this variable. |
77 extern const char* home_directory_override; | 81 extern const char* home_directory_override; |
78 }; | 82 }; |
79 | 83 |
80 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ | 84 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ |
OLD | NEW |