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

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: Created 4 years, 9 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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_window.h" 14 #include "chrome/browser/profiles/profile_window.h"
15 #include "content/public/browser/web_ui_message_handler.h" 15 #include "content/public/browser/web_ui_message_handler.h"
16 #include "google_apis/gaia/google_service_auth_error.h" 16 #include "google_apis/gaia/google_service_auth_error.h"
17 17
18 namespace base { 18 namespace base {
19 class DictionaryValue; 19 class DictionaryValue;
20 class ListValue; 20 class ListValue;
21 } 21 }
22 22
23 #if defined(ENABLE_SUPERVISED_USERS) 23 #if defined(ENABLE_SUPERVISED_USERS)
24 class SupervisedUserRegistrationUtility; 24 class SupervisedUserRegistrationUtility;
25 #endif 25 #endif
26 26
27 // Handler for the 'create profile' page. 27 // Handler for the 'create profile' page.
28 class SigninCreateProfileHandler : public content::WebUIMessageHandler { 28 class SigninCreateProfileHandler : public content::WebUIMessageHandler {
tommycli 2016/03/24 19:28:51 This should have a unit test. (Can be added in a s
Moe 2016/03/24 22:07:57 Absolutely. I will be working on those in the mean
29 public: 29 public:
30 SigninCreateProfileHandler(); 30 SigninCreateProfileHandler();
31 ~SigninCreateProfileHandler() override; 31 ~SigninCreateProfileHandler() override;
32 32
33 void GetLocalizedValues(base::DictionaryValue* localized_strings); 33 void GetLocalizedValues(base::DictionaryValue* localized_strings);
34 34
35 private: 35 private:
36 // WebUIMessageHandler implementation. 36 // WebUIMessageHandler implementation.
37 void RegisterMessages() override; 37 void RegisterMessages() override;
38 // Represents the final profile creation status. It is used to map 38 // Represents the final profile creation status. It is used to map
(...skipping 12 matching lines...) Expand all
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)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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* supervisor_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

Powered by Google App Engine
This is Rietveld 408576698