Chromium Code Reviews| Index: chrome/browser/ui/webui/signin/signin_create_profile_handler.cc |
| diff --git a/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc b/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc |
| index 531399c091f6f6b10b120b8d4635282db11417a7..734fd324d97c9e163bed5d6e9322aae4caed8684 100644 |
| --- a/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc |
| +++ b/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc |
| @@ -24,6 +24,7 @@ |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/profiles/profile_metrics.h" |
| #include "chrome/browser/profiles/profiles_state.h" |
| +#include "chrome/browser/signin/signin_error_controller_factory.h" |
| #include "chrome/browser/signin/signin_manager_factory.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/ui/webui/profile_helper.h" |
| @@ -32,6 +33,7 @@ |
| #include "chrome/grit/generated_resources.h" |
| #include "components/browser_sync/browser/profile_sync_service.h" |
| #include "components/prefs/pref_service.h" |
| +#include "components/signin/core/browser/signin_error_controller.h" |
| #include "components/strings/grit/components_strings.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/web_ui.h" |
| @@ -62,10 +64,6 @@ void SigninCreateProfileHandler::GetLocalizedValues( |
| "manageProfilesSupervisedSignedInLabel", |
| l10n_util::GetStringUTF16( |
| IDS_PROFILES_CREATE_SUPERVISED_MULTI_SIGNED_IN_LABEL)); |
| - localized_strings->SetString( |
| - "manageProfilesSupervisedNotSignedIn", |
| - l10n_util::GetStringUTF16( |
| - IDS_PROFILES_CREATE_SUPERVISED_NOT_SIGNED_IN_HTML)); |
| localized_strings->SetString("createProfileConfirm", |
| l10n_util::GetStringUTF16(IDS_SAVE)); |
| localized_strings->SetString("learnMore", |
| @@ -73,7 +71,6 @@ void SigninCreateProfileHandler::GetLocalizedValues( |
| localized_strings->SetString( |
| "createProfileTitle", |
| l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_TITLE)); |
| - |
| localized_strings->SetString( |
| "supervisedUserLearnMoreTitle", |
| l10n_util::GetStringUTF16(IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_TITLE)); |
| @@ -87,6 +84,22 @@ void SigninCreateProfileHandler::GetLocalizedValues( |
| IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_TEXT, |
| base::ASCIIToUTF16( |
| chrome::kLegacySupervisedUserManagementDisplayURL))); |
| + localized_strings->SetString( |
| + "manageProfilesExistingSupervisedUser", |
| + l10n_util::GetStringUTF16( |
| + IDS_PROFILES_CREATE_LEGACY_SUPERVISED_USER_ERROR_EXISTS_REMOTELY)); |
| + localized_strings->SetString( |
| + "managedProfilesExistingLocalSupervisedUser", |
| + l10n_util::GetStringUTF16( |
| + IDS_PROFILES_CREATE_LEGACY_SUPERVISED_USER_ERROR_EXISTS_LOCALLY)); |
| + localized_strings->SetString( |
| + "supervisorAccountDetailsOutofDateError", |
| + l10n_util::GetStringUTF16( |
| + IDS_PROFILES_CREATE_SUPERVISOR_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR)); |
|
Pam (message me for reviews)
2016/03/24 19:53:14
Existing bugs and docs and other code refer to the
Moe
2016/03/24 22:07:57
Done.
|
| + localized_strings->SetString( |
| + "supervisorAccountNotSelectedError", |
| + l10n_util::GetStringUTF16( |
| + IDS_PROFILES_CREATE_NO_SUPERVISOR_ACCOUNT_ERROR)); |
| } |
| void SigninCreateProfileHandler::RegisterMessages() { |
| @@ -128,6 +141,20 @@ void SigninCreateProfileHandler::RequestDefaultProfileIcons( |
| web_ui()->CallJavascriptFunction("cr.webUIListenerCallback", |
| base::StringValue("profile-icons-received"), |
| image_url_list); |
| + |
| + SendNewProfileDefaults(); |
| +} |
| + |
| +void SigninCreateProfileHandler::SendNewProfileDefaults() { |
| + ProfileInfoCache& cache = |
| + g_browser_process->profile_manager()->GetProfileInfoCache(); |
| + base::DictionaryValue profile_info; |
| + profile_info.SetString("name", cache.ChooseNameForNewProfile(0)); |
| + |
| + web_ui()->CallJavascriptFunction( |
| + "cr.webUIListenerCallback", |
| + base::StringValue("profile-defaults-received"), |
| + profile_info); |
| } |
| void SigninCreateProfileHandler::RequestSignedInProfiles( |
| @@ -327,14 +354,14 @@ void SigninCreateProfileHandler::ShowProfileCreationError( |
| Profile* profile, |
| const base::string16& error) { |
| DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); |
| - profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
| - profile_path_being_created_.clear(); |
| web_ui()->CallJavascriptFunction("cr.webUIListenerCallback", |
| GetWebUIListenerName(PROFILE_CREATION_ERROR), |
| base::StringValue(error)); |
| // The ProfileManager calls us back with a NULL profile in some cases. |
| if (profile) |
| webui::DeleteProfileAtPath(profile->GetPath(), web_ui()); |
| + profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
| + profile_path_being_created_.clear(); |
| } |
| void SigninCreateProfileHandler::RecordProfileCreationMetrics( |
| @@ -446,7 +473,13 @@ void SigninCreateProfileHandler::LoadSupervisorProfileCallback( |
| case Profile::CREATE_STATUS_INITIALIZED: { |
| // We are only interested in Profile::CREATE_STATUS_INITIALIZED when |
| // everything is ready. |
| - // TODO(mahmadi): display proper error message to the user. |
| + if (!IsAccountConnected(supervisor_profile) || |
| + HasAuthError(supervisor_profile)) { |
| + ShowProfileCreationError(nullptr, l10n_util::GetStringUTF16( |
| + IDS_PROFILES_CREATE_SUPERVISOR_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR)); |
| + return; |
| + } |
| + |
| PrefService* prefs = supervisor_profile->GetPrefs(); |
| if (!prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)) |
| return; |
| @@ -494,6 +527,28 @@ void SigninCreateProfileHandler::LoadSupervisorProfileCallback( |
| } |
| } |
| +bool SigninCreateProfileHandler::IsAccountConnected(Profile* profile) |
| + const { |
| + SigninManagerBase* signin_manager = |
| + SigninManagerFactory::GetForProfile(profile); |
| + return signin_manager && signin_manager->IsAuthenticated(); |
| +} |
| + |
| +bool SigninCreateProfileHandler::HasAuthError(Profile* profile) |
| + const { |
| + SigninErrorController* error_controller = |
| + SigninErrorControllerFactory::GetForProfile(profile); |
| + if (!error_controller) |
| + return true; |
| + |
| + GoogleServiceAuthError::State state = error_controller->auth_error().state(); |
| + |
| + return state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || |
| + state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || |
| + state == GoogleServiceAuthError::ACCOUNT_DELETED || |
| + state == GoogleServiceAuthError::ACCOUNT_DISABLED; |
|
Roger Tawa OOO till Jul 10th
2016/03/24 14:39:05
Is there a specific reason to handle these 4 state
Moe
2016/03/24 22:07:57
No specific reason. These 4 states were being chec
|
| +} |
| + |
| void SigninCreateProfileHandler::DoCreateProfileIfPossible( |
| const base::string16& name, |
| const std::string& icon_url, |