@@ -148,113 +148,41 @@ index cd593a24af4fe24ba59577b73b26947765edcc32..1f7a04d72065dbd60761c1a72f3254f9
148
148
return;
149
149
}
150
150
diff --git a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
151
- index 038cb646d31706905deff8935040d63c0afd00f9..2fca7b043f15a8cce3819cc827912fb719a345db 100644
151
+ index 038cb646d31706905deff8935040d63c0afd00f9..54bf8bf6aba07039109f61369b5e441eee0ba184 100644
152
152
--- a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
153
153
+++ b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.cpp
154
154
@@ -102,7 +102,7 @@ void BackendDispatcher::registerDispatcherForDomain(const String& domain, Supple
155
155
m_dispatchers.set(domain, dispatcher);
156
156
}
157
157
158
158
-void BackendDispatcher::dispatch(const String& message)
159
- +BackendDispatcher::DispatchResult BackendDispatcher::dispatch(const String& message, Mode mode , Interceptor&& interceptor)
159
+ +void BackendDispatcher::dispatch(const String& message, Interceptor&& interceptor)
160
160
{
161
161
Ref<BackendDispatcher> protect(*this);
162
162
163
- @@ -120,29 +120,32 @@ void BackendDispatcher::dispatch(const String& message)
164
- if (!JSON::Value::parseJSON(message, parsedMessage)) {
165
- reportProtocolError(ParseError, "Message must be in JSON format"_s);
166
- sendPendingErrors();
167
- - return;
168
- + return DispatchResult::Finished;
169
- }
170
-
171
- if (!parsedMessage->asObject(messageObject)) {
172
- reportProtocolError(InvalidRequest, "Message must be a JSONified object"_s);
173
- sendPendingErrors();
174
- - return;
175
- + return DispatchResult::Finished;
176
- }
177
-
178
- RefPtr<JSON::Value> requestIdValue;
179
- if (!messageObject->getValue("id"_s, requestIdValue)) {
180
- reportProtocolError(InvalidRequest, "'id' property was not found"_s);
181
- sendPendingErrors();
182
- - return;
183
- + return DispatchResult::Finished;
184
- }
185
-
186
- if (!requestIdValue->asInteger(requestId)) {
187
- reportProtocolError(InvalidRequest, "The type of 'id' property must be integer"_s);
188
- sendPendingErrors();
189
- - return;
190
- + return DispatchResult::Finished;
163
+ @@ -143,6 +143,9 @@ void BackendDispatcher::dispatch(const String& message)
191
164
}
192
165
}
193
166
194
- + if (interceptor && interceptor(messageObject) == DispatchResult::Finished )
195
- + return DispatchResult::Finished ;
167
+ + if (interceptor && interceptor(messageObject) == InterceptionResult::Intercepted )
168
+ + return;
196
169
+
197
170
{
198
171
// We could be called re-entrantly from a nested run loop, so restore the previous id.
199
172
SetForScope<Optional<long>> scopedRequestId(m_currentRequestId, requestId);
200
- @@ -151,29 +154,31 @@ void BackendDispatcher::dispatch(const String& message)
201
- if (!messageObject->getValue("method"_s, methodValue)) {
202
- reportProtocolError(InvalidRequest, "'method' property wasn't found"_s);
203
- sendPendingErrors();
204
- - return;
205
- + return DispatchResult::Finished;
206
- }
207
-
208
- String methodString;
209
- if (!methodValue->asString(methodString)) {
210
- reportProtocolError(InvalidRequest, "The type of 'method' property must be string"_s);
211
- sendPendingErrors();
212
- - return;
213
- + return DispatchResult::Finished;
214
- }
215
-
216
- Vector<String> domainAndMethod = methodString.splitAllowingEmptyEntries('.');
217
- if (domainAndMethod.size() != 2 || !domainAndMethod[0].length() || !domainAndMethod[1].length()) {
218
- reportProtocolError(InvalidRequest, "The 'method' property was formatted incorrectly. It should be 'Domain.method'"_s);
219
- sendPendingErrors();
220
- - return;
221
- + return DispatchResult::Finished;
222
- }
223
-
224
- String domain = domainAndMethod[0];
225
- SupplementalBackendDispatcher* domainDispatcher = m_dispatchers.get(domain);
226
- if (!domainDispatcher) {
227
- + if (mode == Mode::ContinueIfDomainIsMissing)
228
- + return DispatchResult::Continue;
229
- reportProtocolError(MethodNotFound, "'" + domain + "' domain was not found");
230
- sendPendingErrors();
231
- - return;
232
- + return DispatchResult::Finished;
233
- }
234
-
235
- String method = domainAndMethod[1];
236
- @@ -182,6 +187,7 @@ void BackendDispatcher::dispatch(const String& message)
237
- if (m_protocolErrors.size())
238
- sendPendingErrors();
239
- }
240
- + return DispatchResult::Finished;
241
- }
242
-
243
- // FIXME: remove this function when legacy InspectorObject symbols are no longer needed <http://webkit.org/b/179847>.
244
173
diff --git a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h
245
- index 95d9d81188e735e8f1b70cc0deee2682cb6714f0..4c67ce34302f74e0d07f64ae53a4eaf18df6669a 100644
174
+ index 95d9d81188e735e8f1b70cc0deee2682cb6714f0..fbab25a07bf35c49faf026a3dfaccd50f50d1ab8 100644
246
175
--- a/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h
247
176
+++ b/Source/JavaScriptCore/inspector/InspectorBackendDispatcher.h
248
- @@ -82,7 +82,11 @@ public:
177
+ @@ -82,7 +82,10 @@ public:
249
178
};
250
179
251
180
void registerDispatcherForDomain(const String& domain, SupplementalBackendDispatcher*);
252
181
- void dispatch(const String& message);
253
182
+
254
- + enum class DispatchResult { Finished, Continue };
255
- + enum class Mode { FailIfDomainIsMissing, ContinueIfDomainIsMissing };
256
- + using Interceptor = WTF::Function<DispatchResult(const RefPtr<JSON::Object>&)>;
257
- + DispatchResult dispatch(const String& message, Mode mode = Mode::FailIfDomainIsMissing, Interceptor&& interceptor = Interceptor());
183
+ + enum class InterceptionResult { Intercepted, Continue };
184
+ + using Interceptor = WTF::Function<InterceptionResult(const RefPtr<JSON::Object>&)>;
185
+ + void dispatch(const String& message, Interceptor&& interceptor = Interceptor());
258
186
259
187
// Note that 'unused' is a workaround so the compiler can pick the right sendResponse based on arity.
260
188
// When <http://webkit.org/b/179847> is fixed or this class is renamed for the JSON::Object case,
@@ -7657,7 +7585,7 @@ index 23b992f3ce45f82f0dcdede6007a2e3a46b7b0b6..7e711e8f5132931e01eac66db6ea60c3
7657
7585
// This reuses the basename of the remote file path so that the filename exposed to DOM API remains the same.
7658
7586
diff --git a/Source/WebKit/UIProcess/BrowserInspectorController.cpp b/Source/WebKit/UIProcess/BrowserInspectorController.cpp
7659
7587
new file mode 100644
7660
- index 0000000000000000000000000000000000000000..300be76e7926ac5eb435ab62df1a973f04520327
7588
+ index 0000000000000000000000000000000000000000..df23f11858e6e60ca238793fe3f37cf19036fbee
7661
7589
--- /dev/null
7662
7590
+++ b/Source/WebKit/UIProcess/BrowserInspectorController.cpp
7663
7591
@@ -0,0 +1,244 @@
@@ -7818,27 +7746,27 @@ index 0000000000000000000000000000000000000000..300be76e7926ac5eb435ab62df1a973f
7818
7746
+
7819
7747
+void BrowserInspectorController::dispatchMessageFromFrontend(const String& message)
7820
7748
+{
7821
- + m_backendDispatcher->dispatch(message, BackendDispatcher::Mode::FailIfDomainIsMissing, [&](const RefPtr<JSON::Object>& messageObject) {
7749
+ + m_backendDispatcher->dispatch(message, [&](const RefPtr<JSON::Object>& messageObject) {
7822
7750
+ RefPtr<JSON::Value> pageProxyIDValue;
7823
7751
+ if (!messageObject->getValue("pageProxyId"_s, pageProxyIDValue))
7824
- + return BackendDispatcher::DispatchResult ::Continue;
7752
+ + return BackendDispatcher::InterceptionResult ::Continue;
7825
7753
+
7826
7754
+ String pageProxyID;
7827
7755
+ if (!pageProxyIDValue->asString(pageProxyID)) {
7828
7756
+ m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidRequest, "The type of 'pageProxyId' must be string"_s);
7829
7757
+ m_backendDispatcher->sendPendingErrors();
7830
- + return BackendDispatcher::DispatchResult::Finished ;
7758
+ + return BackendDispatcher::InterceptionResult::Intercepted ;
7831
7759
+ }
7832
7760
+
7833
7761
+
7834
7762
+ if (auto pageProxyChannel = m_pageProxyChannels.get(pageProxyID)) {
7835
7763
+ pageProxyChannel->dispatchMessageFromFrontend(message);
7836
- + return BackendDispatcher::DispatchResult::Finished ;
7764
+ + return BackendDispatcher::InterceptionResult::Intercepted ;
7837
7765
+ }
7838
7766
+
7839
7767
+ m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidRequest, "Cannot find page proxy with provided 'pageProxyId'"_s);
7840
7768
+ m_backendDispatcher->sendPendingErrors();
7841
- + return BackendDispatcher::DispatchResult::Finished ;
7769
+ + return BackendDispatcher::InterceptionResult::Intercepted ;
7842
7770
+ });
7843
7771
+}
7844
7772
+
@@ -8716,7 +8644,7 @@ index 0000000000000000000000000000000000000000..b5eeeca0f6b8c5c31e3786c0a675e322
8716
8644
+
8717
8645
+} // namespace WebKit
8718
8646
diff --git a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp
8719
- index 6928ca2fbfb6939062e3cd14bb7ba6f2fdc87f5f..c4645302296540a408aa88dabb64fd5e9a04f3f7 100644
8647
+ index 6928ca2fbfb6939062e3cd14bb7ba6f2fdc87f5f..621b99e233ed5cf504fedbd3ca3209c03bcd611f 100644
8720
8648
--- a/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp
8721
8649
+++ b/Source/WebKit/UIProcess/Inspector/InspectorTargetProxy.cpp
8722
8650
@@ -27,11 +27,10 @@
@@ -8756,17 +8684,7 @@ index 6928ca2fbfb6939062e3cd14bb7ba6f2fdc87f5f..c4645302296540a408aa88dabb64fd5e
8756
8684
, m_identifier(targetId)
8757
8685
, m_type(type)
8758
8686
{
8759
- @@ -83,6 +81,9 @@ void InspectorTargetProxy::disconnect()
8760
-
8761
- void InspectorTargetProxy::sendMessageToTargetBackend(const String& message)
8762
- {
8763
- + if (m_page.inspectorController().dispatchMessageToTargetBackend(message))
8764
- + return;
8765
- +
8766
- if (m_provisionalPage) {
8767
- m_provisionalPage->send(Messages::WebPage::SendMessageToTargetBackend(identifier(), message));
8768
- return;
8769
- @@ -97,6 +98,31 @@ void InspectorTargetProxy::didCommitProvisionalTarget()
8687
+ @@ -97,6 +95,31 @@ void InspectorTargetProxy::didCommitProvisionalTarget()
8770
8688
m_provisionalPage = nullptr;
8771
8689
}
8772
8690
@@ -8839,7 +8757,7 @@ index a2239cec8e18850f35f7f88a9c4ebadc62bf4023..79f3ff84327dc075ec96983e04db4b10
8839
8757
8840
8758
} // namespace WebKit
8841
8759
diff --git a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
8842
- index 1861cff806131196ea49b4f8aca6665beebbf6e8..7287fd4bbc06a5791190454bedf02190fe98d2ae 100644
8760
+ index 1861cff806131196ea49b4f8aca6665beebbf6e8..521ef88239d5db7274cd19cd4258581464081f92 100644
8843
8761
--- a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
8844
8762
+++ b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
8845
8763
@@ -26,12 +26,20 @@
@@ -9009,19 +8927,7 @@ index 1861cff806131196ea49b4f8aca6665beebbf6e8..7287fd4bbc06a5791190454bedf02190
9009
8927
m_page.didChangeInspectorFrontendCount(m_frontendRouter->frontendCount());
9010
8928
9011
8929
#if ENABLE(REMOTE_INSPECTOR)
9012
- @@ -136,6 +235,11 @@ void WebPageInspectorController::dispatchMessageFromFrontend(const String& messa
9013
- m_backendDispatcher->dispatch(message);
9014
- }
9015
-
9016
- +bool WebPageInspectorController::dispatchMessageToTargetBackend(const String& message)
9017
- +{
9018
- + return m_backendDispatcher->dispatch(message, BackendDispatcher::Mode::ContinueIfDomainIsMissing) == BackendDispatcher::DispatchResult::Finished;
9019
- +}
9020
- +
9021
- #if ENABLE(REMOTE_INSPECTOR)
9022
- void WebPageInspectorController::setIndicating(bool indicating)
9023
- {
9024
- @@ -150,6 +254,55 @@ void WebPageInspectorController::setIndicating(bool indicating)
8930
+ @@ -150,6 +249,55 @@ void WebPageInspectorController::setIndicating(bool indicating)
9025
8931
}
9026
8932
#endif
9027
8933
@@ -9077,7 +8983,7 @@ index 1861cff806131196ea49b4f8aca6665beebbf6e8..7287fd4bbc06a5791190454bedf02190
9077
8983
void WebPageInspectorController::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type)
9078
8984
{
9079
8985
addTarget(InspectorTargetProxy::create(m_page, targetId, type));
9080
- @@ -169,6 +322 ,33 @@ void WebPageInspectorController::sendMessageToInspectorFrontend(const String& ta
8986
+ @@ -169,6 +317 ,33 @@ void WebPageInspectorController::sendMessageToInspectorFrontend(const String& ta
9081
8987
m_targetAgent->sendMessageFromTargetToFrontend(targetId, message);
9082
8988
}
9083
8989
@@ -9111,7 +9017,7 @@ index 1861cff806131196ea49b4f8aca6665beebbf6e8..7287fd4bbc06a5791190454bedf02190
9111
9017
bool WebPageInspectorController::shouldPauseLoading(const ProvisionalPageProxy& provisionalPage) const
9112
9018
{
9113
9019
if (!m_frontendRouter->hasFrontends())
9114
- @@ -188,7 +368 ,7 @@ void WebPageInspectorController::setContinueLoadingCallback(const ProvisionalPag
9020
+ @@ -188,7 +363 ,7 @@ void WebPageInspectorController::setContinueLoadingCallback(const ProvisionalPag
9115
9021
9116
9022
void WebPageInspectorController::didCreateProvisionalPage(ProvisionalPageProxy& provisionalPage)
9117
9023
{
@@ -9120,7 +9026,7 @@ index 1861cff806131196ea49b4f8aca6665beebbf6e8..7287fd4bbc06a5791190454bedf02190
9120
9026
}
9121
9027
9122
9028
void WebPageInspectorController::willDestroyProvisionalPage(const ProvisionalPageProxy& provisionalPage)
9123
- @@ -241,4 +421 ,20 @@ void WebPageInspectorController::addTarget(std::unique_ptr<InspectorTargetProxy>
9029
+ @@ -241,4 +416 ,20 @@ void WebPageInspectorController::addTarget(std::unique_ptr<InspectorTargetProxy>
9124
9030
m_targets.set(target->identifier(), WTFMove(target));
9125
9031
}
9126
9032
@@ -9142,7 +9048,7 @@ index 1861cff806131196ea49b4f8aca6665beebbf6e8..7287fd4bbc06a5791190454bedf02190
9142
9048
+
9143
9049
} // namespace WebKit
9144
9050
diff --git a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
9145
- index 9ce5ef36b652fd56a843c1d12a4c3c3cf639282c..9b6a239b6db52a55f693654ed65d89dff8dd0ffb 100644
9051
+ index 9ce5ef36b652fd56a843c1d12a4c3c3cf639282c..bb4d6b26bf245aebc2bd0f435a7bb83151331961 100644
9146
9052
--- a/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
9147
9053
+++ b/Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
9148
9054
@@ -26,17 +26,27 @@
@@ -9215,13 +9121,7 @@ index 9ce5ef36b652fd56a843c1d12a4c3c3cf639282c..9b6a239b6db52a55f693654ed65d89df
9215
9121
9216
9122
bool hasLocalFrontend() const;
9217
9123
9218
- @@ -60,15 +97,28 @@ public:
9219
- void disconnectAllFrontends();
9220
-
9221
- void dispatchMessageFromFrontend(const String& message);
9222
- + bool dispatchMessageToTargetBackend(const String&);
9223
-
9224
- #if ENABLE(REMOTE_INSPECTOR)
9124
+ @@ -65,10 +102,22 @@ public:
9225
9125
void setIndicating(bool);
9226
9126
#endif
9227
9127
@@ -9244,15 +9144,15 @@ index 9ce5ef36b652fd56a843c1d12a4c3c3cf639282c..9b6a239b6db52a55f693654ed65d89df
9244
9144
bool shouldPauseLoading(const ProvisionalPageProxy&) const;
9245
9145
void setContinueLoadingCallback(const ProvisionalPageProxy&, WTF::Function<void()>&&);
9246
9146
9247
- @@ -84,6 +134 ,7 @@ private:
9147
+ @@ -84,6 +133 ,7 @@ private:
9248
9148
void createLazyAgents();
9249
9149
9250
9150
void addTarget(std::unique_ptr<InspectorTargetProxy>&&);
9251
9151
+ void adjustPageSettings();
9252
9152
9253
9153
Ref<Inspector::FrontendRouter> m_frontendRouter;
9254
9154
Ref<Inspector::BackendDispatcher> m_backendDispatcher;
9255
- @@ -92,11 +143 ,16 @@ private:
9155
+ @@ -92,11 +142 ,16 @@ private:
9256
9156
WebPageProxy& m_page;
9257
9157
9258
9158
Inspector::InspectorTargetAgent* m_targetAgent;
0 commit comments