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" |
| 39 #include "wtf/TemporaryChange.h" |
38 | 40 |
39 namespace blink { | 41 namespace blink { |
40 | 42 |
41 DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionSta
te) | 43 DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionSta
te) |
42 { | 44 { |
43 if (!base.isValid()) | 45 if (!base.isValid()) { |
44 exceptionState.throwTypeError("Invalid base URL"); | 46 exceptionState.throwTypeError("Invalid base URL"); |
| 47 return; |
| 48 } |
45 | 49 |
46 m_url = KURL(base, url); | 50 m_url = KURL(base, url); |
47 if (!m_url.isValid()) | 51 if (!m_url.isValid()) |
48 exceptionState.throwTypeError("Invalid URL"); | 52 exceptionState.throwTypeError("Invalid URL"); |
49 } | 53 } |
50 | 54 |
| 55 DOMURL::~DOMURL() |
| 56 { |
| 57 } |
| 58 |
| 59 DEFINE_TRACE(DOMURL) |
| 60 { |
| 61 visitor->trace(m_searchParams); |
| 62 } |
| 63 |
51 void DOMURL::setInput(const String& value) | 64 void DOMURL::setInput(const String& value) |
52 { | 65 { |
53 KURL url(blankURL(), value); | 66 KURL url(blankURL(), value); |
54 if (url.isValid()) { | 67 if (url.isValid()) { |
55 m_url = url; | 68 m_url = url; |
56 m_input = String(); | 69 m_input = String(); |
57 } else { | 70 } else { |
58 m_url = KURL(); | 71 m_url = KURL(); |
59 m_input = value; | 72 m_input = value; |
60 } | 73 } |
| 74 update(); |
| 75 } |
| 76 |
| 77 void DOMURL::setSearch(const String& value) |
| 78 { |
| 79 DOMURLUtils::setSearch(value); |
| 80 if (!value.isEmpty() && value[0] == '?') |
| 81 updateSearchParams(value.substring(1)); |
| 82 else |
| 83 updateSearchParams(value); |
61 } | 84 } |
62 | 85 |
63 String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, E
xceptionState& exceptionState) | 86 String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, E
xceptionState& exceptionState) |
64 { | 87 { |
65 DCHECK(blob); | 88 DCHECK(blob); |
66 if (!executionContext) | 89 if (!executionContext) |
67 return String(); | 90 return String(); |
68 if (blob->hasBeenClosed()) { | 91 if (blob->hasBeenClosed()) { |
69 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile(
) ? "File" : "Blob") + " has been closed."); | 92 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile(
) ? "File" : "Blob") + " has been closed."); |
70 return String(); | 93 return String(); |
(...skipping 23 matching lines...) Expand all Loading... |
94 } | 117 } |
95 | 118 |
96 void DOMURL::revokeObjectUUID(ExecutionContext* executionContext, const String&
uuid) | 119 void DOMURL::revokeObjectUUID(ExecutionContext* executionContext, const String&
uuid) |
97 { | 120 { |
98 if (!executionContext) | 121 if (!executionContext) |
99 return; | 122 return; |
100 | 123 |
101 executionContext->publicURLManager().revoke(uuid); | 124 executionContext->publicURLManager().revoke(uuid); |
102 } | 125 } |
103 | 126 |
| 127 URLSearchParams* DOMURL::searchParams() |
| 128 { |
| 129 if (!m_searchParams) |
| 130 m_searchParams = URLSearchParams::create(url().query(), this); |
| 131 |
| 132 return m_searchParams; |
| 133 } |
| 134 |
| 135 void DOMURL::update() |
| 136 { |
| 137 updateSearchParams(url().query()); |
| 138 } |
| 139 |
| 140 void DOMURL::updateSearchParams(const String& queryString) |
| 141 { |
| 142 if (!m_searchParams) |
| 143 return; |
| 144 |
| 145 TemporaryChange<bool> scope(m_isInUpdate, true); |
| 146 ASSERT(m_searchParams->urlObject() == this); |
| 147 m_searchParams->setInput(queryString); |
| 148 } |
| 149 |
104 } // namespace blink | 150 } // namespace blink |
OLD | NEW |