Commit 08ad5561 authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Managed profiles created after interception called "Work"

The profiles were named after the email of the account. This CL changes
to use localized string "Work" instead.

Bug: 1076880
Change-Id: I5a0782ae83d6660bcabcea041761f2f3b493ee04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362827
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799166}
parent 1036ae9d
......@@ -7799,6 +7799,9 @@ the Bookmarks menu.">
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL" desc="Label of the cancel button in the web signin interception bubble">
Cancel
</message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_PROFILE_NAME" desc="Default name for work profiles created after signin interception">
Work
</message>
</if>
<!-- Signin Error tab modal dialog -->
......
541589a9c2310702d7f270499ac30f7f07cebe93
\ No newline at end of file
......@@ -8,7 +8,6 @@
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
......@@ -131,7 +130,7 @@ TokensLoadedCallbackRunner::TokensLoadedCallbackRunner(
DiceSignedInProfileCreator::DiceSignedInProfileCreator(
Profile* source_profile,
CoreAccountId account_id,
const std::string& local_profile_name,
const base::string16& local_profile_name,
base::Optional<size_t> icon_index,
base::OnceCallback<void(Profile*)> callback)
: source_profile_(source_profile),
......@@ -143,7 +142,7 @@ DiceSignedInProfileCreator::DiceSignedInProfileCreator(
icon_index = storage.ChooseAvatarIconIndexForNewProfile();
base::string16 name = local_profile_name.empty()
? storage.ChooseNameForNewProfile(*icon_index)
: base::UTF8ToUTF16(local_profile_name);
: local_profile_name;
ProfileManager::CreateMultiProfileAsync(
name, profiles::GetDefaultAvatarIconUrl(*icon_index),
base::BindRepeating(&DiceSignedInProfileCreator::OnNewProfileCreated,
......
......@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "chrome/browser/profiles/profile.h"
#include "google_apis/gaia/core_account_id.h"
......@@ -26,7 +27,7 @@ class DiceSignedInProfileCreator {
// If |icon_index| is nullopt, a random icon will be selected.
DiceSignedInProfileCreator(Profile* source_profile,
CoreAccountId account_id,
const std::string& local_profile_name,
const base::string16& local_profile_name,
base::Optional<size_t> icon_index,
base::OnceCallback<void(Profile*)> callback);
......
......@@ -161,11 +161,12 @@ TEST_F(DiceSignedInProfileCreatorTest, CreateWithTokensLoaded) {
AccountInfo account_info =
identity_test_env()->MakeAccountAvailable("bob@example.com");
size_t kTestIcon = profiles::GetModernAvatarIconStartIndex();
base::string16 kProfileTestName16 = base::UTF8ToUTF16(kProfileTestName);
base::RunLoop loop;
std::unique_ptr<DiceSignedInProfileCreator> creator =
std::make_unique<DiceSignedInProfileCreator>(
profile(), account_info.account_id, kProfileTestName, kTestIcon,
profile(), account_info.account_id, kProfileTestName16, kTestIcon,
base::BindOnce(&DiceSignedInProfileCreatorTest::OnProfileCreated,
base::Unretained(this), loop.QuitClosure()));
loop.Run();
......@@ -190,7 +191,7 @@ TEST_F(DiceSignedInProfileCreatorTest, CreateWithTokensLoaded) {
ASSERT_TRUE(storage.GetProfileAttributesWithPath(
signed_in_profile()->GetPath(), &entry));
ASSERT_TRUE(entry);
EXPECT_EQ(base::UTF8ToUTF16(kProfileTestName), entry->GetLocalProfileName());
EXPECT_EQ(kProfileTestName16, entry->GetLocalProfileName());
EXPECT_EQ(kTestIcon, entry->GetAvatarIconIndex());
}
......@@ -204,7 +205,7 @@ TEST_F(DiceSignedInProfileCreatorTest, CreateWithTokensNotLoaded) {
set_profile_added_closure(profile_added_loop.QuitClosure());
std::unique_ptr<DiceSignedInProfileCreator> creator =
std::make_unique<DiceSignedInProfileCreator>(
profile(), account_info.account_id, kProfileTestName, base::nullopt,
profile(), account_info.account_id, base::string16(), base::nullopt,
base::BindOnce(&DiceSignedInProfileCreatorTest::OnProfileCreated,
base::Unretained(this), creator_loop.QuitClosure()));
profile_added_loop.Run();
......@@ -239,7 +240,7 @@ TEST_F(DiceSignedInProfileCreatorTest, DeleteWhileCreating) {
identity_test_env()->MakeAccountAvailable("bob@example.com");
std::unique_ptr<DiceSignedInProfileCreator> creator =
std::make_unique<DiceSignedInProfileCreator>(
profile(), account_info.account_id, kProfileTestName, base::nullopt,
profile(), account_info.account_id, base::string16(), base::nullopt,
base::BindOnce(&DiceSignedInProfileCreatorTest::OnProfileCreated,
base::Unretained(this), base::OnceClosure()));
EXPECT_FALSE(creator_callback_called());
......@@ -258,7 +259,7 @@ TEST_F(DiceSignedInProfileCreatorTest, DeleteProfile) {
set_profile_added_closure(profile_added_loop.QuitClosure());
std::unique_ptr<DiceSignedInProfileCreator> creator =
std::make_unique<DiceSignedInProfileCreator>(
profile(), account_info.account_id, kProfileTestName, base::nullopt,
profile(), account_info.account_id, base::string16(), base::nullopt,
base::BindOnce(&DiceSignedInProfileCreatorTest::OnProfileCreated,
base::Unretained(this), creator_loop.QuitClosure()));
profile_added_loop.Run();
......
......@@ -26,8 +26,10 @@
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
......@@ -269,7 +271,7 @@ void DiceWebSigninInterceptor::OnProfileCreationChoice(bool create) {
return;
}
std::string profile_name;
base::string16 profile_name;
base::Optional<AccountInfo> account_info =
identity_manager_
->FindExtendedAccountInfoForAccountWithRefreshTokenByAccountId(
......@@ -278,7 +280,9 @@ void DiceWebSigninInterceptor::OnProfileCreationChoice(bool create) {
bool is_managed = !account_info->hosted_domain.empty() &&
account_info->hosted_domain != kNoHostedDomainFound;
profile_name =
is_managed ? account_info->hosted_domain : account_info->given_name;
is_managed ? l10n_util::GetStringUTF16(
IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_PROFILE_NAME)
: base::UTF8ToUTF16(account_info->given_name);
}
DCHECK(!dice_signed_in_profile_creator_);
......
......@@ -371,7 +371,7 @@ void DiceTurnSyncOnHelper::CreateNewSignedInProfile() {
dice_signed_in_profile_creator_ =
std::make_unique<DiceSignedInProfileCreator>(
profile_, account_info_.account_id,
/*local_profile_name=*/std::string(), /*icon_index=*/base::nullopt,
/*local_profile_name=*/base::string16(), /*icon_index=*/base::nullopt,
base::BindOnce(&DiceTurnSyncOnHelper::OnNewSignedInProfileCreated,
base::Unretained(this)));
}
......
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