Commit 593d0fe9 authored by pam@chromium.org's avatar pam@chromium.org

Fix some timing and display issues with the supervised-user confirmation.

Collect the custodian's signed-in status each time the confirmation
dialog is shown, to catch changes in status that happen after the
Settings page loads.

Also HTML-escape the new profile's name (and the custodian's email,
for good measure), so the confirmation-dialog string can be HTML rather
than text and the link to the management page can be active.

BUG=252860, 252691
TEST=manual

Review URL: https://chromiumcodereview.appspot.com/17155020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208010 0039d316-1c4b-4281-b951-d872f2087c98
parent 672bec75
......@@ -15053,7 +15053,7 @@ After you create a new supervised user, you can manage their settings at any tim
<ph name="NEW_PROFILE_NAME">$1<ex>New User</ex></ph> has been created as a supervised user!
</message>
<message name="IDS_NEW_MANAGED_USER_CREATED_TEXT" desc="Informative text for the confirmation dialog that appears after a supervised user has been created.">
A supervised user named <ph name="NEW_PROFILE_NAME">$1<ex>New User</ex></ph> has been created. To set which websites this supervised user can view, you can configure restrictions and settings by visiting www.chrome.com/manage. If you do not change the default settings, <ph name="NEW_PROFILE_NAME">$1<ex>New User</ex></ph> can browse all sites on the web.
A supervised user named <ph name="NEW_PROFILE_NAME">$1<ex>New User</ex></ph> has been created. To set which websites this supervised user can view, you can configure restrictions and settings by visiting <ph name="BEGIN_LINK">&lt;a target="_blank" href="https://www.chrome.com/manage"&gt;</ph>www.chrome.com/manage<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph>. If you do not change the default settings, <ph name="NEW_PROFILE_NAME">$1<ex>New User</ex></ph> can browse all sites on the web.
Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@gmail.com</ex></ph> for these and further instructions.
</message>
......
......@@ -417,6 +417,10 @@ cr.define('options', function() {
// Inherit from ManageProfileOverlay.
__proto__: ManageProfileOverlay.prototype,
// The signed-in email address of the current profile, or empty if they're
// not signed in.
signedInEmail_: '',
/**
* Configures the overlay to the "create user" mode.
* @override
......@@ -527,6 +531,7 @@ cr.define('options', function() {
this.updateCreateInProgress_(false);
OptionsPage.closeOverlay();
if (profileInfo.isManaged) {
profileInfo.custodianEmail = this.signedInEmail_;
ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo);
OptionsPage.navigateToPage('managedUserCreateConfirm');
}
......@@ -535,19 +540,23 @@ cr.define('options', function() {
/**
* Updates the signed-in or not-signed-in UI when in create mode. Called by
* the handler in response to the 'requestSignedInText' message.
* @param {string} text The text to show for a signed-in user. An empty
* string indicates that the user is not signed in.
* @param {string} email The email address of the currently signed-in user.
* An empty string indicates that the user is not signed in.
* @private
*/
updateSignedInStatus_: function(text) {
var isSignedIn = text !== '';
updateSignedInStatus_: function(email) {
this.signedInEmail_ = email;
var isSignedIn = email !== '';
$('create-profile-managed-signed-in').hidden = !isSignedIn;
$('create-profile-managed-not-signed-in').hidden = isSignedIn;
$('create-profile-managed').disabled = !isSignedIn;
if (!isSignedIn)
if (isSignedIn) {
$('create-profile-managed-signed-in-label').textContent =
loadTimeData.getStringF(
'manageProfilesManagedSignedInLabel', email);
} else {
$('create-profile-managed').checked = false;
$('create-profile-managed-signed-in-label').textContent = text;
}
},
};
......
......@@ -52,21 +52,34 @@ cr.define('options', function() {
* @param {Object} info An object of the form:
* info = {
* name: "Profile Name",
* filePath: "/path/to/profile/data/on/disk"
* filePath: "/path/to/profile/data/on/disk",
* isManaged: (true|false)
* custodianEmail: "example@gmail.com"
* };
* @private
*/
setProfileInfo_: function(info) {
function HTMLEscape(original) {
return original.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
this.profileInfo_ = info;
$('managed-user-created-title').textContent =
loadTimeData.getStringF('managedUserCreatedTitle', info.name);
$('managed-user-created-text').textContent =
loadTimeData.getStringF('managedUserCreatedText',
info.name,
loadTimeData.getString('custodianEmail'));
$('managed-user-created-switch').textContent =
loadTimeData.getStringF('managedUserCreatedSwitch', info.name);
// HTML-escape the user-supplied strings before putting them into
// innerHTML. This is probably excessive for the email address, but
// belt-and-suspenders is cheap here.
$('managed-user-created-text').innerHTML =
loadTimeData.getStringF('managedUserCreatedText',
HTMLEscape(info.name),
HTMLEscape(info.custodianEmail));
},
};
......
......@@ -92,6 +92,8 @@ void ManageProfileHandler::GetLocalizedValues(
{ "manageProfilesDuplicateNameError",
IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR },
{ "manageProfilesIconLabel", IDS_PROFILES_MANAGE_ICON_LABEL },
{ "manageProfilesManagedSignedInLabel",
IDS_PROFILES_CREATE_MANAGED_SIGNED_IN_LABEL },
{ "manageProfilesManagedNotSignedInLabel",
IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LABEL },
{ "manageProfilesManagedNotSignedInLink",
......@@ -394,14 +396,9 @@ void ManageProfileHandler::RequestSignedInText(const base::ListValue* args) {
SigninManagerBase* manager =
SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()));
string16 username = UTF8ToUTF16(manager->GetAuthenticatedUsername());
string16 text = string16();
if (!username.empty()) {
text = l10n_util::GetStringFUTF16(
IDS_PROFILES_CREATE_MANAGED_SIGNED_IN_LABEL, username);
}
StringValue text_value(text);
StringValue username_value(username);
web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus",
text_value);
username_value);
}
void ManageProfileHandler::OnHasProfileShortcuts(bool has_shortcuts) {
......
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