OLD | NEW |
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
11 // copyright notice, this list of conditions and the following disclaimer | 11 // copyright notice, this list of conditions and the following disclaimer |
12 // in the documentation and/or other materials provided with the | 12 // in the documentation and/or other materials provided with the |
13 // distribution. | 13 // distribution. |
14 // * Neither the name of Google Inc. nor the names of its | 14 // * Neither the name of Google Inc. nor the names of its |
15 // contributors may be used to endorse or promote products derived from | 15 // contributors may be used to endorse or promote products derived from |
16 // this software without specific prior written permission. | 16 // this software without specific prior written permission. |
17 // | 17 // |
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 #ifndef GOOGLEURL_SRC_GURL_H__ | 30 #ifndef URL_GURL_H_ |
31 #define GOOGLEURL_SRC_GURL_H__ | 31 #define URL_GURL_H_ |
32 | 32 |
33 #include <iosfwd> | 33 #include <iosfwd> |
34 #include <string> | 34 #include <string> |
35 | 35 |
36 #include "base/string16.h" | 36 #include "base/string16.h" |
37 #include "googleurl/src/url_canon.h" | 37 #include "url/url_canon.h" |
38 #include "googleurl/src/url_canon_stdstring.h" | 38 #include "url/url_canon_stdstring.h" |
39 #include "googleurl/src/url_common.h" | 39 #include "url/url_parse.h" |
40 #include "googleurl/src/url_parse.h" | |
41 | 40 |
42 class GURL { | 41 class GURL { |
43 public: | 42 public: |
44 typedef url_canon::StdStringReplacements<std::string> Replacements; | 43 typedef url_canon::StdStringReplacements<std::string> Replacements; |
45 typedef url_canon::StdStringReplacements<string16> ReplacementsW; | 44 typedef url_canon::StdStringReplacements<string16> ReplacementsW; |
46 | 45 |
47 // Creates an empty, invalid URL. | 46 // Creates an empty, invalid URL. |
48 GURL_API GURL(); | 47 GURL(); |
49 | 48 |
50 // Copy construction is relatively inexpensive, with most of the time going | 49 // Copy construction is relatively inexpensive, with most of the time going |
51 // to reallocating the string. It does not re-parse. | 50 // to reallocating the string. It does not re-parse. |
52 GURL_API GURL(const GURL& other); | 51 GURL(const GURL& other); |
53 | 52 |
54 // The narrow version requires the input be UTF-8. Invalid UTF-8 input will | 53 // The narrow version requires the input be UTF-8. Invalid UTF-8 input will |
55 // result in an invalid URL. | 54 // result in an invalid URL. |
56 // | 55 // |
57 // The wide version should also take an encoding parameter so we know how to | 56 // The wide version should also take an encoding parameter so we know how to |
58 // encode the query parameters. It is probably sufficient for the narrow | 57 // encode the query parameters. It is probably sufficient for the narrow |
59 // version to assume the query parameter encoding should be the same as the | 58 // version to assume the query parameter encoding should be the same as the |
60 // input encoding. | 59 // input encoding. |
61 GURL_API explicit GURL(const std::string& url_string | 60 explicit GURL(const std::string& url_string |
62 /*, output_param_encoding*/); | 61 /*, output_param_encoding*/); |
63 GURL_API explicit GURL(const string16& url_string | 62 explicit GURL(const string16& url_string |
64 /*, output_param_encoding*/); | 63 /*, output_param_encoding*/); |
65 | 64 |
66 // Constructor for URLs that have already been parsed and canonicalized. This | 65 // Constructor for URLs that have already been parsed and canonicalized. This |
67 // is used for conversions from KURL, for example. The caller must supply all | 66 // is used for conversions from KURL, for example. The caller must supply all |
68 // information associated with the URL, which must be correct and consistent. | 67 // information associated with the URL, which must be correct and consistent. |
69 GURL_API GURL(const char* canonical_spec, size_t canonical_spec_len, | 68 GURL(const char* canonical_spec, size_t canonical_spec_len, |
70 const url_parse::Parsed& parsed, bool is_valid); | 69 const url_parse::Parsed& parsed, bool is_valid); |
71 | 70 |
72 GURL_API ~GURL(); | 71 ~GURL(); |
73 | 72 |
74 GURL_API GURL& operator=(const GURL& other); | 73 GURL& operator=(const GURL& other); |
75 | 74 |
76 // Returns true when this object represents a valid parsed URL. When not | 75 // Returns true when this object represents a valid parsed URL. When not |
77 // valid, other functions will still succeed, but you will not get canonical | 76 // valid, other functions will still succeed, but you will not get canonical |
78 // data out in the format you may be expecting. Instead, we keep something | 77 // data out in the format you may be expecting. Instead, we keep something |
79 // "reasonable looking" so that the user can see how it's busted if | 78 // "reasonable looking" so that the user can see how it's busted if |
80 // displayed to them. | 79 // displayed to them. |
81 bool is_valid() const { | 80 bool is_valid() const { |
82 return is_valid_; | 81 return is_valid_; |
83 } | 82 } |
84 | 83 |
(...skipping 11 matching lines...) Expand all Loading... |
96 // | 95 // |
97 // The URL will be ASCII except the reference fragment, which may be UTF-8. | 96 // The URL will be ASCII except the reference fragment, which may be UTF-8. |
98 // It is guaranteed to be valid UTF-8. | 97 // It is guaranteed to be valid UTF-8. |
99 // | 98 // |
100 // The exception is for empty() URLs (which are !is_valid()) but this will | 99 // The exception is for empty() URLs (which are !is_valid()) but this will |
101 // return the empty string without asserting. | 100 // return the empty string without asserting. |
102 // | 101 // |
103 // Used invalid_spec() below to get the unusable spec of an invalid URL. This | 102 // Used invalid_spec() below to get the unusable spec of an invalid URL. This |
104 // separation is designed to prevent errors that may cause security problems | 103 // separation is designed to prevent errors that may cause security problems |
105 // that could result from the mistaken use of an invalid URL. | 104 // that could result from the mistaken use of an invalid URL. |
106 GURL_API const std::string& spec() const; | 105 const std::string& spec() const; |
107 | 106 |
108 // Returns the potentially invalid spec for a the URL. This spec MUST NOT be | 107 // Returns the potentially invalid spec for a the URL. This spec MUST NOT be |
109 // modified or sent over the network. It is designed to be displayed in error | 108 // modified or sent over the network. It is designed to be displayed in error |
110 // messages to the user, as the apperance of the spec may explain the error. | 109 // messages to the user, as the apperance of the spec may explain the error. |
111 // If the spec is valid, the valid spec will be returned. | 110 // If the spec is valid, the valid spec will be returned. |
112 // | 111 // |
113 // The returned string is guaranteed to be valid UTF-8. | 112 // The returned string is guaranteed to be valid UTF-8. |
114 const std::string& possibly_invalid_spec() const { | 113 const std::string& possibly_invalid_spec() const { |
115 return spec_; | 114 return spec_; |
116 } | 115 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // "standard" (SchemeIsStandard() == false) and the input looks relative, we | 147 // "standard" (SchemeIsStandard() == false) and the input looks relative, we |
149 // can't resolve it. In these cases, the result will be an empty, invalid | 148 // can't resolve it. In these cases, the result will be an empty, invalid |
150 // GURL. | 149 // GURL. |
151 // | 150 // |
152 // The result may also be a nonempty, invalid URL if the input has some kind | 151 // The result may also be a nonempty, invalid URL if the input has some kind |
153 // of encoding error. In these cases, we will try to construct a "good" URL | 152 // of encoding error. In these cases, we will try to construct a "good" URL |
154 // that may have meaning to the user, but it will be marked invalid. | 153 // that may have meaning to the user, but it will be marked invalid. |
155 // | 154 // |
156 // It is an error to resolve a URL relative to an invalid URL. The result | 155 // It is an error to resolve a URL relative to an invalid URL. The result |
157 // will be the empty URL. | 156 // will be the empty URL. |
158 GURL_API GURL Resolve(const std::string& relative) const; | 157 GURL Resolve(const std::string& relative) const; |
159 GURL_API GURL Resolve(const string16& relative) const; | 158 GURL Resolve(const string16& relative) const; |
160 | 159 |
161 // Like Resolve() above but takes a character set encoder which will be used | 160 // Like Resolve() above but takes a character set encoder which will be used |
162 // for any query text specified in the input. The charset converter parameter | 161 // for any query text specified in the input. The charset converter parameter |
163 // may be NULL, in which case it will be treated as UTF-8. | 162 // may be NULL, in which case it will be treated as UTF-8. |
164 // | 163 // |
165 // TODO(brettw): These should be replaced with versions that take something | 164 // TODO(brettw): These should be replaced with versions that take something |
166 // more friendly than a raw CharsetConverter (maybe like an ICU character set | 165 // more friendly than a raw CharsetConverter (maybe like an ICU character set |
167 // name). | 166 // name). |
168 GURL_API GURL ResolveWithCharsetConverter( | 167 GURL ResolveWithCharsetConverter( |
169 const std::string& relative, | 168 const std::string& relative, |
170 url_canon::CharsetConverter* charset_converter) const; | 169 url_canon::CharsetConverter* charset_converter) const; |
171 GURL_API GURL ResolveWithCharsetConverter( | 170 GURL ResolveWithCharsetConverter( |
172 const string16& relative, | 171 const string16& relative, |
173 url_canon::CharsetConverter* charset_converter) const; | 172 url_canon::CharsetConverter* charset_converter) const; |
174 | 173 |
175 // Creates a new GURL by replacing the current URL's components with the | 174 // Creates a new GURL by replacing the current URL's components with the |
176 // supplied versions. See the Replacements class in url_canon.h for more. | 175 // supplied versions. See the Replacements class in url_canon.h for more. |
177 // | 176 // |
178 // These are not particularly quick, so avoid doing mutations when possible. | 177 // These are not particularly quick, so avoid doing mutations when possible. |
179 // Prefer the 8-bit version when possible. | 178 // Prefer the 8-bit version when possible. |
180 // | 179 // |
181 // It is an error to replace components of an invalid URL. The result will | 180 // It is an error to replace components of an invalid URL. The result will |
182 // be the empty URL. | 181 // be the empty URL. |
183 // | 182 // |
184 // Note that we use the more general url_canon::Replacements type to give | 183 // Note that we use the more general url_canon::Replacements type to give |
185 // callers extra flexibility rather than our override. | 184 // callers extra flexibility rather than our override. |
186 GURL_API GURL ReplaceComponents( | 185 GURL ReplaceComponents( |
187 const url_canon::Replacements<char>& replacements) const; | 186 const url_canon::Replacements<char>& replacements) const; |
188 GURL_API GURL ReplaceComponents( | 187 GURL ReplaceComponents( |
189 const url_canon::Replacements<char16>& replacements) const; | 188 const url_canon::Replacements<char16>& replacements) const; |
190 | 189 |
191 // A helper function that is equivalent to replacing the path with a slash | 190 // A helper function that is equivalent to replacing the path with a slash |
192 // and clearing out everything after that. We sometimes need to know just the | 191 // and clearing out everything after that. We sometimes need to know just the |
193 // scheme and the authority. If this URL is not a standard URL (it doesn't | 192 // scheme and the authority. If this URL is not a standard URL (it doesn't |
194 // have the regular authority and path sections), then the result will be | 193 // have the regular authority and path sections), then the result will be |
195 // an empty, invalid GURL. Note that this *does* work for file: URLs, which | 194 // an empty, invalid GURL. Note that this *does* work for file: URLs, which |
196 // some callers may want to filter out before calling this. | 195 // some callers may want to filter out before calling this. |
197 // | 196 // |
198 // It is an error to get an empty path on an invalid URL. The result | 197 // It is an error to get an empty path on an invalid URL. The result |
199 // will be the empty URL. | 198 // will be the empty URL. |
200 GURL_API GURL GetWithEmptyPath() const; | 199 GURL GetWithEmptyPath() const; |
201 | 200 |
202 // A helper function to return a GURL containing just the scheme, host, | 201 // A helper function to return a GURL containing just the scheme, host, |
203 // and port from a URL. Equivalent to clearing any username and password, | 202 // and port from a URL. Equivalent to clearing any username and password, |
204 // replacing the path with a slash, and clearing everything after that. If | 203 // replacing the path with a slash, and clearing everything after that. If |
205 // this URL is not a standard URL, then the result will be an empty, | 204 // this URL is not a standard URL, then the result will be an empty, |
206 // invalid GURL. If the URL has neither username nor password, this | 205 // invalid GURL. If the URL has neither username nor password, this |
207 // degenerates to GetWithEmptyPath(). | 206 // degenerates to GetWithEmptyPath(). |
208 // | 207 // |
209 // It is an error to get the origin of an invalid URL. The result | 208 // It is an error to get the origin of an invalid URL. The result |
210 // will be the empty URL. | 209 // will be the empty URL. |
211 GURL_API GURL GetOrigin() const; | 210 GURL GetOrigin() const; |
212 | 211 |
213 // Returns true if the scheme for the current URL is a known "standard" | 212 // Returns true if the scheme for the current URL is a known "standard" |
214 // scheme. Standard schemes have an authority and a path section. This | 213 // scheme. Standard schemes have an authority and a path section. This |
215 // includes file: and filesystem:, which some callers may want to filter out | 214 // includes file: and filesystem:, which some callers may want to filter out |
216 // explicitly by calling SchemeIsFile[System]. | 215 // explicitly by calling SchemeIsFile[System]. |
217 GURL_API bool IsStandard() const; | 216 bool IsStandard() const; |
218 | 217 |
219 // Returns true if the given parameter (should be lower-case ASCII to match | 218 // Returns true if the given parameter (should be lower-case ASCII to match |
220 // the canonicalized scheme) is the scheme for this URL. This call is more | 219 // the canonicalized scheme) is the scheme for this URL. This call is more |
221 // efficient than getting the scheme and comparing it because no copies or | 220 // efficient than getting the scheme and comparing it because no copies or |
222 // object constructions are done. | 221 // object constructions are done. |
223 GURL_API bool SchemeIs(const char* lower_ascii_scheme) const; | 222 bool SchemeIs(const char* lower_ascii_scheme) const; |
224 | 223 |
225 // We often need to know if this is a file URL. File URLs are "standard", but | 224 // We often need to know if this is a file URL. File URLs are "standard", but |
226 // are often treated separately by some programs. | 225 // are often treated separately by some programs. |
227 bool SchemeIsFile() const { | 226 bool SchemeIsFile() const { |
228 return SchemeIs("file"); | 227 return SchemeIs("file"); |
229 } | 228 } |
230 | 229 |
231 // FileSystem URLs need to be treated differently in some cases. | 230 // FileSystem URLs need to be treated differently in some cases. |
232 bool SchemeIsFileSystem() const { | 231 bool SchemeIsFileSystem() const { |
233 return SchemeIs("filesystem"); | 232 return SchemeIs("filesystem"); |
234 } | 233 } |
235 | 234 |
236 // If the scheme indicates a secure connection | 235 // If the scheme indicates a secure connection |
237 bool SchemeIsSecure() const { | 236 bool SchemeIsSecure() const { |
238 return SchemeIs("https") || SchemeIs("wss") || | 237 return SchemeIs("https") || SchemeIs("wss") || |
239 (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); | 238 (SchemeIsFileSystem() && inner_url() && inner_url()->SchemeIsSecure()); |
240 } | 239 } |
241 | 240 |
242 // Returns true if the hostname is an IP address. Note: this function isn't | 241 // Returns true if the hostname is an IP address. Note: this function isn't |
243 // as cheap as a simple getter because it re-parses the hostname to verify. | 242 // as cheap as a simple getter because it re-parses the hostname to verify. |
244 // This currently identifies only IPv4 addresses (bug 822685). | 243 // This currently identifies only IPv4 addresses (bug 822685). |
245 GURL_API bool HostIsIPAddress() const; | 244 bool HostIsIPAddress() const; |
246 | 245 |
247 // Getters for various components of the URL. The returned string will be | 246 // Getters for various components of the URL. The returned string will be |
248 // empty if the component is empty or is not present. | 247 // empty if the component is empty or is not present. |
249 std::string scheme() const { // Not including the colon. See also SchemeIs. | 248 std::string scheme() const { // Not including the colon. See also SchemeIs. |
250 return ComponentString(parsed_.scheme); | 249 return ComponentString(parsed_.scheme); |
251 } | 250 } |
252 std::string username() const { | 251 std::string username() const { |
253 return ComponentString(parsed_.username); | 252 return ComponentString(parsed_.username); |
254 } | 253 } |
255 std::string password() const { | 254 std::string password() const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 300 } |
302 bool has_query() const { | 301 bool has_query() const { |
303 return parsed_.query.len >= 0; | 302 return parsed_.query.len >= 0; |
304 } | 303 } |
305 bool has_ref() const { | 304 bool has_ref() const { |
306 return parsed_.ref.len >= 0; | 305 return parsed_.ref.len >= 0; |
307 } | 306 } |
308 | 307 |
309 // Returns a parsed version of the port. Can also be any of the special | 308 // Returns a parsed version of the port. Can also be any of the special |
310 // values defined in Parsed for ExtractPort. | 309 // values defined in Parsed for ExtractPort. |
311 GURL_API int IntPort() const; | 310 int IntPort() const; |
312 | 311 |
313 // Returns the port number of the url, or the default port number. | 312 // Returns the port number of the url, or the default port number. |
314 // If the scheme has no concept of port (or unknown default) returns | 313 // If the scheme has no concept of port (or unknown default) returns |
315 // PORT_UNSPECIFIED. | 314 // PORT_UNSPECIFIED. |
316 GURL_API int EffectiveIntPort() const; | 315 int EffectiveIntPort() const; |
317 | 316 |
318 // Extracts the filename portion of the path and returns it. The filename | 317 // Extracts the filename portion of the path and returns it. The filename |
319 // is everything after the last slash in the path. This may be empty. | 318 // is everything after the last slash in the path. This may be empty. |
320 GURL_API std::string ExtractFileName() const; | 319 std::string ExtractFileName() const; |
321 | 320 |
322 // Returns the path that should be sent to the server. This is the path, | 321 // Returns the path that should be sent to the server. This is the path, |
323 // parameter, and query portions of the URL. It is guaranteed to be ASCII. | 322 // parameter, and query portions of the URL. It is guaranteed to be ASCII. |
324 GURL_API std::string PathForRequest() const; | 323 std::string PathForRequest() const; |
325 | 324 |
326 // Returns the host, excluding the square brackets surrounding IPv6 address | 325 // Returns the host, excluding the square brackets surrounding IPv6 address |
327 // literals. This can be useful for passing to getaddrinfo(). | 326 // literals. This can be useful for passing to getaddrinfo(). |
328 GURL_API std::string HostNoBrackets() const; | 327 std::string HostNoBrackets() const; |
329 | 328 |
330 // Returns true if this URL's host matches or is in the same domain as | 329 // Returns true if this URL's host matches or is in the same domain as |
331 // the given input string. For example if this URL was "www.google.com", | 330 // the given input string. For example if this URL was "www.google.com", |
332 // this would match "com", "google.com", and "www.google.com | 331 // this would match "com", "google.com", and "www.google.com |
333 // (input domain should be lower-case ASCII to match the canonicalized | 332 // (input domain should be lower-case ASCII to match the canonicalized |
334 // scheme). This call is more efficient than getting the host and check | 333 // scheme). This call is more efficient than getting the host and check |
335 // whether host has the specific domain or not because no copies or | 334 // whether host has the specific domain or not because no copies or |
336 // object constructions are done. | 335 // object constructions are done. |
337 // | 336 // |
338 // If function DomainIs has parameter domain_len, which means the parameter | 337 // If function DomainIs has parameter domain_len, which means the parameter |
339 // lower_ascii_domain does not gurantee to terminate with NULL character. | 338 // lower_ascii_domain does not gurantee to terminate with NULL character. |
340 GURL_API bool DomainIs(const char* lower_ascii_domain, int domain_len) const; | 339 bool DomainIs(const char* lower_ascii_domain, int domain_len) const; |
341 | 340 |
342 // If function DomainIs only has parameter lower_ascii_domain, which means | 341 // If function DomainIs only has parameter lower_ascii_domain, which means |
343 // domain string should be terminate with NULL character. | 342 // domain string should be terminate with NULL character. |
344 bool DomainIs(const char* lower_ascii_domain) const { | 343 bool DomainIs(const char* lower_ascii_domain) const { |
345 return DomainIs(lower_ascii_domain, | 344 return DomainIs(lower_ascii_domain, |
346 static_cast<int>(strlen(lower_ascii_domain))); | 345 static_cast<int>(strlen(lower_ascii_domain))); |
347 } | 346 } |
348 | 347 |
349 // Swaps the contents of this GURL object with the argument without doing | 348 // Swaps the contents of this GURL object with the argument without doing |
350 // any memory allocations. | 349 // any memory allocations. |
351 GURL_API void Swap(GURL* other); | 350 void Swap(GURL* other); |
352 | 351 |
353 // Returns a reference to a singleton empty GURL. This object is for callers | 352 // Returns a reference to a singleton empty GURL. This object is for callers |
354 // who return references but don't have anything to return in some cases. | 353 // who return references but don't have anything to return in some cases. |
355 // This function may be called from any thread. | 354 // This function may be called from any thread. |
356 GURL_API static const GURL& EmptyGURL(); | 355 static const GURL& EmptyGURL(); |
357 | 356 |
358 // Returns the inner URL of a nested URL [currently only non-null for | 357 // Returns the inner URL of a nested URL [currently only non-null for |
359 // filesystem: URLs]. | 358 // filesystem: URLs]. |
360 const GURL* inner_url() const { | 359 const GURL* inner_url() const { |
361 return inner_url_; | 360 return inner_url_; |
362 } | 361 } |
363 | 362 |
364 private: | 363 private: |
365 // Returns the substring of the input identified by the given component. | 364 // Returns the substring of the input identified by the given component. |
366 std::string ComponentString(const url_parse::Component& comp) const { | 365 std::string ComponentString(const url_parse::Component& comp) const { |
(...skipping 13 matching lines...) Expand all Loading... |
380 // Identified components of the canonical spec. | 379 // Identified components of the canonical spec. |
381 url_parse::Parsed parsed_; | 380 url_parse::Parsed parsed_; |
382 | 381 |
383 // Used for nested schemes [currently only filesystem:]. | 382 // Used for nested schemes [currently only filesystem:]. |
384 GURL* inner_url_; | 383 GURL* inner_url_; |
385 | 384 |
386 // TODO bug 684583: Add encoding for query params. | 385 // TODO bug 684583: Add encoding for query params. |
387 }; | 386 }; |
388 | 387 |
389 // Stream operator so GURL can be used in assertion statements. | 388 // Stream operator so GURL can be used in assertion statements. |
390 GURL_API std::ostream& operator<<(std::ostream& out, const GURL& url); | 389 std::ostream& operator<<(std::ostream& out, const GURL& url); |
391 | 390 |
392 #endif // GOOGLEURL_SRC_GURL_H__ | 391 #endif // URL_GURL_H_ |
OLD | NEW |