OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
| 11 #include "base/base_paths.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/format_macros.h" | 17 #include "base/format_macros.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/path_service.h" |
19 #include "base/prefs/pref_registry_simple.h" | 21 #include "base/prefs/pref_registry_simple.h" |
20 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
21 #include "base/prefs/scoped_user_pref_update.h" | 23 #include "base/prefs/scoped_user_pref_update.h" |
22 #include "base/rand_util.h" | 24 #include "base/rand_util.h" |
23 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
24 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
25 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
26 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
27 #include "base/threading/worker_pool.h" | 29 #include "base/threading/worker_pool.h" |
28 #include "base/values.h" | 30 #include "base/values.h" |
(...skipping 18 matching lines...) Expand all Loading... |
47 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 49 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
48 #include "chrome/browser/chromeos/session_length_limiter.h" | 50 #include "chrome/browser/chromeos/session_length_limiter.h" |
49 #include "chrome/browser/managed_mode/chromeos/managed_user_password_service_fac
tory.h" | 51 #include "chrome/browser/managed_mode/chromeos/managed_user_password_service_fac
tory.h" |
50 #include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.
h" | 52 #include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.
h" |
51 #include "chrome/browser/net/nss_context.h" | 53 #include "chrome/browser/net/nss_context.h" |
52 #include "chrome/browser/profiles/profile.h" | 54 #include "chrome/browser/profiles/profile.h" |
53 #include "chrome/browser/profiles/profile_manager.h" | 55 #include "chrome/browser/profiles/profile_manager.h" |
54 #include "chrome/browser/sync/profile_sync_service.h" | 56 #include "chrome/browser/sync/profile_sync_service.h" |
55 #include "chrome/browser/sync/profile_sync_service_factory.h" | 57 #include "chrome/browser/sync/profile_sync_service_factory.h" |
56 #include "chrome/common/chrome_constants.h" | 58 #include "chrome/common/chrome_constants.h" |
| 59 #include "chrome/common/chrome_paths.h" |
57 #include "chrome/common/chrome_switches.h" | 60 #include "chrome/common/chrome_switches.h" |
58 #include "chrome/common/crash_keys.h" | 61 #include "chrome/common/crash_keys.h" |
59 #include "chrome/common/pref_names.h" | 62 #include "chrome/common/pref_names.h" |
60 #include "chromeos/cert_loader.h" | 63 #include "chromeos/cert_loader.h" |
61 #include "chromeos/chromeos_switches.h" | 64 #include "chromeos/chromeos_switches.h" |
62 #include "chromeos/cryptohome/async_method_caller.h" | 65 #include "chromeos/cryptohome/async_method_caller.h" |
63 #include "chromeos/dbus/dbus_thread_manager.h" | 66 #include "chromeos/dbus/dbus_thread_manager.h" |
64 #include "chromeos/login/login_state.h" | 67 #include "chromeos/login/login_state.h" |
65 #include "chromeos/settings/cros_settings_names.h" | 68 #include "chromeos/settings/cros_settings_names.h" |
66 #include "content/public/browser/browser_thread.h" | 69 #include "content/public/browser/browser_thread.h" |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 is_current_user_new_ = true; | 1535 is_current_user_new_ = true; |
1533 active_user_ = User::CreateRetailModeUser(); | 1536 active_user_ = User::CreateRetailModeUser(); |
1534 GetUserImageManager(UserManager::kRetailModeUserName)->UserLoggedIn( | 1537 GetUserImageManager(UserManager::kRetailModeUserName)->UserLoggedIn( |
1535 is_current_user_new_, | 1538 is_current_user_new_, |
1536 true); | 1539 true); |
1537 WallpaperManager::Get()->SetUserWallpaperNow( | 1540 WallpaperManager::Get()->SetUserWallpaperNow( |
1538 UserManager::kRetailModeUserName); | 1541 UserManager::kRetailModeUserName); |
1539 } | 1542 } |
1540 | 1543 |
1541 void UserManagerImpl::NotifyOnLogin() { | 1544 void UserManagerImpl::NotifyOnLogin() { |
| 1545 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1546 |
| 1547 // Override user homedir, check for ProfileManager being initialized as |
| 1548 // it may not exist in unit tests. |
| 1549 if (g_browser_process->profile_manager()) { |
| 1550 if (GetLoggedInUsers().size() == 1) { |
| 1551 base::FilePath homedir = ProfileHelper::GetProfilePathByUserIdHash( |
| 1552 primary_user_->username_hash()); |
| 1553 PathService::Override(base::DIR_HOME, homedir); |
| 1554 } |
| 1555 } |
| 1556 |
1542 UpdateNumberOfUsers(); | 1557 UpdateNumberOfUsers(); |
1543 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
1544 NotifyActiveUserHashChanged(active_user_->username_hash()); | 1558 NotifyActiveUserHashChanged(active_user_->username_hash()); |
1545 NotifyActiveUserChanged(active_user_); | 1559 NotifyActiveUserChanged(active_user_); |
| 1560 UpdateLoginState(); |
1546 | 1561 |
1547 UpdateLoginState(); | |
1548 // TODO(nkostylev): Deprecate this notification in favor of | 1562 // TODO(nkostylev): Deprecate this notification in favor of |
1549 // ActiveUserChanged() observer call. | 1563 // ActiveUserChanged() observer call. |
1550 content::NotificationService::current()->Notify( | 1564 content::NotificationService::current()->Notify( |
1551 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 1565 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
1552 content::Source<UserManager>(this), | 1566 content::Source<UserManager>(this), |
1553 content::Details<const User>(active_user_)); | 1567 content::Details<const User>(active_user_)); |
1554 | 1568 |
1555 // Owner must be first user in session. DeviceSettingsService can't deal with | 1569 // Owner must be first user in session. DeviceSettingsService can't deal with |
1556 // multiple user and will mix up ownership, crbug.com/230018. | 1570 // multiple user and will mix up ownership, crbug.com/230018. |
1557 if (GetLoggedInUsers().size() == 1) { | 1571 if (GetLoggedInUsers().size() == 1) { |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 } | 2098 } |
2085 | 2099 |
2086 void UserManagerImpl::DeleteUser(User* user) { | 2100 void UserManagerImpl::DeleteUser(User* user) { |
2087 const bool is_active_user = (user == active_user_); | 2101 const bool is_active_user = (user == active_user_); |
2088 delete user; | 2102 delete user; |
2089 if (is_active_user) | 2103 if (is_active_user) |
2090 active_user_ = NULL; | 2104 active_user_ = NULL; |
2091 } | 2105 } |
2092 | 2106 |
2093 } // namespace chromeos | 2107 } // namespace chromeos |
OLD | NEW |