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

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: rebase 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
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/loader/FrameFetchContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/loader/FrameFetchContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698