Chromium Code Reviews| Index: Source/core/inspector/InspectorResourceAgent.cpp |
| diff --git a/Source/core/inspector/InspectorResourceAgent.cpp b/Source/core/inspector/InspectorResourceAgent.cpp |
| index 8aec85c9d0b3695925377e18911f1eced012a139..c78ce2d4e63e1ea700df864633e626631c804ab4 100644 |
| --- a/Source/core/inspector/InspectorResourceAgent.cpp |
| +++ b/Source/core/inspector/InspectorResourceAgent.cpp |
| @@ -95,6 +95,22 @@ namespace { |
| // Keep in sync with kDevToolsRequestInitiator defined in devtools_network_controller.cc |
| const char kDevToolsEmulateNetworkConditionsClientId[] = "X-DevTools-Emulate-Network-Conditions-Client-Id"; |
| +// Pattern may contain stars ('*') which match to any (possibly empty) string. |
| +// Stars implicitly assumed at the begin/end of pattern. |
| +bool matches(const String& url, const String& pattern) |
| +{ |
| + Vector<String> parts; |
| + pattern.split("*", parts); |
| + size_t pos = 0; |
| + for (const String& part : parts) { |
| + pos = url.find(part, pos); |
| + if (pos == kNotFound) |
| + return false; |
| + pos += part.length(); |
| + } |
| + return true; |
| +} |
| + |
| static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers) |
| { |
| RefPtr<JSONObject> headersObject = JSONObject::create(); |
| @@ -407,7 +423,8 @@ 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)) |
| + fprintf(stderr, "matches: %s -> %s -> %d\n", url.utf8().data(), entry.key.utf8().data(), matches(url, entry.key)); |
|
caseq
2015/09/09 00:54:42
please remove this.
dgozman
2015/09/09 00:56:53
Hmm... I thought presubmit catches fprintf.
|
| + if (matches(url, entry.key)) |
| return true; |
| } |
| return false; |