| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 ui_url_filter_->SetBlacklist(&blacklist_); | 149 ui_url_filter_->SetBlacklist(&blacklist_); |
| 150 BrowserThread::PostTask( | 150 BrowserThread::PostTask( |
| 151 BrowserThread::IO, | 151 BrowserThread::IO, |
| 152 FROM_HERE, | 152 FROM_HERE, |
| 153 base::Bind(&SupervisedUserURLFilter::SetBlacklist, | 153 base::Bind(&SupervisedUserURLFilter::SetBlacklist, |
| 154 io_url_filter_, | 154 io_url_filter_, |
| 155 &blacklist_)); | 155 &blacklist_)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 SupervisedUserService::SupervisedUserService(Profile* profile) | 158 SupervisedUserService::SupervisedUserService(Profile* profile) |
| 159 : profile_(profile), | 159 : includes_sync_sessions_type_(true), |
| 160 profile_(profile), |
| 160 active_(false), | 161 active_(false), |
| 161 delegate_(NULL), | 162 delegate_(NULL), |
| 162 #if defined(ENABLE_EXTENSIONS) | 163 #if defined(ENABLE_EXTENSIONS) |
| 163 extension_registry_observer_(this), | 164 extension_registry_observer_(this), |
| 164 #endif | 165 #endif |
| 165 waiting_for_sync_initialization_(false), | 166 waiting_for_sync_initialization_(false), |
| 166 is_profile_active_(false), | 167 is_profile_active_(false), |
| 167 elevated_for_testing_(false), | 168 elevated_for_testing_(false), |
| 168 did_init_(false), | 169 did_init_(false), |
| 169 did_shutdown_(false), | 170 did_shutdown_(false), |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 UpdateSiteLists(); | 394 UpdateSiteLists(); |
| 394 } | 395 } |
| 395 } | 396 } |
| 396 #endif // defined(ENABLE_EXTENSIONS) | 397 #endif // defined(ENABLE_EXTENSIONS) |
| 397 | 398 |
| 398 syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const { | 399 syncer::ModelTypeSet SupervisedUserService::GetPreferredDataTypes() const { |
| 399 if (!ProfileIsSupervised()) | 400 if (!ProfileIsSupervised()) |
| 400 return syncer::ModelTypeSet(); | 401 return syncer::ModelTypeSet(); |
| 401 | 402 |
| 402 syncer::ModelTypeSet result; | 403 syncer::ModelTypeSet result; |
| 403 result.Put(syncer::SESSIONS); | 404 if (IncludesSyncSessionsType()) |
| 405 result.Put(syncer::SESSIONS); |
| 404 result.Put(syncer::EXTENSIONS); | 406 result.Put(syncer::EXTENSIONS); |
| 405 result.Put(syncer::EXTENSION_SETTINGS); | 407 result.Put(syncer::EXTENSION_SETTINGS); |
| 406 result.Put(syncer::APPS); | 408 result.Put(syncer::APPS); |
| 407 result.Put(syncer::APP_SETTINGS); | 409 result.Put(syncer::APP_SETTINGS); |
| 408 result.Put(syncer::APP_NOTIFICATIONS); | 410 result.Put(syncer::APP_NOTIFICATIONS); |
| 409 result.Put(syncer::APP_LIST); | 411 result.Put(syncer::APP_LIST); |
| 410 return result; | 412 return result; |
| 411 } | 413 } |
| 412 | 414 |
| 415 void SupervisedUserService::OnHistoryRecordingStateChanged() { |
| 416 includes_sync_sessions_type_ = |
| 417 profile_->GetPrefs()->GetBoolean(prefs::kRecordHistory); |
| 418 ProfileSyncServiceFactory::GetForProfile(profile_) |
| 419 ->ReconfigureDatatypeManager(); |
| 420 } |
| 421 |
| 422 bool SupervisedUserService::IncludesSyncSessionsType() const { |
| 423 return includes_sync_sessions_type_; |
| 424 } |
| 425 |
| 413 void SupervisedUserService::OnStateChanged() { | 426 void SupervisedUserService::OnStateChanged() { |
| 414 ProfileSyncService* service = | 427 ProfileSyncService* service = |
| 415 ProfileSyncServiceFactory::GetForProfile(profile_); | 428 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 416 if (waiting_for_sync_initialization_ && service->sync_initialized() && | 429 if (waiting_for_sync_initialization_ && service->sync_initialized() && |
| 417 service->backend_mode() == ProfileSyncService::SYNC) { | 430 service->backend_mode() == ProfileSyncService::SYNC) { |
| 418 waiting_for_sync_initialization_ = false; | 431 waiting_for_sync_initialization_ = false; |
| 419 service->RemoveObserver(this); | 432 service->RemoveObserver(this); |
| 420 FinishSetupSync(); | 433 FinishSetupSync(); |
| 421 return; | 434 return; |
| 422 } | 435 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 void SupervisedUserService::Init() { | 686 void SupervisedUserService::Init() { |
| 674 DCHECK(!did_init_); | 687 DCHECK(!did_init_); |
| 675 did_init_ = true; | 688 did_init_ = true; |
| 676 DCHECK(GetSettingsService()->IsReady()); | 689 DCHECK(GetSettingsService()->IsReady()); |
| 677 | 690 |
| 678 pref_change_registrar_.Init(profile_->GetPrefs()); | 691 pref_change_registrar_.Init(profile_->GetPrefs()); |
| 679 pref_change_registrar_.Add( | 692 pref_change_registrar_.Add( |
| 680 prefs::kSupervisedUserId, | 693 prefs::kSupervisedUserId, |
| 681 base::Bind(&SupervisedUserService::OnSupervisedUserIdChanged, | 694 base::Bind(&SupervisedUserService::OnSupervisedUserIdChanged, |
| 682 base::Unretained(this))); | 695 base::Unretained(this))); |
| 696 pref_change_registrar_.Add( |
| 697 prefs::kRecordHistory, |
| 698 base::Bind(&SupervisedUserService::OnHistoryRecordingStateChanged, |
| 699 base::Unretained(this))); |
| 683 | 700 |
| 684 ProfileSyncService* sync_service = | 701 ProfileSyncService* sync_service = |
| 685 ProfileSyncServiceFactory::GetForProfile(profile_); | 702 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 686 // Can be null in tests. | 703 // Can be null in tests. |
| 687 if (sync_service) | 704 if (sync_service) |
| 688 sync_service->AddPreferenceProvider(this); | 705 sync_service->AddPreferenceProvider(this); |
| 689 | 706 |
| 690 SetActive(ProfileIsSupervised()); | 707 SetActive(ProfileIsSupervised()); |
| 691 } | 708 } |
| 692 | 709 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 // The active user can be NULL in unit tests. | 947 // The active user can be NULL in unit tests. |
| 931 if (user_manager::UserManager::Get()->GetActiveUser()) { | 948 if (user_manager::UserManager::Get()->GetActiveUser()) { |
| 932 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 949 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
| 933 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 950 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
| 934 } | 951 } |
| 935 return std::string(); | 952 return std::string(); |
| 936 #else | 953 #else |
| 937 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 954 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
| 938 #endif | 955 #endif |
| 939 } | 956 } |
| OLD | NEW |