| 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( |
| 742 user_manager::chromeos::GuestAccountId()); |
| 742 } | 743 } |
| 743 | 744 |
| 744 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { | 745 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { |
| 745 ChromeUserManager::RegularUserLoggedIn(account_id); | 746 ChromeUserManager::RegularUserLoggedIn(account_id); |
| 746 | 747 |
| 747 if (FakeOwnership()) { | 748 if (FakeOwnership()) { |
| 748 const AccountId owner_account_id = GetActiveUser()->GetAccountId(); | 749 const AccountId owner_account_id = GetActiveUser()->GetAccountId(); |
| 749 VLOG(1) << "Set device owner to: " << owner_account_id.GetUserEmail(); | 750 VLOG(1) << "Set device owner to: " << owner_account_id.GetUserEmail(); |
| 750 CrosSettings::Get()->SetString(kDeviceOwner, | 751 CrosSettings::Get()->SetString(kDeviceOwner, |
| 751 owner_account_id.GetUserEmail()); | 752 owner_account_id.GetUserEmail()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 command_line->AppendSwitch(::switches::kForceAppMode); | 872 command_line->AppendSwitch(::switches::kForceAppMode); |
| 872 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); | 873 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); |
| 873 | 874 |
| 874 // Disable window animation since kiosk app runs in a single full screen | 875 // Disable window animation since kiosk app runs in a single full screen |
| 875 // window and window animation causes start-up janks. | 876 // window and window animation causes start-up janks. |
| 876 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); | 877 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); |
| 877 } | 878 } |
| 878 | 879 |
| 879 void ChromeUserManagerImpl::DemoAccountLoggedIn() { | 880 void ChromeUserManagerImpl::DemoAccountLoggedIn() { |
| 880 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 881 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 881 active_user_ = user_manager::User::CreateKioskAppUser(login::DemoAccountId()); | 882 active_user_ = user_manager::User::CreateKioskAppUser( |
| 883 user_manager::chromeos::DemoAccountId()); |
| 882 active_user_->SetStubImage( | 884 active_user_->SetStubImage( |
| 883 base::MakeUnique<user_manager::UserImage>( | 885 base::MakeUnique<user_manager::UserImage>( |
| 884 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 886 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 885 IDR_PROFILE_PICTURE_LOADING)), | 887 IDR_PROFILE_PICTURE_LOADING)), |
| 886 user_manager::User::USER_IMAGE_INVALID, false); | 888 user_manager::User::USER_IMAGE_INVALID, false); |
| 887 WallpaperManager::Get()->SetUserWallpaperNow(login::DemoAccountId()); | 889 WallpaperManager::Get()->SetUserWallpaperNow( |
| 890 user_manager::chromeos::DemoAccountId()); |
| 888 | 891 |
| 889 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 892 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 890 command_line->AppendSwitch(::switches::kForceAppMode); | 893 command_line->AppendSwitch(::switches::kForceAppMode); |
| 891 command_line->AppendSwitchASCII(::switches::kAppId, | 894 command_line->AppendSwitchASCII(::switches::kAppId, |
| 892 DemoAppLauncher::kDemoAppId); | 895 DemoAppLauncher::kDemoAppId); |
| 893 | 896 |
| 894 // Disable window animation since the demo app runs in a single full screen | 897 // Disable window animation since the demo app runs in a single full screen |
| 895 // window and window animation causes start-up janks. | 898 // window and window animation causes start-up janks. |
| 896 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 899 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 897 wm::switches::kWindowAnimationsDisabled); | 900 wm::switches::kWindowAnimationsDisabled); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 | 1259 |
| 1257 bool ChromeUserManagerImpl::GetPlatformKnownUserId( | 1260 bool ChromeUserManagerImpl::GetPlatformKnownUserId( |
| 1258 const std::string& user_email, | 1261 const std::string& user_email, |
| 1259 const std::string& gaia_id, | 1262 const std::string& gaia_id, |
| 1260 AccountId* out_account_id) const { | 1263 AccountId* out_account_id) const { |
| 1261 return chrome_user_manager_util::GetPlatformKnownUserId(user_email, gaia_id, | 1264 return chrome_user_manager_util::GetPlatformKnownUserId(user_email, gaia_id, |
| 1262 out_account_id); | 1265 out_account_id); |
| 1263 } | 1266 } |
| 1264 | 1267 |
| 1265 const AccountId& ChromeUserManagerImpl::GetGuestAccountId() const { | 1268 const AccountId& ChromeUserManagerImpl::GetGuestAccountId() const { |
| 1266 return login::GuestAccountId(); | 1269 return user_manager::chromeos::GuestAccountId(); |
| 1267 } | 1270 } |
| 1268 | 1271 |
| 1269 bool ChromeUserManagerImpl::IsFirstExecAfterBoot() const { | 1272 bool ChromeUserManagerImpl::IsFirstExecAfterBoot() const { |
| 1270 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 1273 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1271 chromeos::switches::kFirstExecAfterBoot); | 1274 chromeos::switches::kFirstExecAfterBoot); |
| 1272 } | 1275 } |
| 1273 | 1276 |
| 1274 void ChromeUserManagerImpl::AsyncRemoveCryptohome( | 1277 void ChromeUserManagerImpl::AsyncRemoveCryptohome( |
| 1275 const AccountId& account_id) const { | 1278 const AccountId& account_id) const { |
| 1276 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( | 1279 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( |
| 1277 cryptohome::Identification(account_id), | 1280 cryptohome::Identification(account_id), |
| 1278 base::Bind(&OnRemoveUserComplete, account_id)); | 1281 base::Bind(&OnRemoveUserComplete, account_id)); |
| 1279 } | 1282 } |
| 1280 | 1283 |
| 1281 bool ChromeUserManagerImpl::IsGuestAccountId( | 1284 bool ChromeUserManagerImpl::IsGuestAccountId( |
| 1282 const AccountId& account_id) const { | 1285 const AccountId& account_id) const { |
| 1283 return account_id == login::GuestAccountId(); | 1286 return account_id == user_manager::chromeos::GuestAccountId(); |
| 1284 } | 1287 } |
| 1285 | 1288 |
| 1286 bool ChromeUserManagerImpl::IsStubAccountId(const AccountId& account_id) const { | 1289 bool ChromeUserManagerImpl::IsStubAccountId(const AccountId& account_id) const { |
| 1287 return account_id == login::StubAccountId(); | 1290 return account_id == user_manager::chromeos::StubAccountId(); |
| 1288 } | 1291 } |
| 1289 | 1292 |
| 1290 bool ChromeUserManagerImpl::IsSupervisedAccountId( | 1293 bool ChromeUserManagerImpl::IsSupervisedAccountId( |
| 1291 const AccountId& account_id) const { | 1294 const AccountId& account_id) const { |
| 1292 return gaia::ExtractDomainName(account_id.GetUserEmail()) == | 1295 return gaia::ExtractDomainName(account_id.GetUserEmail()) == |
| 1293 chromeos::login::kSupervisedUserDomain; | 1296 user_manager::chromeos::kSupervisedUserDomain; |
| 1294 } | 1297 } |
| 1295 | 1298 |
| 1296 bool ChromeUserManagerImpl::HasBrowserRestarted() const { | 1299 bool ChromeUserManagerImpl::HasBrowserRestarted() const { |
| 1297 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1300 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1298 return base::SysInfo::IsRunningOnChromeOS() && | 1301 return base::SysInfo::IsRunningOnChromeOS() && |
| 1299 command_line->HasSwitch(chromeos::switches::kLoginUser); | 1302 command_line->HasSwitch(chromeos::switches::kLoginUser); |
| 1300 } | 1303 } |
| 1301 | 1304 |
| 1302 const gfx::ImageSkia& ChromeUserManagerImpl::GetResourceImagekiaNamed( | 1305 const gfx::ImageSkia& ChromeUserManagerImpl::GetResourceImagekiaNamed( |
| 1303 int id) const { | 1306 int id) const { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 break; | 1344 break; |
| 1342 default: | 1345 default: |
| 1343 NOTREACHED(); | 1346 NOTREACHED(); |
| 1344 break; | 1347 break; |
| 1345 } | 1348 } |
| 1346 | 1349 |
| 1347 return user; | 1350 return user; |
| 1348 } | 1351 } |
| 1349 | 1352 |
| 1350 } // namespace chromeos | 1353 } // namespace chromeos |
| OLD | NEW |