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

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

Issue 1315043008: [DevTools] Show blocked requests in Network panel. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 3 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.h » ('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 e5c6833f0bd03293ec698e2c7b1712e56950ac6a..8aec85c9d0b3695925377e18911f1eced012a139 100644
--- a/Source/core/inspector/InspectorResourceAgent.cpp
+++ b/Source/core/inspector/InspectorResourceAgent.cpp
@@ -208,6 +208,25 @@ TypeBuilder::Network::ResourcePriority::Enum resourcePriorityJSON(ResourceLoadPr
return TypeBuilder::Network::ResourcePriority::Medium;
}
+TypeBuilder::Network::BlockedReason::Enum buildBlockedReason(ResourceRequestBlockedReason reason)
+{
+ switch (reason) {
+ case ResourceRequestBlockedReasonCSP:
+ return TypeBuilder::Network::BlockedReason::Enum::Csp;
+ case ResourceRequestBlockedReasonMixedContent:
+ return TypeBuilder::Network::BlockedReason::Enum::Mixed_content;
+ case ResourceRequestBlockedReasonOrigin:
+ return TypeBuilder::Network::BlockedReason::Enum::Origin;
+ case ResourceRequestBlockedReasonInspector:
+ return TypeBuilder::Network::BlockedReason::Enum::Inspector;
+ case ResourceRequestBlockedReasonOther:
+ return TypeBuilder::Network::BlockedReason::Enum::Other;
+ case ResourceRequestBlockedReasonNone:
+ default:
+ ASSERT_NOT_REACHED();
+ return TypeBuilder::Network::BlockedReason::Enum::Other;
+ }
+}
} // namespace
@@ -383,24 +402,27 @@ DEFINE_TRACE(InspectorResourceAgent)
InspectorBaseAgent::trace(visitor);
}
-bool InspectorResourceAgent::shouldBlockRequest(LocalFrame* frame, const ResourceRequest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo)
+bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request)
{
String url = request.url().string();
RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs);
for (const auto& entry : *blockedURLs) {
- if (url.contains(entry.key)) {
- unsigned long identifier = createUniqueIdentifier();
- willSendRequestInternal(frame, identifier, loader, request, ResourceResponse(), initiatorInfo);
-
- String requestId = IdentifiersFactory::requestId(identifier);
- bool blocked = true;
- frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), InspectorPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String(), nullptr, &blocked);
+ if (url.contains(entry.key))
return true;
- }
}
return false;
}
+void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRequest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo, ResourceRequestBlockedReason reason)
+{
+ unsigned long identifier = createUniqueIdentifier();
+ willSendRequestInternal(frame, identifier, loader, request, ResourceResponse(), initiatorInfo);
+
+ String requestId = IdentifiersFactory::requestId(identifier);
+ TypeBuilder::Network::BlockedReason::Enum protocolReason = buildBlockedReason(reason);
+ frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), InspectorPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String(), nullptr, &protocolReason);
+}
+
void InspectorResourceAgent::willSendRequestInternal(LocalFrame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo)
{
String requestId = IdentifiersFactory::requestId(identifier);
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/loader/FrameFetchContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698