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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_url_filter.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/json/json_file_value_serializer.h" 15 #include "base/json/json_file_value_serializer.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/sha1.h" 18 #include "base/sha1.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/task_runner_util.h" 21 #include "base/task_runner_util.h"
22 #include "base/threading/sequenced_worker_pool.h" 22 #include "base/threading/sequenced_worker_pool.h"
23 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist. h" 23 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist. h"
24 #include "components/google/core/browser/google_util.h" 24 #include "components/google/core/browser/google_util.h"
25 #include "components/policy/core/browser/url_blacklist_manager.h" 25 #include "components/policy/core/browser/url_blacklist_manager.h"
26 #include "components/url_formatter/url_fixer.h" 26 #include "components/url_formatter/url_fixer.h"
27 #include "components/url_matcher/url_matcher.h" 27 #include "components/url_matcher/url_matcher.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "extensions/features/features.h"
29 #include "net/base/escape.h" 30 #include "net/base/escape.h"
30 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
31 #include "net/base/url_util.h" 32 #include "net/base/url_util.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 #include "url/url_constants.h" 34 #include "url/url_constants.h"
34 35
35 #if defined(ENABLE_EXTENSIONS) 36 #if BUILDFLAG(ENABLE_EXTENSIONS)
36 #include "extensions/common/extension_urls.h" 37 #include "extensions/common/extension_urls.h"
37 #endif 38 #endif
38 39
39 using content::BrowserThread; 40 using content::BrowserThread;
40 using net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES; 41 using net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES;
41 using net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES; 42 using net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES;
42 using net::registry_controlled_domains::GetCanonicalHostRegistryLength; 43 using net::registry_controlled_domains::GetCanonicalHostRegistryLength;
43 using policy::URLBlacklist; 44 using policy::URLBlacklist;
44 using url_matcher::URLMatcher; 45 using url_matcher::URLMatcher;
45 using url_matcher::URLMatcherConditionSet; 46 using url_matcher::URLMatcherConditionSet;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // allowed. 86 // allowed.
86 const char* kFilteredSchemes[] = { 87 const char* kFilteredSchemes[] = {
87 "http", 88 "http",
88 "https", 89 "https",
89 "ftp", 90 "ftp",
90 "gopher", 91 "gopher",
91 "ws", 92 "ws",
92 "wss" 93 "wss"
93 }; 94 };
94 95
95 #if defined(ENABLE_EXTENSIONS) 96 #if BUILDFLAG(ENABLE_EXTENSIONS)
96 const char* kCrxDownloadUrls[] = { 97 const char* kCrxDownloadUrls[] = {
97 "https://clients2.googleusercontent.com/crx/blobs/", 98 "https://clients2.googleusercontent.com/crx/blobs/",
98 "https://chrome.google.com/webstore/download/" 99 "https://chrome.google.com/webstore/download/"
99 }; 100 };
100 #endif 101 #endif
101 102
102 // This class encapsulates all the state that is required during construction of 103 // This class encapsulates all the state that is required during construction of
103 // a new SupervisedUserURLFilter::Contents. 104 // a new SupervisedUserURLFilter::Contents.
104 class FilterBuilder { 105 class FilterBuilder {
105 public: 106 public:
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 GURL effective_url = GetEmbeddedURL(url); 343 GURL effective_url = GetEmbeddedURL(url);
343 if (!effective_url.is_valid()) 344 if (!effective_url.is_valid())
344 effective_url = url; 345 effective_url = url;
345 346
346 *reason = supervised_user_error_page::MANUAL; 347 *reason = supervised_user_error_page::MANUAL;
347 348
348 // URLs with a non-standard scheme (e.g. chrome://) are always allowed. 349 // URLs with a non-standard scheme (e.g. chrome://) are always allowed.
349 if (!HasFilteredScheme(effective_url)) 350 if (!HasFilteredScheme(effective_url))
350 return ALLOW; 351 return ALLOW;
351 352
352 #if defined(ENABLE_EXTENSIONS) 353 #if BUILDFLAG(ENABLE_EXTENSIONS)
353 // Allow webstore crx downloads. This applies to both extension installation 354 // Allow webstore crx downloads. This applies to both extension installation
354 // and updates. 355 // and updates.
355 if (extension_urls::GetWebstoreUpdateUrl() == Normalize(effective_url)) 356 if (extension_urls::GetWebstoreUpdateUrl() == Normalize(effective_url))
356 return ALLOW; 357 return ALLOW;
357 358
358 // The actual CRX files are downloaded from other URLs. Allow them too. 359 // The actual CRX files are downloaded from other URLs. Allow them too.
359 for (const char* crx_download_url_str : kCrxDownloadUrls) { 360 for (const char* crx_download_url_str : kCrxDownloadUrls) {
360 GURL crx_download_url(crx_download_url_str); 361 GURL crx_download_url(crx_download_url_str);
361 if (effective_url.SchemeIs(url::kHttpsScheme) && 362 if (effective_url.SchemeIs(url::kHttpsScheme) &&
362 crx_download_url.host_piece() == effective_url.host_piece() && 363 crx_download_url.host_piece() == effective_url.host_piece() &&
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 624
624 FilteringBehavior behavior = 625 FilteringBehavior behavior =
625 GetBehaviorFromSafeSearchClassification(classification); 626 GetBehaviorFromSafeSearchClassification(classification);
626 627
627 callback.Run(behavior, supervised_user_error_page::ASYNC_CHECKER, uncertain); 628 callback.Run(behavior, supervised_user_error_page::ASYNC_CHECKER, uncertain);
628 for (Observer& observer : observers_) { 629 for (Observer& observer : observers_) {
629 observer.OnURLChecked(url, behavior, 630 observer.OnURLChecked(url, behavior,
630 supervised_user_error_page::ASYNC_CHECKER, uncertain); 631 supervised_user_error_page::ASYNC_CHECKER, uncertain);
631 } 632 }
632 } 633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698