Index: Source/core/inspector/InspectorResourceAgent.cpp |
diff --git a/Source/core/inspector/InspectorResourceAgent.cpp b/Source/core/inspector/InspectorResourceAgent.cpp |
index c15570da9dd94e595674fab1f83bf71d54ee4b47..f41864a7072f3ccce29940d95082f30b3eb9a454 100644 |
--- a/Source/core/inspector/InspectorResourceAgent.cpp |
+++ b/Source/core/inspector/InspectorResourceAgent.cpp |
@@ -86,6 +86,7 @@ static const char extraRequestHeaders[] = "extraRequestHeaders"; |
static const char cacheDisabled[] = "cacheDisabled"; |
static const char userAgentOverride[] = "userAgentOverride"; |
static const char monitoringXHR[] = "monitoringXHR"; |
+static const char blockedURLs[] = "blockedURLs"; |
} |
namespace { |
@@ -365,6 +366,17 @@ DEFINE_TRACE(InspectorResourceAgent) |
InspectorBaseAgent::trace(visitor); |
} |
+bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) |
+{ |
+ String url = request.url().string(); |
+ RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); |
+ for (const auto& blocked : *blockedURLs) { |
+ if (url.contains(blocked.key)) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
void InspectorResourceAgent::willSendRequest(LocalFrame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) |
{ |
// Ignore the request initiated internally. |
@@ -882,6 +894,20 @@ void InspectorResourceAgent::getResponseBody(ErrorString* errorString, const Str |
callback->sendFailure("No data found for resource with given identifier"); |
} |
+void InspectorResourceAgent::addBlockedURL(ErrorString*, const String& url) |
+{ |
+ RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); |
+ blockedURLs->setBoolean(url, true); |
+ m_state->setObject(ResourceAgentState::blockedURLs, blockedURLs.release()); |
+} |
+ |
+void InspectorResourceAgent::removeBlockedURL(ErrorString*, const String& url) |
+{ |
+ RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); |
+ blockedURLs->remove(url); |
+ m_state->setObject(ResourceAgentState::blockedURLs, blockedURLs.release()); |
+} |
+ |
void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId) |
{ |
String actualRequestId = requestId; |