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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 DCHECK_EQ(profile_path_being_created_.value(), profile->GetPath().value()); | 248 DCHECK_EQ(profile_path_being_created_.value(), profile->GetPath().value()); |
249 profile_path_being_created_.clear(); | 249 profile_path_being_created_.clear(); |
250 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); | 250 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); |
251 base::DictionaryValue dict; | 251 base::DictionaryValue dict; |
252 dict.SetString("name", | 252 dict.SetString("name", |
253 profile->GetPrefs()->GetString(prefs::kProfileName)); | 253 profile->GetPrefs()->GetString(prefs::kProfileName)); |
254 dict.Set("filePath", base::CreateFilePathValue(profile->GetPath())); | 254 dict.Set("filePath", base::CreateFilePathValue(profile->GetPath())); |
255 bool is_supervised = | 255 bool is_supervised = |
256 profile_creation_type_ == SUPERVISED_PROFILE_CREATION || | 256 profile_creation_type_ == SUPERVISED_PROFILE_CREATION || |
257 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT; | 257 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT; |
258 dict.SetBoolean("isManaged", is_supervised); | 258 dict.SetBoolean("isSupervised", is_supervised); |
259 web_ui()->CallJavascriptFunction( | 259 web_ui()->CallJavascriptFunction( |
260 GetJavascriptMethodName(PROFILE_CREATION_SUCCESS), dict); | 260 GetJavascriptMethodName(PROFILE_CREATION_SUCCESS), dict); |
261 | 261 |
262 // If the new profile is a supervised user, instead of opening a new window | 262 // If the new profile is a supervised user, instead of opening a new window |
263 // right away, a confirmation overlay will be shown by JS from the creation | 263 // right away, a confirmation overlay will be shown by JS from the creation |
264 // dialog. If we are importing an existing supervised profile or creating a | 264 // dialog. If we are importing an existing supervised profile or creating a |
265 // new non-supervised user profile we don't show any confirmation, so open | 265 // new non-supervised user profile we don't show any confirmation, so open |
266 // the new window now. | 266 // the new window now. |
267 if (profile_creation_type_ != SUPERVISED_PROFILE_CREATION) { | 267 if (profile_creation_type_ != SUPERVISED_PROFILE_CREATION) { |
268 // Opening the new window must be the last action, after all callbacks | 268 // Opening the new window must be the last action, after all callbacks |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 389 } |
390 | 390 |
391 return l10n_util::GetStringUTF16(message_id); | 391 return l10n_util::GetStringUTF16(message_id); |
392 } | 392 } |
393 | 393 |
394 std::string CreateProfileHandler::GetJavascriptMethodName( | 394 std::string CreateProfileHandler::GetJavascriptMethodName( |
395 ProfileCreationStatus status) const { | 395 ProfileCreationStatus status) const { |
396 switch (status) { | 396 switch (status) { |
397 case PROFILE_CREATION_SUCCESS: | 397 case PROFILE_CREATION_SUCCESS: |
398 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 398 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
399 "BrowserOptions.showManagedUserImportSuccess" : | 399 "BrowserOptions.showSupervisedUserImportSuccess" : |
400 "BrowserOptions.showCreateProfileSuccess"; | 400 "BrowserOptions.showCreateProfileSuccess"; |
401 case PROFILE_CREATION_ERROR: | 401 case PROFILE_CREATION_ERROR: |
402 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 402 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
403 "BrowserOptions.showManagedUserImportError" : | 403 "BrowserOptions.showSupervisedUserImportError" : |
404 "BrowserOptions.showCreateProfileError"; | 404 "BrowserOptions.showCreateProfileError"; |
405 } | 405 } |
406 | 406 |
407 NOTREACHED(); | 407 NOTREACHED(); |
408 return std::string(); | 408 return std::string(); |
409 } | 409 } |
410 | 410 |
411 bool CreateProfileHandler::IsValidExistingSupervisedUserId( | 411 bool CreateProfileHandler::IsValidExistingSupervisedUserId( |
412 const std::string& existing_supervised_user_id) const { | 412 const std::string& existing_supervised_user_id) const { |
413 if (existing_supervised_user_id.empty()) | 413 if (existing_supervised_user_id.empty()) |
(...skipping 11 matching lines...) Expand all Loading... |
425 g_browser_process->profile_manager()->GetProfileInfoCache(); | 425 g_browser_process->profile_manager()->GetProfileInfoCache(); |
426 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { | 426 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { |
427 if (existing_supervised_user_id == | 427 if (existing_supervised_user_id == |
428 cache.GetSupervisedUserIdOfProfileAtIndex(i)) | 428 cache.GetSupervisedUserIdOfProfileAtIndex(i)) |
429 return false; | 429 return false; |
430 } | 430 } |
431 return true; | 431 return true; |
432 } | 432 } |
433 | 433 |
434 } // namespace options | 434 } // namespace options |
OLD | NEW |