Chromium Code Reviews| Index: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
| diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
| index 9fef1a147ed3dc52f8e0e4e4d5052785e3c128f4..481e90fe0694cfa1ea2f3451383f75990a88636e 100644 |
| --- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
| +++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
| @@ -99,6 +99,8 @@ const char kJsApiUserManagerRemoveUserWarningLoadStats[] = |
| "removeUserWarningLoadStats"; |
| const char kJsApiUserManagerGetRemoveWarningDialogMessage[] = |
| "getRemoveWarningDialogMessage"; |
| +const char kJsApiUserManagerIsAtLeastOneProfileUnlocked[] = |
| + "isAtLeastOneProfileUnlocked"; |
| const size_t kAvatarIconSize = 180; |
| const int kMaxOAuthRetries = 3; |
| @@ -465,6 +467,15 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { |
| DCHECK(profiles::IsMultipleProfilesEnabled()); |
| + if (profiles::AreAllProfilesLocked()) { |
| + web_ui()->CallJavascriptFunction( |
| + "cr.webUIListenerCallback", |
| + base::StringValue("show-error-dialog"), |
| + base::StringValue(l10n_util::GetStringUTF8( |
| + IDS_USER_MANAGER_REMOVE_PROFILE_PROFILES_LOCKED_ERROR))); |
| + return; |
| + } |
| + |
| // The callback is run if the only profile has been deleted, and a new |
| // profile has been created to replace it. |
| webui::DeleteProfileAtPath(profile_path, |
| @@ -484,6 +495,18 @@ void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { |
| } |
| } |
| +void UserManagerScreenHandler::HandleIsAtLeastOneProfileUnlocked( |
| + const base::ListValue* args) { |
| + std::string webui_callback_id_; |
|
Roger Tawa OOO till Jul 10th
2016/05/30 19:03:45
Should remove trailing _ since this is a local var
Moe
2016/05/30 20:21:41
Done.
|
| + CHECK_EQ(1U, args->GetSize()); |
| + bool success = args->GetString(0, &webui_callback_id_); |
| + DCHECK(success); |
| + |
| + web_ui()->CallJavascriptFunction("cr.webUIResponse", |
| + base::StringValue(webui_callback_id_), |
| + base::FundamentalValue(!profiles::AreAllProfilesLocked())); |
| +} |
| + |
| void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { |
| const base::Value* profile_path_value = NULL; |
| if (!args->Get(0, &profile_path_value)) |
| @@ -689,6 +712,10 @@ void UserManagerScreenHandler::RegisterMessages() { |
| kJsApiUserManagerGetRemoveWarningDialogMessage, |
| base::Bind(&UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage, |
| base::Unretained(this))); |
| + web_ui()->RegisterMessageCallback( |
| + kJsApiUserManagerIsAtLeastOneProfileUnlocked, |
| + base::Bind(&UserManagerScreenHandler::HandleIsAtLeastOneProfileUnlocked, |
| + base::Unretained(this))); |
| const content::WebUI::MessageCallback& kDoNothingCallback = |
| base::Bind(&HandleAndDoNothing); |
| @@ -826,6 +853,15 @@ void UserManagerScreenHandler::GetLocalizedValues( |
| base::string16()); |
| localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg", |
| base::string16()); |
| + |
| + // Error message when trying to add a profile while all profiles are locked. |
| + localized_strings->SetString("AddProfileAllProfilesLockedError", |
| + l10n_util::GetStringUTF16( |
| + IDS_USER_MANAGER_ADD_PROFILE_PROFILES_LOCKED_ERROR)); |
| + // Error message when trying to browse as guest while all profiles are locked. |
| + localized_strings->SetString("BrowseAsGuestAllProfilesLockedError", |
| + l10n_util::GetStringUTF16( |
| + IDS_USER_MANAGER_GO_GUEST_PROFILES_LOCKED_ERROR)); |
| } |
| void UserManagerScreenHandler::SendUserList() { |