Index: components/test_runner/mock_web_document_subresource_filter.cc |
diff --git a/components/test_runner/mock_web_document_subresource_filter.cc b/components/test_runner/mock_web_document_subresource_filter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bdd1e53a04d6655b5e244380f65611b6b6685de5 |
--- /dev/null |
+++ b/components/test_runner/mock_web_document_subresource_filter.cc |
@@ -0,0 +1,33 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/test_runner/mock_web_document_subresource_filter.h" |
+ |
+#include <algorithm> |
+ |
+#include "base/strings/string_util.h" |
+#include "third_party/WebKit/public/platform/WebURL.h" |
+#include "url/gurl.h" |
+ |
+namespace test_runner { |
+ |
+MockWebDocumentSubresourceFilter::MockWebDocumentSubresourceFilter( |
+ const std::vector<std::string>& disallowed_path_suffixes) |
+ : disallowed_path_suffixes_(disallowed_path_suffixes) {} |
+ |
+MockWebDocumentSubresourceFilter::~MockWebDocumentSubresourceFilter() {} |
+ |
+bool MockWebDocumentSubresourceFilter::allowLoad( |
+ const blink::WebURL& resource_url, |
+ blink::WebURLRequest::RequestContext /* ignored */) { |
+ const std::string resource_path(GURL(resource_url).path()); |
+ return std::find_if(disallowed_path_suffixes_.begin(), |
+ disallowed_path_suffixes_.end(), |
+ [&resource_path](const std::string& suffix) { |
+ return base::EndsWith(resource_path, suffix, |
+ base::CompareCase::SENSITIVE); |
+ }) == disallowed_path_suffixes_.end(); |
battre
2016/05/30 15:29:25
Isn't this easier to read?
for (const string& suff
engedy
2016/05/30 20:54:00
I think that's a matter of taste. I have to agree
battre
2016/05/31 08:28:32
Works for me. Maybe it also makes sense to add som
engedy
2016/05/31 08:58:16
Agreed. I will do that in a follow-up CL.
|
+} |
+ |
+} // namespace test_runner |