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