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

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

Issue 1878143002: Convert //chrome/browser/supervised_user from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "chrome/browser/supervised_user/supervised_user_service.h" 5 #include "chrome/browser/supervised_user/supervised_user_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 SupervisedUserServiceObserver* observer) { 392 SupervisedUserServiceObserver* observer) {
393 observer_list_.AddObserver(observer); 393 observer_list_.AddObserver(observer);
394 } 394 }
395 395
396 void SupervisedUserService::RemoveObserver( 396 void SupervisedUserService::RemoveObserver(
397 SupervisedUserServiceObserver* observer) { 397 SupervisedUserServiceObserver* observer) {
398 observer_list_.RemoveObserver(observer); 398 observer_list_.RemoveObserver(observer);
399 } 399 }
400 400
401 void SupervisedUserService::AddPermissionRequestCreator( 401 void SupervisedUserService::AddPermissionRequestCreator(
402 scoped_ptr<PermissionRequestCreator> creator) { 402 std::unique_ptr<PermissionRequestCreator> creator) {
403 permissions_creators_.push_back(creator.release()); 403 permissions_creators_.push_back(creator.release());
404 } 404 }
405 405
406 void SupervisedUserService::SetSafeSearchURLReporter( 406 void SupervisedUserService::SetSafeSearchURLReporter(
407 scoped_ptr<SafeSearchURLReporter> reporter) { 407 std::unique_ptr<SafeSearchURLReporter> reporter) {
408 url_reporter_ = std::move(reporter); 408 url_reporter_ = std::move(reporter);
409 } 409 }
410 410
411 SupervisedUserService::URLFilterContext::URLFilterContext() 411 SupervisedUserService::URLFilterContext::URLFilterContext()
412 : ui_url_filter_(new SupervisedUserURLFilter), 412 : ui_url_filter_(new SupervisedUserURLFilter),
413 io_url_filter_(new SupervisedUserURLFilter) {} 413 io_url_filter_(new SupervisedUserURLFilter) {}
414 SupervisedUserService::URLFilterContext::~URLFilterContext() {} 414 SupervisedUserService::URLFilterContext::~URLFilterContext() {}
415 415
416 SupervisedUserURLFilter* 416 SupervisedUserURLFilter*
417 SupervisedUserService::URLFilterContext::ui_url_filter() const { 417 SupervisedUserService::URLFilterContext::ui_url_filter() const {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 base::Bind(&SupervisedUserURLFilter::SetBlacklist, 450 base::Bind(&SupervisedUserURLFilter::SetBlacklist,
451 io_url_filter_, 451 io_url_filter_,
452 blacklist)); 452 blacklist));
453 } 453 }
454 454
455 bool SupervisedUserService::URLFilterContext::HasBlacklist() const { 455 bool SupervisedUserService::URLFilterContext::HasBlacklist() const {
456 return ui_url_filter_->HasBlacklist(); 456 return ui_url_filter_->HasBlacklist();
457 } 457 }
458 458
459 void SupervisedUserService::URLFilterContext::SetManualHosts( 459 void SupervisedUserService::URLFilterContext::SetManualHosts(
460 scoped_ptr<std::map<std::string, bool> > host_map) { 460 std::unique_ptr<std::map<std::string, bool>> host_map) {
461 ui_url_filter_->SetManualHosts(host_map.get()); 461 ui_url_filter_->SetManualHosts(host_map.get());
462 BrowserThread::PostTask( 462 BrowserThread::PostTask(
463 BrowserThread::IO, 463 BrowserThread::IO,
464 FROM_HERE, 464 FROM_HERE,
465 base::Bind(&SupervisedUserURLFilter::SetManualHosts, 465 base::Bind(&SupervisedUserURLFilter::SetManualHosts,
466 io_url_filter_, base::Owned(host_map.release()))); 466 io_url_filter_, base::Owned(host_map.release())));
467 } 467 }
468 468
469 void SupervisedUserService::URLFilterContext::SetManualURLs( 469 void SupervisedUserService::URLFilterContext::SetManualURLs(
470 scoped_ptr<std::map<GURL, bool> > url_map) { 470 std::unique_ptr<std::map<GURL, bool>> url_map) {
471 ui_url_filter_->SetManualURLs(url_map.get()); 471 ui_url_filter_->SetManualURLs(url_map.get());
472 BrowserThread::PostTask( 472 BrowserThread::PostTask(
473 BrowserThread::IO, 473 BrowserThread::IO,
474 FROM_HERE, 474 FROM_HERE,
475 base::Bind(&SupervisedUserURLFilter::SetManualURLs, 475 base::Bind(&SupervisedUserURLFilter::SetManualURLs,
476 io_url_filter_, base::Owned(url_map.release()))); 476 io_url_filter_, base::Owned(url_map.release())));
477 } 477 }
478 478
479 void SupervisedUserService::URLFilterContext::Clear() { 479 void SupervisedUserService::URLFilterContext::Clear() {
480 ui_url_filter_->Clear(); 480 ui_url_filter_->Clear();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 void SupervisedUserService::UpdateBlacklist() { 874 void SupervisedUserService::UpdateBlacklist() {
875 bool use_blacklist = supervised_users::IsSafeSitesBlacklistEnabled(profile_); 875 bool use_blacklist = supervised_users::IsSafeSitesBlacklistEnabled(profile_);
876 url_filter_context_.SetBlacklist(use_blacklist ? &blacklist_ : nullptr); 876 url_filter_context_.SetBlacklist(use_blacklist ? &blacklist_ : nullptr);
877 FOR_EACH_OBSERVER( 877 FOR_EACH_OBSERVER(
878 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); 878 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged());
879 } 879 }
880 880
881 void SupervisedUserService::UpdateManualHosts() { 881 void SupervisedUserService::UpdateManualHosts() {
882 const base::DictionaryValue* dict = 882 const base::DictionaryValue* dict =
883 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts); 883 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts);
884 scoped_ptr<std::map<std::string, bool> > host_map( 884 std::unique_ptr<std::map<std::string, bool>> host_map(
885 new std::map<std::string, bool>()); 885 new std::map<std::string, bool>());
886 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 886 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
887 bool allow = false; 887 bool allow = false;
888 bool result = it.value().GetAsBoolean(&allow); 888 bool result = it.value().GetAsBoolean(&allow);
889 DCHECK(result); 889 DCHECK(result);
890 (*host_map)[it.key()] = allow; 890 (*host_map)[it.key()] = allow;
891 } 891 }
892 url_filter_context_.SetManualHosts(std::move(host_map)); 892 url_filter_context_.SetManualHosts(std::move(host_map));
893 893
894 FOR_EACH_OBSERVER( 894 FOR_EACH_OBSERVER(
895 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); 895 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged());
896 } 896 }
897 897
898 void SupervisedUserService::UpdateManualURLs() { 898 void SupervisedUserService::UpdateManualURLs() {
899 const base::DictionaryValue* dict = 899 const base::DictionaryValue* dict =
900 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs); 900 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs);
901 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); 901 std::unique_ptr<std::map<GURL, bool>> url_map(new std::map<GURL, bool>());
902 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 902 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
903 bool allow = false; 903 bool allow = false;
904 bool result = it.value().GetAsBoolean(&allow); 904 bool result = it.value().GetAsBoolean(&allow);
905 DCHECK(result); 905 DCHECK(result);
906 (*url_map)[GURL(it.key())] = allow; 906 (*url_map)[GURL(it.key())] = allow;
907 } 907 }
908 url_filter_context_.SetManualURLs(std::move(url_map)); 908 url_filter_context_.SetManualURLs(std::move(url_map));
909 909
910 FOR_EACH_OBSERVER( 910 FOR_EACH_OBSERVER(
911 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); 911 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); 1058 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile"));
1059 1059
1060 is_profile_active_ = profile_became_active; 1060 is_profile_active_ = profile_became_active;
1061 } 1061 }
1062 #endif // !defined(OS_ANDROID) 1062 #endif // !defined(OS_ANDROID)
1063 1063
1064 void SupervisedUserService::OnSiteListUpdated() { 1064 void SupervisedUserService::OnSiteListUpdated() {
1065 FOR_EACH_OBSERVER( 1065 FOR_EACH_OBSERVER(
1066 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); 1066 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged());
1067 } 1067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698