Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3493)

Unified Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 22405002: Move the managed user ID validity check out of the general code path (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698