Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1179)

Unified Diff: components/test_runner/mock_web_document_subresource_filter.cc

Issue 2022783002: Skeleton of the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698