| 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 "platform/PlatformExport.h" | 29 #include "platform/weborigin/OriginExport.h" |
| 30 #include "url/third_party/mozilla/url_parse.h" | 30 #include "url/third_party/mozilla/url_parse.h" |
| 31 #include "url/url_canon.h" | 31 #include "url/url_canon.h" |
| 32 #include "wtf/Allocator.h" | 32 #include "wtf/Allocator.h" |
| 33 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
| 34 #include "wtf/HashTableDeletedValueType.h" | 34 #include "wtf/HashTableDeletedValueType.h" |
| 35 #include "wtf/text/WTFString.h" | 35 #include "wtf/text/WTFString.h" |
| 36 #include <memory> | 36 #include <memory> |
| 37 | 37 |
| 38 namespace WTF { | 38 namespace WTF { |
| 39 class TextEncoding; | 39 class TextEncoding; |
| 40 } | 40 } |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 struct KURLHash; | 44 struct KURLHash; |
| 45 | 45 |
| 46 enum ParsedURLStringTag { ParsedURLString }; | 46 enum ParsedURLStringTag { ParsedURLString }; |
| 47 | 47 |
| 48 class PLATFORM_EXPORT KURL { | 48 class ORIGIN_EXPORT KURL { |
| 49 USING_FAST_MALLOC(KURL); | 49 USING_FAST_MALLOC(KURL); |
| 50 public: | 50 public: |
| 51 // This must be called during initialization (before we create | 51 // This must be called during initialization (before we create |
| 52 // other threads). | 52 // other threads). |
| 53 static void initialize(); | 53 static void initialize(); |
| 54 | 54 |
| 55 KURL(); | 55 KURL(); |
| 56 KURL(const KURL&); | 56 KURL(const KURL&); |
| 57 KURL& operator=(const KURL&); | 57 KURL& operator=(const KURL&); |
| 58 | 58 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 void setPath(const String&); | 160 void setPath(const String&); |
| 161 | 161 |
| 162 // The query may begin with a question mark, or, if not, one will be added | 162 // The query may begin with a question mark, or, if not, one will be added |
| 163 // for you. Setting the query to the empty string will leave a "?" in the | 163 // for you. Setting the query to the empty string will leave a "?" in the |
| 164 // URL (with nothing after it). To clear the query, pass a null string. | 164 // URL (with nothing after it). To clear the query, pass a null string. |
| 165 void setQuery(const String&); | 165 void setQuery(const String&); |
| 166 | 166 |
| 167 void setFragmentIdentifier(const String&); | 167 void setFragmentIdentifier(const String&); |
| 168 void removeFragmentIdentifier(); | 168 void removeFragmentIdentifier(); |
| 169 | 169 |
| 170 PLATFORM_EXPORT friend bool equalIgnoringFragmentIdentifier(const KURL&, con
st KURL&); | 170 ORIGIN_EXPORT friend bool equalIgnoringFragmentIdentifier(const KURL&, const
KURL&); |
| 171 | 171 |
| 172 unsigned hostStart() const; | 172 unsigned hostStart() const; |
| 173 unsigned hostEnd() const; | 173 unsigned hostEnd() const; |
| 174 | 174 |
| 175 unsigned pathStart() const; | 175 unsigned pathStart() const; |
| 176 unsigned pathEnd() const; | 176 unsigned pathEnd() const; |
| 177 unsigned pathAfterLastSlash() const; | 177 unsigned pathAfterLastSlash() const; |
| 178 | 178 |
| 179 operator const String&() const { return getString(); } | 179 operator const String&() const { return getString(); } |
| 180 | 180 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 198 void initInnerURL(); | 198 void initInnerURL(); |
| 199 void initProtocolIsInHTTPFamily(); | 199 void initProtocolIsInHTTPFamily(); |
| 200 | 200 |
| 201 bool m_isValid; | 201 bool m_isValid; |
| 202 bool m_protocolIsInHTTPFamily; | 202 bool m_protocolIsInHTTPFamily; |
| 203 url::Parsed m_parsed; | 203 url::Parsed m_parsed; |
| 204 String m_string; | 204 String m_string; |
| 205 std::unique_ptr<KURL> m_innerURL; | 205 std::unique_ptr<KURL> m_innerURL; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 PLATFORM_EXPORT bool operator==(const KURL&, const KURL&); | 208 ORIGIN_EXPORT bool operator==(const KURL&, const KURL&); |
| 209 PLATFORM_EXPORT bool operator==(const KURL&, const String&); | 209 ORIGIN_EXPORT bool operator==(const KURL&, const String&); |
| 210 PLATFORM_EXPORT bool operator==(const String&, const KURL&); | 210 ORIGIN_EXPORT bool operator==(const String&, const KURL&); |
| 211 PLATFORM_EXPORT bool operator!=(const KURL&, const KURL&); | 211 ORIGIN_EXPORT bool operator!=(const KURL&, const KURL&); |
| 212 PLATFORM_EXPORT bool operator!=(const KURL&, const String&); | 212 ORIGIN_EXPORT bool operator!=(const KURL&, const String&); |
| 213 PLATFORM_EXPORT bool operator!=(const String&, const KURL&); | 213 ORIGIN_EXPORT bool operator!=(const String&, const KURL&); |
| 214 | 214 |
| 215 PLATFORM_EXPORT bool equalIgnoringFragmentIdentifier(const KURL&, const KURL&); | 215 ORIGIN_EXPORT bool equalIgnoringFragmentIdentifier(const KURL&, const KURL&); |
| 216 | 216 |
| 217 PLATFORM_EXPORT const KURL& blankURL(); | 217 ORIGIN_EXPORT const KURL& blankURL(); |
| 218 PLATFORM_EXPORT const KURL& srcdocURL(); | 218 ORIGIN_EXPORT const KURL& srcdocURL(); |
| 219 | 219 |
| 220 // Functions to do URL operations on strings. | 220 // Functions to do URL operations on strings. |
| 221 // These are operations that aren't faster on a parsed URL. | 221 // These are operations that aren't faster on a parsed URL. |
| 222 // These are also different from the KURL functions in that they don't require t
he string to be a valid and parsable URL. | 222 // These are also different from the KURL functions in that they don't require t
he string to be a valid and parsable URL. |
| 223 // This is especially important because valid javascript URLs are not necessaril
y considered valid by KURL. | 223 // This is especially important because valid javascript URLs are not necessaril
y considered valid by KURL. |
| 224 | 224 |
| 225 PLATFORM_EXPORT bool protocolIs(const String& url, const char* protocol); | 225 ORIGIN_EXPORT bool protocolIs(const String& url, const char* protocol); |
| 226 PLATFORM_EXPORT bool protocolIsJavaScript(const String& url); | 226 ORIGIN_EXPORT bool protocolIsJavaScript(const String& url); |
| 227 | 227 |
| 228 PLATFORM_EXPORT bool isValidProtocol(const String&); | 228 ORIGIN_EXPORT bool isValidProtocol(const String&); |
| 229 | 229 |
| 230 // Unescapes the given string using URL escaping rules, given an optional | 230 // Unescapes the given string using URL escaping rules, given an optional |
| 231 // encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00" | 231 // encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00" |
| 232 // in it, the resulting string will have embedded null characters! | 232 // in it, the resulting string will have embedded null characters! |
| 233 PLATFORM_EXPORT String decodeURLEscapeSequences(const String&); | 233 ORIGIN_EXPORT String decodeURLEscapeSequences(const String&); |
| 234 PLATFORM_EXPORT String decodeURLEscapeSequences(const String&, const WTF::TextEn
coding&); | 234 ORIGIN_EXPORT String decodeURLEscapeSequences(const String&, const WTF::TextEnco
ding&); |
| 235 | 235 |
| 236 PLATFORM_EXPORT String encodeWithURLEscapeSequences(const String&); | 236 ORIGIN_EXPORT String encodeWithURLEscapeSequences(const String&); |
| 237 | 237 |
| 238 // Inlines. | 238 // Inlines. |
| 239 | 239 |
| 240 inline bool operator==(const KURL& a, const KURL& b) | 240 inline bool operator==(const KURL& a, const KURL& b) |
| 241 { | 241 { |
| 242 return a.getString() == b.getString(); | 242 return a.getString() == b.getString(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 inline bool operator==(const KURL& a, const String& b) | 245 inline bool operator==(const KURL& a, const String& b) |
| 246 { | 246 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 272 namespace WTF { | 272 namespace WTF { |
| 273 | 273 |
| 274 // KURLHash is the default hash for String | 274 // KURLHash is the default hash for String |
| 275 template<> struct DefaultHash<blink::KURL> { | 275 template<> struct DefaultHash<blink::KURL> { |
| 276 typedef blink::KURLHash Hash; | 276 typedef blink::KURLHash Hash; |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 } // namespace WTF | 279 } // namespace WTF |
| 280 | 280 |
| 281 #endif // KURL_h | 281 #endif // KURL_h |
| OLD | NEW |