OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/test_runner/mock_web_document_subresource_filter.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "base/strings/string_util.h" |
| 10 #include "third_party/WebKit/public/platform/WebURL.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 namespace test_runner { |
| 14 |
| 15 MockWebDocumentSubresourceFilter::MockWebDocumentSubresourceFilter( |
| 16 const std::vector<std::string>& disallowed_path_suffixes) |
| 17 : disallowed_path_suffixes_(disallowed_path_suffixes) {} |
| 18 |
| 19 MockWebDocumentSubresourceFilter::~MockWebDocumentSubresourceFilter() {} |
| 20 |
| 21 bool MockWebDocumentSubresourceFilter::allowLoad( |
| 22 const blink::WebURL& resource_url, |
| 23 blink::WebURLRequest::RequestContext /* ignored */) { |
| 24 const std::string resource_path(GURL(resource_url).path()); |
| 25 return std::find_if(disallowed_path_suffixes_.begin(), |
| 26 disallowed_path_suffixes_.end(), |
| 27 [&resource_path](const std::string& suffix) { |
| 28 return base::EndsWith(resource_path, suffix, |
| 29 base::CompareCase::SENSITIVE); |
| 30 }) == disallowed_path_suffixes_.end(); |
| 31 } |
| 32 |
| 33 } // namespace test_runner |
OLD | NEW |