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 #include "chrome/browser/ui/webui/options/create_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options/create_profile_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 base::DictionaryValue dict; | 193 base::DictionaryValue dict; |
194 dict.SetString("name", | 194 dict.SetString("name", |
195 profile->GetPrefs()->GetString(prefs::kProfileName)); | 195 profile->GetPrefs()->GetString(prefs::kProfileName)); |
196 dict.Set("filePath", base::CreateFilePathValue(profile->GetPath())); | 196 dict.Set("filePath", base::CreateFilePathValue(profile->GetPath())); |
197 #if defined(ENABLE_SUPERVISED_USERS) | 197 #if defined(ENABLE_SUPERVISED_USERS) |
198 bool is_supervised = | 198 bool is_supervised = |
199 profile_creation_type_ == SUPERVISED_PROFILE_CREATION || | 199 profile_creation_type_ == SUPERVISED_PROFILE_CREATION || |
200 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT; | 200 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT; |
201 dict.SetBoolean("isSupervised", is_supervised); | 201 dict.SetBoolean("isSupervised", is_supervised); |
202 #endif | 202 #endif |
203 web_ui()->CallJavascriptFunction( | 203 web_ui()->CallJavascriptFunctionUnsafe( |
204 GetJavascriptMethodName(PROFILE_CREATION_SUCCESS), dict); | 204 GetJavascriptMethodName(PROFILE_CREATION_SUCCESS), dict); |
205 | 205 |
206 // If the new profile is a supervised user, instead of opening a new window | 206 // If the new profile is a supervised user, instead of opening a new window |
207 // right away, a confirmation overlay will be shown by JS from the creation | 207 // right away, a confirmation overlay will be shown by JS from the creation |
208 // dialog. If we are importing an existing supervised profile or creating a | 208 // dialog. If we are importing an existing supervised profile or creating a |
209 // new non-supervised user profile we don't show any confirmation, so open | 209 // new non-supervised user profile we don't show any confirmation, so open |
210 // the new window now. | 210 // the new window now. |
211 bool should_open_new_window = true; | 211 bool should_open_new_window = true; |
212 #if defined(ENABLE_SUPERVISED_USERS) | 212 #if defined(ENABLE_SUPERVISED_USERS) |
213 if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) | 213 if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) |
214 should_open_new_window = false; | 214 should_open_new_window = false; |
215 #endif | 215 #endif |
216 | 216 |
217 if (should_open_new_window) { | 217 if (should_open_new_window) { |
218 // Opening the new window must be the last action, after all callbacks | 218 // Opening the new window must be the last action, after all callbacks |
219 // have been run, to give them a chance to initialize the profile. | 219 // have been run, to give them a chance to initialize the profile. |
220 webui::OpenNewWindowForProfile(profile, Profile::CREATE_STATUS_INITIALIZED); | 220 webui::OpenNewWindowForProfile(profile, Profile::CREATE_STATUS_INITIALIZED); |
221 } | 221 } |
222 profile_creation_type_ = NO_CREATION_IN_PROGRESS; | 222 profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
223 } | 223 } |
224 | 224 |
225 void CreateProfileHandler::ShowProfileCreationError( | 225 void CreateProfileHandler::ShowProfileCreationError( |
226 Profile* profile, | 226 Profile* profile, |
227 const base::string16& error) { | 227 const base::string16& error) { |
228 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); | 228 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); |
229 profile_creation_type_ = NO_CREATION_IN_PROGRESS; | 229 profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
230 profile_path_being_created_.clear(); | 230 profile_path_being_created_.clear(); |
231 web_ui()->CallJavascriptFunction( | 231 web_ui()->CallJavascriptFunctionUnsafe( |
232 GetJavascriptMethodName(PROFILE_CREATION_ERROR), | 232 GetJavascriptMethodName(PROFILE_CREATION_ERROR), |
233 base::StringValue(error)); | 233 base::StringValue(error)); |
234 // The ProfileManager calls us back with a NULL profile in some cases. | 234 // The ProfileManager calls us back with a NULL profile in some cases. |
235 if (profile) { | 235 if (profile) { |
236 webui::DeleteProfileAtPath(profile->GetPath(), | 236 webui::DeleteProfileAtPath(profile->GetPath(), |
237 web_ui(), | 237 web_ui(), |
238 ProfileMetrics::DELETE_PROFILE_SETTINGS); | 238 ProfileMetrics::DELETE_PROFILE_SETTINGS); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 error_msg = GetProfileCreationErrorMessageSignin(); | 424 error_msg = GetProfileCreationErrorMessageSignin(); |
425 } else { | 425 } else { |
426 error_msg = GetProfileCreationErrorMessageRemote(); | 426 error_msg = GetProfileCreationErrorMessageRemote(); |
427 } | 427 } |
428 ShowProfileCreationError(profile, error_msg); | 428 ShowProfileCreationError(profile, error_msg); |
429 } | 429 } |
430 | 430 |
431 void CreateProfileHandler::ShowProfileCreationWarning( | 431 void CreateProfileHandler::ShowProfileCreationWarning( |
432 const base::string16& warning) { | 432 const base::string16& warning) { |
433 DCHECK_EQ(SUPERVISED_PROFILE_CREATION, profile_creation_type_); | 433 DCHECK_EQ(SUPERVISED_PROFILE_CREATION, profile_creation_type_); |
434 web_ui()->CallJavascriptFunction("BrowserOptions.showCreateProfileWarning", | 434 web_ui()->CallJavascriptFunctionUnsafe( |
435 base::StringValue(warning)); | 435 "BrowserOptions.showCreateProfileWarning", base::StringValue(warning)); |
436 } | 436 } |
437 | 437 |
438 void CreateProfileHandler::RecordSupervisedProfileCreationMetrics( | 438 void CreateProfileHandler::RecordSupervisedProfileCreationMetrics( |
439 GoogleServiceAuthError::State error_state) { | 439 GoogleServiceAuthError::State error_state) { |
440 if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) { | 440 if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) { |
441 UMA_HISTOGRAM_ENUMERATION("Profile.SupervisedProfileCreateError", | 441 UMA_HISTOGRAM_ENUMERATION("Profile.SupervisedProfileCreateError", |
442 error_state, | 442 error_state, |
443 GoogleServiceAuthError::NUM_STATES); | 443 GoogleServiceAuthError::NUM_STATES); |
444 UMA_HISTOGRAM_MEDIUM_TIMES( | 444 UMA_HISTOGRAM_MEDIUM_TIMES( |
445 "Profile.SupervisedProfileTotalCreateTime", | 445 "Profile.SupervisedProfileTotalCreateTime", |
(...skipping 27 matching lines...) Expand all Loading... |
473 GetProfileAttributesStorage().GetAllProfilesAttributes(); | 473 GetProfileAttributesStorage().GetAllProfilesAttributes(); |
474 for (const ProfileAttributesEntry* entry : entries) { | 474 for (const ProfileAttributesEntry* entry : entries) { |
475 if (existing_supervised_user_id == entry->GetSupervisedUserId()) | 475 if (existing_supervised_user_id == entry->GetSupervisedUserId()) |
476 return false; | 476 return false; |
477 } | 477 } |
478 return true; | 478 return true; |
479 } | 479 } |
480 #endif | 480 #endif |
481 | 481 |
482 } // namespace options | 482 } // namespace options |
OLD | NEW |