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/signin/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/value_conversions.h" | 9 #include "base/value_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { | 338 void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { |
339 DCHECK(args); | 339 DCHECK(args); |
340 const base::Value* profile_path_value; | 340 const base::Value* profile_path_value; |
341 if (!args->Get(0, &profile_path_value)) | 341 if (!args->Get(0, &profile_path_value)) |
342 return; | 342 return; |
343 | 343 |
344 base::FilePath profile_path; | 344 base::FilePath profile_path; |
345 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) | 345 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) |
346 return; | 346 return; |
347 | 347 |
348 // This handler could have been called in managed mode, for example because | 348 // This handler could have been called for a supervised user, for example |
349 // the user fiddled with the web inspector. Silently return in this case. | 349 // because the user fiddled with the web inspector. Silently return in this |
350 if (Profile::FromWebUI(web_ui())->IsManaged()) | 350 // case. |
| 351 if (Profile::FromWebUI(web_ui())->IsSupervised()) |
351 return; | 352 return; |
352 | 353 |
353 if (!profiles::IsMultipleProfilesEnabled()) | 354 if (!profiles::IsMultipleProfilesEnabled()) |
354 return; | 355 return; |
355 | 356 |
356 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 357 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
357 profile_path, | 358 profile_path, |
358 base::Bind(&OpenNewWindowForProfile, desktop_type_)); | 359 base::Bind(&OpenNewWindowForProfile, desktop_type_)); |
359 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); | 360 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); |
360 } | 361 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 570 |
570 void UserManagerScreenHandler::SendUserList() { | 571 void UserManagerScreenHandler::SendUserList() { |
571 base::ListValue users_list; | 572 base::ListValue users_list; |
572 base::FilePath active_profile_path = | 573 base::FilePath active_profile_path = |
573 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); | 574 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); |
574 const ProfileInfoCache& info_cache = | 575 const ProfileInfoCache& info_cache = |
575 g_browser_process->profile_manager()->GetProfileInfoCache(); | 576 g_browser_process->profile_manager()->GetProfileInfoCache(); |
576 | 577 |
577 user_auth_type_map_.clear(); | 578 user_auth_type_map_.clear(); |
578 | 579 |
579 // If the active user is a managed user, then they may not perform | 580 // If the active user is a supervised user, then they may not perform |
580 // certain actions (i.e. delete another user). | 581 // certain actions (i.e. delete another user). |
581 bool active_user_is_managed = Profile::FromWebUI(web_ui())->IsManaged(); | 582 bool active_user_is_supervised = Profile::FromWebUI(web_ui())->IsSupervised(); |
582 for (size_t i = 0; i < info_cache.GetNumberOfProfiles(); ++i) { | 583 for (size_t i = 0; i < info_cache.GetNumberOfProfiles(); ++i) { |
583 base::DictionaryValue* profile_value = new base::DictionaryValue(); | 584 base::DictionaryValue* profile_value = new base::DictionaryValue(); |
584 | 585 |
585 base::FilePath profile_path = info_cache.GetPathOfProfileAtIndex(i); | 586 base::FilePath profile_path = info_cache.GetPathOfProfileAtIndex(i); |
586 bool is_active_user = (profile_path == active_profile_path); | 587 bool is_active_user = (profile_path == active_profile_path); |
587 | 588 |
588 profile_value->SetString( | 589 profile_value->SetString( |
589 kKeyUsername, info_cache.GetUserNameOfProfileAtIndex(i)); | 590 kKeyUsername, info_cache.GetUserNameOfProfileAtIndex(i)); |
590 profile_value->SetString( | 591 profile_value->SetString( |
591 kKeyEmailAddress, info_cache.GetUserNameOfProfileAtIndex(i)); | 592 kKeyEmailAddress, info_cache.GetUserNameOfProfileAtIndex(i)); |
592 profile_value->SetString( | 593 profile_value->SetString( |
593 kKeyDisplayName, info_cache.GetNameOfProfileAtIndex(i)); | 594 kKeyDisplayName, info_cache.GetNameOfProfileAtIndex(i)); |
594 profile_value->SetString(kKeyProfilePath, profile_path.MaybeAsASCII()); | 595 profile_value->SetString(kKeyProfilePath, profile_path.MaybeAsASCII()); |
595 profile_value->SetBoolean(kKeyPublicAccount, false); | 596 profile_value->SetBoolean(kKeyPublicAccount, false); |
596 profile_value->SetBoolean( | 597 profile_value->SetBoolean( |
597 kKeyLocallyManagedUser, info_cache.ProfileIsManagedAtIndex(i)); | 598 kKeyLocallyManagedUser, info_cache.ProfileIsSupervisedAtIndex(i)); |
598 profile_value->SetBoolean(kKeySignedIn, is_active_user); | 599 profile_value->SetBoolean(kKeySignedIn, is_active_user); |
599 profile_value->SetBoolean( | 600 profile_value->SetBoolean( |
600 kKeyNeedsSignin, info_cache.ProfileIsSigninRequiredAtIndex(i)); | 601 kKeyNeedsSignin, info_cache.ProfileIsSigninRequiredAtIndex(i)); |
601 profile_value->SetBoolean(kKeyIsOwner, false); | 602 profile_value->SetBoolean(kKeyIsOwner, false); |
602 profile_value->SetBoolean(kKeyCanRemove, !active_user_is_managed); | 603 profile_value->SetBoolean(kKeyCanRemove, !active_user_is_supervised); |
603 profile_value->SetBoolean(kKeyIsDesktop, true); | 604 profile_value->SetBoolean(kKeyIsDesktop, true); |
604 profile_value->SetString( | 605 profile_value->SetString( |
605 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); | 606 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); |
606 | 607 |
607 // The row of user pods should display the active user first. | 608 // The row of user pods should display the active user first. |
608 if (is_active_user) | 609 if (is_active_user) |
609 users_list.Insert(0, profile_value); | 610 users_list.Insert(0, profile_value); |
610 else | 611 else |
611 users_list.Append(profile_value); | 612 users_list.Append(profile_value); |
612 } | 613 } |
(...skipping 21 matching lines...) Expand all Loading... |
634 } else { | 635 } else { |
635 web_ui()->CallJavascriptFunction( | 636 web_ui()->CallJavascriptFunction( |
636 "cr.ui.Oobe.showSignInError", | 637 "cr.ui.Oobe.showSignInError", |
637 base::FundamentalValue(0), | 638 base::FundamentalValue(0), |
638 base::StringValue( | 639 base::StringValue( |
639 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), | 640 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING)), |
640 base::StringValue(""), | 641 base::StringValue(""), |
641 base::FundamentalValue(0)); | 642 base::FundamentalValue(0)); |
642 } | 643 } |
643 } | 644 } |
OLD | NEW |