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

Side by Side Diff: components/policy/core/browser/url_blacklist_manager.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 11 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 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 "components/policy/core/browser/url_blacklist_manager.h" 5 #include "components/policy/core/browser/url_blacklist_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8
9 #include <limits> 8 #include <limits>
9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const size_t kMaxFiltersPerPolicy = 1000; 60 const size_t kMaxFiltersPerPolicy = 1000;
61 61
62 // A task that builds the blacklist on a background thread. 62 // A task that builds the blacklist on a background thread.
63 scoped_ptr<URLBlacklist> BuildBlacklist( 63 scoped_ptr<URLBlacklist> BuildBlacklist(
64 scoped_ptr<base::ListValue> block, 64 scoped_ptr<base::ListValue> block,
65 scoped_ptr<base::ListValue> allow, 65 scoped_ptr<base::ListValue> allow,
66 URLBlacklist::SegmentURLCallback segment_url) { 66 URLBlacklist::SegmentURLCallback segment_url) {
67 scoped_ptr<URLBlacklist> blacklist(new URLBlacklist(segment_url)); 67 scoped_ptr<URLBlacklist> blacklist(new URLBlacklist(segment_url));
68 blacklist->Block(block.get()); 68 blacklist->Block(block.get());
69 blacklist->Allow(allow.get()); 69 blacklist->Allow(allow.get());
70 return blacklist.Pass(); 70 return blacklist;
71 } 71 }
72 72
73 // Tokenise the parameter |query| and add appropriate query element matcher 73 // Tokenise the parameter |query| and add appropriate query element matcher
74 // conditions to the |query_conditions|. 74 // conditions to the |query_conditions|.
75 void ProcessQueryToConditions( 75 void ProcessQueryToConditions(
76 url_matcher::URLMatcherConditionFactory* condition_factory, 76 url_matcher::URLMatcherConditionFactory* condition_factory,
77 const std::string& query, 77 const std::string& query,
78 bool allow, 78 bool allow,
79 std::set<URLQueryElementMatcherCondition>* query_conditions) { 79 std::set<URLQueryElementMatcherCondition>* query_conditions) {
80 url::Component query_left = url::MakeRange(0, query.length()); 80 url::Component query_left = url::MakeRange(0, query.length());
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if (!scheme.empty()) 354 if (!scheme.empty())
355 scheme_filter.reset(new URLMatcherSchemeFilter(scheme)); 355 scheme_filter.reset(new URLMatcherSchemeFilter(scheme));
356 356
357 scoped_ptr<URLMatcherPortFilter> port_filter; 357 scoped_ptr<URLMatcherPortFilter> port_filter;
358 if (port != 0) { 358 if (port != 0) {
359 std::vector<URLMatcherPortFilter::Range> ranges; 359 std::vector<URLMatcherPortFilter::Range> ranges;
360 ranges.push_back(URLMatcherPortFilter::CreateRange(port)); 360 ranges.push_back(URLMatcherPortFilter::CreateRange(port));
361 port_filter.reset(new URLMatcherPortFilter(ranges)); 361 port_filter.reset(new URLMatcherPortFilter(ranges));
362 } 362 }
363 363
364 return new URLMatcherConditionSet(id, 364 return new URLMatcherConditionSet(id, conditions, query_conditions,
365 conditions, 365 std::move(scheme_filter),
366 query_conditions, 366 std::move(port_filter));
367 scheme_filter.Pass(),
368 port_filter.Pass());
369 } 367 }
370 368
371 // static 369 // static
372 bool URLBlacklist::FilterTakesPrecedence(const FilterComponents& lhs, 370 bool URLBlacklist::FilterTakesPrecedence(const FilterComponents& lhs,
373 const FilterComponents& rhs) { 371 const FilterComponents& rhs) {
374 // The "*" wildcard is the lowest priority filter. 372 // The "*" wildcard is the lowest priority filter.
375 if (rhs.IsBlacklistWildcard()) 373 if (rhs.IsBlacklistWildcard())
376 return true; 374 return true;
377 375
378 if (lhs.match_subdomains && !rhs.match_subdomains) 376 if (lhs.match_subdomains && !rhs.match_subdomains)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 base::Bind(&BuildBlacklist, 476 base::Bind(&BuildBlacklist,
479 base::Passed(&block), 477 base::Passed(&block),
480 base::Passed(&allow), 478 base::Passed(&allow),
481 segment_url_), 479 segment_url_),
482 base::Bind(&URLBlacklistManager::SetBlacklist, 480 base::Bind(&URLBlacklistManager::SetBlacklist,
483 io_weak_ptr_factory_.GetWeakPtr())); 481 io_weak_ptr_factory_.GetWeakPtr()));
484 } 482 }
485 483
486 void URLBlacklistManager::SetBlacklist(scoped_ptr<URLBlacklist> blacklist) { 484 void URLBlacklistManager::SetBlacklist(scoped_ptr<URLBlacklist> blacklist) {
487 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 485 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
488 blacklist_ = blacklist.Pass(); 486 blacklist_ = std::move(blacklist);
489 } 487 }
490 488
491 bool URLBlacklistManager::IsURLBlocked(const GURL& url) const { 489 bool URLBlacklistManager::IsURLBlocked(const GURL& url) const {
492 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 490 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
493 return blacklist_->IsURLBlocked(url); 491 return blacklist_->IsURLBlocked(url);
494 } 492 }
495 493
496 bool URLBlacklistManager::ShouldBlockRequestForFrame(const GURL& url, 494 bool URLBlacklistManager::ShouldBlockRequestForFrame(const GURL& url,
497 int* reason) const { 495 int* reason) const {
498 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 496 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
499 497
500 bool block = false; 498 bool block = false;
501 if (override_blacklist_.Run(url, &block, reason)) 499 if (override_blacklist_.Run(url, &block, reason))
502 return block; 500 return block;
503 501
504 *reason = net::ERR_BLOCKED_BY_ADMINISTRATOR; 502 *reason = net::ERR_BLOCKED_BY_ADMINISTRATOR;
505 return IsURLBlocked(url); 503 return IsURLBlocked(url);
506 } 504 }
507 505
508 // static 506 // static
509 void URLBlacklistManager::RegisterProfilePrefs( 507 void URLBlacklistManager::RegisterProfilePrefs(
510 user_prefs::PrefRegistrySyncable* registry) { 508 user_prefs::PrefRegistrySyncable* registry) {
511 registry->RegisterListPref(policy_prefs::kUrlBlacklist); 509 registry->RegisterListPref(policy_prefs::kUrlBlacklist);
512 registry->RegisterListPref(policy_prefs::kUrlWhitelist); 510 registry->RegisterListPref(policy_prefs::kUrlWhitelist);
513 } 511 }
514 512
515 } // namespace policy 513 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698