Commit 242124e8 authored by noms's avatar noms Committed by Commit bot

[Profiles] Trim profile names in chrome://settings

And validate them accordingly (all-space names are still empty and invalid).

BUG=405913
TEST=Go to chrome://settings. Try to enter "      " for the profile name. The
textbox should stay red. Enter "     batman    " for the profile name, and save.
The name should be saved as just "batman". Expect some bat signals.

Review URL: https://codereview.chromium.org/532023003

Cr-Commit-Position: refs/heads/master@{#293571}
parent 1e1bbdec
......@@ -13,7 +13,7 @@
<span id="manage-profile-name-label" for="manage-profile-name"
i18n-content="manageProfilesNameLabel">
</span>
<input id="manage-profile-name" type="text" required>
<input id="manage-profile-name" type="text" pattern=".*\S.*" required>
</label>
</div>
<div id="manage-profile-error-bubble" hidden></div>
......
......@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
......@@ -80,6 +81,7 @@ void CreateProfileHandler::CreateProfile(const base::ListValue* args) {
bool create_shortcut = false;
bool supervised_user = false;
if (args->GetString(0, &name) && args->GetString(1, &icon)) {
base::TrimWhitespace(name, base::TRIM_ALL, &name);
if (args->GetBoolean(2, &create_shortcut)) {
bool success = args->GetBoolean(3, &supervised_user);
DCHECK(success);
......
......@@ -9,6 +9,7 @@
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/value_conversions.h"
#include "base/values.h"
......@@ -381,6 +382,7 @@ void ManageProfileHandler::SetProfileIconAndName(const base::ListValue* args) {
if (!args->GetString(2, &new_profile_name))
return;
base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name);
profiles::UpdateProfileName(profile, new_profile_name);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment