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 size_t done = 0; | |
103 size_t pos = 0; | |
caseq
2015/09/08 23:02:14
move down to actual usage?
| |
104 while (done < pattern.length()) { | |
105 size_t index = pattern.find('*', done); | |
106 if (index == kNotFound) | |
107 index = pattern.length(); | |
108 if (index > done) { | |
109 pos = url.find(pattern.substring(done, index - done)); | |
caseq
2015/09/08 23:02:14
So a*b*c would match "bac", right?
| |
110 if (pos == kNotFound) | |
111 return false; | |
112 pos = pos + index - done; | |
caseq
2015/09/08 23:02:14
what is the effect of this?
| |
113 } | |
114 done = index + 1; | |
115 } | |
116 return true; | |
117 } | |
118 | |
98 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers ) | 119 static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers ) |
99 { | 120 { |
100 RefPtr<JSONObject> headersObject = JSONObject::create(); | 121 RefPtr<JSONObject> headersObject = JSONObject::create(); |
101 for (const auto& header : headers) | 122 for (const auto& header : headers) |
102 headersObject->setString(header.key.string(), header.value); | 123 headersObject->setString(header.key.string(), header.value); |
103 return headersObject; | 124 return headersObject; |
104 } | 125 } |
105 | 126 |
106 class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient { | 127 class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient { |
107 WTF_MAKE_NONCOPYABLE(InspectorFileReaderLoaderClient); | 128 WTF_MAKE_NONCOPYABLE(InspectorFileReaderLoaderClient); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 visitor->trace(m_replayXHRsToBeDeleted); | 421 visitor->trace(m_replayXHRsToBeDeleted); |
401 visitor->trace(m_pendingXHRReplayData); | 422 visitor->trace(m_pendingXHRReplayData); |
402 InspectorBaseAgent::trace(visitor); | 423 InspectorBaseAgent::trace(visitor); |
403 } | 424 } |
404 | 425 |
405 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) | 426 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) |
406 { | 427 { |
407 String url = request.url().string(); | 428 String url = request.url().string(); |
408 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs); | 429 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs); |
409 for (const auto& entry : *blockedURLs) { | 430 for (const auto& entry : *blockedURLs) { |
410 if (url.contains(entry.key)) | 431 if (matches(url, entry.key)) |
411 return true; | 432 return true; |
412 } | 433 } |
413 return false; | 434 return false; |
414 } | 435 } |
415 | 436 |
416 void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRe quest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo, ResourceRequestBlockedReason reason) | 437 void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRe quest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo, ResourceRequestBlockedReason reason) |
417 { | 438 { |
418 unsigned long identifier = createUniqueIdentifier(); | 439 unsigned long identifier = createUniqueIdentifier(); |
419 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse (), initiatorInfo); | 440 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse (), initiatorInfo); |
420 | 441 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) | 1104 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) |
1084 { | 1105 { |
1085 } | 1106 } |
1086 | 1107 |
1087 bool InspectorResourceAgent::shouldForceCORSPreflight() | 1108 bool InspectorResourceAgent::shouldForceCORSPreflight() |
1088 { | 1109 { |
1089 return m_state->getBoolean(ResourceAgentState::cacheDisabled); | 1110 return m_state->getBoolean(ResourceAgentState::cacheDisabled); |
1090 } | 1111 } |
1091 | 1112 |
1092 } // namespace blink | 1113 } // namespace blink |
OLD | NEW |