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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/profiles/profile_window.h" | 12 #include "chrome/browser/profiles/profile_window.h" |
13 #include "chrome/browser/ui/host_desktop.h" | |
14 #include "chrome/browser/ui/webui/options/options_ui.h" | 13 #include "chrome/browser/ui/webui/options/options_ui.h" |
15 #include "google_apis/gaia/google_service_auth_error.h" | 14 #include "google_apis/gaia/google_service_auth_error.h" |
16 | 15 |
17 | 16 |
18 namespace base { | 17 namespace base { |
19 class DictionaryValue; | 18 class DictionaryValue; |
20 class ListValue; | 19 class ListValue; |
21 } | 20 } |
22 | 21 |
23 #if defined(ENABLE_SUPERVISED_USERS) | 22 #if defined(ENABLE_SUPERVISED_USERS) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // (optional, boolean) | 67 // (optional, boolean) |
69 // 4: a string representing the supervised user ID. | 68 // 4: a string representing the supervised user ID. |
70 void CreateProfile(const base::ListValue* args); | 69 void CreateProfile(const base::ListValue* args); |
71 | 70 |
72 // If a local error occurs during profile creation, then show an appropriate | 71 // If a local error occurs during profile creation, then show an appropriate |
73 // error message. However, if profile creation succeeded and the | 72 // error message. However, if profile creation succeeded and the |
74 // profile being created/imported is a supervised user profile, | 73 // profile being created/imported is a supervised user profile, |
75 // then proceed with the registration step. Otherwise, update the UI | 74 // then proceed with the registration step. Otherwise, update the UI |
76 // as the final task after a new profile has been created. | 75 // as the final task after a new profile has been created. |
77 void OnProfileCreated(bool create_shortcut, | 76 void OnProfileCreated(bool create_shortcut, |
78 chrome::HostDesktopType desktop_type, | |
79 const std::string& supervised_user_id, | 77 const std::string& supervised_user_id, |
80 Profile* profile, | 78 Profile* profile, |
81 Profile::CreateStatus status); | 79 Profile::CreateStatus status); |
82 | 80 |
83 void HandleProfileCreationSuccess(bool create_shortcut, | 81 void HandleProfileCreationSuccess(bool create_shortcut, |
84 chrome::HostDesktopType desktop_type, | |
85 const std::string& supervised_user_id, | 82 const std::string& supervised_user_id, |
86 Profile* profile); | 83 Profile* profile); |
87 | 84 |
88 // Creates desktop shortcut and updates the UI to indicate success | 85 // Creates desktop shortcut and updates the UI to indicate success |
89 // when creating a profile. | 86 // when creating a profile. |
90 void CreateShortcutAndShowSuccess(bool create_shortcut, | 87 void CreateShortcutAndShowSuccess(bool create_shortcut, Profile* profile); |
91 chrome::HostDesktopType desktop_type, | |
92 Profile* profile); | |
93 | 88 |
94 // Updates the UI to show an error when creating a profile. | 89 // Updates the UI to show an error when creating a profile. |
95 void ShowProfileCreationError(Profile* profile, const base::string16& error); | 90 void ShowProfileCreationError(Profile* profile, const base::string16& error); |
96 | 91 |
97 // Updates the UI to show a non-fatal warning when creating a profile. | 92 // Updates the UI to show a non-fatal warning when creating a profile. |
98 void ShowProfileCreationWarning(const base::string16& warning); | 93 void ShowProfileCreationWarning(const base::string16& warning); |
99 | 94 |
100 // Records UMA histograms relevant to profile creation. | 95 // Records UMA histograms relevant to profile creation. |
101 void RecordProfileCreationMetrics(Profile::CreateStatus status); | 96 void RecordProfileCreationMetrics(Profile::CreateStatus status); |
102 | 97 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 131 |
137 // Internal implementation. This may safely be called whether profile creation | 132 // Internal implementation. This may safely be called whether profile creation |
138 // or registration is in progress or not. |user_initiated| should be true if | 133 // or registration is in progress or not. |user_initiated| should be true if |
139 // the cancellation was deliberately requested by the user, and false if it | 134 // the cancellation was deliberately requested by the user, and false if it |
140 // was caused implicitly, e.g. by shutting down the browser. | 135 // was caused implicitly, e.g. by shutting down the browser. |
141 void CancelProfileRegistration(bool user_initiated); | 136 void CancelProfileRegistration(bool user_initiated); |
142 | 137 |
143 // After a new supervised-user profile has been created, registers the user | 138 // After a new supervised-user profile has been created, registers the user |
144 // with the management server. | 139 // with the management server. |
145 void RegisterSupervisedUser(bool create_shortcut, | 140 void RegisterSupervisedUser(bool create_shortcut, |
146 chrome::HostDesktopType desktop_type, | |
147 const std::string& managed_user_id, | 141 const std::string& managed_user_id, |
148 Profile* new_profile); | 142 Profile* new_profile); |
149 | 143 |
150 // Called back with the result of the supervised user registration. | 144 // Called back with the result of the supervised user registration. |
151 void OnSupervisedUserRegistered(bool create_shortcut, | 145 void OnSupervisedUserRegistered(bool create_shortcut, |
152 chrome::HostDesktopType desktop_type, | |
153 Profile* profile, | 146 Profile* profile, |
154 const GoogleServiceAuthError& error); | 147 const GoogleServiceAuthError& error); |
155 | 148 |
156 // Records UMA histograms relevant to supervised user profiles | 149 // Records UMA histograms relevant to supervised user profiles |
157 // creation and registration. | 150 // creation and registration. |
158 void RecordSupervisedProfileCreationMetrics( | 151 void RecordSupervisedProfileCreationMetrics( |
159 GoogleServiceAuthError::State error_state); | 152 GoogleServiceAuthError::State error_state); |
160 | 153 |
161 bool IsValidExistingSupervisedUserId( | 154 bool IsValidExistingSupervisedUserId( |
162 const std::string& existing_supervised_user_id) const; | 155 const std::string& existing_supervised_user_id) const; |
163 | 156 |
164 scoped_ptr<SupervisedUserRegistrationUtility> | 157 scoped_ptr<SupervisedUserRegistrationUtility> |
165 supervised_user_registration_utility_; | 158 supervised_user_registration_utility_; |
166 #endif | 159 #endif |
167 | 160 |
168 base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; | 161 base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; |
169 | 162 |
170 DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); | 163 DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); |
171 }; | 164 }; |
172 | 165 |
173 } // namespace options | 166 } // namespace options |
174 | 167 |
175 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 168 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
OLD | NEW |