OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 case MixedContentChecker::ContextTypeBlockable: | 186 case MixedContentChecker::ContextTypeBlockable: |
187 return TypeBuilder::Network::Request::MixedContentType::Blockable; | 187 return TypeBuilder::Network::Request::MixedContentType::Blockable; |
188 case MixedContentChecker::ContextTypeOptionallyBlockable: | 188 case MixedContentChecker::ContextTypeOptionallyBlockable: |
189 case MixedContentChecker::ContextTypeShouldBeBlockable: | 189 case MixedContentChecker::ContextTypeShouldBeBlockable: |
190 return TypeBuilder::Network::Request::MixedContentType::Optionally_block
able; | 190 return TypeBuilder::Network::Request::MixedContentType::Optionally_block
able; |
191 } | 191 } |
192 | 192 |
193 return TypeBuilder::Network::Request::MixedContentType::None; | 193 return TypeBuilder::Network::Request::MixedContentType::None; |
194 } | 194 } |
195 | 195 |
| 196 TypeBuilder::Network::BlockedReason::Enum buildBlockedReason(InspectorRequestBlo
ckedReason reason) |
| 197 { |
| 198 switch (reason) { |
| 199 case InspectorRequestBlockedReasonCSP: |
| 200 return TypeBuilder::Network::BlockedReason::Enum::Csp; |
| 201 case InspectorRequestBlockedReasonMixedContent: |
| 202 return TypeBuilder::Network::BlockedReason::Enum::Mixed_content; |
| 203 case InspectorRequestBlockedReasonOrigin: |
| 204 return TypeBuilder::Network::BlockedReason::Enum::Origin; |
| 205 case InspectorRequestBlockedReasonInspector: |
| 206 return TypeBuilder::Network::BlockedReason::Enum::Inspector; |
| 207 case InspectorRequestBlockedReasonOther: |
| 208 case InspectorRequestBlockedReasonNone: |
| 209 return TypeBuilder::Network::BlockedReason::Enum::Other; |
| 210 } |
| 211 return TypeBuilder::Network::BlockedReason::Enum::Other; |
| 212 } |
| 213 |
196 } // namespace | 214 } // namespace |
197 | 215 |
198 void InspectorResourceAgent::restore() | 216 void InspectorResourceAgent::restore() |
199 { | 217 { |
200 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled)) | 218 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled)) |
201 enable(); | 219 enable(); |
202 } | 220 } |
203 | 221 |
204 static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(con
st ResourceLoadTiming& timing) | 222 static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(con
st ResourceLoadTiming& timing) |
205 { | 223 { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 377 |
360 DEFINE_TRACE(InspectorResourceAgent) | 378 DEFINE_TRACE(InspectorResourceAgent) |
361 { | 379 { |
362 visitor->trace(m_pageAgent); | 380 visitor->trace(m_pageAgent); |
363 visitor->trace(m_replayXHRs); | 381 visitor->trace(m_replayXHRs); |
364 visitor->trace(m_replayXHRsToBeDeleted); | 382 visitor->trace(m_replayXHRsToBeDeleted); |
365 visitor->trace(m_pendingXHRReplayData); | 383 visitor->trace(m_pendingXHRReplayData); |
366 InspectorBaseAgent::trace(visitor); | 384 InspectorBaseAgent::trace(visitor); |
367 } | 385 } |
368 | 386 |
369 bool InspectorResourceAgent::shouldBlockRequest(LocalFrame* frame, const Resourc
eRequest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorIn
fo) | 387 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) |
370 { | 388 { |
371 String url = request.url().string(); | 389 String url = request.url().string(); |
372 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc
kedURLs); | 390 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc
kedURLs); |
373 for (const auto& entry : *blockedURLs) { | 391 for (const auto& entry : *blockedURLs) { |
374 if (url.contains(entry.key)) { | 392 if (url.contains(entry.key)) |
375 unsigned long identifier = createUniqueIdentifier(); | |
376 willSendRequestInternal(frame, identifier, loader, request, Resource
Response(), initiatorInfo); | |
377 | |
378 String requestId = IdentifiersFactory::requestId(identifier); | |
379 bool blocked = true; | |
380 frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(),
InspectorPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)),
String(), nullptr, &blocked); | |
381 return true; | 393 return true; |
382 } | |
383 } | 394 } |
384 return false; | 395 return false; |
385 } | 396 } |
386 | 397 |
| 398 void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRe
quest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo,
InspectorRequestBlockedReason reason) |
| 399 { |
| 400 unsigned long identifier = createUniqueIdentifier(); |
| 401 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse
(), initiatorInfo); |
| 402 |
| 403 String requestId = IdentifiersFactory::requestId(identifier); |
| 404 TypeBuilder::Network::BlockedReason::Enum protocolReason = buildBlockedReaso
n(reason); |
| 405 frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), Inspecto
rPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String()
, nullptr, &protocolReason); |
| 406 } |
| 407 |
387 void InspectorResourceAgent::willSendRequestInternal(LocalFrame* frame, unsigned
long identifier, DocumentLoader* loader, const ResourceRequest& request, const
ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) | 408 void InspectorResourceAgent::willSendRequestInternal(LocalFrame* frame, unsigned
long identifier, DocumentLoader* loader, const ResourceRequest& request, const
ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) |
388 { | 409 { |
389 String requestId = IdentifiersFactory::requestId(identifier); | 410 String requestId = IdentifiersFactory::requestId(identifier); |
390 String loaderId = IdentifiersFactory::loaderId(loader); | 411 String loaderId = IdentifiersFactory::loaderId(loader); |
391 m_resourcesData->resourceCreated(requestId, loaderId); | 412 m_resourcesData->resourceCreated(requestId, loaderId); |
392 | 413 |
393 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource; | 414 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource; |
394 if (initiatorInfo.name == FetchInitiatorTypeNames::xmlhttprequest) { | 415 if (initiatorInfo.name == FetchInitiatorTypeNames::xmlhttprequest) { |
395 type = InspectorPageAgent::XHRResource; | 416 type = InspectorPageAgent::XHRResource; |
396 m_resourcesData->setResourceType(requestId, type); | 417 m_resourcesData->setResourceType(requestId, type); |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) | 1065 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) |
1045 { | 1066 { |
1046 } | 1067 } |
1047 | 1068 |
1048 bool InspectorResourceAgent::shouldForceCORSPreflight() | 1069 bool InspectorResourceAgent::shouldForceCORSPreflight() |
1049 { | 1070 { |
1050 return m_state->getBoolean(ResourceAgentState::cacheDisabled); | 1071 return m_state->getBoolean(ResourceAgentState::cacheDisabled); |
1051 } | 1072 } |
1052 | 1073 |
1053 } // namespace blink | 1074 } // namespace blink |
OLD | NEW |