Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 } | 716 } |
| 717 | 717 |
| 718 void SupervisedUserService::StartSetupSync() { | 718 void SupervisedUserService::StartSetupSync() { |
| 719 // Tell the sync service that setup is in progress so we don't start syncing | 719 // Tell the sync service that setup is in progress so we don't start syncing |
| 720 // until we've finished configuration. | 720 // until we've finished configuration. |
| 721 sync_blocker_ = ProfileSyncServiceFactory::GetForProfile(profile_) | 721 sync_blocker_ = ProfileSyncServiceFactory::GetForProfile(profile_) |
| 722 ->GetSetupInProgressHandle(); | 722 ->GetSetupInProgressHandle(); |
| 723 } | 723 } |
| 724 | 724 |
| 725 void SupervisedUserService::FinishSetupSyncWhenReady() { | 725 void SupervisedUserService::FinishSetupSyncWhenReady() { |
| 726 // If we're already waiting for the Sync backend, there's nothing to do here. | 726 // If we're already waiting for the Sync backend, there's nothing to do here. |
|
skym
2016/12/05 19:38:55
backend
maxbogue
2016/12/05 22:17:10
Done.
| |
| 727 if (waiting_for_sync_initialization_) | 727 if (waiting_for_sync_initialization_) |
| 728 return; | 728 return; |
| 729 | 729 |
| 730 // Continue in FinishSetupSync() once the Sync backend has been initialized. | 730 // Continue in FinishSetupSync() once the Sync backend has been initialized. |
|
skym
2016/12/05 19:38:55
backend
maxbogue
2016/12/05 22:17:10
Done.
| |
| 731 browser_sync::ProfileSyncService* service = | 731 browser_sync::ProfileSyncService* service = |
| 732 ProfileSyncServiceFactory::GetForProfile(profile_); | 732 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 733 if (service->IsBackendInitialized()) { | 733 if (service->IsEngineInitialized()) { |
| 734 FinishSetupSync(); | 734 FinishSetupSync(); |
| 735 } else { | 735 } else { |
| 736 service->AddObserver(this); | 736 service->AddObserver(this); |
| 737 waiting_for_sync_initialization_ = true; | 737 waiting_for_sync_initialization_ = true; |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 void SupervisedUserService::FinishSetupSync() { | 741 void SupervisedUserService::FinishSetupSync() { |
| 742 browser_sync::ProfileSyncService* service = | 742 browser_sync::ProfileSyncService* service = |
| 743 ProfileSyncServiceFactory::GetForProfile(profile_); | 743 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 744 DCHECK(service->IsBackendInitialized()); | 744 DCHECK(service->IsEngineInitialized()); |
| 745 | 745 |
| 746 // Sync nothing (except types which are set via GetPreferredDataTypes). | 746 // Sync nothing (except types which are set via GetPreferredDataTypes). |
| 747 bool sync_everything = false; | 747 bool sync_everything = false; |
| 748 syncer::ModelTypeSet synced_datatypes; | 748 syncer::ModelTypeSet synced_datatypes; |
| 749 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); | 749 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); |
| 750 | 750 |
| 751 // Notify ProfileSyncService that we are done with configuration. | 751 // Notify ProfileSyncService that we are done with configuration. |
| 752 sync_blocker_.reset(); | 752 sync_blocker_.reset(); |
| 753 service->SetFirstSetupComplete(); | 753 service->SetFirstSetupComplete(); |
| 754 } | 754 } |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1256 result.Put(syncer::APP_SETTINGS); | 1256 result.Put(syncer::APP_SETTINGS); |
| 1257 result.Put(syncer::APP_NOTIFICATIONS); | 1257 result.Put(syncer::APP_NOTIFICATIONS); |
| 1258 result.Put(syncer::APP_LIST); | 1258 result.Put(syncer::APP_LIST); |
| 1259 return result; | 1259 return result; |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 #if !defined(OS_ANDROID) | 1262 #if !defined(OS_ANDROID) |
| 1263 void SupervisedUserService::OnStateChanged() { | 1263 void SupervisedUserService::OnStateChanged() { |
| 1264 browser_sync::ProfileSyncService* service = | 1264 browser_sync::ProfileSyncService* service = |
| 1265 ProfileSyncServiceFactory::GetForProfile(profile_); | 1265 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 1266 if (waiting_for_sync_initialization_ && service->IsBackendInitialized()) { | 1266 if (waiting_for_sync_initialization_ && service->IsEngineInitialized()) { |
| 1267 waiting_for_sync_initialization_ = false; | 1267 waiting_for_sync_initialization_ = false; |
| 1268 service->RemoveObserver(this); | 1268 service->RemoveObserver(this); |
| 1269 FinishSetupSync(); | 1269 FinishSetupSync(); |
| 1270 return; | 1270 return; |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 DLOG_IF(ERROR, service->GetAuthError().state() == | 1273 DLOG_IF(ERROR, service->GetAuthError().state() == |
| 1274 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) | 1274 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) |
| 1275 << "Credentials rejected"; | 1275 << "Credentials rejected"; |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { | 1278 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { |
| 1279 bool profile_became_active = profile_->IsSameProfile(browser->profile()); | 1279 bool profile_became_active = profile_->IsSameProfile(browser->profile()); |
| 1280 if (!is_profile_active_ && profile_became_active) | 1280 if (!is_profile_active_ && profile_became_active) |
| 1281 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); | 1281 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); |
| 1282 else if (is_profile_active_ && !profile_became_active) | 1282 else if (is_profile_active_ && !profile_became_active) |
| 1283 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 1283 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 1284 | 1284 |
| 1285 is_profile_active_ = profile_became_active; | 1285 is_profile_active_ = profile_became_active; |
| 1286 } | 1286 } |
| 1287 #endif // !defined(OS_ANDROID) | 1287 #endif // !defined(OS_ANDROID) |
| 1288 | 1288 |
| 1289 void SupervisedUserService::OnSiteListUpdated() { | 1289 void SupervisedUserService::OnSiteListUpdated() { |
| 1290 for (SupervisedUserServiceObserver& observer : observer_list_) | 1290 for (SupervisedUserServiceObserver& observer : observer_list_) |
| 1291 observer.OnURLFilterChanged(); | 1291 observer.OnURLFilterChanged(); |
| 1292 } | 1292 } |
| OLD | NEW |