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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 result.Put(syncer::SESSIONS); | 397 result.Put(syncer::SESSIONS); |
398 result.Put(syncer::EXTENSIONS); | 398 result.Put(syncer::EXTENSIONS); |
399 result.Put(syncer::EXTENSION_SETTINGS); | 399 result.Put(syncer::EXTENSION_SETTINGS); |
400 result.Put(syncer::APPS); | 400 result.Put(syncer::APPS); |
401 result.Put(syncer::APP_SETTINGS); | 401 result.Put(syncer::APP_SETTINGS); |
402 result.Put(syncer::APP_NOTIFICATIONS); | 402 result.Put(syncer::APP_NOTIFICATIONS); |
403 result.Put(syncer::APP_LIST); | 403 result.Put(syncer::APP_LIST); |
404 return result; | 404 return result; |
405 } | 405 } |
406 | 406 |
407 void SupervisedUserService::OnStateChanged() { | 407 void SupervisedUserService::OnStateChanged() { |
Marc Treib
2014/09/26 08:42:38
This does get called when the backend_mode changes
Nicolas Zea
2014/09/26 17:09:22
It does. And it looks like that comment is quite o
| |
408 ProfileSyncService* service = | 408 ProfileSyncService* service = |
409 ProfileSyncServiceFactory::GetForProfile(profile_); | 409 ProfileSyncServiceFactory::GetForProfile(profile_); |
410 if (waiting_for_sync_initialization_ && service->sync_initialized()) { | 410 if (waiting_for_sync_initialization_ && service->sync_initialized() && |
411 service->backend_mode() == ProfileSyncService::SYNC) { | |
411 waiting_for_sync_initialization_ = false; | 412 waiting_for_sync_initialization_ = false; |
412 service->RemoveObserver(this); | 413 service->RemoveObserver(this); |
413 FinishSetupSync(); | 414 FinishSetupSync(); |
414 return; | 415 return; |
415 } | 416 } |
416 | 417 |
417 DLOG_IF(ERROR, service->GetAuthError().state() == | 418 DLOG_IF(ERROR, service->GetAuthError().state() == |
418 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) | 419 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) |
419 << "Credentials rejected"; | 420 << "Credentials rejected"; |
420 } | 421 } |
(...skipping 10 matching lines...) Expand all Loading... | |
431 } | 432 } |
432 | 433 |
433 void SupervisedUserService::FinishSetupSyncWhenReady() { | 434 void SupervisedUserService::FinishSetupSyncWhenReady() { |
434 // If we're already waiting for the Sync backend, there's nothing to do here. | 435 // If we're already waiting for the Sync backend, there's nothing to do here. |
435 if (waiting_for_sync_initialization_) | 436 if (waiting_for_sync_initialization_) |
436 return; | 437 return; |
437 | 438 |
438 // Continue in FinishSetupSync() once the Sync backend has been initialized. | 439 // Continue in FinishSetupSync() once the Sync backend has been initialized. |
439 ProfileSyncService* service = | 440 ProfileSyncService* service = |
440 ProfileSyncServiceFactory::GetForProfile(profile_); | 441 ProfileSyncServiceFactory::GetForProfile(profile_); |
441 if (service->sync_initialized()) { | 442 if (service->sync_initialized() && |
443 service->backend_mode() == ProfileSyncService::SYNC) { | |
442 FinishSetupSync(); | 444 FinishSetupSync(); |
443 } else { | 445 } else { |
444 service->AddObserver(this); | 446 service->AddObserver(this); |
445 waiting_for_sync_initialization_ = true; | 447 waiting_for_sync_initialization_ = true; |
446 } | 448 } |
447 } | 449 } |
448 | 450 |
449 void SupervisedUserService::FinishSetupSync() { | 451 void SupervisedUserService::FinishSetupSync() { |
450 ProfileSyncService* service = | 452 ProfileSyncService* service = |
451 ProfileSyncServiceFactory::GetForProfile(profile_); | 453 ProfileSyncServiceFactory::GetForProfile(profile_); |
452 DCHECK(service->sync_initialized()); | 454 DCHECK(service->sync_initialized() && |
Marc Treib
2014/09/26 08:42:38
Hm, so the underlying problem was that sync_initia
Nicolas Zea
2014/09/26 17:09:22
Yeah, I agree this is confusing. For now, since th
| |
455 service->backend_mode() == ProfileSyncService::SYNC); | |
453 | 456 |
454 // Sync nothing (except types which are set via GetPreferredDataTypes). | 457 // Sync nothing (except types which are set via GetPreferredDataTypes). |
455 bool sync_everything = false; | 458 bool sync_everything = false; |
456 syncer::ModelTypeSet synced_datatypes; | 459 syncer::ModelTypeSet synced_datatypes; |
457 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); | 460 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); |
458 | 461 |
459 // Notify ProfileSyncService that we are done with configuration. | 462 // Notify ProfileSyncService that we are done with configuration. |
460 service->SetSetupInProgress(false); | 463 service->SetSetupInProgress(false); |
461 service->SetSyncSetupCompleted(); | 464 service->SetSyncSetupCompleted(); |
462 } | 465 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 // The active user can be NULL in unit tests. | 873 // The active user can be NULL in unit tests. |
871 if (user_manager::UserManager::Get()->GetActiveUser()) { | 874 if (user_manager::UserManager::Get()->GetActiveUser()) { |
872 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 875 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
873 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 876 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
874 } | 877 } |
875 return std::string(); | 878 return std::string(); |
876 #else | 879 #else |
877 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 880 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
878 #endif | 881 #endif |
879 } | 882 } |
OLD | NEW |