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 "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/format_macros.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
18 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
19 #include "base/prefs/scoped_user_pref_update.h" | 20 #include "base/prefs/scoped_user_pref_update.h" |
20 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
24 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
(...skipping 17 matching lines...) Expand all Loading... |
42 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 43 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
43 #include "chrome/browser/chromeos/session_length_limiter.h" | 44 #include "chrome/browser/chromeos/session_length_limiter.h" |
44 #include "chrome/browser/lifetime/application_lifetime.h" | 45 #include "chrome/browser/lifetime/application_lifetime.h" |
45 #include "chrome/browser/policy/browser_policy_connector.h" | 46 #include "chrome/browser/policy/browser_policy_connector.h" |
46 #include "chrome/browser/profiles/profile.h" | 47 #include "chrome/browser/profiles/profile.h" |
47 #include "chrome/browser/profiles/profile_manager.h" | 48 #include "chrome/browser/profiles/profile_manager.h" |
48 #include "chrome/browser/sync/profile_sync_service.h" | 49 #include "chrome/browser/sync/profile_sync_service.h" |
49 #include "chrome/browser/sync/profile_sync_service_factory.h" | 50 #include "chrome/browser/sync/profile_sync_service_factory.h" |
50 #include "chrome/common/chrome_constants.h" | 51 #include "chrome/common/chrome_constants.h" |
51 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/crash_keys.h" |
52 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
53 #include "chromeos/chromeos_switches.h" | 55 #include "chromeos/chromeos_switches.h" |
54 #include "chromeos/cryptohome/async_method_caller.h" | 56 #include "chromeos/cryptohome/async_method_caller.h" |
55 #include "chromeos/dbus/dbus_thread_manager.h" | 57 #include "chromeos/dbus/dbus_thread_manager.h" |
56 #include "chromeos/login/login_state.h" | 58 #include "chromeos/login/login_state.h" |
57 #include "chromeos/settings/cros_settings_names.h" | 59 #include "chromeos/settings/cros_settings_names.h" |
58 #include "content/public/browser/browser_thread.h" | 60 #include "content/public/browser/browser_thread.h" |
59 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
60 #include "google_apis/gaia/gaia_auth_util.h" | 62 #include "google_apis/gaia/gaia_auth_util.h" |
61 #include "google_apis/gaia/google_service_auth_error.h" | 63 #include "google_apis/gaia/google_service_auth_error.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 session_started_(false), | 188 session_started_(false), |
187 user_sessions_restored_(false), | 189 user_sessions_restored_(false), |
188 is_current_user_owner_(false), | 190 is_current_user_owner_(false), |
189 is_current_user_new_(false), | 191 is_current_user_new_(false), |
190 is_current_user_ephemeral_regular_user_(false), | 192 is_current_user_ephemeral_regular_user_(false), |
191 ephemeral_users_enabled_(false), | 193 ephemeral_users_enabled_(false), |
192 supervised_user_manager_(new SupervisedUserManagerImpl(this)), | 194 supervised_user_manager_(new SupervisedUserManagerImpl(this)), |
193 manager_creation_time_(base::TimeTicks::Now()), | 195 manager_creation_time_(base::TimeTicks::Now()), |
194 multi_profile_first_run_notification_( | 196 multi_profile_first_run_notification_( |
195 new MultiProfileFirstRunNotification) { | 197 new MultiProfileFirstRunNotification) { |
| 198 UpdateNumberOfUsers(); |
196 // UserManager instance should be used only on UI thread. | 199 // UserManager instance should be used only on UI thread. |
197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
198 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, | 201 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
199 content::NotificationService::AllSources()); | 202 content::NotificationService::AllSources()); |
200 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 203 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
201 content::NotificationService::AllSources()); | 204 content::NotificationService::AllSources()); |
202 registrar_.Add(this, | 205 registrar_.Add(this, |
203 chrome::NOTIFICATION_PROFILE_CREATED, | 206 chrome::NOTIFICATION_PROFILE_CREATED, |
204 content::NotificationService::AllSources()); | 207 content::NotificationService::AllSources()); |
205 RetrieveTrustedDevicePolicies(); | 208 RetrieveTrustedDevicePolicies(); |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 is_current_user_new_ = true; | 1373 is_current_user_new_ = true; |
1371 active_user_ = User::CreateRetailModeUser(); | 1374 active_user_ = User::CreateRetailModeUser(); |
1372 GetUserImageManager(UserManager::kRetailModeUserName)->UserLoggedIn( | 1375 GetUserImageManager(UserManager::kRetailModeUserName)->UserLoggedIn( |
1373 is_current_user_new_, | 1376 is_current_user_new_, |
1374 true); | 1377 true); |
1375 WallpaperManager::Get()->SetInitialUserWallpaper( | 1378 WallpaperManager::Get()->SetInitialUserWallpaper( |
1376 UserManager::kRetailModeUserName, false); | 1379 UserManager::kRetailModeUserName, false); |
1377 } | 1380 } |
1378 | 1381 |
1379 void UserManagerImpl::NotifyOnLogin() { | 1382 void UserManagerImpl::NotifyOnLogin() { |
| 1383 UpdateNumberOfUsers(); |
1380 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1384 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1381 NotifyActiveUserHashChanged(active_user_->username_hash()); | 1385 NotifyActiveUserHashChanged(active_user_->username_hash()); |
1382 NotifyActiveUserChanged(active_user_); | 1386 NotifyActiveUserChanged(active_user_); |
1383 | 1387 |
1384 UpdateLoginState(); | 1388 UpdateLoginState(); |
1385 // TODO(nkostylev): Deprecate this notification in favor of | 1389 // TODO(nkostylev): Deprecate this notification in favor of |
1386 // ActiveUserChanged() observer call. | 1390 // ActiveUserChanged() observer call. |
1387 content::NotificationService::current()->Notify( | 1391 content::NotificationService::current()->Notify( |
1388 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 1392 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
1389 content::Source<UserManager>(this), | 1393 content::Source<UserManager>(this), |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 } | 1694 } |
1691 | 1695 |
1692 void UserManagerImpl::NotifyActiveUserChanged(const User* active_user) { | 1696 void UserManagerImpl::NotifyActiveUserChanged(const User* active_user) { |
1693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1694 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, | 1698 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, |
1695 session_state_observer_list_, | 1699 session_state_observer_list_, |
1696 ActiveUserChanged(active_user)); | 1700 ActiveUserChanged(active_user)); |
1697 } | 1701 } |
1698 | 1702 |
1699 void UserManagerImpl::NotifyUserAddedToSession(const User* added_user) { | 1703 void UserManagerImpl::NotifyUserAddedToSession(const User* added_user) { |
| 1704 UpdateNumberOfUsers(); |
1700 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1705 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1701 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, | 1706 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, |
1702 session_state_observer_list_, | 1707 session_state_observer_list_, |
1703 UserAddedToSession(added_user)); | 1708 UserAddedToSession(added_user)); |
1704 } | 1709 } |
1705 | 1710 |
1706 void UserManagerImpl::NotifyActiveUserHashChanged(const std::string& hash) { | 1711 void UserManagerImpl::NotifyActiveUserHashChanged(const std::string& hash) { |
1707 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1708 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, | 1713 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, |
1709 session_state_observer_list_, | 1714 session_state_observer_list_, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 } | 1867 } |
1863 } | 1868 } |
1864 | 1869 |
1865 void UserManagerImpl::DoUpdateAccountLocale( | 1870 void UserManagerImpl::DoUpdateAccountLocale( |
1866 const std::string& user_id, | 1871 const std::string& user_id, |
1867 const std::string& resolved_locale) { | 1872 const std::string& resolved_locale) { |
1868 if (User* user = FindUserAndModify(user_id)) | 1873 if (User* user = FindUserAndModify(user_id)) |
1869 user->SetAccountLocale(resolved_locale); | 1874 user->SetAccountLocale(resolved_locale); |
1870 } | 1875 } |
1871 | 1876 |
| 1877 void UserManagerImpl::UpdateNumberOfUsers() { |
| 1878 base::debug::SetCrashKeyValue(crash_keys::kNumberOfUsers, |
| 1879 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); |
| 1880 } |
1872 | 1881 |
1873 } // namespace chromeos | 1882 } // namespace chromeos |
OLD | NEW |