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

Side by Side Diff: components/test_runner/mock_web_document_subresource_filter.cc

Issue 2683413003: Introduce AsyncDocumentSubresourceFilter. (Closed)
Patch Set: Fix fix blink test build. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/test_runner/mock_web_document_subresource_filter.h" 5 #include "components/test_runner/mock_web_document_subresource_filter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "third_party/WebKit/public/platform/WebURL.h" 10 #include "third_party/WebKit/public/platform/WebURL.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace test_runner { 13 namespace test_runner {
14 14
15 MockWebDocumentSubresourceFilter::MockWebDocumentSubresourceFilter( 15 MockWebDocumentSubresourceFilter::MockWebDocumentSubresourceFilter(
16 const std::vector<std::string>& disallowed_path_suffixes) 16 const std::vector<std::string>& disallowed_path_suffixes)
17 : disallowed_path_suffixes_(disallowed_path_suffixes) {} 17 : disallowed_path_suffixes_(disallowed_path_suffixes) {}
18 18
19 MockWebDocumentSubresourceFilter::~MockWebDocumentSubresourceFilter() {} 19 MockWebDocumentSubresourceFilter::~MockWebDocumentSubresourceFilter() {}
20 20
21 blink::WebDocumentSubresourceFilter::LoadPolicy 21 blink::WebDocumentSubresourceFilterLoadPolicy
22 MockWebDocumentSubresourceFilter::getLoadPolicy( 22 MockWebDocumentSubresourceFilter::getLoadPolicy(
23 const blink::WebURL& resource_url, 23 const blink::WebURL& resource_url,
24 blink::WebURLRequest::RequestContext /* ignored */) { 24 blink::WebURLRequest::RequestContext /* ignored */) {
25 const std::string resource_path(GURL(resource_url).path()); 25 const std::string resource_path(GURL(resource_url).path());
26 return std::find_if(disallowed_path_suffixes_.begin(), 26 return std::find_if(disallowed_path_suffixes_.begin(),
27 disallowed_path_suffixes_.end(), 27 disallowed_path_suffixes_.end(),
28 [&resource_path](const std::string& suffix) { 28 [&resource_path](const std::string& suffix) {
29 return base::EndsWith(resource_path, suffix, 29 return base::EndsWith(resource_path, suffix,
30 base::CompareCase::SENSITIVE); 30 base::CompareCase::SENSITIVE);
31 }) == disallowed_path_suffixes_.end() 31 }) == disallowed_path_suffixes_.end()
32 ? Allow 32 ? blink::WebDocumentSubresourceFilterLoadPolicy::Allow
33 : Disallow; 33 : blink::WebDocumentSubresourceFilterLoadPolicy::Disallow;
34 } 34 }
35 35
36 void MockWebDocumentSubresourceFilter::reportDisallowedLoad() {} 36 void MockWebDocumentSubresourceFilter::reportDisallowedLoad() {}
37 37
38 } // namespace test_runner 38 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698