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

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

Issue 2438063002: user_manager: Remove deps on session_manager (Closed)
Patch Set: fix nits in PS1 Created 4 years, 2 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
« no previous file with comments | « components/user_manager/user_manager_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/format_macros.h" 15 #include "base/format_macros.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/task_runner.h" 24 #include "base/task_runner.h"
25 #include "base/values.h" 25 #include "base/values.h"
26 #include "components/prefs/pref_registry_simple.h" 26 #include "components/prefs/pref_registry_simple.h"
27 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
28 #include "components/prefs/scoped_user_pref_update.h" 28 #include "components/prefs/scoped_user_pref_update.h"
29 #include "components/session_manager/core/session_manager.h"
30 #include "components/user_manager/known_user.h" 29 #include "components/user_manager/known_user.h"
31 #include "components/user_manager/remove_user_delegate.h" 30 #include "components/user_manager/remove_user_delegate.h"
32 #include "components/user_manager/user_type.h" 31 #include "components/user_manager/user_type.h"
33 #include "google_apis/gaia/gaia_auth_util.h" 32 #include "google_apis/gaia/gaia_auth_util.h"
34 33
35 namespace user_manager { 34 namespace user_manager {
36 namespace { 35 namespace {
37 36
38 // A vector pref of the the regular users known on this device, arranged in LRU 37 // A vector pref of the the regular users known on this device, arranged in LRU
39 // order. 38 // order.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return; 242 return;
244 243
245 if (AccountId::FromUserEmail(GetActiveUser()->email()) != 244 if (AccountId::FromUserEmail(GetActiveUser()->email()) !=
246 last_session_active_account_id_) 245 last_session_active_account_id_)
247 SwitchActiveUser(last_session_active_account_id_); 246 SwitchActiveUser(last_session_active_account_id_);
248 247
249 // Make sure that this function gets run only once. 248 // Make sure that this function gets run only once.
250 last_session_active_account_id_.clear(); 249 last_session_active_account_id_.clear();
251 } 250 }
252 251
253 void UserManagerBase::SessionStarted() { 252 void UserManagerBase::OnSessionStarted() {
254 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 253 DCHECK(task_runner_->RunsTasksOnCurrentThread());
255 session_started_ = true;
256 254
257 CallUpdateLoginState(); 255 CallUpdateLoginState();
258 session_manager::SessionManager::Get()->SetSessionState(
259 session_manager::SessionState::ACTIVE);
260
261 GetLocalState()->CommitPendingWrite(); 256 GetLocalState()->CommitPendingWrite();
262 } 257 }
263 258
264 void UserManagerBase::RemoveUser(const AccountId& account_id, 259 void UserManagerBase::RemoveUser(const AccountId& account_id,
265 RemoveUserDelegate* delegate) { 260 RemoveUserDelegate* delegate) {
266 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 261 DCHECK(task_runner_->RunsTasksOnCurrentThread());
267 262
268 if (!CanUserBeRemoved(FindUser(account_id))) 263 if (!CanUserBeRemoved(FindUser(account_id)))
269 return; 264 return;
270 265
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 bool UserManagerBase::IsLoggedInAsKioskApp() const { 579 bool UserManagerBase::IsLoggedInAsKioskApp() const {
585 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 580 DCHECK(task_runner_->RunsTasksOnCurrentThread());
586 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_KIOSK_APP; 581 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_KIOSK_APP;
587 } 582 }
588 583
589 bool UserManagerBase::IsLoggedInAsStub() const { 584 bool UserManagerBase::IsLoggedInAsStub() const {
590 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 585 DCHECK(task_runner_->RunsTasksOnCurrentThread());
591 return IsUserLoggedIn() && IsStubAccountId(active_user_->GetAccountId()); 586 return IsUserLoggedIn() && IsStubAccountId(active_user_->GetAccountId());
592 } 587 }
593 588
594 bool UserManagerBase::IsSessionStarted() const {
595 DCHECK(task_runner_->RunsTasksOnCurrentThread());
596 return session_started_;
597 }
598
599 bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( 589 bool UserManagerBase::IsUserNonCryptohomeDataEphemeral(
600 const AccountId& account_id) const { 590 const AccountId& account_id) const {
601 // Data belonging to the guest and stub users is always ephemeral. 591 // Data belonging to the guest and stub users is always ephemeral.
602 if (IsGuestAccountId(account_id) || IsStubAccountId(account_id)) 592 if (IsGuestAccountId(account_id) || IsStubAccountId(account_id))
603 return true; 593 return true;
604 594
605 // Data belonging to the owner, anyone found on the user list and obsolete 595 // Data belonging to the owner, anyone found on the user list and obsolete
606 // device local accounts whose data has not been removed yet is not ephemeral. 596 // device local accounts whose data has not been removed yet is not ephemeral.
607 if (account_id == GetOwnerAccountId() || UserExistsInList(account_id) || 597 if (account_id == GetOwnerAccountId() || UserExistsInList(account_id) ||
608 IsDeviceLocalAccountMarkedForRemoval(account_id)) { 598 IsDeviceLocalAccountMarkedForRemoval(account_id)) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 } 1062 }
1073 1063
1074 void UserManagerBase::DeleteUser(User* user) { 1064 void UserManagerBase::DeleteUser(User* user) {
1075 const bool is_active_user = (user == active_user_); 1065 const bool is_active_user = (user == active_user_);
1076 delete user; 1066 delete user;
1077 if (is_active_user) 1067 if (is_active_user)
1078 active_user_ = nullptr; 1068 active_user_ = nullptr;
1079 } 1069 }
1080 1070
1081 } // namespace user_manager 1071 } // namespace user_manager
OLDNEW
« no previous file with comments | « components/user_manager/user_manager_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698