Index: chrome/browser/ui/webui/signin/signin_create_profile_handler.h |
diff --git a/chrome/browser/ui/webui/options/create_profile_handler.h b/chrome/browser/ui/webui/signin/signin_create_profile_handler.h |
similarity index 65% |
copy from chrome/browser/ui/webui/options/create_profile_handler.h |
copy to chrome/browser/ui/webui/signin/signin_create_profile_handler.h |
index cb017faf97160a6375c7d6cf60805cb1a67f31ae..19d52d4d5e03ed4453849bb9a1b91fd109e421e9 100644 |
--- a/chrome/browser/ui/webui/options/create_profile_handler.h |
+++ b/chrome/browser/ui/webui/signin/signin_create_profile_handler.h |
@@ -1,9 +1,11 @@ |
-// 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. |
-#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
-#define CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
+#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ |
+#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ |
+ |
+#include <string> |
#include "base/macros.h" |
#include "base/memory/weak_ptr.h" |
@@ -11,10 +13,9 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_window.h" |
#include "chrome/browser/ui/host_desktop.h" |
-#include "chrome/browser/ui/webui/options/options_ui.h" |
+#include "content/public/browser/web_ui_message_handler.h" |
#include "google_apis/gaia/google_service_auth_error.h" |
- |
namespace base { |
class DictionaryValue; |
class ListValue; |
@@ -24,21 +25,17 @@ class ListValue; |
class SupervisedUserRegistrationUtility; |
#endif |
-namespace options { |
- |
-// Handler for the 'create profile' overlay. |
-class CreateProfileHandler: public OptionsPageUIHandler { |
+// Handler for the 'create profile' page. |
+class SigninCreateProfileHandler : public content::WebUIMessageHandler { |
public: |
- CreateProfileHandler(); |
- ~CreateProfileHandler() override; |
+ SigninCreateProfileHandler(); |
+ ~SigninCreateProfileHandler() override; |
- // OptionsPageUIHandler implementation. |
- void GetLocalizedValues(base::DictionaryValue* localized_strings) override; |
+ void GetLocalizedValues(base::DictionaryValue* localized_strings); |
+ private: |
// WebUIMessageHandler implementation. |
void RegisterMessages() override; |
- |
- private: |
// Represents the final profile creation status. It is used to map |
// the status to the javascript method to be called. |
enum ProfileCreationStatus { |
@@ -58,6 +55,16 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
NO_CREATION_IN_PROGRESS |
}; |
+ // Callback for the "requestDefaultProfileIcons" message. |
+ // Sends the array of default profile icon URLs to WebUI. |
+ void RequestDefaultProfileIcons(const base::ListValue* args); |
+ |
+ // Callback for the "requestSignedInProfiles" message. |
+ // Sends the email address of the signed-in user, or an empty string if the |
+ // user is not signed in. Also sends information about whether supervised |
+ // users may be created. |
+ void RequestSignedInProfiles(const base::ListValue* args); |
+ |
// Asynchronously creates and initializes a new profile. |
// The arguments are as follows: |
// 0: name (string) |
@@ -67,6 +74,7 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
// 3: a flag stating whether the user should be supervised |
// (optional, boolean) |
// 4: a string representing the supervised user ID. |
+ // 5: a string representing the supervisor profile path. |
void CreateProfile(const base::ListValue* args); |
// If a local error occurs during profile creation, then show an appropriate |
@@ -77,12 +85,14 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
void OnProfileCreated(bool create_shortcut, |
chrome::HostDesktopType desktop_type, |
const std::string& supervised_user_id, |
+ Profile* supervisor_profile, |
Profile* profile, |
Profile::CreateStatus status); |
void HandleProfileCreationSuccess(bool create_shortcut, |
chrome::HostDesktopType desktop_type, |
const std::string& supervised_user_id, |
+ Profile* supervisor_profile, |
Profile* profile); |
// Creates desktop shortcut and updates the UI to indicate success |
@@ -103,8 +113,8 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
base::string16 GetProfileCreationErrorMessageLocal() const; |
#if defined(ENABLE_SUPERVISED_USERS) |
// The following error messages only apply to supervised profiles. |
- base::string16 GetProfileCreationErrorMessageRemote() const; |
- base::string16 GetProfileCreationErrorMessageSignin() const; |
+ base::string16 GetProfileCreateErrorMessageRemote() const; |
+ base::string16 GetProfileCreateErrorMessageSignin() const; |
#endif |
std::string GetJavascriptMethodName(ProfileCreationStatus status) const; |
@@ -121,12 +131,29 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
// The value is only relevant while we are creating/importing a profile. |
ProfileCreationOperationType profile_creation_type_; |
+ // Asynchronously creates and initializes a new profile. |
+ void DoCreateProfile(const base::string16& name, |
+ const std::string& icon_url, |
+ bool create_shortcut, |
+ const std::string& supervised_user_id, |
+ Profile* supervisor_profile); |
+ |
#if defined(ENABLE_SUPERVISED_USERS) |
- // Extracts the supervised user ID from the args passed into CreateProfile, |
- // sets |profile_creation_type_| if necessary, and returns true if the |
- // supervised user id specified in |args| are valid. |
- bool ProcessSupervisedCreateProfileArgs(const base::ListValue* args, |
- std::string* supervised_user_id); |
+ // Extracts the supervised user ID and the supervisor user profile path from |
+ // the args passed into CreateProfile. |
+ bool GetSupervisedCreateProfileArgs(const base::ListValue* args, |
+ std::string* supervised_user_id, |
+ base::FilePath* supervisor_profile_path); |
+ |
+ // Callback that runs once the supervisor profile has been loaded. It sets |
+ // |profile_creation_type_| if necessary, and calls |DoCreateProfile| if the |
+ // supervised user id specified in |args| is valid. |
+ void 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); |
// Cancels creation of a supervised-user profile currently in progress, as |
// indicated by profile_path_being_created_, removing the object and files |
@@ -145,6 +172,7 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
void RegisterSupervisedUser(bool create_shortcut, |
chrome::HostDesktopType desktop_type, |
const std::string& managed_user_id, |
+ Profile* supervisor_profile, |
Profile* new_profile); |
// Called back with the result of the supervised user registration. |
@@ -158,18 +186,20 @@ class CreateProfileHandler: public OptionsPageUIHandler { |
void RecordSupervisedProfileCreationMetrics( |
GoogleServiceAuthError::State error_state); |
- bool IsValidExistingSupervisedUserId( |
- const std::string& existing_supervised_user_id) const; |
+ void 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); |
scoped_ptr<SupervisedUserRegistrationUtility> |
supervised_user_registration_utility_; |
#endif |
- base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; |
+ base::WeakPtrFactory<SigninCreateProfileHandler> weak_ptr_factory_; |
- DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); |
+ DISALLOW_COPY_AND_ASSIGN(SigninCreateProfileHandler); |
}; |
-} // namespace options |
- |
-#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ |