OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_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 "chrome/browser/ui/webui/options/options_ui.h" | 15 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 16 #include "chrome/common/features.h" |
16 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
17 | 18 |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 class ListValue; | 22 class ListValue; |
22 } | 23 } |
23 | 24 |
24 #if defined(ENABLE_SUPERVISED_USERS) | 25 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
25 class SupervisedUserRegistrationUtility; | 26 class SupervisedUserRegistrationUtility; |
26 #endif | 27 #endif |
27 | 28 |
28 namespace options { | 29 namespace options { |
29 | 30 |
30 // Handler for the 'create profile' overlay. | 31 // Handler for the 'create profile' overlay. |
31 class CreateProfileHandler: public OptionsPageUIHandler { | 32 class CreateProfileHandler: public OptionsPageUIHandler { |
32 public: | 33 public: |
33 CreateProfileHandler(); | 34 CreateProfileHandler(); |
34 ~CreateProfileHandler() override; | 35 ~CreateProfileHandler() override; |
35 | 36 |
36 // OptionsPageUIHandler implementation. | 37 // OptionsPageUIHandler implementation. |
37 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; | 38 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; |
38 | 39 |
39 // WebUIMessageHandler implementation. | 40 // WebUIMessageHandler implementation. |
40 void RegisterMessages() override; | 41 void RegisterMessages() override; |
41 | 42 |
42 private: | 43 private: |
43 // Represents the final profile creation status. It is used to map | 44 // Represents the final profile creation status. It is used to map |
44 // the status to the javascript method to be called. | 45 // the status to the javascript method to be called. |
45 enum ProfileCreationStatus { | 46 enum ProfileCreationStatus { |
46 PROFILE_CREATION_SUCCESS, | 47 PROFILE_CREATION_SUCCESS, |
47 PROFILE_CREATION_ERROR, | 48 PROFILE_CREATION_ERROR, |
48 }; | 49 }; |
49 | 50 |
50 // Represents the type of the in progress profile creation operation. | 51 // Represents the type of the in progress profile creation operation. |
51 // It is used to map the type of the profile creation operation to the | 52 // It is used to map the type of the profile creation operation to the |
52 // correct UMA metric name. | 53 // correct UMA metric name. |
53 enum ProfileCreationOperationType { | 54 enum ProfileCreationOperationType { |
54 #if defined(ENABLE_SUPERVISED_USERS) | 55 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
55 SUPERVISED_PROFILE_CREATION, | 56 SUPERVISED_PROFILE_CREATION, |
56 SUPERVISED_PROFILE_IMPORT, | 57 SUPERVISED_PROFILE_IMPORT, |
57 #endif | 58 #endif |
58 NON_SUPERVISED_PROFILE_CREATION, | 59 NON_SUPERVISED_PROFILE_CREATION, |
59 NO_CREATION_IN_PROGRESS | 60 NO_CREATION_IN_PROGRESS |
60 }; | 61 }; |
61 | 62 |
62 // Asynchronously creates and initializes a new profile. | 63 // Asynchronously creates and initializes a new profile. |
63 // The arguments are as follows: | 64 // The arguments are as follows: |
64 // 0: name (string) | 65 // 0: name (string) |
(...skipping 26 matching lines...) Expand all Loading... |
91 // Updates the UI to show an error when creating a profile. | 92 // Updates the UI to show an error when creating a profile. |
92 void ShowProfileCreationError(Profile* profile, const base::string16& error); | 93 void ShowProfileCreationError(Profile* profile, const base::string16& error); |
93 | 94 |
94 // Updates the UI to show a non-fatal warning when creating a profile. | 95 // Updates the UI to show a non-fatal warning when creating a profile. |
95 void ShowProfileCreationWarning(const base::string16& warning); | 96 void ShowProfileCreationWarning(const base::string16& warning); |
96 | 97 |
97 // Records UMA histograms relevant to profile creation. | 98 // Records UMA histograms relevant to profile creation. |
98 void RecordProfileCreationMetrics(Profile::CreateStatus status); | 99 void RecordProfileCreationMetrics(Profile::CreateStatus status); |
99 | 100 |
100 base::string16 GetProfileCreationErrorMessageLocal() const; | 101 base::string16 GetProfileCreationErrorMessageLocal() const; |
101 #if defined(ENABLE_SUPERVISED_USERS) | 102 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
102 // The following error messages only apply to supervised profiles. | 103 // The following error messages only apply to supervised profiles. |
103 base::string16 GetProfileCreationErrorMessageRemote() const; | 104 base::string16 GetProfileCreationErrorMessageRemote() const; |
104 base::string16 GetProfileCreationErrorMessageSignin() const; | 105 base::string16 GetProfileCreationErrorMessageSignin() const; |
105 #endif | 106 #endif |
106 | 107 |
107 std::string GetJavascriptMethodName(ProfileCreationStatus status) const; | 108 std::string GetJavascriptMethodName(ProfileCreationStatus status) const; |
108 | 109 |
109 // Used to allow cancelling a profile creation (particularly a supervised-user | 110 // Used to allow cancelling a profile creation (particularly a supervised-user |
110 // registration) in progress. Set when profile creation is begun, and | 111 // registration) in progress. Set when profile creation is begun, and |
111 // cleared when all the callbacks have been run and creation is complete. | 112 // cleared when all the callbacks have been run and creation is complete. |
112 base::FilePath profile_path_being_created_; | 113 base::FilePath profile_path_being_created_; |
113 | 114 |
114 // Used to track how long profile creation takes. | 115 // Used to track how long profile creation takes. |
115 base::TimeTicks profile_creation_start_time_; | 116 base::TimeTicks profile_creation_start_time_; |
116 | 117 |
117 // Indicates the type of the in progress profile creation operation. | 118 // Indicates the type of the in progress profile creation operation. |
118 // The value is only relevant while we are creating/importing a profile. | 119 // The value is only relevant while we are creating/importing a profile. |
119 ProfileCreationOperationType profile_creation_type_; | 120 ProfileCreationOperationType profile_creation_type_; |
120 | 121 |
121 #if defined(ENABLE_SUPERVISED_USERS) | 122 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
122 // Extracts the supervised user ID from the args passed into CreateProfile, | 123 // Extracts the supervised user ID from the args passed into CreateProfile, |
123 // sets |profile_creation_type_| if necessary, and returns true if the | 124 // sets |profile_creation_type_| if necessary, and returns true if the |
124 // supervised user id specified in |args| are valid. | 125 // supervised user id specified in |args| are valid. |
125 bool ProcessSupervisedCreateProfileArgs(const base::ListValue* args, | 126 bool ProcessSupervisedCreateProfileArgs(const base::ListValue* args, |
126 std::string* supervised_user_id); | 127 std::string* supervised_user_id); |
127 | 128 |
128 // Cancels creation of a supervised-user profile currently in progress, as | 129 // Cancels creation of a supervised-user profile currently in progress, as |
129 // indicated by profile_path_being_created_, removing the object and files | 130 // indicated by profile_path_being_created_, removing the object and files |
130 // and canceling supervised-user registration. This is the handler for the | 131 // and canceling supervised-user registration. This is the handler for the |
131 // "cancelCreateProfile" message. |args| is not used. | 132 // "cancelCreateProfile" message. |args| is not used. |
(...skipping 29 matching lines...) Expand all Loading... |
161 #endif | 162 #endif |
162 | 163 |
163 base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; | 164 base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; |
164 | 165 |
165 DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); | 166 DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); |
166 }; | 167 }; |
167 | 168 |
168 } // namespace options | 169 } // namespace options |
169 | 170 |
170 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 171 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
OLD | NEW |