| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 #if defined(ENABLE_THEMES) | 60 #if defined(ENABLE_THEMES) |
| 61 #include "chrome/browser/themes/theme_service.h" | 61 #include "chrome/browser/themes/theme_service.h" |
| 62 #include "chrome/browser/themes/theme_service_factory.h" | 62 #include "chrome/browser/themes/theme_service_factory.h" |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 using base::DictionaryValue; | 65 using base::DictionaryValue; |
| 66 using base::UserMetricsAction; | 66 using base::UserMetricsAction; |
| 67 using content::BrowserThread; | 67 using content::BrowserThread; |
| 68 | 68 |
| 69 bool SupervisedUserService::Delegate::IsChildAccount() const { |
| 70 return false; |
| 71 } |
| 72 |
| 69 base::FilePath SupervisedUserService::Delegate::GetBlacklistPath() const { | 73 base::FilePath SupervisedUserService::Delegate::GetBlacklistPath() const { |
| 70 return base::FilePath(); | 74 return base::FilePath(); |
| 71 } | 75 } |
| 72 | 76 |
| 73 GURL SupervisedUserService::Delegate::GetBlacklistURL() const { | 77 GURL SupervisedUserService::Delegate::GetBlacklistURL() const { |
| 74 return GURL(); | 78 return GURL(); |
| 75 } | 79 } |
| 76 | 80 |
| 77 std::string SupervisedUserService::Delegate::GetSafeSitesCx() const { | 81 std::string SupervisedUserService::Delegate::GetSafeSitesCx() const { |
| 78 return std::string(); | 82 return std::string(); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 bool success) { | 619 bool success) { |
| 616 if (success) { | 620 if (success) { |
| 617 callback.Run(true); | 621 callback.Run(true); |
| 618 return; | 622 return; |
| 619 } | 623 } |
| 620 | 624 |
| 621 AddAccessRequestInternal(url, callback, index + 1); | 625 AddAccessRequestInternal(url, callback, index + 1); |
| 622 } | 626 } |
| 623 | 627 |
| 624 void SupervisedUserService::OnSupervisedUserIdChanged() { | 628 void SupervisedUserService::OnSupervisedUserIdChanged() { |
| 625 std::string supervised_user_id = | 629 SetActive(ProfileIsSupervised()); |
| 626 profile_->GetPrefs()->GetString(prefs::kSupervisedUserId); | |
| 627 SetActive(!supervised_user_id.empty()); | |
| 628 } | 630 } |
| 629 | 631 |
| 630 void SupervisedUserService::OnDefaultFilteringBehaviorChanged() { | 632 void SupervisedUserService::OnDefaultFilteringBehaviorChanged() { |
| 631 DCHECK(ProfileIsSupervised()); | 633 DCHECK(ProfileIsSupervised()); |
| 632 | 634 |
| 633 int behavior_value = profile_->GetPrefs()->GetInteger( | 635 int behavior_value = profile_->GetPrefs()->GetInteger( |
| 634 prefs::kDefaultSupervisedUserFilteringBehavior); | 636 prefs::kDefaultSupervisedUserFilteringBehavior); |
| 635 SupervisedUserURLFilter::FilteringBehavior behavior = | 637 SupervisedUserURLFilter::FilteringBehavior behavior = |
| 636 SupervisedUserURLFilter::BehaviorFromInt(behavior_value); | 638 SupervisedUserURLFilter::BehaviorFromInt(behavior_value); |
| 637 url_filter_context_.SetDefaultFilteringBehavior(behavior); | 639 url_filter_context_.SetDefaultFilteringBehavior(behavior); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 bool SupervisedUserService::AccessRequestsEnabled() { | 687 bool SupervisedUserService::AccessRequestsEnabled() { |
| 686 return FindEnabledPermissionRequestCreator(0) < permissions_creators_.size(); | 688 return FindEnabledPermissionRequestCreator(0) < permissions_creators_.size(); |
| 687 } | 689 } |
| 688 | 690 |
| 689 void SupervisedUserService::AddAccessRequest(const GURL& url, | 691 void SupervisedUserService::AddAccessRequest(const GURL& url, |
| 690 const SuccessCallback& callback) { | 692 const SuccessCallback& callback) { |
| 691 AddAccessRequestInternal(SupervisedUserURLFilter::Normalize(url), callback, | 693 AddAccessRequestInternal(SupervisedUserURLFilter::Normalize(url), callback, |
| 692 0); | 694 0); |
| 693 } | 695 } |
| 694 | 696 |
| 697 bool SupervisedUserService::IsChildAccount() const { |
| 698 return delegate_ && delegate_->IsChildAccount(); |
| 699 } |
| 700 |
| 695 void SupervisedUserService::InitSync(const std::string& refresh_token) { | 701 void SupervisedUserService::InitSync(const std::string& refresh_token) { |
| 696 StartSetupSync(); | 702 StartSetupSync(); |
| 697 | 703 |
| 698 ProfileOAuth2TokenService* token_service = | 704 ProfileOAuth2TokenService* token_service = |
| 699 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 705 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 700 token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail, | 706 token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail, |
| 701 refresh_token); | 707 refresh_token); |
| 702 | 708 |
| 703 FinishSetupSyncWhenReady(); | 709 FinishSetupSyncWhenReady(); |
| 704 } | 710 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 // The active user can be NULL in unit tests. | 994 // The active user can be NULL in unit tests. |
| 989 if (user_manager::UserManager::Get()->GetActiveUser()) { | 995 if (user_manager::UserManager::Get()->GetActiveUser()) { |
| 990 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 996 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
| 991 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 997 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
| 992 } | 998 } |
| 993 return std::string(); | 999 return std::string(); |
| 994 #else | 1000 #else |
| 995 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 1001 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
| 996 #endif | 1002 #endif |
| 997 } | 1003 } |
| OLD | NEW |