OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/supervised_user/supervised_user_url_filter.h" | 5 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
13 #include "base/sha1.h" | 13 #include "base/sha1.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
18 #include "chrome/browser/supervised_user/experimental/supervised_user_async_url_
checker.h" | 18 #include "chrome/browser/supervised_user/experimental/supervised_user_async_url_
checker.h" |
19 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist.
h" | 19 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist.
h" |
20 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
21 #include "components/policy/core/browser/url_blacklist_manager.h" | 21 #include "components/policy/core/browser/url_blacklist_manager.h" |
22 #include "components/url_fixer/url_fixer.h" | 22 #include "components/url_formatter/url_fixer.h" |
23 #include "components/url_matcher/url_matcher.h" | 23 #include "components/url_matcher/url_matcher.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 25 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 using net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES; | 29 using net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES; |
30 using net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES; | 30 using net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES; |
31 using net::registry_controlled_domains::GetRegistryLength; | 31 using net::registry_controlled_domains::GetRegistryLength; |
32 using policy::URLBlacklist; | 32 using policy::URLBlacklist; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 | 89 |
90 bool FilterBuilder::AddPattern(const std::string& pattern, int site_id) { | 90 bool FilterBuilder::AddPattern(const std::string& pattern, int site_id) { |
91 std::string scheme; | 91 std::string scheme; |
92 std::string host; | 92 std::string host; |
93 uint16 port; | 93 uint16 port; |
94 std::string path; | 94 std::string path; |
95 std::string query; | 95 std::string query; |
96 bool match_subdomains = true; | 96 bool match_subdomains = true; |
97 URLBlacklist::SegmentURLCallback callback = | 97 URLBlacklist::SegmentURLCallback callback = |
98 static_cast<URLBlacklist::SegmentURLCallback>(url_fixer::SegmentURL); | 98 static_cast<URLBlacklist::SegmentURLCallback>(url_formatter::SegmentURL); |
99 if (!URLBlacklist::FilterToComponents( | 99 if (!URLBlacklist::FilterToComponents( |
100 callback, pattern, | 100 callback, pattern, |
101 &scheme, &host, &match_subdomains, &port, &path, &query)) { | 101 &scheme, &host, &match_subdomains, &port, &path, &query)) { |
102 LOG(ERROR) << "Invalid pattern " << pattern; | 102 LOG(ERROR) << "Invalid pattern " << pattern; |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 scoped_refptr<URLMatcherConditionSet> condition_set = | 106 scoped_refptr<URLMatcherConditionSet> condition_set = |
107 URLBlacklist::CreateConditionSet( | 107 URLBlacklist::CreateConditionSet( |
108 &contents_->url_matcher, ++matcher_id_, | 108 &contents_->url_matcher, ++matcher_id_, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 467 |
468 void SupervisedUserURLFilter::CheckCallback( | 468 void SupervisedUserURLFilter::CheckCallback( |
469 const FilteringBehaviorCallback& callback, | 469 const FilteringBehaviorCallback& callback, |
470 const GURL& url, | 470 const GURL& url, |
471 FilteringBehavior behavior, | 471 FilteringBehavior behavior, |
472 bool uncertain) const { | 472 bool uncertain) const { |
473 DCHECK(default_behavior_ != BLOCK); | 473 DCHECK(default_behavior_ != BLOCK); |
474 | 474 |
475 callback.Run(behavior, ASYNC_CHECKER, uncertain); | 475 callback.Run(behavior, ASYNC_CHECKER, uncertain); |
476 } | 476 } |
OLD | NEW |