| Index: third_party/WebKit/Source/core/loader/DocumentSubresourceFilterClient.cpp
|
| diff --git a/third_party/WebKit/Source/core/loader/DocumentSubresourceFilterClient.cpp b/third_party/WebKit/Source/core/loader/DocumentSubresourceFilterClient.cpp
|
| index f9be09e1bf93d0d8cf0f088c5889776bd5c6ea9a..5306dfd1611bee939e36220ddb46c4f5ef6193d5 100644
|
| --- a/third_party/WebKit/Source/core/loader/DocumentSubresourceFilterClient.cpp
|
| +++ b/third_party/WebKit/Source/core/loader/DocumentSubresourceFilterClient.cpp
|
| @@ -4,8 +4,11 @@
|
|
|
| #include "core/loader/DocumentSubresourceFilterClient.h"
|
|
|
| +#include "core/dom/TaskRunnerHelper.h"
|
| #include "core/loader/DocumentLoader.h"
|
| -#include "public/platform/WebDocumentSubresourceFilter.h"
|
| +#include "platform/WebTaskRunner.h"
|
| +#include "platform/weborigin/KURL.h"
|
| +#include "public/platform/WebTraceLocation.h"
|
|
|
| namespace blink {
|
|
|
| @@ -32,20 +35,45 @@ bool DocumentSubresourceFilterClient::allowLoad(
|
| // Pair<url string, context> -> LoadPolicy.
|
| WebDocumentSubresourceFilter::LoadPolicy loadPolicy =
|
| m_subresourceFilter->getLoadPolicy(resourceUrl, requestContext);
|
| - if (reportingPolicy == Report) {
|
| - switch (loadPolicy) {
|
| - case WebDocumentSubresourceFilter::Allow:
|
| - break;
|
| - case WebDocumentSubresourceFilter::Disallow:
|
| - m_subresourceFilter->reportDisallowedLoad();
|
| - // fall through
|
| - case WebDocumentSubresourceFilter::WouldDisallow:
|
| - m_documentLoader->didObserveLoadingBehavior(
|
| - WebLoadingBehaviorSubresourceFilterMatch);
|
| - break;
|
| - }
|
| - }
|
| + if (reportingPolicy == Report)
|
| + notifyLoad(resourceUrl, loadPolicy);
|
| + return loadPolicy != WebDocumentSubresourceFilter::Disallow;
|
| +}
|
| +
|
| +bool DocumentSubresourceFilterClient::allowWebSocketConnection(
|
| + const KURL& resourceUrl) {
|
| + // TODO(csharrison): Should probably have a new API for this in
|
| + // WebDocumentSubresourceFilter rather than sending subresource context.
|
| + WebDocumentSubresourceFilter::LoadPolicy loadPolicy =
|
| + m_subresourceFilter->getLoadPolicy(
|
| + resourceUrl, WebURLRequest::RequestContextSubresource);
|
| +
|
| + // Post a task to notify this load to avoid unduly blocking the worker
|
| + // thread.
|
| + TaskRunnerHelper::get(TaskType::Networking, m_documentLoader->frame())
|
| + ->postTask(BLINK_FROM_HERE,
|
| + WTF::bind(&DocumentSubresourceFilterClient::notifyLoad,
|
| + wrapPersistent(this), resourceUrl, loadPolicy));
|
| return loadPolicy != WebDocumentSubresourceFilter::Disallow;
|
| }
|
|
|
| +void DocumentSubresourceFilterClient::notifyLoad(
|
| + const KURL& resourceUrl,
|
| + WebDocumentSubresourceFilter::LoadPolicy loadPolicy) {
|
| + // TODO(csharrison): Add devtools logging here.
|
| + // May need to call InspectorInstrumentation::didReceiveWebSocketFrameError
|
| + // for websocket filtering.
|
| + switch (loadPolicy) {
|
| + case WebDocumentSubresourceFilter::Allow:
|
| + break;
|
| + case WebDocumentSubresourceFilter::Disallow:
|
| + m_subresourceFilter->reportDisallowedLoad();
|
| + // fall through
|
| + case WebDocumentSubresourceFilter::WouldDisallow:
|
| + m_documentLoader->didObserveLoadingBehavior(
|
| + WebLoadingBehaviorSubresourceFilterMatch);
|
| + break;
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|