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 3 // found in the LICENSE file. 4 5 #include "supervised_user_sync_data_type_controller.h" 6 7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" 9 #include "content/public/browser/browser_thread.h" 10 SupervisedUserSyncDataTypeController(syncer::ModelType type,sync_driver::SyncApiComponentFactory * sync_factory,Profile * profile)11SupervisedUserSyncDataTypeController::SupervisedUserSyncDataTypeController( 12 syncer::ModelType type, 13 sync_driver::SyncApiComponentFactory* sync_factory, 14 Profile* profile) 15 : sync_driver::UIDataTypeController( 16 content::BrowserThread::GetMessageLoopProxyForThread( 17 content::BrowserThread::UI), 18 base::Bind(&browser_sync::ChromeReportUnrecoverableError), 19 type, 20 sync_factory), 21 profile_(profile) { 22 DCHECK(type == syncer::SUPERVISED_USERS || 23 type == syncer::SUPERVISED_USER_SETTINGS || 24 type == syncer::SUPERVISED_USER_SHARED_SETTINGS); 25 } 26 ~SupervisedUserSyncDataTypeController()27SupervisedUserSyncDataTypeController::~SupervisedUserSyncDataTypeController() {} 28 ReadyForStart() const29bool SupervisedUserSyncDataTypeController::ReadyForStart() const { 30 switch (type()) { 31 case syncer::SUPERVISED_USERS: 32 return !profile_->IsSupervised(); 33 case syncer::SUPERVISED_USER_SETTINGS: 34 return profile_->IsSupervised(); 35 case syncer::SUPERVISED_USER_SHARED_SETTINGS: 36 return true; 37 default: 38 NOTREACHED(); 39 } 40 return false; 41 } 42