OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Motorola Mobility Inc. | 3 * Copyright (C) 2012 Motorola Mobility Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 12 matching lines...) Expand all Loading... | |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/dom/DOMURL.h" | 27 #include "core/dom/DOMURL.h" |
28 | 28 |
29 #include "bindings/core/v8/ExceptionMessages.h" | 29 #include "bindings/core/v8/ExceptionMessages.h" |
30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
32 #include "core/dom/ExecutionContext.h" | 32 #include "core/dom/ExecutionContext.h" |
33 #include "core/dom/URLSearchParams.h" | |
33 #include "core/fetch/MemoryCache.h" | 34 #include "core/fetch/MemoryCache.h" |
34 #include "core/fileapi/Blob.h" | 35 #include "core/fileapi/Blob.h" |
35 #include "core/html/PublicURLManager.h" | 36 #include "core/html/PublicURLManager.h" |
36 #include "platform/blob/BlobURL.h" | 37 #include "platform/blob/BlobURL.h" |
37 #include "platform/weborigin/SecurityOrigin.h" | 38 #include "platform/weborigin/SecurityOrigin.h" |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionSta te) | 42 DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionSta te) |
42 { | 43 { |
43 if (!base.isValid()) | 44 if (!base.isValid()) { |
44 exceptionState.throwTypeError("Invalid base URL"); | 45 exceptionState.throwTypeError("Invalid base URL"); |
46 return; | |
47 } | |
Mike West
2016/04/05 12:43:51
Whoops! Nice catch. Is there a test for this?
sof
2016/04/05 15:23:18
The final test in url-constructor.html
| |
45 | 48 |
46 m_url = KURL(base, url); | 49 m_url = KURL(base, url); |
47 if (!m_url.isValid()) | 50 if (!m_url.isValid()) |
48 exceptionState.throwTypeError("Invalid URL"); | 51 exceptionState.throwTypeError("Invalid URL"); |
49 } | 52 } |
50 | 53 |
54 DEFINE_TRACE(DOMURL) | |
55 { | |
56 visitor->trace(m_searchParams); | |
57 } | |
58 | |
51 void DOMURL::setInput(const String& value) | 59 void DOMURL::setInput(const String& value) |
52 { | 60 { |
53 KURL url(blankURL(), value); | 61 KURL url(blankURL(), value); |
54 if (url.isValid()) { | 62 if (url.isValid()) { |
55 m_url = url; | 63 m_url = url; |
56 m_input = String(); | 64 m_input = String(); |
57 } else { | 65 } else { |
58 m_url = KURL(); | 66 m_url = KURL(); |
59 m_input = value; | 67 m_input = value; |
60 } | 68 } |
69 update(); | |
70 } | |
71 | |
72 void DOMURL::setSearch(const String& value) | |
73 { | |
74 DOMURLUtils::setSearch(value); | |
75 if (!value.isEmpty() && value[0] == '?') | |
Mike West
2016/04/05 12:43:51
Nit: It might make sense to move this check into `
sof
2016/04/05 15:23:18
That won't quite work if you set url.href with som
| |
76 updateSearchParams(value.substring(1)); | |
77 else | |
78 updateSearchParams(value); | |
61 } | 79 } |
62 | 80 |
63 String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, E xceptionState& exceptionState) | 81 String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, E xceptionState& exceptionState) |
64 { | 82 { |
65 ASSERT(blob); | 83 ASSERT(blob); |
66 if (!executionContext) | 84 if (!executionContext) |
67 return String(); | 85 return String(); |
68 if (blob->hasBeenClosed()) { | 86 if (blob->hasBeenClosed()) { |
69 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile( ) ? "File" : "Blob") + " has been closed."); | 87 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile( ) ? "File" : "Blob") + " has been closed."); |
70 return String(); | 88 return String(); |
(...skipping 23 matching lines...) Expand all Loading... | |
94 } | 112 } |
95 | 113 |
96 void DOMURL::revokeObjectUUID(ExecutionContext* executionContext, const String& uuid) | 114 void DOMURL::revokeObjectUUID(ExecutionContext* executionContext, const String& uuid) |
97 { | 115 { |
98 if (!executionContext) | 116 if (!executionContext) |
99 return; | 117 return; |
100 | 118 |
101 executionContext->publicURLManager().revoke(uuid); | 119 executionContext->publicURLManager().revoke(uuid); |
102 } | 120 } |
103 | 121 |
122 URLSearchParams* DOMURL::searchParams() | |
123 { | |
124 if (!m_searchParams) | |
125 m_searchParams = URLSearchParams::create(url().query(), this); | |
126 | |
127 return m_searchParams; | |
128 } | |
129 | |
130 void DOMURL::update() | |
131 { | |
132 updateSearchParams(url().query()); | |
133 } | |
134 | |
135 void DOMURL::updateSearchParams(const String& queryString) | |
136 { | |
137 if (!m_searchParams) | |
138 return; | |
139 | |
140 ASSERT(m_searchParams->urlObject() == this); | |
141 m_searchParams->setInput(queryString); | |
142 } | |
143 | |
104 } // namespace blink | 144 } // namespace blink |
OLD | NEW |