| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 | 12 |
| 13 namespace url_parse { | 13 namespace base { |
| 14 struct Component; | 14 class FilePath; |
| 15 struct Parsed; | |
| 16 } | 15 } |
| 17 | 16 |
| 18 class FilePath; | 17 namespace url_parse { |
| 18 struct Component; |
| 19 struct Parsed; |
| 20 } |
| 19 | 21 |
| 20 // This object is designed to convert various types of input into URLs that we | 22 // 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 | 23 // 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 | 24 // options. This is NOT the place for converting between different types of |
| 23 // URLs or parsing them, see net_util.h for that. | 25 // URLs or parsing them, see net_util.h for that. |
| 24 namespace URLFixerUpper { | 26 namespace URLFixerUpper { |
| 25 | 27 |
| 26 // Segments the given text string into parts of a URL. This is most useful | 28 // 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 | 29 // for schemes such as http, https, and ftp where |SegmentURL| will find many |
| 28 // segments. Currently does not segment "file" schemes. | 30 // segments. Currently does not segment "file" schemes. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 55 | 57 |
| 56 // Converts |text| to a fixed-up URL, allowing it to be a relative path on | 58 // Converts |text| to a fixed-up URL, allowing it to be a relative path on |
| 57 // the local filesystem. Begin searching in |base_dir|; if empty, use the | 59 // the local filesystem. Begin searching in |base_dir|; if empty, use the |
| 58 // current working directory. If this resolves to a file on disk, convert it | 60 // current working directory. If this resolves to a file on disk, convert it |
| 59 // to a "file:" URL in |fixed_up_url|; otherwise, fall back to the behavior | 61 // to a "file:" URL in |fixed_up_url|; otherwise, fall back to the behavior |
| 60 // of FixupURL(). | 62 // of FixupURL(). |
| 61 // | 63 // |
| 62 // For "regular" input, even if it is possibly a file with a full path, you | 64 // For "regular" input, even if it is possibly a file with a full path, you |
| 63 // should use FixupURL() directly. This function should only be used when | 65 // should use FixupURL() directly. This function should only be used when |
| 64 // relative path handling is desired, as for command line processing. | 66 // relative path handling is desired, as for command line processing. |
| 65 GURL FixupRelativeFile(const FilePath& base_dir, const FilePath& text); | 67 GURL FixupRelativeFile(const base::FilePath& base_dir, const base::FilePath& t
ext); |
| 66 | 68 |
| 67 // Offsets the beginning index of |part| by |offset|, which is allowed to be | 69 // Offsets the beginning index of |part| by |offset|, which is allowed to be |
| 68 // negative. In some cases, the desired component does not exist at the given | 70 // negative. In some cases, the desired component does not exist at the given |
| 69 // offset. For example, when converting from "http://foo" to "foo", the | 71 // offset. For example, when converting from "http://foo" to "foo", the |
| 70 // scheme component no longer exists. In such a case, the beginning index is | 72 // scheme component no longer exists. In such a case, the beginning index is |
| 71 // set to 0. | 73 // set to 0. |
| 72 // Does nothing if |part| is invalid. | 74 // Does nothing if |part| is invalid. |
| 73 void OffsetComponent(int offset, url_parse::Component* part); | 75 void OffsetComponent(int offset, url_parse::Component* part); |
| 74 | 76 |
| 75 // For paths like ~, we use $HOME for the current user's home | 77 // For paths like ~, we use $HOME for the current user's home |
| 76 // directory. For tests, we allow our idea of $HOME to be overriden | 78 // directory. For tests, we allow our idea of $HOME to be overriden |
| 77 // by this variable. | 79 // by this variable. |
| 78 extern const char* home_directory_override; | 80 extern const char* home_directory_override; |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ | 83 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ |
| OLD | NEW |