OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/signin/signin_create_profile_handler.h" | 5 #include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 // We are only interested in Profile::CREATE_STATUS_INITIALIZED when | 566 // We are only interested in Profile::CREATE_STATUS_INITIALIZED when |
567 // everything is ready. | 567 // everything is ready. |
568 if (!IsAccountConnected(custodian_profile) || | 568 if (!IsAccountConnected(custodian_profile) || |
569 HasAuthError(custodian_profile)) { | 569 HasAuthError(custodian_profile)) { |
570 ShowProfileCreationError(nullptr, l10n_util::GetStringFUTF16( | 570 ShowProfileCreationError(nullptr, l10n_util::GetStringFUTF16( |
571 IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR, | 571 IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR, |
572 base::ASCIIToUTF16(custodian_profile->GetProfileUserName()))); | 572 base::ASCIIToUTF16(custodian_profile->GetProfileUserName()))); |
573 return; | 573 return; |
574 } | 574 } |
575 | 575 |
576 // TODO(mahmadi): return proper error message if policy-controlled prefs | |
577 // prohibit adding supervised users (also disable the controls in the UI). | |
578 PrefService* prefs = custodian_profile->GetPrefs(); | 576 PrefService* prefs = custodian_profile->GetPrefs(); |
579 if (!prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)) | 577 if (!prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)) { |
| 578 ShowProfileCreationError( |
| 579 nullptr, |
| 580 l10n_util::GetStringUTF16( |
| 581 IDS_PROFILES_CREATE_SUPERVISED_NOT_ALLOWED_BY_POLICY)); |
580 return; | 582 return; |
| 583 } |
581 | 584 |
582 if (!supervised_user_id.empty()) { | 585 if (!supervised_user_id.empty()) { |
583 profile_creation_type_ = SUPERVISED_PROFILE_IMPORT; | 586 profile_creation_type_ = SUPERVISED_PROFILE_IMPORT; |
584 | 587 |
585 // Load all supervised users managed by this user in order to | 588 // Load all supervised users managed by this user in order to |
586 // check if this supervised user already exists on this device. | 589 // check if this supervised user already exists on this device. |
587 SupervisedUserSyncService* supervised_user_sync_service = | 590 SupervisedUserSyncService* supervised_user_sync_service = |
588 SupervisedUserSyncServiceFactory::GetForProfile(custodian_profile); | 591 SupervisedUserSyncServiceFactory::GetForProfile(custodian_profile); |
589 if (supervised_user_sync_service) { | 592 if (supervised_user_sync_service) { |
590 supervised_user_sync_service->GetSupervisedUsersAsync(base::Bind( | 593 supervised_user_sync_service->GetSupervisedUsersAsync(base::Bind( |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 profiles::OpenBrowserWindowForProfile( | 805 profiles::OpenBrowserWindowForProfile( |
803 base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback, | 806 base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback, |
804 weak_ptr_factory_.GetWeakPtr()), | 807 weak_ptr_factory_.GetWeakPtr()), |
805 false, // Don't create a window if one already exists. | 808 false, // Don't create a window if one already exists. |
806 true, // Create a first run window. | 809 true, // Create a first run window. |
807 profile, | 810 profile, |
808 Profile::CREATE_STATUS_INITIALIZED); | 811 Profile::CREATE_STATUS_INITIALIZED); |
809 } | 812 } |
810 | 813 |
811 #endif | 814 #endif |
OLD | NEW |