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

Unified Diff: chrome/browser/ui/webui/signin/signin_create_profile_handler.cc

Issue 1630903002: material design user manager with create profile flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed roger's comments Created 4 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/signin/signin_create_profile_handler.cc
diff --git a/chrome/browser/ui/webui/options/create_profile_handler.cc b/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
similarity index 59%
copy from chrome/browser/ui/webui/options/create_profile_handler.cc
copy to chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
index a85a4f4830dfad2561fb3bbd2ec48a0773a5a419..95f11fa25c6fc7bbcb4ac55180f36619d336b986 100644
--- a/chrome/browser/ui/webui/options/create_profile_handler.cc
+++ b/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/options/create_profile_handler.h"
+#include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h"
#include <stddef.h>
@@ -11,6 +11,9 @@
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/task_runner_util.h"
+#include "base/threading/thread_restrictions.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -18,11 +21,15 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/options/options_handlers_helper.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/browser_sync/browser/profile_sync_service.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
@@ -34,46 +41,108 @@
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#endif
-namespace options {
-
-CreateProfileHandler::CreateProfileHandler()
+SigninCreateProfileHandler::SigninCreateProfileHandler()
: profile_creation_type_(NO_CREATION_IN_PROGRESS),
weak_ptr_factory_(this) {
}
-CreateProfileHandler::~CreateProfileHandler() {
+SigninCreateProfileHandler::~SigninCreateProfileHandler() {
#if defined(ENABLE_SUPERVISED_USERS)
// Cancellation is only supported for supervised users.
CancelProfileRegistration(false);
#endif
}
-void CreateProfileHandler::GetLocalizedValues(
+void SigninCreateProfileHandler::GetLocalizedValues(
base::DictionaryValue* localized_strings) {
+ localized_strings->SetString("manageProfilesSupervisedSignedInLabel",
+ l10n_util::GetStringUTF16(
anthonyvd 2016/01/29 15:50:17 nit: need 2 extra leading spaces
Moe 2016/02/01 01:11:13 Done.
+ IDS_PROFILES_CREATE_SUPERVISED_MULTI_SIGNED_IN_LABEL));
+ localized_strings->SetString("manageProfilesSupervisedNotSignedIn",
+ l10n_util::GetStringUTF16(
anthonyvd 2016/01/29 15:50:17 nit: need 2 extra leading spaces
Moe 2016/02/01 01:11:13 Done.
+ IDS_PROFILES_CREATE_SUPERVISED_NOT_SIGNED_IN_HTML));
+ localized_strings->SetString("createProfileConfirm",
+ l10n_util::GetStringUTF16(IDS_SAVE));
+ localized_strings->SetString("learnMore",
+ l10n_util::GetStringUTF16(IDS_LEARN_MORE));
anthonyvd 2016/01/29 15:50:17 nit: need 2 extra leading spaces
Moe 2016/02/01 01:11:13 Done.
+ localized_strings->SetString("createProfileTitle",
+ l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_TITLE));
+
+ localized_strings->SetString("supervisedUserLearnMoreTitle",
+ l10n_util::GetStringUTF16(IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_TITLE));
+ localized_strings->SetString("supervisedUserLearnMoreDone",
+ l10n_util::GetStringUTF16(
+ IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_DONE_BUTTON));
+ localized_strings->SetString("supervisedUserLearnMoreText",
+ l10n_util::GetStringFUTF16(
+ IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_TEXT,
+ base::ASCIIToUTF16(
+ chrome::kLegacySupervisedUserManagementDisplayURL)));
}
-void CreateProfileHandler::RegisterMessages() {
+void SigninCreateProfileHandler::RegisterMessages() {
#if defined(ENABLE_SUPERVISED_USERS)
// Cancellation is only supported for supervised users.
web_ui()->RegisterMessageCallback(
"cancelCreateProfile",
- base::Bind(&CreateProfileHandler::HandleCancelProfileCreation,
+ base::Bind(&SigninCreateProfileHandler::HandleCancelProfileCreation,
base::Unretained(this)));
#endif
web_ui()->RegisterMessageCallback(
"createProfile",
- base::Bind(&CreateProfileHandler::CreateProfile,
+ base::Bind(&SigninCreateProfileHandler::CreateProfile,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "requestDefaultProfileIcons",
+ base::Bind(&SigninCreateProfileHandler::RequestDefaultProfileIcons,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "requestCreateProfileUpdate",
+ base::Bind(&SigninCreateProfileHandler::RequestCreateProfileUpdate,
base::Unretained(this)));
}
-void CreateProfileHandler::CreateProfile(const base::ListValue* args) {
-#if defined(ENABLE_SUPERVISED_USERS)
- // This handler could have been called for a supervised user, for example
- // because the user fiddled with the web inspector. Silently return.
- if (Profile::FromWebUI(web_ui())->IsSupervised())
- return;
-#endif
+void SigninCreateProfileHandler::RequestDefaultProfileIcons(
+ const base::ListValue* args) {
+ base::ListValue image_url_list;
+
+ // Add the default avatar icons.
+ for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); i++) {
+ std::string url = profiles::GetDefaultAvatarIconUrl(i);
Mike Lerman 2016/01/29 19:48:22 This is going to include the grey silhouette, kPla
Moe 2016/02/01 01:11:13 Done.
+ image_url_list.AppendString(url);
+ }
+
+ web_ui()->CallJavascriptFunction(
+ "cr.ui.ProfileApi.receiveAvailableIcons",
+ image_url_list);
+}
+
+void SigninCreateProfileHandler::RequestCreateProfileUpdate(
Mike Lerman 2016/01/29 19:48:22 This method name doesn't seem to reflect what the
Moe 2016/02/01 01:11:13 Done.
+ const base::ListValue* args) {
+ base::ListValue user_info_list;
+ ProfileManager* pm = g_browser_process->profile_manager();
anthonyvd 2016/01/29 15:50:17 nit: Chrome code tends to use full names over abre
Moe 2016/02/01 01:11:13 Done.
+ const ProfileInfoCache& cache = pm->GetProfileInfoCache();
anthonyvd 2016/01/29 15:50:18 The ProfileInfoCache is deprecated, so you should
Moe 2016/02/01 01:11:13 Done.
+ for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
+ if (!cache.ProfileIsAuthErrorAtIndex(i)) {
Mike Lerman 2016/01/29 19:48:22 I think skipping profiles where there's an auth er
Moe 2016/02/01 01:11:13 Done.
+ base::string16 username = cache.GetUserNameOfProfileAtIndex(i);
+ if (username.empty())
+ continue;
+ base::string16 profile_path =
+ cache.GetPathOfProfileAtIndex(i).AsUTF16Unsafe();
+ base::DictionaryValue* user_info = new base::DictionaryValue();
+ user_info->SetString("username", username);
+ user_info->SetString("profile_path", profile_path);
+
+ user_info_list.Append(user_info);
+ }
+ }
+ web_ui()->CallJavascriptFunction("cr.ui.ProfileApi.updateSignedInUsers",
Mike Lerman 2016/01/29 19:48:22 thought: what if the profile's locked?
Moe 2016/02/01 01:11:13 The decision was to allow any user add a supervise
+ user_info_list);
+}
+void SigninCreateProfileHandler::CreateProfile(const base::ListValue* args) {
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -101,28 +170,49 @@ void CreateProfileHandler::CreateProfile(const base::ListValue* args) {
#endif
args->GetBoolean(2, &create_shortcut);
}
- std::string supervised_user_id;
#if defined(ENABLE_SUPERVISED_USERS)
- if (!ProcessSupervisedCreateProfileArgs(args, &supervised_user_id))
- return;
+ std::string supervised_user_id;
+ base::FilePath supervisor_profile_path;
+ if (GetSupervisedCreateProfileArgs(args, &supervised_user_id,
+ &supervisor_profile_path)) {
+ // Load supervisor profile.
+ g_browser_process->profile_manager()->CreateProfileAsync(
+ supervisor_profile_path,
+ base::Bind(&SigninCreateProfileHandler::LoadSupervisorProfileCallback,
+ weak_ptr_factory_.GetWeakPtr(), name, icon_url,
+ create_shortcut, supervised_user_id),
+ base::string16(), std::string(), std::string());
+ } else {
+ DoCreateProfile(name, icon_url, create_shortcut, std::string(), nullptr);
+ }
+#else
+ DoCreateProfile(name, icon_url, create_shortcut, std::string(), nullptr);
#endif
+}
+void SigninCreateProfileHandler::DoCreateProfile(const base::string16& name,
+ const std::string& icon_url,
+ bool create_shortcut,
+ const std::string& supervised_user_id,
+ Profile* supervisor_profile) {
ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG);
profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync(
name, icon_url,
- base::Bind(&CreateProfileHandler::OnProfileCreated,
+ base::Bind(&SigninCreateProfileHandler::OnProfileCreated,
weak_ptr_factory_.GetWeakPtr(),
create_shortcut,
- helper::GetDesktopType(web_ui()),
- supervised_user_id),
+ options::helper::GetDesktopType(web_ui()),
+ supervised_user_id,
+ supervisor_profile),
supervised_user_id);
}
-void CreateProfileHandler::OnProfileCreated(
+void SigninCreateProfileHandler::OnProfileCreated(
bool create_shortcut,
chrome::HostDesktopType desktop_type,
const std::string& supervised_user_id,
+ Profile* supervisor_profile,
Profile* profile,
Profile::CreateStatus status) {
if (status != Profile::CREATE_STATUS_CREATED)
@@ -139,7 +229,8 @@ void CreateProfileHandler::OnProfileCreated(
}
case Profile::CREATE_STATUS_INITIALIZED: {
HandleProfileCreationSuccess(create_shortcut, desktop_type,
- supervised_user_id, profile);
+ supervised_user_id, supervisor_profile,
+ profile);
break;
}
// User-initiated cancellation is handled in CancelProfileRegistration and
@@ -155,10 +246,11 @@ void CreateProfileHandler::OnProfileCreated(
}
}
-void CreateProfileHandler::HandleProfileCreationSuccess(
+void SigninCreateProfileHandler::HandleProfileCreationSuccess(
bool create_shortcut,
chrome::HostDesktopType desktop_type,
const std::string& supervised_user_id,
+ Profile* supervisor_profile,
Profile* profile) {
switch (profile_creation_type_) {
case NON_SUPERVISED_PROFILE_CREATION: {
@@ -170,7 +262,7 @@ void CreateProfileHandler::HandleProfileCreationSuccess(
case SUPERVISED_PROFILE_CREATION:
case SUPERVISED_PROFILE_IMPORT:
RegisterSupervisedUser(create_shortcut, desktop_type,
- supervised_user_id, profile);
+ supervised_user_id, supervisor_profile, profile);
break;
#endif
case NO_CREATION_IN_PROGRESS:
@@ -179,7 +271,7 @@ void CreateProfileHandler::HandleProfileCreationSuccess(
}
}
-void CreateProfileHandler::CreateShortcutAndShowSuccess(
+void SigninCreateProfileHandler::CreateShortcutAndShowSuccess(
bool create_shortcut,
chrome::HostDesktopType desktop_type,
Profile* profile) {
@@ -221,14 +313,14 @@ void CreateProfileHandler::CreateShortcutAndShowSuccess(
if (should_open_new_window) {
// Opening the new window must be the last action, after all callbacks
// have been run, to give them a chance to initialize the profile.
- helper::OpenNewWindowForProfile(desktop_type,
+ options::helper::OpenNewWindowForProfile(desktop_type,
profile,
Profile::CREATE_STATUS_INITIALIZED);
}
profile_creation_type_ = NO_CREATION_IN_PROGRESS;
}
-void CreateProfileHandler::ShowProfileCreationError(
+void SigninCreateProfileHandler::ShowProfileCreationError(
Profile* profile,
const base::string16& error) {
DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
@@ -239,10 +331,10 @@ void CreateProfileHandler::ShowProfileCreationError(
base::StringValue(error));
// The ProfileManager calls us back with a NULL profile in some cases.
if (profile)
- helper::DeleteProfileAtPath(profile->GetPath(), web_ui());
+ options::helper::DeleteProfileAtPath(profile->GetPath(), web_ui());
}
-void CreateProfileHandler::RecordProfileCreationMetrics(
+void SigninCreateProfileHandler::RecordProfileCreationMetrics(
Profile::CreateStatus status) {
UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
status,
@@ -252,7 +344,7 @@ void CreateProfileHandler::RecordProfileCreationMetrics(
base::TimeTicks::Now() - profile_creation_start_time_);
}
-base::string16 CreateProfileHandler::GetProfileCreationErrorMessageLocal()
+base::string16 SigninCreateProfileHandler::GetProfileCreationErrorMessageLocal()
const {
int message_id = IDS_PROFILES_CREATE_LOCAL_ERROR;
#if defined(ENABLE_SUPERVISED_USERS)
@@ -264,7 +356,7 @@ base::string16 CreateProfileHandler::GetProfileCreationErrorMessageLocal()
}
#if defined(ENABLE_SUPERVISED_USERS)
-base::string16 CreateProfileHandler::GetProfileCreationErrorMessageRemote()
+base::string16 SigninCreateProfileHandler::GetProfileCreateErrorMessageRemote()
const {
return l10n_util::GetStringUTF16(
profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
@@ -272,7 +364,7 @@ base::string16 CreateProfileHandler::GetProfileCreationErrorMessageRemote()
IDS_PROFILES_CREATE_REMOTE_ERROR);
}
-base::string16 CreateProfileHandler::GetProfileCreationErrorMessageSignin()
+base::string16 SigninCreateProfileHandler::GetProfileCreateErrorMessageSignin()
const {
return l10n_util::GetStringUTF16(
profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
@@ -281,7 +373,7 @@ base::string16 CreateProfileHandler::GetProfileCreationErrorMessageSignin()
}
#endif
-std::string CreateProfileHandler::GetJavascriptMethodName(
+std::string SigninCreateProfileHandler::GetJavascriptMethodName(
ProfileCreationStatus status) const {
switch (profile_creation_type_) {
#if defined(ENABLE_SUPERVISED_USERS)
@@ -297,9 +389,9 @@ std::string CreateProfileHandler::GetJavascriptMethodName(
default:
switch (status) {
case PROFILE_CREATION_SUCCESS:
- return "BrowserOptions.showCreateProfileSuccess";
+ return "cr.ui.ProfileApi.onCreateProfileSuccess";
case PROFILE_CREATION_ERROR:
- return "BrowserOptions.showCreateProfileError";
+ return "cr.ui.ProfileApi.onCreateProfileError";
}
break;
}
@@ -309,25 +401,57 @@ std::string CreateProfileHandler::GetJavascriptMethodName(
}
#if defined(ENABLE_SUPERVISED_USERS)
-bool CreateProfileHandler::ProcessSupervisedCreateProfileArgs(
- const base::ListValue* args, std::string* supervised_user_id) {
+bool SigninCreateProfileHandler::GetSupervisedCreateProfileArgs(
+ const base::ListValue* args, std::string* supervised_user_id,
+ base::FilePath* supervisor_profile_path) {
bool supervised_user = false;
- if (args->GetSize() >= 5) {
- bool success = args->GetBoolean(3, &supervised_user);
- DCHECK(success);
-
- success = args->GetString(4, supervised_user_id);
- DCHECK(success);
+ if (args->GetSize() >= 6) {
+ DCHECK(args->GetBoolean(3, &supervised_user));
+ DCHECK(args->GetString(4, supervised_user_id));
+ const base::Value* profile_path_value;
+ DCHECK(args->Get(5, &profile_path_value));
+ DCHECK(base::GetValueAsFilePath(*profile_path_value,
+ supervisor_profile_path));
}
+ return supervised_user;
+}
- if (supervised_user) {
- if (!IsValidExistingSupervisedUserId(*supervised_user_id))
- return false;
- profile_creation_type_ = SUPERVISED_PROFILE_IMPORT;
- if (supervised_user_id->empty()) {
+void SigninCreateProfileHandler::LoadSupervisorProfileCallback(
+ const base::string16& name,
+ const std::string& icon_url,
+ bool create_shortcut,
+ const std::string& supervised_user_id,
+ Profile* supervisor_profile,
+ Profile::CreateStatus status) {
+
+ // This method gets called once before with Profile::CREATE_STATUS_CREATED.
+ // We are only interested in Profile::CREATE_STATUS_INITIALIZED when
+ // everything is ready. Ignore Profile::CREATE_STATUS_CREATED.
+ if (status == Profile::CREATE_STATUS_INITIALIZED) {
+
+ // TODO(mahmadi): display proper error message to the user.
+ PrefService* prefs = supervisor_profile->GetPrefs();
+ if (!prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed))
+ return;
+
+ if (!supervised_user_id.empty()) {
+
+ profile_creation_type_ = SUPERVISED_PROFILE_IMPORT;
+
+ SupervisedUserSyncService* supervised_user_sync_service =
+ SupervisedUserSyncServiceFactory::GetForProfile(supervisor_profile);
+ if (supervised_user_sync_service) {
+ supervised_user_sync_service->GetSupervisedUsersAsync(
+ base::Bind(
+ &SigninCreateProfileHandler::DoCreateProfileIfPossible,
+ weak_ptr_factory_.GetWeakPtr(), name, icon_url,
+ create_shortcut, supervised_user_id, supervisor_profile));
+ }
+ } else {
+
profile_creation_type_ = SUPERVISED_PROFILE_CREATION;
- *supervised_user_id =
+ std::string new_supervised_user_id =
SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
// If sync is not yet fully initialized, the creation may take extra time,
@@ -335,19 +459,44 @@ bool CreateProfileHandler::ProcessSupervisedCreateProfileArgs(
// won't have the same potential delay.
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- Profile::FromWebUI(web_ui()));
+ supervisor_profile);
ProfileSyncService::SyncStatusSummary status =
sync_service->QuerySyncStatusSummary();
if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) {
ShowProfileCreationWarning(l10n_util::GetStringUTF16(
IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN));
}
+
+ DoCreateProfile(name, icon_url, create_shortcut, new_supervised_user_id,
+ supervisor_profile);
}
}
Mike Lerman 2016/01/29 19:48:22 If this was returned to with some error code, then
Moe 2016/02/01 01:11:13 Done.
- return true;
}
-void CreateProfileHandler::HandleCancelProfileCreation(
+void SigninCreateProfileHandler::DoCreateProfileIfPossible(
+ const base::string16& name,
+ const std::string& icon_url,
+ bool create_shortcut,
+ const std::string& supervised_user_id,
+ Profile* supervisor_profile,
+ const base::DictionaryValue* dict) {
+ DCHECK(dict);
+ if (!dict->HasKey(supervised_user_id))
+ return;
+
+ // Check if this supervised user already exists on this machine.
+ const ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
+ if (supervised_user_id == cache.GetSupervisedUserIdOfProfileAtIndex(i))
+ return;
Mike Lerman 2016/01/29 19:48:22 Shouldn't there be some feedback to the user that
Moe 2016/02/01 01:11:13 I agree. For now I'm going to use the generic loca
+ }
+
+ DoCreateProfile(name, icon_url, create_shortcut, supervised_user_id,
+ supervisor_profile);
+}
+
+void SigninCreateProfileHandler::HandleCancelProfileCreation(
const base::ListValue* args) {
CancelProfileRegistration(true);
}
@@ -355,7 +504,8 @@ void CreateProfileHandler::HandleCancelProfileCreation(
// Non-supervised user creation cannot be canceled. (Creating a non-supervised
// profile shouldn't take significant time, and it can easily be deleted
// afterward.)
-void CreateProfileHandler::CancelProfileRegistration(bool user_initiated) {
+void SigninCreateProfileHandler::CancelProfileRegistration(
+ bool user_initiated) {
if (profile_path_being_created_.empty())
return;
@@ -377,16 +527,17 @@ void CreateProfileHandler::CancelProfileRegistration(bool user_initiated) {
DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
profile_creation_type_ = NO_CREATION_IN_PROGRESS;
- // Cancelling registration means the callback passed into
+ // Canceling registration means the callback passed into
// RegisterAndInitSync() won't be called, so the cleanup must be done here.
profile_path_being_created_.clear();
- helper::DeleteProfileAtPath(new_profile->GetPath(), web_ui());
+ options::helper::DeleteProfileAtPath(new_profile->GetPath(), web_ui());
}
-void CreateProfileHandler::RegisterSupervisedUser(
+void SigninCreateProfileHandler::RegisterSupervisedUser(
bool create_shortcut,
chrome::HostDesktopType desktop_type,
const std::string& supervised_user_id,
+ Profile* supervisor_profile,
Profile* new_profile) {
DCHECK_EQ(profile_path_being_created_.value(),
new_profile->GetPath().value());
@@ -396,19 +547,19 @@ void CreateProfileHandler::RegisterSupervisedUser(
// Register the supervised user using the profile of the custodian.
supervised_user_registration_utility_ =
- SupervisedUserRegistrationUtility::Create(Profile::FromWebUI(web_ui()));
+ SupervisedUserRegistrationUtility::Create(supervisor_profile);
supervised_user_service->RegisterAndInitSync(
supervised_user_registration_utility_.get(),
- Profile::FromWebUI(web_ui()),
+ supervisor_profile,
supervised_user_id,
- base::Bind(&CreateProfileHandler::OnSupervisedUserRegistered,
+ base::Bind(&SigninCreateProfileHandler::OnSupervisedUserRegistered,
weak_ptr_factory_.GetWeakPtr(),
create_shortcut,
desktop_type,
new_profile));
}
-void CreateProfileHandler::OnSupervisedUserRegistered(
+void SigninCreateProfileHandler::OnSupervisedUserRegistered(
bool create_shortcut,
chrome::HostDesktopType desktop_type,
Profile* profile,
@@ -425,21 +576,21 @@ void CreateProfileHandler::OnSupervisedUserRegistered(
state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
state == GoogleServiceAuthError::ACCOUNT_DELETED ||
state == GoogleServiceAuthError::ACCOUNT_DISABLED) {
- error_msg = GetProfileCreationErrorMessageSignin();
+ error_msg = GetProfileCreateErrorMessageSignin();
} else {
- error_msg = GetProfileCreationErrorMessageRemote();
+ error_msg = GetProfileCreateErrorMessageRemote();
}
ShowProfileCreationError(profile, error_msg);
}
-void CreateProfileHandler::ShowProfileCreationWarning(
+void SigninCreateProfileHandler::ShowProfileCreationWarning(
const base::string16& warning) {
DCHECK_EQ(SUPERVISED_PROFILE_CREATION, profile_creation_type_);
- web_ui()->CallJavascriptFunction("BrowserOptions.showCreateProfileWarning",
+ web_ui()->CallJavascriptFunction("cr.ui.ProfileApi.onCreateProfileWarning",
base::StringValue(warning));
}
-void CreateProfileHandler::RecordSupervisedProfileCreationMetrics(
+void SigninCreateProfileHandler::RecordSupervisedProfileCreationMetrics(
GoogleServiceAuthError::State error_state) {
if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) {
UMA_HISTOGRAM_ENUMERATION("Profile.SupervisedProfileCreateError",
@@ -459,28 +610,4 @@ void CreateProfileHandler::RecordSupervisedProfileCreationMetrics(
}
}
-bool CreateProfileHandler::IsValidExistingSupervisedUserId(
- const std::string& existing_supervised_user_id) const {
- if (existing_supervised_user_id.empty())
- return true;
-
- Profile* profile = Profile::FromWebUI(web_ui());
- const base::DictionaryValue* dict =
- SupervisedUserSyncServiceFactory::GetForProfile(profile)->
- GetSupervisedUsers();
- if (!dict->HasKey(existing_supervised_user_id))
- return false;
-
- // Check if this supervised user already exists on this machine.
- const ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
- if (existing_supervised_user_id ==
- cache.GetSupervisedUserIdOfProfileAtIndex(i))
- return false;
- }
- return true;
-}
#endif
-
-} // namespace options

Powered by Google App Engine
This is Rietveld 408576698