Index: chrome/browser/ui/webui/options/browser_options_handler.cc |
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc |
index 09946702e4decb239c4f07a6df58e2fdbd0d9006..ccdaae1e0099ff9609833b0facbd9ceaa0e038ec 100644 |
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc |
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc |
@@ -1123,8 +1123,6 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
DCHECK(success); |
} |
} |
- if (!IsValidExistingManagedUserId(managed_user_id)) |
- return; |
std::vector<ProfileManager::CreateCallback> callbacks; |
if (create_shortcut) |
@@ -1136,6 +1134,9 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
managed_user); |
if (managed_user && ManagedUserService::AreManagedUsersEnabled()) { |
+ if (!IsValidExistingManagedUserId(managed_user_id)) |
+ return; |
+ |
if (managed_user_id.empty()) { |
managed_user_id = |
ManagedUserRegistrationUtility::GenerateNewManagedUserId(); |
@@ -1745,20 +1746,21 @@ void BrowserOptionsHandler::SetupProxySettingsSection() { |
bool BrowserOptionsHandler::IsValidExistingManagedUserId( |
const std::string& existing_managed_user_id) const { |
+ if (existing_managed_user_id.empty()) |
+ return true; |
+ |
if (!CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kAllowCreateExistingManagedUsers)) { |
return false; |
} |
- if (existing_managed_user_id.empty()) |
- return true; |
DictionaryPrefUpdate update(Profile::FromWebUI(web_ui())->GetPrefs(), |
prefs::kManagedUsers); |
DictionaryValue* dict = update.Get(); |
if (!dict->HasKey(existing_managed_user_id)) |
return false; |
- // Check if this managed user is already exists on this machine. |
+ // Check if this managed user already exists on this machine. |
const ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { |