Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1660)

Side by Side Diff: components/user_manager/user_manager_base.cc

Issue 1922143002: Disabled ARC for ephemeral users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: same Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/user_manager/user_manager_base.h" 5 #include "components/user_manager/user_manager_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 531 DCHECK(task_runner_->RunsTasksOnCurrentThread());
532 return is_current_user_new_; 532 return is_current_user_new_;
533 } 533 }
534 534
535 bool UserManagerBase::IsCurrentUserNonCryptohomeDataEphemeral() const { 535 bool UserManagerBase::IsCurrentUserNonCryptohomeDataEphemeral() const {
536 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 536 DCHECK(task_runner_->RunsTasksOnCurrentThread());
537 return IsUserLoggedIn() && 537 return IsUserLoggedIn() &&
538 IsUserNonCryptohomeDataEphemeral(GetLoggedInUser()->GetAccountId()); 538 IsUserNonCryptohomeDataEphemeral(GetLoggedInUser()->GetAccountId());
539 } 539 }
540 540
541 bool UserManagerBase::IsCurrentUserCryptohomeDataEphemeral() const {
542 DCHECK(task_runner_->RunsTasksOnCurrentThread());
543 return IsUserLoggedIn() &&
544 IsUserCryptohomeDataEphemeral(GetActiveUser()->GetAccountId());
545 }
546
541 bool UserManagerBase::CanCurrentUserLock() const { 547 bool UserManagerBase::CanCurrentUserLock() const {
542 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 548 DCHECK(task_runner_->RunsTasksOnCurrentThread());
543 return IsUserLoggedIn() && active_user_->can_lock(); 549 return IsUserLoggedIn() && active_user_->can_lock();
544 } 550 }
545 551
546 bool UserManagerBase::IsUserLoggedIn() const { 552 bool UserManagerBase::IsUserLoggedIn() const {
547 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 553 DCHECK(task_runner_->RunsTasksOnCurrentThread());
548 return active_user_; 554 return active_user_;
549 } 555 }
550 556
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 620 }
615 621
616 // Data belonging to any other user is ephemeral when: 622 // Data belonging to any other user is ephemeral when:
617 // a) Going through the regular login flow and the ephemeral users policy is 623 // a) Going through the regular login flow and the ephemeral users policy is
618 // enabled. 624 // enabled.
619 // - or - 625 // - or -
620 // b) The browser is restarting after a crash. 626 // b) The browser is restarting after a crash.
621 return AreEphemeralUsersEnabled() || HasBrowserRestarted(); 627 return AreEphemeralUsersEnabled() || HasBrowserRestarted();
622 } 628 }
623 629
630 bool UserManagerBase::IsUserCryptohomeDataEphemeral(
631 const AccountId& account_id) const {
632 // Don't consider stub users data as ephemeral.
633 if (IsStubAccountId(account_id))
634 return false;
635
636 // Data belonging to the guest and demo users is always ephemeral.
637 if (IsGuestAccountId(account_id) || IsDemoApp(account_id))
638 return true;
639
640 // Data belonging to the public accounts is always ephemeral.
641 const User* user = FindUser(account_id);
642 if (user && user->GetType() == USER_TYPE_PUBLIC_ACCOUNT)
643 return true;
644
645 // Ephemeral users.
646 if (user && user->GetType() == USER_TYPE_REGULAR &&
647 FindUserInList(account_id) == nullptr) {
648 return true;
649 }
650
651 return false;
652 }
653
624 void UserManagerBase::AddObserver(UserManager::Observer* obs) { 654 void UserManagerBase::AddObserver(UserManager::Observer* obs) {
625 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 655 DCHECK(task_runner_->RunsTasksOnCurrentThread());
626 observer_list_.AddObserver(obs); 656 observer_list_.AddObserver(obs);
627 } 657 }
628 658
629 void UserManagerBase::RemoveObserver(UserManager::Observer* obs) { 659 void UserManagerBase::RemoveObserver(UserManager::Observer* obs) {
630 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 660 DCHECK(task_runner_->RunsTasksOnCurrentThread());
631 observer_list_.RemoveObserver(obs); 661 observer_list_.RemoveObserver(obs);
632 } 662 }
633 663
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 } 1073 }
1044 1074
1045 void UserManagerBase::DeleteUser(User* user) { 1075 void UserManagerBase::DeleteUser(User* user) {
1046 const bool is_active_user = (user == active_user_); 1076 const bool is_active_user = (user == active_user_);
1047 delete user; 1077 delete user;
1048 if (is_active_user) 1078 if (is_active_user)
1049 active_user_ = nullptr; 1079 active_user_ = nullptr;
1050 } 1080 }
1051 1081
1052 } // namespace user_manager 1082 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698