Commit 330b4ec7 authored by Olya Kalitova's avatar Olya Kalitova Committed by Commit Bot

Retrieve username from user, not profile

Changes retrieval of username for default Crostini container from user
(Chrome OS specific concept) instead of profile.

Test: manually
Bug: 996439
Change-Id: Ib87961b2d7211c258766413f3196527671121a3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847299
Commit-Queue: Olya Kalitova <okalitova@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704139}
parent da74dc03
......@@ -182,7 +182,7 @@ TEST_F(CrostiniInstallerTest, InstallFlow) {
.WillRepeatedly(SaveArg<1>(&last_progress));
expectation_set +=
EXPECT_CALL(*disk_mount_manager_mock_,
MountPath("sshfs://testing_profile@hostname:", _, _, _, _, _))
MountPath("sshfs://test@hostname:", _, _, _, _, _))
.WillOnce(Invoke(&mount_path_waiter_, &MountPathWaiter::MountPath));
// |OnProgress()| should not happens after |OnFinished()|
EXPECT_CALL(mock_callbacks_, OnFinished(InstallerError::kNone))
......
......@@ -40,6 +40,7 @@
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
......@@ -473,18 +474,12 @@ std::string CryptohomeIdForProfile(Profile* profile) {
}
std::string DefaultContainerUserNameForProfile(Profile* profile) {
// Get rid of the @domain.name in the profile user name (an email address).
std::string container_username = profile->GetProfileUserName();
if (container_username.empty()) {
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user) {
return kCrostiniDefaultUsername;
}
if (container_username.find('@') != std::string::npos) {
// gaia::CanonicalizeEmail CHECKs its argument contains'@'.
container_username = gaia::CanonicalizeEmail(container_username);
// |container_username| may have changed, so we have to find again.
return container_username.substr(0, container_username.find('@'));
}
return container_username;
return user->GetAccountName(/*use_display_email=*/false);
}
base::FilePath ContainerChromeOSBaseDirectory() {
......
......@@ -103,8 +103,7 @@ void LoadIcons(Profile* profile,
// Retrieves cryptohome_id from profile.
std::string CryptohomeIdForProfile(Profile* profile);
// Retrieves username from profile. This is the text until '@' in
// profile->GetProfileUserName() email address.
// Retrieves username from profile.
std::string DefaultContainerUserNameForProfile(Profile* profile);
// Returns the mount directory within the container where paths from the Chrome
......
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