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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // If sync is not yet fully initialized, the creation may take extra time, | 101 // If sync is not yet fully initialized, the creation may take extra time, |
102 // so show a message. Import doesn't wait for an acknowledgement, so it | 102 // so show a message. Import doesn't wait for an acknowledgement, so it |
103 // won't have the same potential delay. | 103 // won't have the same potential delay. |
104 ProfileSyncService* sync_service = | 104 ProfileSyncService* sync_service = |
105 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 105 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
106 current_profile); | 106 current_profile); |
107 ProfileSyncService::SyncStatusSummary status = | 107 ProfileSyncService::SyncStatusSummary status = |
108 sync_service->QuerySyncStatusSummary(); | 108 sync_service->QuerySyncStatusSummary(); |
109 if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) { | 109 if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) { |
110 ShowProfileCreationWarning(l10n_util::GetStringUTF16( | 110 ShowProfileCreationWarning(l10n_util::GetStringUTF16( |
111 IDS_PROFILES_CREATE_MANAGED_JUST_SIGNED_IN)); | 111 IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN)); |
112 } | 112 } |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG); | 116 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG); |
117 | 117 |
118 profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync( | 118 profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync( |
119 name, icon, | 119 name, icon, |
120 base::Bind(&CreateProfileHandler::OnProfileCreated, | 120 base::Bind(&CreateProfileHandler::OnProfileCreated, |
121 weak_ptr_factory_.GetWeakPtr(), | 121 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 base::string16 CreateProfileHandler::GetProfileCreationErrorMessage( | 365 base::string16 CreateProfileHandler::GetProfileCreationErrorMessage( |
366 ProfileCreationErrorType error) const { | 366 ProfileCreationErrorType error) const { |
367 int message_id = -1; | 367 int message_id = -1; |
368 switch (error) { | 368 switch (error) { |
369 case SIGNIN_ERROR: | 369 case SIGNIN_ERROR: |
370 message_id = | 370 message_id = |
371 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 371 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
372 IDS_MANAGED_USER_IMPORT_SIGN_IN_ERROR : | 372 IDS_SUPERVISED_USER_IMPORT_SIGN_IN_ERROR : |
373 IDS_PROFILES_CREATE_SIGN_IN_ERROR; | 373 IDS_PROFILES_CREATE_SIGN_IN_ERROR; |
374 break; | 374 break; |
375 case REMOTE_ERROR: | 375 case REMOTE_ERROR: |
376 message_id = | 376 message_id = |
377 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 377 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
378 IDS_MANAGED_USER_IMPORT_REMOTE_ERROR : | 378 IDS_SUPERVISED_USER_IMPORT_REMOTE_ERROR : |
379 IDS_PROFILES_CREATE_REMOTE_ERROR; | 379 IDS_PROFILES_CREATE_REMOTE_ERROR; |
380 break; | 380 break; |
381 case LOCAL_ERROR: | 381 case LOCAL_ERROR: |
382 message_id = | 382 message_id = |
383 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? | 383 profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ? |
384 IDS_MANAGED_USER_IMPORT_LOCAL_ERROR : | 384 IDS_SUPERVISED_USER_IMPORT_LOCAL_ERROR : |
385 IDS_PROFILES_CREATE_LOCAL_ERROR; | 385 IDS_PROFILES_CREATE_LOCAL_ERROR; |
386 break; | 386 break; |
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) { |
(...skipping 28 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 |