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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 387 } |
388 | 388 |
389 return l10n_util::GetStringUTF16(message_id); | 389 return l10n_util::GetStringUTF16(message_id); |
390 } | 390 } |
391 | 391 |
392 std::string CreateProfileHandler::GetJavascriptMethodName( | 392 std::string CreateProfileHandler::GetJavascriptMethodName( |
393 ProfileCreationStatus status) const { | 393 ProfileCreationStatus status) const { |
394 switch (status) { | 394 switch (status) { |
395 case PROFILE_CREATION_SUCCESS: | 395 case PROFILE_CREATION_SUCCESS: |
396 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 396 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
397 "BrowserOptions.showManagedUserImportSuccess" : | 397 "BrowserOptions.showSupervisedUserImportSuccess" : |
398 "BrowserOptions.showCreateProfileSuccess"; | 398 "BrowserOptions.showCreateProfileSuccess"; |
399 case PROFILE_CREATION_ERROR: | 399 case PROFILE_CREATION_ERROR: |
400 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 400 return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
401 "BrowserOptions.showManagedUserImportError" : | 401 "BrowserOptions.showSupervisedUserImportError" : |
402 "BrowserOptions.showCreateProfileError"; | 402 "BrowserOptions.showCreateProfileError"; |
403 } | 403 } |
404 | 404 |
405 NOTREACHED(); | 405 NOTREACHED(); |
406 return std::string(); | 406 return std::string(); |
407 } | 407 } |
408 | 408 |
409 bool CreateProfileHandler::IsValidExistingSupervisedUserId( | 409 bool CreateProfileHandler::IsValidExistingSupervisedUserId( |
410 const std::string& existing_supervised_user_id) const { | 410 const std::string& existing_supervised_user_id) const { |
411 if (existing_supervised_user_id.empty()) | 411 if (existing_supervised_user_id.empty()) |
(...skipping 11 matching lines...) Expand all Loading... |
423 g_browser_process->profile_manager()->GetProfileInfoCache(); | 423 g_browser_process->profile_manager()->GetProfileInfoCache(); |
424 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { | 424 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { |
425 if (existing_supervised_user_id == | 425 if (existing_supervised_user_id == |
426 cache.GetSupervisedUserIdOfProfileAtIndex(i)) | 426 cache.GetSupervisedUserIdOfProfileAtIndex(i)) |
427 return false; | 427 return false; |
428 } | 428 } |
429 return true; | 429 return true; |
430 } | 430 } |
431 | 431 |
432 } // namespace options | 432 } // namespace options |
OLD | NEW |