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

Side by Side Diff: chrome/browser/ui/webui/signin/signin_create_profile_handler.h

Issue 1826903002: updated UI, default profile name, check for existing supervised user before create (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 SUPERVISED_PROFILE_IMPORT, 51 SUPERVISED_PROFILE_IMPORT,
52 #endif 52 #endif
53 NON_SUPERVISED_PROFILE_CREATION, 53 NON_SUPERVISED_PROFILE_CREATION,
54 NO_CREATION_IN_PROGRESS 54 NO_CREATION_IN_PROGRESS
55 }; 55 };
56 56
57 // Callback for the "requestDefaultProfileIcons" message. 57 // Callback for the "requestDefaultProfileIcons" message.
58 // Sends the array of default profile icon URLs to WebUI. 58 // Sends the array of default profile icon URLs to WebUI.
59 void RequestDefaultProfileIcons(const base::ListValue* args); 59 void RequestDefaultProfileIcons(const base::ListValue* args);
60 60
61 // Sends an object to WebUI of the form: { "name": profileName } after
62 // "requestDefaultProfileIcons" is fulfilled.
63 void SendNewProfileDefaults();
64
61 // Callback for the "requestSignedInProfiles" message. 65 // Callback for the "requestSignedInProfiles" message.
62 // Sends the email address of the signed-in user, or an empty string if the 66 // Sends the email address of the signed-in user, or an empty string if the
63 // user is not signed in. Also sends information about whether supervised 67 // user is not signed in. Also sends information about whether supervised
64 // users may be created. 68 // users may be created.
65 void RequestSignedInProfiles(const base::ListValue* args); 69 void RequestSignedInProfiles(const base::ListValue* args);
66 70
67 // Asynchronously creates and initializes a new profile. 71 // Asynchronously creates and initializes a new profile.
68 // The arguments are as follows: 72 // The arguments are as follows:
69 // 0: name (string) 73 // 0: name (string)
70 // 1: icon (string) 74 // 1: icon (string)
71 // 2: a flag stating whether we should create a profile desktop shortcut 75 // 2: a flag stating whether we should create a profile desktop shortcut
72 // (optional, boolean) 76 // (optional, boolean)
73 // 3: a flag stating whether the user should be supervised 77 // 3: a flag stating whether the user should be supervised
74 // (optional, boolean) 78 // (optional, boolean)
75 // 4: a string representing the supervised user ID. 79 // 4: a string representing the supervised user ID.
76 // 5: a string representing the supervisor profile path. 80 // 5: a string representing the custodian profile path.
77 void CreateProfile(const base::ListValue* args); 81 void CreateProfile(const base::ListValue* args);
78 82
79 // If a local error occurs during profile creation, then show an appropriate 83 // If a local error occurs during profile creation, then show an appropriate
80 // error message. However, if profile creation succeeded and the 84 // error message. However, if profile creation succeeded and the
81 // profile being created/imported is a supervised user profile, 85 // profile being created/imported is a supervised user profile,
82 // then proceed with the registration step. Otherwise, update the UI 86 // then proceed with the registration step. Otherwise, update the UI
83 // as the final task after a new profile has been created. 87 // as the final task after a new profile has been created.
84 void OnProfileCreated(bool create_shortcut, 88 void OnProfileCreated(bool create_shortcut,
85 const std::string& supervised_user_id, 89 const std::string& supervised_user_id,
86 Profile* supervisor_profile, 90 Profile* custodian_profile,
87 Profile* profile, 91 Profile* profile,
88 Profile::CreateStatus status); 92 Profile::CreateStatus status);
89 93
90 void HandleProfileCreationSuccess(bool create_shortcut, 94 void HandleProfileCreationSuccess(bool create_shortcut,
91 const std::string& supervised_user_id, 95 const std::string& supervised_user_id,
92 Profile* supervisor_profile, 96 Profile* custodian_profile,
93 Profile* profile); 97 Profile* profile);
94 98
95 // Creates desktop shortcut and updates the UI to indicate success 99 // Creates desktop shortcut and updates the UI to indicate success
96 // when creating a profile. 100 // when creating a profile.
97 void CreateShortcutAndShowSuccess(bool create_shortcut, Profile* profile); 101 void CreateShortcutAndShowSuccess(bool create_shortcut, Profile* profile);
98 102
99 // Updates the UI to show an error when creating a profile. 103 // Updates the UI to show an error when creating a profile.
100 void ShowProfileCreationError(Profile* profile, const base::string16& error); 104 void ShowProfileCreationError(Profile* profile, const base::string16& error);
101 105
102 // Updates the UI to show a non-fatal warning when creating a profile. 106 // Updates the UI to show a non-fatal warning when creating a profile.
(...skipping 21 matching lines...) Expand all
124 128
125 // Indicates the type of the in progress profile creation operation. 129 // Indicates the type of the in progress profile creation operation.
126 // The value is only relevant while we are creating/importing a profile. 130 // The value is only relevant while we are creating/importing a profile.
127 ProfileCreationOperationType profile_creation_type_; 131 ProfileCreationOperationType profile_creation_type_;
128 132
129 // Asynchronously creates and initializes a new profile. 133 // Asynchronously creates and initializes a new profile.
130 void DoCreateProfile(const base::string16& name, 134 void DoCreateProfile(const base::string16& name,
131 const std::string& icon_url, 135 const std::string& icon_url,
132 bool create_shortcut, 136 bool create_shortcut,
133 const std::string& supervised_user_id, 137 const std::string& supervised_user_id,
134 Profile* supervisor_profile); 138 Profile* custodian_profile);
135 139
136 #if defined(ENABLE_SUPERVISED_USERS) 140 #if defined(ENABLE_SUPERVISED_USERS)
137 // Extracts the supervised user ID and the supervisor user profile path from 141 // Extracts the supervised user ID and the custodian user profile path from
138 // the args passed into CreateProfile. 142 // the args passed into CreateProfile.
139 bool GetSupervisedCreateProfileArgs(const base::ListValue* args, 143 bool GetSupervisedCreateProfileArgs(const base::ListValue* args,
140 std::string* supervised_user_id, 144 std::string* supervised_user_id,
141 base::FilePath* supervisor_profile_path); 145 base::FilePath* custodian_profile_path);
142 146
143 // Callback that runs once the supervisor profile has been loaded. It sets 147 // Callback that runs once the custodian profile has been loaded. It sets
144 // |profile_creation_type_| if necessary, and calls |DoCreateProfile| if the 148 // |profile_creation_type_| if necessary, and calls |DoCreateProfile| if the
145 // supervised user id specified in |args| is valid. 149 // supervised user id specified in |args| is valid.
146 void LoadSupervisorProfileCallback(const base::string16& name, 150 void LoadCustodianProfileCallback(const base::string16& name,
147 const std::string& icon_url, 151 const std::string& icon_url,
148 bool create_shortcut, 152 bool create_shortcut,
149 const std::string& supervised_user_id, 153 const std::string& supervised_user_id,
150 Profile* supervisor_profile, 154 Profile* custodian_profile,
151 Profile::CreateStatus status); 155 Profile::CreateStatus status);
152 156
153 // Cancels creation of a supervised-user profile currently in progress, as 157 // Cancels creation of a supervised-user profile currently in progress, as
154 // indicated by profile_path_being_created_, removing the object and files 158 // indicated by profile_path_being_created_, removing the object and files
155 // and canceling supervised-user registration. This is the handler for the 159 // and canceling supervised-user registration. This is the handler for the
156 // "cancelCreateProfile" message. |args| is not used. 160 // "cancelCreateProfile" message. |args| is not used.
157 void HandleCancelProfileCreation(const base::ListValue* args); 161 void HandleCancelProfileCreation(const base::ListValue* args);
158 162
159 // Internal implementation. This may safely be called whether profile creation 163 // Internal implementation. This may safely be called whether profile creation
160 // or registration is in progress or not. |user_initiated| should be true if 164 // or registration is in progress or not. |user_initiated| should be true if
161 // the cancellation was deliberately requested by the user, and false if it 165 // the cancellation was deliberately requested by the user, and false if it
162 // was caused implicitly, e.g. by shutting down the browser. 166 // was caused implicitly, e.g. by shutting down the browser.
163 void CancelProfileRegistration(bool user_initiated); 167 void CancelProfileRegistration(bool user_initiated);
164 168
165 // After a new supervised-user profile has been created, registers the user 169 // After a new supervised-user profile has been created, registers the user
166 // with the management server. 170 // with the management server.
167 void RegisterSupervisedUser(bool create_shortcut, 171 void RegisterSupervisedUser(bool create_shortcut,
168 const std::string& managed_user_id, 172 const std::string& managed_user_id,
169 Profile* supervisor_profile, 173 Profile* custodian_profile,
170 Profile* new_profile); 174 Profile* new_profile);
171 175
172 // Called back with the result of the supervised user registration. 176 // Called back with the result of the supervised user registration.
173 void OnSupervisedUserRegistered(bool create_shortcut, 177 void OnSupervisedUserRegistered(bool create_shortcut,
174 Profile* profile, 178 Profile* profile,
175 const GoogleServiceAuthError& error); 179 const GoogleServiceAuthError& error);
176 180
177 // Records UMA histograms relevant to supervised user profiles 181 // Records UMA histograms relevant to supervised user profiles
178 // creation and registration. 182 // creation and registration.
179 void RecordSupervisedProfileCreationMetrics( 183 void RecordSupervisedProfileCreationMetrics(
180 GoogleServiceAuthError::State error_state); 184 GoogleServiceAuthError::State error_state);
181 185
186 // Creates the supervised user with the given |supervised_user_id| if the user
187 // doesn't already exist on the machine.
182 void DoCreateProfileIfPossible(const base::string16& name, 188 void DoCreateProfileIfPossible(const base::string16& name,
183 const std::string& icon_url, 189 const std::string& icon_url,
184 bool create_shortcut, 190 bool create_shortcut,
185 const std::string& supervised_user_id, 191 const std::string& supervised_user_id,
186 Profile* supervisor_profile, 192 Profile* custodian_profile,
187 const base::DictionaryValue* dict); 193 const base::DictionaryValue* dict);
188 194
189 scoped_ptr<SupervisedUserRegistrationUtility> 195 scoped_ptr<SupervisedUserRegistrationUtility>
190 supervised_user_registration_utility_; 196 supervised_user_registration_utility_;
191 #endif 197 #endif
192 198
199 // Returns true if profile has signed into chrome.
200 bool IsAccountConnected(Profile* profile) const;
201 // Returns true if profile has authentication error.
202 bool HasAuthError(Profile* profile) const;
203
193 base::WeakPtrFactory<SigninCreateProfileHandler> weak_ptr_factory_; 204 base::WeakPtrFactory<SigninCreateProfileHandler> weak_ptr_factory_;
194 205
195 DISALLOW_COPY_AND_ASSIGN(SigninCreateProfileHandler); 206 DISALLOW_COPY_AND_ASSIGN(SigninCreateProfileHandler);
196 }; 207 };
197 208
198 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ 209 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/md_user_manager_ui.cc ('k') | chrome/browser/ui/webui/signin/signin_create_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698