Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: Source/core/inspector/InspectorResourceAgent.cpp

Issue 1295903005: [DevTools] Implementation of resource requests blocked by specific urls. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorResourceAgent.cpp
diff --git a/Source/core/inspector/InspectorResourceAgent.cpp b/Source/core/inspector/InspectorResourceAgent.cpp
index 1abfe5b54ab4cc72f619e7984b4a85ad11c79634..da00709a67fb7c85620e7a26b85b737f455ecc28 100644
--- a/Source/core/inspector/InspectorResourceAgent.cpp
+++ b/Source/core/inspector/InspectorResourceAgent.cpp
@@ -85,6 +85,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 {
@@ -349,6 +350,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(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo)
{
// Ignore the request initiated internally.
@@ -864,6 +876,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;

Powered by Google App Engine
This is Rietveld 408576698