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

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

Issue 132013002: Replace own callback handling with Promises. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
Index: chrome/browser/ui/webui/options/managed_user_import_handler.cc
diff --git a/chrome/browser/ui/webui/options/managed_user_import_handler.cc b/chrome/browser/ui/webui/options/managed_user_import_handler.cc
index 1722b6459499fe77f6a8520bc5216f18282e281f..d8f96e1e2b5165085bbca636d6f51e98667613ef 100644
--- a/chrome/browser/ui/webui/options/managed_user_import_handler.cc
+++ b/chrome/browser/ui/webui/options/managed_user_import_handler.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -62,6 +63,7 @@ void ManagedUserImportHandler::GetLocalizedValues(
{ "managedUserImportSigninError", IDS_MANAGED_USER_IMPORT_SIGN_IN_ERROR },
{ "managedUserAlreadyOnThisDevice",
IDS_MANAGED_USER_ALREADY_ON_THIS_DEVICE },
+ { "managedUserNameConflict", IDS_MANAGED_USER_NAME_CONFLICT },
{ "noExistingManagedUsers", IDS_MANAGED_USER_NO_EXISTING_ERROR },
{ "managedUserSelectAvatarTitle", IDS_MANAGED_USER_SELECT_AVATAR_TITLE },
{ "managedUserSelectAvatarText", IDS_MANAGED_USER_SELECT_AVATAR_TEXT },
@@ -122,9 +124,20 @@ void ManagedUserImportHandler::SendExistingManagedUsers(
DCHECK(dict);
const ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
+
+ // Collect the names of the local profiles.
+ std::vector<base::string16> profile_names_list =
+ ProfileInfoCache::GetProfileNames();
+ std::set<std::string> profile_names;
+ for (size_t i = 0; i < profile_names_list.size(); ++i)
+ profile_names.insert(UTF16ToUTF8(profile_names_list[i]));
+
+ // Collect the ids of local supervised user profiles.
std::set<std::string> managed_user_ids;
- for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i)
- managed_user_ids.insert(cache.GetManagedUserIdOfProfileAtIndex(i));
+ for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
+ if (cache.ProfileIsManagedAtIndex(i))
+ managed_user_ids.insert(cache.GetManagedUserIdOfProfileAtIndex(i));
+ }
base::ListValue managed_users;
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
@@ -157,6 +170,8 @@ void ManagedUserImportHandler::SendExistingManagedUsers(
bool on_current_device =
managed_user_ids.find(it.key()) != managed_user_ids.end();
managed_user->SetBoolean("onCurrentDevice", on_current_device);
+ bool name_conflict = profile_names.find(name) != profile_names.end();
+ managed_user->SetBoolean("nameConflict", name_conflict);
managed_users.Append(managed_user);
}

Powered by Google App Engine
This is Rietveld 408576698