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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 static const char userAgentOverride[] = "userAgentOverride"; | 88 static const char userAgentOverride[] = "userAgentOverride"; |
89 static const char monitoringXHR[] = "monitoringXHR"; | 89 static const char monitoringXHR[] = "monitoringXHR"; |
90 static const char blockedURLs[] = "blockedURLs"; | 90 static const char blockedURLs[] = "blockedURLs"; |
91 } | 91 } |
92 | 92 |
93 namespace { | 93 namespace { |
94 | 94 |
95 // Keep in sync with kDevToolsRequestInitiator defined in devtools_network_contr
oller.cc | 95 // Keep in sync with kDevToolsRequestInitiator defined in devtools_network_contr
oller.cc |
96 const char kDevToolsEmulateNetworkConditionsClientId[] = "X-DevTools-Emulate-Net
work-Conditions-Client-Id"; | 96 const char kDevToolsEmulateNetworkConditionsClientId[] = "X-DevTools-Emulate-Net
work-Conditions-Client-Id"; |
97 | 97 |
| 98 // Pattern may contain stars ('*') which match to any (possibly empty) string. |
| 99 // Stars implicitly assumed at the begin/end of pattern. |
| 100 bool matches(const String& url, const String& pattern) |
| 101 { |
| 102 Vector<String> parts; |
| 103 pattern.split("*", parts); |
| 104 size_t pos = 0; |
| 105 for (const String& part : parts) { |
| 106 pos = url.find(part, pos); |
| 107 if (pos == kNotFound) |
| 108 return false; |
| 109 pos += part.length(); |
| 110 } |
| 111 return true; |
| 112 } |
| 113 |
98 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers
) | 114 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers
) |
99 { | 115 { |
100 RefPtr<JSONObject> headersObject = JSONObject::create(); | 116 RefPtr<JSONObject> headersObject = JSONObject::create(); |
101 for (const auto& header : headers) | 117 for (const auto& header : headers) |
102 headersObject->setString(header.key.string(), header.value); | 118 headersObject->setString(header.key.string(), header.value); |
103 return headersObject; | 119 return headersObject; |
104 } | 120 } |
105 | 121 |
106 class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient { | 122 class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient { |
107 WTF_MAKE_NONCOPYABLE(InspectorFileReaderLoaderClient); | 123 WTF_MAKE_NONCOPYABLE(InspectorFileReaderLoaderClient); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 visitor->trace(m_replayXHRsToBeDeleted); | 416 visitor->trace(m_replayXHRsToBeDeleted); |
401 visitor->trace(m_pendingXHRReplayData); | 417 visitor->trace(m_pendingXHRReplayData); |
402 InspectorBaseAgent::trace(visitor); | 418 InspectorBaseAgent::trace(visitor); |
403 } | 419 } |
404 | 420 |
405 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) | 421 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) |
406 { | 422 { |
407 String url = request.url().string(); | 423 String url = request.url().string(); |
408 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc
kedURLs); | 424 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc
kedURLs); |
409 for (const auto& entry : *blockedURLs) { | 425 for (const auto& entry : *blockedURLs) { |
410 if (url.contains(entry.key)) | 426 if (matches(url, entry.key)) |
411 return true; | 427 return true; |
412 } | 428 } |
413 return false; | 429 return false; |
414 } | 430 } |
415 | 431 |
416 void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRe
quest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo,
ResourceRequestBlockedReason reason) | 432 void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRe
quest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo,
ResourceRequestBlockedReason reason) |
417 { | 433 { |
418 unsigned long identifier = createUniqueIdentifier(); | 434 unsigned long identifier = createUniqueIdentifier(); |
419 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse
(), initiatorInfo); | 435 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse
(), initiatorInfo); |
420 | 436 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) | 1099 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) |
1084 { | 1100 { |
1085 } | 1101 } |
1086 | 1102 |
1087 bool InspectorResourceAgent::shouldForceCORSPreflight() | 1103 bool InspectorResourceAgent::shouldForceCORSPreflight() |
1088 { | 1104 { |
1089 return m_state->getBoolean(ResourceAgentState::cacheDisabled); | 1105 return m_state->getBoolean(ResourceAgentState::cacheDisabled); |
1090 } | 1106 } |
1091 | 1107 |
1092 } // namespace blink | 1108 } // namespace blink |
OLD | NEW |