OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ash/session_controller_client.h" | 5 #include "chrome/browser/ui/ash/session_controller_client.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/public/cpp/session_types.h" | 10 #include "ash/public/cpp/session_types.h" |
11 #include "ash/public/interfaces/constants.mojom.h" | 11 #include "ash/public/interfaces/constants.mojom.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/chromeos/login/user_flow.h" | 17 #include "chrome/browser/chromeos/login/user_flow.h" |
18 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 18 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
19 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 19 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/supervised_user/supervised_user_service.h" | 22 #include "chrome/browser/supervised_user/supervised_user_service.h" |
23 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 23 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
24 #include "chrome/browser/ui/ash/multi_user/user_switch_util.h" | 24 #include "chrome/browser/ui/ash/multi_user/user_switch_util.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "chrome/grit/theme_resources.h" | 26 #include "chrome/grit/theme_resources.h" |
27 #include "chromeos/dbus/dbus_thread_manager.h" | 27 #include "chromeos/dbus/dbus_thread_manager.h" |
28 #include "chromeos/dbus/session_manager_client.h" | 28 #include "chromeos/dbus/session_manager_client.h" |
| 29 #include "components/prefs/pref_change_registrar.h" |
29 #include "components/prefs/pref_service.h" | 30 #include "components/prefs/pref_service.h" |
30 #include "components/session_manager/core/session_manager.h" | 31 #include "components/session_manager/core/session_manager.h" |
31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
32 #include "content/public/common/service_manager_connection.h" | 33 #include "content/public/common/service_manager_connection.h" |
33 #include "content/public/common/service_names.mojom.h" | 34 #include "content/public/common/service_names.mojom.h" |
34 #include "mojo/public/cpp/bindings/equals_traits.h" | 35 #include "mojo/public/cpp/bindings/equals_traits.h" |
35 #include "services/service_manager/public/cpp/connector.h" | 36 #include "services/service_manager/public/cpp/connector.h" |
36 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
37 #include "ui/gfx/image/image_skia.h" | 38 #include "ui/gfx/image/image_skia.h" |
38 | 39 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 if (profile->IsSupervised()) { | 371 if (profile->IsSupervised()) { |
371 // There can be only one supervised user per session. | 372 // There can be only one supervised user per session. |
372 DCHECK(!supervised_user_profile_); | 373 DCHECK(!supervised_user_profile_); |
373 supervised_user_profile_ = profile; | 374 supervised_user_profile_ = profile; |
374 | 375 |
375 // Watch for changes to supervised user manager/custodians. | 376 // Watch for changes to supervised user manager/custodians. |
376 SupervisedUserServiceFactory::GetForProfile(supervised_user_profile_) | 377 SupervisedUserServiceFactory::GetForProfile(supervised_user_profile_) |
377 ->AddObserver(this); | 378 ->AddObserver(this); |
378 } | 379 } |
379 | 380 |
| 381 base::Closure session_info_changed_closure = |
| 382 base::Bind(&SessionControllerClient::SendSessionInfoIfChanged, |
| 383 weak_ptr_factory_.GetWeakPtr()); |
| 384 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar = |
| 385 base::MakeUnique<PrefChangeRegistrar>(); |
| 386 pref_change_registrar->Init(profile->GetPrefs()); |
| 387 pref_change_registrar->Add(prefs::kAllowScreenLock, |
| 388 session_info_changed_closure); |
| 389 pref_change_registrar->Add(prefs::kEnableAutoScreenLock, |
| 390 session_info_changed_closure); |
| 391 pref_change_registrars_.push_back(std::move(pref_change_registrar)); |
| 392 |
380 // Needed because the user-to-profile mapping isn't available until later, | 393 // Needed because the user-to-profile mapping isn't available until later, |
381 // which is needed in UserToUserSession(). | 394 // which is needed in UserToUserSession(). |
382 base::ThreadTaskRunnerHandle::Get()->PostTask( | 395 base::ThreadTaskRunnerHandle::Get()->PostTask( |
383 FROM_HERE, base::Bind(&SessionControllerClient::SendUserSessionForProfile, | 396 FROM_HERE, base::Bind(&SessionControllerClient::SendUserSessionForProfile, |
384 weak_ptr_factory_.GetWeakPtr(), profile)); | 397 weak_ptr_factory_.GetWeakPtr(), profile)); |
385 } | 398 } |
386 | 399 |
387 void SessionControllerClient::SendUserSessionForProfile(Profile* profile) { | 400 void SessionControllerClient::SendUserSessionForProfile(Profile* profile) { |
388 DCHECK(profile); | 401 DCHECK(profile); |
389 const User* user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 402 const User* user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 const UserList logged_in_users = user_manager->GetLoggedInUsers(); | 451 const UserList logged_in_users = user_manager->GetLoggedInUsers(); |
439 std::vector<uint32_t> user_session_ids; | 452 std::vector<uint32_t> user_session_ids; |
440 for (auto* user : user_manager->GetLRULoggedInUsers()) { | 453 for (auto* user : user_manager->GetLRULoggedInUsers()) { |
441 const uint32_t user_session_id = GetSessionId(*user); | 454 const uint32_t user_session_id = GetSessionId(*user); |
442 DCHECK_NE(0u, user_session_id); | 455 DCHECK_NE(0u, user_session_id); |
443 user_session_ids.push_back(user_session_id); | 456 user_session_ids.push_back(user_session_id); |
444 } | 457 } |
445 | 458 |
446 session_controller_->SetUserSessionOrder(user_session_ids); | 459 session_controller_->SetUserSessionOrder(user_session_ids); |
447 } | 460 } |
OLD | NEW |