| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r
ights 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef KURL_h | 26 #ifndef KURL_h |
| 27 #define KURL_h | 27 #define KURL_h |
| 28 | 28 |
| 29 #include "weborigin/WebOriginExport.h" | 29 #include "platform/PlatformExport.h" |
| 30 #include "wtf/Forward.h" | 30 #include "wtf/Forward.h" |
| 31 #include "wtf/HashMap.h" | 31 #include "wtf/HashMap.h" |
| 32 #include "wtf/HashTableDeletedValueType.h" | 32 #include "wtf/HashTableDeletedValueType.h" |
| 33 #include "wtf/OwnPtr.h" | 33 #include "wtf/OwnPtr.h" |
| 34 #include "wtf/text/CString.h" | 34 #include "wtf/text/CString.h" |
| 35 #include "wtf/text/TextEncoding.h" | 35 #include "wtf/text/TextEncoding.h" |
| 36 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
| 37 #include <url/third_party/mozilla/url_parse.h> | 37 #include <url/third_party/mozilla/url_parse.h> |
| 38 #include <url/url_canon.h> | 38 #include <url/url_canon.h> |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 struct KURLHash; | 42 struct KURLHash; |
| 43 | 43 |
| 44 enum ParsedURLStringTag { ParsedURLString }; | 44 enum ParsedURLStringTag { ParsedURLString }; |
| 45 | 45 |
| 46 class WEBORIGIN_EXPORT KURL { | 46 class PLATFORM_EXPORT KURL { |
| 47 public: | 47 public: |
| 48 KURL() | 48 KURL() |
| 49 : m_isValid(false) | 49 : m_isValid(false) |
| 50 , m_protocolIsInHTTPFamily(false) | 50 , m_protocolIsInHTTPFamily(false) |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 KURL(const KURL&); | 54 KURL(const KURL&); |
| 55 KURL& operator=(const KURL&); | 55 KURL& operator=(const KURL&); |
| 56 | 56 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 // done with the same input. | 81 // done with the same input. |
| 82 KURL(const AtomicString& canonicalString, const url_parse::Parsed&, bool isV
alid); | 82 KURL(const AtomicString& canonicalString, const url_parse::Parsed&, bool isV
alid); |
| 83 | 83 |
| 84 String strippedForUseAsReferrer() const; | 84 String strippedForUseAsReferrer() const; |
| 85 | 85 |
| 86 // FIXME: The above functions should be harmonized so that passing a | 86 // FIXME: The above functions should be harmonized so that passing a |
| 87 // base of null or the empty string gives the same result as the | 87 // base of null or the empty string gives the same result as the |
| 88 // standard String constructor. | 88 // standard String constructor. |
| 89 | 89 |
| 90 // Makes a deep copy. Helpful only if you need to use a KURL on another | 90 // Makes a deep copy. Helpful only if you need to use a KURL on another |
| 91 // thread. Since the underlying StringImpl objects are immutable, there's | 91 // thread. Since the underlying StringImpl objects are immutable, there's |
| 92 // no other reason to ever prefer copy() over plain old assignment. | 92 // no other reason to ever prefer copy() over plain old assignment. |
| 93 KURL copy() const; | 93 KURL copy() const; |
| 94 | 94 |
| 95 bool isNull() const; | 95 bool isNull() const; |
| 96 bool isEmpty() const; | 96 bool isEmpty() const; |
| 97 bool isValid() const; | 97 bool isValid() const; |
| 98 | 98 |
| 99 // Returns true if this URL has a path. Note that "http://foo.com/" has a | 99 // Returns true if this URL has a path. Note that "http://foo.com/" has a |
| 100 // path of "/", so this function will return true. Only invalid or | 100 // path of "/", so this function will return true. Only invalid or |
| 101 // non-hierarchical (like "javascript:") URLs will have no path. | 101 // non-hierarchical (like "javascript:") URLs will have no path. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void setPath(const String&); | 152 void setPath(const String&); |
| 153 | 153 |
| 154 // The query may begin with a question mark, or, if not, one will be added | 154 // The query may begin with a question mark, or, if not, one will be added |
| 155 // for you. Setting the query to the empty string will leave a "?" in the | 155 // for you. Setting the query to the empty string will leave a "?" in the |
| 156 // URL (with nothing after it). To clear the query, pass a null string. | 156 // URL (with nothing after it). To clear the query, pass a null string. |
| 157 void setQuery(const String&); | 157 void setQuery(const String&); |
| 158 | 158 |
| 159 void setFragmentIdentifier(const String&); | 159 void setFragmentIdentifier(const String&); |
| 160 void removeFragmentIdentifier(); | 160 void removeFragmentIdentifier(); |
| 161 | 161 |
| 162 WEBORIGIN_EXPORT friend bool equalIgnoringFragmentIdentifier(const KURL&, co
nst KURL&); | 162 PLATFORM_EXPORT friend bool equalIgnoringFragmentIdentifier(const KURL&, con
st KURL&); |
| 163 | 163 |
| 164 unsigned hostStart() const; | 164 unsigned hostStart() const; |
| 165 unsigned hostEnd() const; | 165 unsigned hostEnd() const; |
| 166 | 166 |
| 167 unsigned pathStart() const; | 167 unsigned pathStart() const; |
| 168 unsigned pathEnd() const; | 168 unsigned pathEnd() const; |
| 169 unsigned pathAfterLastSlash() const; | 169 unsigned pathAfterLastSlash() const; |
| 170 | 170 |
| 171 operator const String&() const { return string(); } | 171 operator const String&() const { return string(); } |
| 172 | 172 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 194 void initInnerURL(); | 194 void initInnerURL(); |
| 195 void initProtocolIsInHTTPFamily(); | 195 void initProtocolIsInHTTPFamily(); |
| 196 | 196 |
| 197 bool m_isValid; | 197 bool m_isValid; |
| 198 bool m_protocolIsInHTTPFamily; | 198 bool m_protocolIsInHTTPFamily; |
| 199 url_parse::Parsed m_parsed; | 199 url_parse::Parsed m_parsed; |
| 200 String m_string; | 200 String m_string; |
| 201 OwnPtr<KURL> m_innerURL; | 201 OwnPtr<KURL> m_innerURL; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 WEBORIGIN_EXPORT bool operator==(const KURL&, const KURL&); | 204 PLATFORM_EXPORT bool operator==(const KURL&, const KURL&); |
| 205 WEBORIGIN_EXPORT bool operator==(const KURL&, const String&); | 205 PLATFORM_EXPORT bool operator==(const KURL&, const String&); |
| 206 WEBORIGIN_EXPORT bool operator==(const String&, const KURL&); | 206 PLATFORM_EXPORT bool operator==(const String&, const KURL&); |
| 207 WEBORIGIN_EXPORT bool operator!=(const KURL&, const KURL&); | 207 PLATFORM_EXPORT bool operator!=(const KURL&, const KURL&); |
| 208 WEBORIGIN_EXPORT bool operator!=(const KURL&, const String&); | 208 PLATFORM_EXPORT bool operator!=(const KURL&, const String&); |
| 209 WEBORIGIN_EXPORT bool operator!=(const String&, const KURL&); | 209 PLATFORM_EXPORT bool operator!=(const String&, const KURL&); |
| 210 | 210 |
| 211 WEBORIGIN_EXPORT bool equalIgnoringFragmentIdentifier(const KURL&, const KURL&); | 211 PLATFORM_EXPORT bool equalIgnoringFragmentIdentifier(const KURL&, const KURL&); |
| 212 | 212 |
| 213 WEBORIGIN_EXPORT const KURL& blankURL(); | 213 PLATFORM_EXPORT const KURL& blankURL(); |
| 214 | 214 |
| 215 // Functions to do URL operations on strings. | 215 // Functions to do URL operations on strings. |
| 216 // These are operations that aren't faster on a parsed URL. | 216 // These are operations that aren't faster on a parsed URL. |
| 217 // These are also different from the KURL functions in that they don't require t
he string to be a valid and parsable URL. | 217 // These are also different from the KURL functions in that they don't require t
he string to be a valid and parsable URL. |
| 218 // This is especially important because valid javascript URLs are not necessaril
y considered valid by KURL. | 218 // This is especially important because valid javascript URLs are not necessaril
y considered valid by KURL. |
| 219 | 219 |
| 220 WEBORIGIN_EXPORT bool protocolIs(const String& url, const char* protocol); | 220 PLATFORM_EXPORT bool protocolIs(const String& url, const char* protocol); |
| 221 WEBORIGIN_EXPORT bool protocolIsJavaScript(const String& url); | 221 PLATFORM_EXPORT bool protocolIsJavaScript(const String& url); |
| 222 | 222 |
| 223 WEBORIGIN_EXPORT bool isValidProtocol(const String&); | 223 PLATFORM_EXPORT bool isValidProtocol(const String&); |
| 224 | 224 |
| 225 // Unescapes the given string using URL escaping rules, given an optional | 225 // Unescapes the given string using URL escaping rules, given an optional |
| 226 // encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00" | 226 // encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00" |
| 227 // in it, the resulting string will have embedded null characters! | 227 // in it, the resulting string will have embedded null characters! |
| 228 WEBORIGIN_EXPORT String decodeURLEscapeSequences(const String&); | 228 PLATFORM_EXPORT String decodeURLEscapeSequences(const String&); |
| 229 WEBORIGIN_EXPORT String decodeURLEscapeSequences(const String&, const WTF::TextE
ncoding&); | 229 PLATFORM_EXPORT String decodeURLEscapeSequences(const String&, const WTF::TextEn
coding&); |
| 230 | 230 |
| 231 WEBORIGIN_EXPORT String encodeWithURLEscapeSequences(const String&); | 231 PLATFORM_EXPORT String encodeWithURLEscapeSequences(const String&); |
| 232 | 232 |
| 233 // Inlines. | 233 // Inlines. |
| 234 | 234 |
| 235 inline bool operator==(const KURL& a, const KURL& b) | 235 inline bool operator==(const KURL& a, const KURL& b) |
| 236 { | 236 { |
| 237 return a.string() == b.string(); | 237 return a.string() == b.string(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 inline bool operator==(const KURL& a, const String& b) | 240 inline bool operator==(const KURL& a, const String& b) |
| 241 { | 241 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 268 | 268 |
| 269 // KURLHash is the default hash for String | 269 // KURLHash is the default hash for String |
| 270 template<typename T> struct DefaultHash; | 270 template<typename T> struct DefaultHash; |
| 271 template<> struct DefaultHash<WebCore::KURL> { | 271 template<> struct DefaultHash<WebCore::KURL> { |
| 272 typedef WebCore::KURLHash Hash; | 272 typedef WebCore::KURLHash Hash; |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 } // namespace WTF | 275 } // namespace WTF |
| 276 | 276 |
| 277 #endif // KURL_h | 277 #endif // KURL_h |
| OLD | NEW |