OLD | NEW |
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 "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <set> | 10 #include <set> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "chrome/browser/supervised_user/chromeos/manager_password_service_facto
ry.h" | 53 #include "chrome/browser/supervised_user/chromeos/manager_password_service_facto
ry.h" |
54 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_servi
ce_factory.h" | 54 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_servi
ce_factory.h" |
55 #include "chrome/common/chrome_constants.h" | 55 #include "chrome/common/chrome_constants.h" |
56 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
57 #include "chrome/common/crash_keys.h" | 57 #include "chrome/common/crash_keys.h" |
58 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
59 #include "chrome/grit/theme_resources.h" | 59 #include "chrome/grit/theme_resources.h" |
60 #include "chromeos/chromeos_switches.h" | 60 #include "chromeos/chromeos_switches.h" |
61 #include "chromeos/cryptohome/async_method_caller.h" | 61 #include "chromeos/cryptohome/async_method_caller.h" |
62 #include "chromeos/login/login_state.h" | 62 #include "chromeos/login/login_state.h" |
63 #include "chromeos/login/user_names.h" | |
64 #include "chromeos/settings/cros_settings_names.h" | 63 #include "chromeos/settings/cros_settings_names.h" |
65 #include "chromeos/timezone/timezone_resolver.h" | 64 #include "chromeos/timezone/timezone_resolver.h" |
66 #include "components/policy/policy_constants.h" | 65 #include "components/policy/policy_constants.h" |
67 #include "components/prefs/pref_registry_simple.h" | 66 #include "components/prefs/pref_registry_simple.h" |
68 #include "components/prefs/pref_service.h" | 67 #include "components/prefs/pref_service.h" |
69 #include "components/prefs/scoped_user_pref_update.h" | 68 #include "components/prefs/scoped_user_pref_update.h" |
70 #include "components/session_manager/core/session_manager.h" | 69 #include "components/session_manager/core/session_manager.h" |
71 #include "components/signin/core/account_id/account_id.h" | 70 #include "components/signin/core/account_id/account_id.h" |
72 #include "components/user_manager/known_user.h" | 71 #include "components/user_manager/known_user.h" |
73 #include "components/user_manager/remove_user_delegate.h" | 72 #include "components/user_manager/remove_user_delegate.h" |
74 #include "components/user_manager/user.h" | 73 #include "components/user_manager/user.h" |
75 #include "components/user_manager/user_image/user_image.h" | 74 #include "components/user_manager/user_image/user_image.h" |
| 75 #include "components/user_manager/user_names.h" |
76 #include "components/user_manager/user_type.h" | 76 #include "components/user_manager/user_type.h" |
77 #include "content/public/browser/browser_thread.h" | 77 #include "content/public/browser/browser_thread.h" |
78 #include "content/public/browser/notification_service.h" | 78 #include "content/public/browser/notification_service.h" |
79 #include "extensions/common/features/feature_session_type.h" | 79 #include "extensions/common/features/feature_session_type.h" |
80 #include "ui/base/l10n/l10n_util.h" | 80 #include "ui/base/l10n/l10n_util.h" |
81 #include "ui/base/resource/resource_bundle.h" | 81 #include "ui/base/resource/resource_bundle.h" |
82 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" | 82 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" |
83 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" | 83 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" |
84 #include "ui/gfx/image/image_skia.h" | 84 #include "ui/gfx/image/image_skia.h" |
85 #include "ui/wm/core/wm_core_switches.h" | 85 #include "ui/wm/core/wm_core_switches.h" |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 // TODO(nkostylev): Add support for passing guest session cryptohome | 731 // TODO(nkostylev): Add support for passing guest session cryptohome |
732 // mount point. Legacy (--login-profile) value will be used for now. | 732 // mount point. Legacy (--login-profile) value will be used for now. |
733 // http://crosbug.com/230859 | 733 // http://crosbug.com/230859 |
734 active_user_->SetStubImage( | 734 active_user_->SetStubImage( |
735 base::MakeUnique<user_manager::UserImage>( | 735 base::MakeUnique<user_manager::UserImage>( |
736 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 736 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
737 IDR_PROFILE_PICTURE_LOADING)), | 737 IDR_PROFILE_PICTURE_LOADING)), |
738 user_manager::User::USER_IMAGE_INVALID, false); | 738 user_manager::User::USER_IMAGE_INVALID, false); |
739 | 739 |
740 // Initializes wallpaper after active_user_ is set. | 740 // Initializes wallpaper after active_user_ is set. |
741 WallpaperManager::Get()->SetUserWallpaperNow(login::GuestAccountId()); | 741 WallpaperManager::Get()->SetUserWallpaperNow(user_manager::GuestAccountId()); |
742 } | 742 } |
743 | 743 |
744 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { | 744 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { |
745 ChromeUserManager::RegularUserLoggedIn(account_id); | 745 ChromeUserManager::RegularUserLoggedIn(account_id); |
746 | 746 |
747 if (FakeOwnership()) { | 747 if (FakeOwnership()) { |
748 const AccountId owner_account_id = GetActiveUser()->GetAccountId(); | 748 const AccountId owner_account_id = GetActiveUser()->GetAccountId(); |
749 VLOG(1) << "Set device owner to: " << owner_account_id.GetUserEmail(); | 749 VLOG(1) << "Set device owner to: " << owner_account_id.GetUserEmail(); |
750 CrosSettings::Get()->SetString(kDeviceOwner, | 750 CrosSettings::Get()->SetString(kDeviceOwner, |
751 owner_account_id.GetUserEmail()); | 751 owner_account_id.GetUserEmail()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 command_line->AppendSwitch(::switches::kForceAppMode); | 871 command_line->AppendSwitch(::switches::kForceAppMode); |
872 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); | 872 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); |
873 | 873 |
874 // Disable window animation since kiosk app runs in a single full screen | 874 // Disable window animation since kiosk app runs in a single full screen |
875 // window and window animation causes start-up janks. | 875 // window and window animation causes start-up janks. |
876 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); | 876 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); |
877 } | 877 } |
878 | 878 |
879 void ChromeUserManagerImpl::DemoAccountLoggedIn() { | 879 void ChromeUserManagerImpl::DemoAccountLoggedIn() { |
880 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 880 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
881 active_user_ = user_manager::User::CreateKioskAppUser(login::DemoAccountId()); | 881 active_user_ = |
| 882 user_manager::User::CreateKioskAppUser(user_manager::DemoAccountId()); |
882 active_user_->SetStubImage( | 883 active_user_->SetStubImage( |
883 base::MakeUnique<user_manager::UserImage>( | 884 base::MakeUnique<user_manager::UserImage>( |
884 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 885 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
885 IDR_PROFILE_PICTURE_LOADING)), | 886 IDR_PROFILE_PICTURE_LOADING)), |
886 user_manager::User::USER_IMAGE_INVALID, false); | 887 user_manager::User::USER_IMAGE_INVALID, false); |
887 WallpaperManager::Get()->SetUserWallpaperNow(login::DemoAccountId()); | 888 WallpaperManager::Get()->SetUserWallpaperNow(user_manager::DemoAccountId()); |
888 | 889 |
889 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 890 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
890 command_line->AppendSwitch(::switches::kForceAppMode); | 891 command_line->AppendSwitch(::switches::kForceAppMode); |
891 command_line->AppendSwitchASCII(::switches::kAppId, | 892 command_line->AppendSwitchASCII(::switches::kAppId, |
892 DemoAppLauncher::kDemoAppId); | 893 DemoAppLauncher::kDemoAppId); |
893 | 894 |
894 // Disable window animation since the demo app runs in a single full screen | 895 // Disable window animation since the demo app runs in a single full screen |
895 // window and window animation causes start-up janks. | 896 // window and window animation causes start-up janks. |
896 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 897 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
897 wm::switches::kWindowAnimationsDisabled); | 898 wm::switches::kWindowAnimationsDisabled); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1257 |
1257 bool ChromeUserManagerImpl::GetPlatformKnownUserId( | 1258 bool ChromeUserManagerImpl::GetPlatformKnownUserId( |
1258 const std::string& user_email, | 1259 const std::string& user_email, |
1259 const std::string& gaia_id, | 1260 const std::string& gaia_id, |
1260 AccountId* out_account_id) const { | 1261 AccountId* out_account_id) const { |
1261 return chrome_user_manager_util::GetPlatformKnownUserId(user_email, gaia_id, | 1262 return chrome_user_manager_util::GetPlatformKnownUserId(user_email, gaia_id, |
1262 out_account_id); | 1263 out_account_id); |
1263 } | 1264 } |
1264 | 1265 |
1265 const AccountId& ChromeUserManagerImpl::GetGuestAccountId() const { | 1266 const AccountId& ChromeUserManagerImpl::GetGuestAccountId() const { |
1266 return login::GuestAccountId(); | 1267 return user_manager::GuestAccountId(); |
1267 } | 1268 } |
1268 | 1269 |
1269 bool ChromeUserManagerImpl::IsFirstExecAfterBoot() const { | 1270 bool ChromeUserManagerImpl::IsFirstExecAfterBoot() const { |
1270 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 1271 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
1271 chromeos::switches::kFirstExecAfterBoot); | 1272 chromeos::switches::kFirstExecAfterBoot); |
1272 } | 1273 } |
1273 | 1274 |
1274 void ChromeUserManagerImpl::AsyncRemoveCryptohome( | 1275 void ChromeUserManagerImpl::AsyncRemoveCryptohome( |
1275 const AccountId& account_id) const { | 1276 const AccountId& account_id) const { |
1276 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( | 1277 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( |
1277 cryptohome::Identification(account_id), | 1278 cryptohome::Identification(account_id), |
1278 base::Bind(&OnRemoveUserComplete, account_id)); | 1279 base::Bind(&OnRemoveUserComplete, account_id)); |
1279 } | 1280 } |
1280 | 1281 |
1281 bool ChromeUserManagerImpl::IsGuestAccountId( | 1282 bool ChromeUserManagerImpl::IsGuestAccountId( |
1282 const AccountId& account_id) const { | 1283 const AccountId& account_id) const { |
1283 return account_id == login::GuestAccountId(); | 1284 return account_id == user_manager::GuestAccountId(); |
1284 } | 1285 } |
1285 | 1286 |
1286 bool ChromeUserManagerImpl::IsStubAccountId(const AccountId& account_id) const { | 1287 bool ChromeUserManagerImpl::IsStubAccountId(const AccountId& account_id) const { |
1287 return account_id == login::StubAccountId(); | 1288 return account_id == user_manager::StubAccountId(); |
1288 } | 1289 } |
1289 | 1290 |
1290 bool ChromeUserManagerImpl::IsSupervisedAccountId( | 1291 bool ChromeUserManagerImpl::IsSupervisedAccountId( |
1291 const AccountId& account_id) const { | 1292 const AccountId& account_id) const { |
1292 return gaia::ExtractDomainName(account_id.GetUserEmail()) == | 1293 return gaia::ExtractDomainName(account_id.GetUserEmail()) == |
1293 chromeos::login::kSupervisedUserDomain; | 1294 user_manager::kSupervisedUserDomain; |
1294 } | 1295 } |
1295 | 1296 |
1296 bool ChromeUserManagerImpl::HasBrowserRestarted() const { | 1297 bool ChromeUserManagerImpl::HasBrowserRestarted() const { |
1297 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1298 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
1298 return base::SysInfo::IsRunningOnChromeOS() && | 1299 return base::SysInfo::IsRunningOnChromeOS() && |
1299 command_line->HasSwitch(chromeos::switches::kLoginUser); | 1300 command_line->HasSwitch(chromeos::switches::kLoginUser); |
1300 } | 1301 } |
1301 | 1302 |
1302 const gfx::ImageSkia& ChromeUserManagerImpl::GetResourceImagekiaNamed( | 1303 const gfx::ImageSkia& ChromeUserManagerImpl::GetResourceImagekiaNamed( |
1303 int id) const { | 1304 int id) const { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 break; | 1342 break; |
1342 default: | 1343 default: |
1343 NOTREACHED(); | 1344 NOTREACHED(); |
1344 break; | 1345 break; |
1345 } | 1346 } |
1346 | 1347 |
1347 return user; | 1348 return user; |
1348 } | 1349 } |
1349 | 1350 |
1350 } // namespace chromeos | 1351 } // namespace chromeos |
OLD | NEW |