Commit c2a5e7be authored by A Olsen's avatar A Olsen Committed by Commit Bot

Remove 1 more CrosSettings->Set

When kStubCrosSettings switch is set, the logged in user is treated
as the owner of the device, and of the stubbed settings (which don't
need a real owner key).

This change moves this promotion of the user to the owner out of
ChromeUserManagerImpl and into CrosSettings. This untangles the two
classes slightly, and also it means that we can get rid of one
call to CrosSettings->Set, which is being removed.

See go/writepath for more background

Bug: 433840
Change-Id: I9f4a34b34d0160d220558e512b9d1c56b3e253a1
Reviewed-on: https://chromium-review.googlesource.com/c/1314491Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: A Olsen <olsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604937}
parent 369d12d4
...@@ -367,24 +367,6 @@ void ChromeUserManagerImpl::Shutdown() { ...@@ -367,24 +367,6 @@ void ChromeUserManagerImpl::Shutdown() {
registrar_.RemoveAll(); registrar_.RemoveAll();
} }
void ChromeUserManagerImpl::UserLoggedIn(const AccountId& account_id,
const std::string& username_hash,
bool browser_restart,
bool is_child) {
if (FakeOwnership()) {
std::string owner_email;
chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner,
&owner_email);
if (owner_email.empty()) {
owner_email = account_id.GetUserEmail();
VLOG(1) << "Set device owner to: " << owner_email;
CrosSettings::Get()->SetString(kDeviceOwner, owner_email);
}
}
ChromeUserManager::UserLoggedIn(account_id, username_hash, browser_restart,
is_child);
}
MultiProfileUserController* MultiProfileUserController*
ChromeUserManagerImpl::GetMultiProfileUserController() { ChromeUserManagerImpl::GetMultiProfileUserController() {
return multi_profile_user_controller_.get(); return multi_profile_user_controller_.get();
......
...@@ -82,10 +82,6 @@ class ChromeUserManagerImpl ...@@ -82,10 +82,6 @@ class ChromeUserManagerImpl
// UserManager implementation: // UserManager implementation:
void Shutdown() override; void Shutdown() override;
void UserLoggedIn(const AccountId& account_id,
const std::string& user_id_hash,
bool browser_restart,
bool is_child) override;
user_manager::UserList GetUsersAllowedForMultiProfile() const override; user_manager::UserList GetUsersAllowedForMultiProfile() const override;
user_manager::UserList GetUsersAllowedForSupervisedUsersCreation() user_manager::UserList GetUsersAllowedForSupervisedUsersCreation()
const override; const override;
......
...@@ -69,11 +69,18 @@ CrosSettings::CrosSettings(DeviceSettingsService* device_settings_service, ...@@ -69,11 +69,18 @@ CrosSettings::CrosSettings(DeviceSettingsService* device_settings_service,
// This is safe since |this| is never deleted. // This is safe since |this| is never deleted.
base::Unretained(this))); base::Unretained(this)));
if (base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess();
switches::kStubCrosSettings)) { if (commandLine->HasSwitch(switches::kStubCrosSettings)) {
std::unique_ptr<StubCrosSettingsProvider> stubbed_provider = std::unique_ptr<StubCrosSettingsProvider> stubbed_provider =
std::make_unique<StubCrosSettingsProvider>(notify_cb); std::make_unique<StubCrosSettingsProvider>(notify_cb);
stubbed_provider_ptr_ = stubbed_provider.get(); stubbed_provider_ptr_ = stubbed_provider.get();
// When kStubCrosSettings is set, then kLoginUser is treated as the device
// owner (if it is also set):
if (commandLine->HasSwitch(switches::kLoginUser)) {
stubbed_provider->Set(
kDeviceOwner,
base::Value(commandLine->GetSwitchValueASCII(switches::kLoginUser)));
}
AddSettingsProvider(std::move(stubbed_provider)); AddSettingsProvider(std::move(stubbed_provider));
} else { } else {
......
...@@ -488,7 +488,8 @@ const char kLoginManager[] = "login-manager"; ...@@ -488,7 +488,8 @@ const char kLoginManager[] = "login-manager";
// to pass user_id hash for primary user. // to pass user_id hash for primary user.
const char kLoginProfile[] = "login-profile"; const char kLoginProfile[] = "login-profile";
// Specifies the user which is already logged in. // Specifies the user which is already logged in. If kStubCrosSettings is set,
// this user will also be treated as the owner (see kStubCrosSettings).
const char kLoginUser[] = "login-user"; const char kLoginUser[] = "login-user";
// The memory pressure threshold selection which is used to decide whether and // The memory pressure threshold selection which is used to decide whether and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment