OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef URLSearchParams_h | 5 #ifndef URLSearchParams_h |
6 #define URLSearchParams_h | 6 #define URLSearchParams_h |
7 | 7 |
8 #include "bindings/core/v8/Iterable.h" | 8 #include "bindings/core/v8/Iterable.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "bindings/core/v8/UnionTypesCore.h" | 10 #include "bindings/core/v8/UnionTypesCore.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "platform/network/EncodedFormData.h" | 12 #include "platform/network/EncodedFormData.h" |
13 #include "wtf/Forward.h" | 13 #include "wtf/Forward.h" |
14 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
15 #include <base/gtest_prod_util.h> | 15 #include <base/gtest_prod_util.h> |
16 #include <utility> | 16 #include <utility> |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class ExceptionState; | 20 class ExceptionState; |
| 21 class DOMURL; |
21 | 22 |
22 typedef USVStringOrURLSearchParams URLSearchParamsInit; | 23 typedef USVStringOrURLSearchParams URLSearchParamsInit; |
23 | 24 |
24 class CORE_EXPORT URLSearchParams final : public GarbageCollectedFinalized<URLSe
archParams>, public ScriptWrappable, public PairIterable<String, String> { | 25 class CORE_EXPORT URLSearchParams final : public GarbageCollectedFinalized<URLSe
archParams>, public ScriptWrappable, public PairIterable<String, String> { |
25 DEFINE_WRAPPERTYPEINFO(); | 26 DEFINE_WRAPPERTYPEINFO(); |
26 | 27 |
27 public: | 28 public: |
28 // TODO(mkwst): We should support integration with URLUtils, as explored in | |
29 // https://codereview.chromium.org/143313002/. That approach is totally | |
30 // reasonable, but relies on Node switching to Oilpan. Sigbjorn assures me | |
31 // that this will happen Real Soon Now(tm). | |
32 static URLSearchParams* create(const URLSearchParamsInit&); | 29 static URLSearchParams* create(const URLSearchParamsInit&); |
33 | 30 |
34 // TODO(mkwst): ScriptWrappable doesn't have a destructor with Oilpan, so th
is | 31 static URLSearchParams* create(const String& queryString, DOMURL* urlObject
= nullptr) |
35 // won't need to be virtual once that's the default. | 32 { |
36 virtual ~URLSearchParams(); | 33 return new URLSearchParams(queryString, urlObject); |
| 34 } |
| 35 |
| 36 ~URLSearchParams(); |
37 | 37 |
38 // URLSearchParams interface methods | 38 // URLSearchParams interface methods |
39 String toString() const; | 39 String toString() const; |
40 void append(const String& name, const String& value); | 40 void append(const String& name, const String& value); |
41 void deleteAllWithName(const String&); | 41 void deleteAllWithName(const String&); |
42 String get(const String&) const; | 42 String get(const String&) const; |
43 Vector<String> getAll(const String&) const; | 43 Vector<String> getAll(const String&) const; |
44 bool has(const String&) const; | 44 bool has(const String&) const; |
45 void set(const String& name, const String& value); | 45 void set(const String& name, const String& value); |
46 void setInput(const String&); | 46 void setInput(const String&); |
47 | 47 |
48 // Internal helpers | 48 // Internal helpers |
49 PassRefPtr<EncodedFormData> encodeFormData() const; | 49 PassRefPtr<EncodedFormData> encodeFormData() const; |
50 const Vector<std::pair<String, String>>& params() const { return m_params; } | 50 const Vector<std::pair<String, String>>& params() const { return m_params; } |
51 | 51 |
| 52 #if ENABLE(ASSERT) |
| 53 DOMURL* urlObject() const; |
| 54 #endif |
| 55 |
52 DECLARE_TRACE(); | 56 DECLARE_TRACE(); |
53 | 57 |
54 private: | 58 private: |
55 FRIEND_TEST_ALL_PREFIXES(URLSearchParamsTest, EncodedFormData); | 59 FRIEND_TEST_ALL_PREFIXES(URLSearchParamsTest, EncodedFormData); |
56 | 60 |
57 explicit URLSearchParams(const String&); | 61 explicit URLSearchParams(const String&, DOMURL* = nullptr); |
58 explicit URLSearchParams(URLSearchParams*); | 62 explicit URLSearchParams(URLSearchParams*); |
| 63 |
| 64 void runUpdateSteps(); |
| 65 IterationSource* startIteration(ScriptState*, ExceptionState&) override; |
| 66 |
59 Vector<std::pair<String, String>> m_params; | 67 Vector<std::pair<String, String>> m_params; |
60 | 68 |
61 IterationSource* startIteration(ScriptState*, ExceptionState&) override; | 69 Member<DOMURL> m_urlObject; |
| 70 bool m_isUpdating = false; |
62 }; | 71 }; |
63 | 72 |
64 } // namespace blink | 73 } // namespace blink |
65 | 74 |
66 #endif // URLSearchParams_h | 75 #endif // URLSearchParams_h |
OLD | NEW |