Skip to content

Commit

Permalink
Management WebUi: Do not show account domain if account is not managed
Browse files Browse the repository at this point in the history
Bug: 1012920
Change-Id: Ifccd4d4eab21ba21d0e7984add2b26757e5cbec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929450
Reviewed-by: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Yann Dago <ydago@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721201}
  • Loading branch information
Yann Dago authored and Commit Bot committed Dec 3, 2019
1 parent b51efd6 commit bcf1a25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/ui/managed_ui_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ IN_PROC_BROWSER_TEST_F(ManagedUiTest, GetManagedUiMenuItemLabel) {

TestingProfile::Builder builder_with_domain;
builder_with_domain.SetProfileName("foobar@example.com");
builder_with_domain.OverridePolicyConnectorIsManagedForTesting(true);
auto profile_with_domain = builder_with_domain.Build();

EXPECT_EQ(base::ASCIIToUTF16("Managed by your organization"),
Expand All @@ -72,6 +73,7 @@ IN_PROC_BROWSER_TEST_F(ManagedUiTest, GetManagedUiWebUILabel) {

TestingProfile::Builder builder_with_domain;
builder_with_domain.SetProfileName("foobar@example.com");
builder_with_domain.OverridePolicyConnectorIsManagedForTesting(true);
auto profile_with_domain = builder_with_domain.Build();

EXPECT_EQ(
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/ui/webui/management_ui_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ const char* GetReportingTypeValue(ReportingType reportingType) {
// TODO(raleksandov) Move to util class or smth similar.
// static
std::string ManagementUIHandler::GetAccountDomain(Profile* profile) {
if (!IsProfileManaged(profile))
return std::string();
auto username = profile->GetProfileUserName();
size_t email_separator_pos = username.find('@');
bool is_email = email_separator_pos != std::string::npos &&
Expand Down
9 changes: 6 additions & 3 deletions chrome/browser/ui/webui/management_ui_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateManagedConsumerDomain) {
TestingProfile::Builder builder;
builder.SetProfileName("managed@gmail.com");
builder.OverridePolicyConnectorIsManagedForTesting(true);
auto profile = builder.Build();

base::string16 extensions_installed;
Expand Down Expand Up @@ -238,6 +239,7 @@ TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateUnmanagedKnownDomain) {
TestingProfile::Builder builder;
builder.SetProfileName("managed@manager.com");
builder.OverridePolicyConnectorIsManagedForTesting(true);
auto profile = builder.Build();

base::string16 extension_reporting_title;
Expand Down Expand Up @@ -305,6 +307,7 @@ TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateManagedKnownDomain) {
TestingProfile::Builder builder;
builder.SetProfileName("managed@gmail.com.manager.com.gmail.com");
builder.OverridePolicyConnectorIsManagedForTesting(true);
auto profile = builder.Build();

base::string16 extension_reporting_title;
Expand Down Expand Up @@ -345,6 +348,7 @@ TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateManagedAccountKnownDomain) {
TestingProfile::Builder builder;
builder.SetProfileName("managed@manager.com");
builder.OverridePolicyConnectorIsManagedForTesting(true);
auto profile = builder.Build();
const auto device_type = ui::GetChromeOSDeviceTypeResourceId();

Expand Down Expand Up @@ -480,6 +484,7 @@ TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateManagedDeviceAndAccountMultipleDomains) {
TestingProfile::Builder builder;
builder.SetProfileName("managed@manager.com");
builder.OverridePolicyConnectorIsManagedForTesting(true);
auto profile = builder.Build();
const auto device_type = ui::GetChromeOSDeviceTypeResourceId();

Expand Down Expand Up @@ -696,9 +701,7 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
info.GetAsDictionary(&threat_protection_info);
EXPECT_TRUE(threat_protection_info->FindListKey("info")->GetList().empty());
EXPECT_EQ(
l10n_util::GetStringFUTF16(
IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION_BY,
base::UTF8ToUTF16("manager.com")),
l10n_util::GetStringUTF16(IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION),
base::UTF8ToUTF16(*threat_protection_info->FindStringKey("description")));

// When policies are set to values that enable the feature, report it.
Expand Down

0 comments on commit bcf1a25

Please sign in to comment.