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_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 bool SupervisedUserService::AccessRequestsEnabled() { | 655 bool SupervisedUserService::AccessRequestsEnabled() { |
656 return FindEnabledPermissionRequestCreator(0) < permissions_creators_.size(); | 656 return FindEnabledPermissionRequestCreator(0) < permissions_creators_.size(); |
657 } | 657 } |
658 | 658 |
659 void SupervisedUserService::AddAccessRequest(const GURL& url, | 659 void SupervisedUserService::AddAccessRequest(const GURL& url, |
660 const SuccessCallback& callback) { | 660 const SuccessCallback& callback) { |
661 AddAccessRequestInternal(SupervisedUserURLFilter::Normalize(url), callback, | 661 AddAccessRequestInternal(SupervisedUserURLFilter::Normalize(url), callback, |
662 0); | 662 0); |
663 } | 663 } |
664 | 664 |
665 SupervisedUserService::ManualBehavior | |
666 SupervisedUserService::GetManualBehaviorForHost( | |
667 const std::string& hostname) { | |
668 const base::DictionaryValue* dict = | |
669 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts); | |
670 bool allow = false; | |
671 if (!dict->GetBooleanWithoutPathExpansion(hostname, &allow)) | |
672 return MANUAL_NONE; | |
673 | |
674 return allow ? MANUAL_ALLOW : MANUAL_BLOCK; | |
675 } | |
676 | |
677 SupervisedUserService::ManualBehavior | |
678 SupervisedUserService::GetManualBehaviorForURL( | |
679 const GURL& url) { | |
680 const base::DictionaryValue* dict = | |
681 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs); | |
682 GURL normalized_url = SupervisedUserURLFilter::Normalize(url); | |
683 bool allow = false; | |
684 if (!dict->GetBooleanWithoutPathExpansion(normalized_url.spec(), &allow)) | |
685 return MANUAL_NONE; | |
686 | |
687 return allow ? MANUAL_ALLOW : MANUAL_BLOCK; | |
688 } | |
689 | |
690 void SupervisedUserService::GetManualExceptionsForHost( | |
691 const std::string& host, | |
692 std::vector<GURL>* urls) { | |
693 const base::DictionaryValue* dict = | |
694 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs); | |
695 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | |
696 GURL url(it.key()); | |
697 if (url.host() == host) | |
698 urls->push_back(url); | |
699 } | |
700 } | |
701 | |
702 void SupervisedUserService::InitSync(const std::string& refresh_token) { | 665 void SupervisedUserService::InitSync(const std::string& refresh_token) { |
703 StartSetupSync(); | 666 StartSetupSync(); |
704 | 667 |
705 ProfileOAuth2TokenService* token_service = | 668 ProfileOAuth2TokenService* token_service = |
706 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 669 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
707 token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail, | 670 token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail, |
708 refresh_token); | 671 refresh_token); |
709 | 672 |
710 FinishSetupSyncWhenReady(); | 673 FinishSetupSyncWhenReady(); |
711 } | 674 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 // The active user can be NULL in unit tests. | 944 // The active user can be NULL in unit tests. |
982 if (user_manager::UserManager::Get()->GetActiveUser()) { | 945 if (user_manager::UserManager::Get()->GetActiveUser()) { |
983 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 946 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
984 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 947 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
985 } | 948 } |
986 return std::string(); | 949 return std::string(); |
987 #else | 950 #else |
988 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 951 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
989 #endif | 952 #endif |
990 } | 953 } |
OLD | NEW |