OLD | NEW |
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_attributes_storage.h" | 14 #include "chrome/browser/profiles/profile_attributes_storage.h" |
15 #include "chrome/browser/profiles/profile_window.h" | 15 #include "chrome/browser/profiles/profile_window.h" |
| 16 #include "chrome/common/features.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
19 #include "google_apis/gaia/google_service_auth_error.h" | 20 #include "google_apis/gaia/google_service_auth_error.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class DictionaryValue; | 23 class DictionaryValue; |
23 class ListValue; | 24 class ListValue; |
24 } | 25 } |
25 | 26 |
26 #if defined(ENABLE_SUPERVISED_USERS) | 27 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
27 class SupervisedUserRegistrationUtility; | 28 class SupervisedUserRegistrationUtility; |
28 #endif | 29 #endif |
29 | 30 |
30 // Handler for the 'create profile' page. | 31 // Handler for the 'create profile' page. |
31 class SigninCreateProfileHandler : public content::WebUIMessageHandler, | 32 class SigninCreateProfileHandler : public content::WebUIMessageHandler, |
32 public content::NotificationObserver, | 33 public content::NotificationObserver, |
33 public ProfileAttributesStorage::Observer { | 34 public ProfileAttributesStorage::Observer { |
34 public: | 35 public: |
35 SigninCreateProfileHandler(); | 36 SigninCreateProfileHandler(); |
36 ~SigninCreateProfileHandler() override; | 37 ~SigninCreateProfileHandler() override; |
37 | 38 |
38 void GetLocalizedValues(base::DictionaryValue* localized_strings); | 39 void GetLocalizedValues(base::DictionaryValue* localized_strings); |
39 | 40 |
40 protected: | 41 protected: |
41 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 42 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
42 ReturnDefaultProfileNameAndIcons); | 43 ReturnDefaultProfileNameAndIcons); |
43 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 44 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
44 ReturnSignedInProfiles); | 45 ReturnSignedInProfiles); |
45 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 46 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
46 CreateProfile); | 47 CreateProfile); |
47 #if defined(ENABLE_SUPERVISED_USERS) | 48 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
48 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 49 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
49 CreateSupervisedUser); | 50 CreateSupervisedUser); |
50 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 51 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
51 ImportSupervisedUser); | 52 ImportSupervisedUser); |
52 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 53 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
53 ImportSupervisedUserAlreadyOnDevice); | 54 ImportSupervisedUserAlreadyOnDevice); |
54 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 55 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
55 CustodianNotAuthenticated); | 56 CustodianNotAuthenticated); |
56 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, | 57 FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest, |
57 CustodianHasAuthError); | 58 CustodianHasAuthError); |
(...skipping 18 matching lines...) Expand all Loading... |
76 // the status to the javascript method to be called. | 77 // the status to the javascript method to be called. |
77 enum ProfileCreationStatus { | 78 enum ProfileCreationStatus { |
78 PROFILE_CREATION_SUCCESS, | 79 PROFILE_CREATION_SUCCESS, |
79 PROFILE_CREATION_ERROR, | 80 PROFILE_CREATION_ERROR, |
80 }; | 81 }; |
81 | 82 |
82 // Represents the type of the in progress profile creation operation. | 83 // Represents the type of the in progress profile creation operation. |
83 // It is used to map the type of the profile creation operation to the | 84 // It is used to map the type of the profile creation operation to the |
84 // correct UMA metric name. | 85 // correct UMA metric name. |
85 enum ProfileCreationOperationType { | 86 enum ProfileCreationOperationType { |
86 #if defined(ENABLE_SUPERVISED_USERS) | 87 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
87 SUPERVISED_PROFILE_CREATION, | 88 SUPERVISED_PROFILE_CREATION, |
88 SUPERVISED_PROFILE_IMPORT, | 89 SUPERVISED_PROFILE_IMPORT, |
89 #endif | 90 #endif |
90 NON_SUPERVISED_PROFILE_CREATION, | 91 NON_SUPERVISED_PROFILE_CREATION, |
91 NO_CREATION_IN_PROGRESS | 92 NO_CREATION_IN_PROGRESS |
92 }; | 93 }; |
93 | 94 |
94 // Callback for the "requestDefaultProfileIcons" message. | 95 // Callback for the "requestDefaultProfileIcons" message. |
95 // Sends the array of default profile icon URLs to WebUI. | 96 // Sends the array of default profile icon URLs to WebUI. |
96 void RequestDefaultProfileIcons(const base::ListValue* args); | 97 void RequestDefaultProfileIcons(const base::ListValue* args); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // The value is only relevant while we are creating/importing a profile. | 172 // The value is only relevant while we are creating/importing a profile. |
172 ProfileCreationOperationType profile_creation_type_; | 173 ProfileCreationOperationType profile_creation_type_; |
173 | 174 |
174 // Asynchronously creates and initializes a new profile. | 175 // Asynchronously creates and initializes a new profile. |
175 virtual void DoCreateProfile(const base::string16& name, | 176 virtual void DoCreateProfile(const base::string16& name, |
176 const std::string& icon_url, | 177 const std::string& icon_url, |
177 bool create_shortcut, | 178 bool create_shortcut, |
178 const std::string& supervised_user_id, | 179 const std::string& supervised_user_id, |
179 Profile* custodian_profile); | 180 Profile* custodian_profile); |
180 | 181 |
181 #if defined(ENABLE_SUPERVISED_USERS) | 182 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
182 base::string16 GetProfileCreateErrorMessageRemote() const; | 183 base::string16 GetProfileCreateErrorMessageRemote() const; |
183 base::string16 GetProfileCreateErrorMessageSignin() const; | 184 base::string16 GetProfileCreateErrorMessageSignin() const; |
184 | 185 |
185 // Extracts the supervised user ID and the custodian user profile path from | 186 // Extracts the supervised user ID and the custodian user profile path from |
186 // the args passed into CreateProfile. | 187 // the args passed into CreateProfile. |
187 bool GetSupervisedCreateProfileArgs(const base::ListValue* args, | 188 bool GetSupervisedCreateProfileArgs(const base::ListValue* args, |
188 std::string* supervised_user_id, | 189 std::string* supervised_user_id, |
189 base::FilePath* custodian_profile_path); | 190 base::FilePath* custodian_profile_path); |
190 | 191 |
191 // Callback that runs once the custodian profile has been loaded. It sets | 192 // Callback that runs once the custodian profile has been loaded. It sets |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 256 |
256 content::NotificationRegistrar registrar_; | 257 content::NotificationRegistrar registrar_; |
257 | 258 |
258 base::WeakPtrFactory<SigninCreateProfileHandler> weak_ptr_factory_; | 259 base::WeakPtrFactory<SigninCreateProfileHandler> weak_ptr_factory_; |
259 | 260 |
260 private: | 261 private: |
261 DISALLOW_COPY_AND_ASSIGN(SigninCreateProfileHandler); | 262 DISALLOW_COPY_AND_ASSIGN(SigninCreateProfileHandler); |
262 }; | 263 }; |
263 | 264 |
264 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ | 265 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_ |
OLD | NEW |