Commit 6e9d1cac authored by Brian Malcolm's avatar Brian Malcolm Committed by Commit Bot

GetDeviceManagedUiWebUILabel:display device info rather than user info

This is used as a header in the CROS device settings page.

BUG=chromium:1081272

Change-Id: I20995464c23df17911ed5b425d0dfdb221434aca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446535
Commit-Queue: Brian Malcolm <bmalcolm@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarNicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813829}
parent 5a4717f4
......@@ -12,7 +12,10 @@
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "ui/chromeos/devicetype_utils.h"
#endif
......@@ -61,17 +64,22 @@ base::string16 GetManagedUiWebUILabel(Profile* profile) {
}
#if defined(OS_CHROMEOS)
base::string16 GetDeviceManagedUiWebUILabel(Profile* profile) {
std::string account_manager = ManagementUIHandler::GetAccountManager(profile);
base::string16 GetDeviceManagedUiWebUILabel() {
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
const std::string device_manager =
connector->IsActiveDirectoryManaged()
? connector->GetRealm()
: connector->GetEnterpriseDomainManager();
int string_id = IDS_DEVICE_MANAGED_WITH_HYPERLINK;
std::vector<base::string16> replacements;
replacements.push_back(base::UTF8ToUTF16(chrome::kChromeUIManagementURL));
replacements.push_back(ui::GetChromeOSDeviceName());
if (!account_manager.empty()) {
if (!device_manager.empty()) {
string_id = IDS_DEVICE_MANAGED_BY_WITH_HYPERLINK;
replacements.push_back(base::UTF8ToUTF16(account_manager));
replacements.push_back(base::UTF8ToUTF16(device_manager));
}
return l10n_util::GetStringFUTF16(string_id, replacements, nullptr);
......
......@@ -33,7 +33,7 @@ base::string16 GetManagedUiWebUILabel(Profile* profile);
#if defined(OS_CHROMEOS)
// The label for the WebUI footnote for Managed UI indicating that the device
// is mananged. These strings contain HTML for an <a> element.
base::string16 GetDeviceManagedUiWebUILabel(Profile* profile);
base::string16 GetDeviceManagedUiWebUILabel();
#endif
} // namespace chrome
......
......@@ -16,6 +16,10 @@
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
#endif
class ManagedUiTest : public InProcessBrowserTest {
public:
ManagedUiTest() = default;
......@@ -87,14 +91,14 @@ IN_PROC_BROWSER_TEST_F(ManagedUiTest, GetManagedUiWebUILabel) {
"Your <a href=\"chrome://management\">browser is managed</a> by "
"example.com"),
chrome::GetManagedUiWebUILabel(profile_with_domain.get()));
}
#if defined(OS_CHROMEOS)
EXPECT_EQ(base::ASCIIToUTF16("Your <a target=\"_blank\" "
"href=\"chrome://management\">Chrome device is "
"managed</a> by your organization"),
chrome::GetDeviceManagedUiWebUILabel(profile.get()));
using ManagedUiTestCros = policy::DevicePolicyCrosBrowserTest;
IN_PROC_BROWSER_TEST_F(ManagedUiTestCros, GetManagedUiWebUILabel) {
EXPECT_EQ(base::ASCIIToUTF16("Your <a target=\"_blank\" "
"href=\"chrome://management\">Chrome device is "
"managed</a> by example.com"),
chrome::GetDeviceManagedUiWebUILabel(profile_with_domain.get()));
#endif
chrome::GetDeviceManagedUiWebUILabel());
}
#endif
......@@ -114,7 +114,7 @@ std::unique_ptr<base::DictionaryValue> ManagedUIHandler::GetDataSourceUpdate()
base::Value(chrome::GetManagedUiWebUILabel(profile_)));
#if defined(OS_CHROMEOS)
update->SetKey("deviceManagedByOrg",
base::Value(chrome::GetDeviceManagedUiWebUILabel(profile_)));
base::Value(chrome::GetDeviceManagedUiWebUILabel()));
#endif
update->SetKey("isManaged", base::Value(managed_));
return update;
......
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