Commit 5dace10e authored by A Olsen's avatar A Olsen Committed by Commit Bot

UI for In-session pw change confirmation dialog.

HTML + CSS + strings to make a dialog at chrome://confirm-password-change
This dialog doesn't yet do anything - but it is guarded by the
InSessionPasswordChange policy, which is turned off everywhere.

Looks like this: https://screenshot.googleplex.com/KkxDvzXjx6u.png

Bug: 930109
Change-Id: Ifac386689586da97353a5512d7a3cb687aa6dbd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1655478
Commit-Queue: A Olsen <olsen@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672515}
parent a2bb0043
......@@ -484,6 +484,8 @@
<include name="IDR_PASSWORD_CHANGE_JS" file="resources\chromeos\password_change\password_change.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_PASSWORD_CHANGE_CSS" file="resources\chromeos\password_change\password_change.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_PASSWORD_CHANGE_AUTHENTICATOR_JS" file="resources\gaia_auth_host\password_change_authenticator.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_CONFIRM_PASSWORD_CHANGE_HTML" file="resources\chromeos\password_change\confirm_password_change.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<include name="IDR_CONFIRM_PASSWORD_CHANGE_JS" file="resources\chromeos\password_change\confirm_password_change.js" type="chrome_html" />
<include name="IDR_CROSH_BUILTIN_MANIFEST" file="resources\chromeos\crosh_builtin\manifest.json" type="BINDATA" />
<include name="IDR_CRYPTOHOME_HTML" file="resources\chromeos\cryptohome.html" flattenhtml="true" type="BINDATA" />
......
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script src="confirm_password_change.js"></script>
<script src="strings.js"></script>
<dom-module id="confirm-password-change">
<template>
<style>
::part(dialog) {
/* We don't show the dialogs border using CSS since we show this
dialog inside a system dialog - we don't want two borders. */
border-radius: 0;
height: 100%;
width: 100%;
}
.label {
@apply --cr-form-field-label;
}
#prompt {
margin-bottom: 20px;
}
cr-input[type='password'] {
font-size: 20px;
}
#password-match-error-container {
margin-top: -16px;
}
#error-icon {
--iron-icon-fill-color: var(--google-red-600);
}
#password-match-error {
color: var(--google-red-600);
display: inline-block;
}
</style>
<cr-dialog id="dialog" exportparts="dialog">
<div slot="title">[[i18n('title')]]</div>
<div slot="body" spellcheck="false">
<div id="prompt">[[i18n('bothPasswordsPrompt')]]</div>
<div>
<cr-input id="old-password" type="password"
label="[[i18n('oldPassword')]]">
</cr-input>
</div>
<div>
<cr-input id="new-password" type="password"
label="[[i18n('newPassword')]]">
</cr-input>
<cr-input id="confirm-new-password" type="password"
label="[[i18n('confirmNewPassword')]]">
</cr-input>
</div>
<div id="password-match-error-container">
<iron-icon id="error-icon" icon="cr:warning"></iron-icon>
<div id="password-match-error">[[i18n('matchError')]]</div>
</div>
</div>
<div slot="button-container">
<cr-button class="action-button">
[[i18n('save')]]
</cr-button>
</div>
</cr-dialog>
</template>
</dom-module>
</head>
<body>
<confirm-password-change id="main-element"></confirm-password-change>
</body>
</html>
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview 'confirm-password-change' is a dialog so that the user can
* either confirm their old password, or confirm their new password (twice),
* or both, as part of an in-session password change.
*/
// TODO(https://crbug.com/930109): Logic is not done. Need to add logic to
// show a spinner, to show only some of the password fields, to show errors,
// and to handle clicks on the save button.
Polymer({
is: 'confirm-password-change',
behaviors: [I18nBehavior, WebUIListenerBehavior],
/** @override */
attached: function() {
this.$.dialog.showModal();
},
/** @private */
cancel_: function() {
this.$.dialog.cancel();
},
});
......@@ -493,6 +493,13 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
return &NewWebUI<chromeos::InSessionPasswordChangeUI>;
}
if (url.host_piece() == chrome::kChromeUIConfirmPasswordChangeHost) {
if (!profile->GetPrefs()->GetBoolean(
prefs::kSamlInSessionPasswordChangeEnabled)) {
return nullptr;
}
return &NewWebUI<chromeos::InSessionConfirmPasswordChangeUI>;
}
if (url.host_piece() == chrome::kChromeUIAccountManagerWelcomeHost)
return &NewWebUI<chromeos::AccountManagerWelcomeUI>;
if (url.host_piece() == chrome::kChromeUIAccountMigrationWelcomeHost)
......
......@@ -12,12 +12,14 @@
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h"
#include "chrome/browser/ui/webui/localized_string.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/login/auth/saml_password_attributes.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui_data_source.h"
......@@ -132,4 +134,43 @@ InSessionPasswordChangeUI::InSessionPasswordChangeUI(content::WebUI* web_ui)
InSessionPasswordChangeUI::~InSessionPasswordChangeUI() = default;
InSessionConfirmPasswordChangeUI::InSessionConfirmPasswordChangeUI(
content::WebUI* web_ui)
: ui::WebDialogUI(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
CHECK(profile->GetPrefs()->GetBoolean(
prefs::kSamlInSessionPasswordChangeEnabled));
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIConfirmPasswordChangeHost);
static constexpr LocalizedString kLocalizedStrings[] = {
{"title", IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_TITLE},
{"bothPasswordsPrompt",
IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_BOTH_PASSWORDS_PROMPT},
{"oldPasswordPrompt",
IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_OLD_PASSWORD_PROMPT},
{"newPasswordPrompt",
IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_NEW_PASSWORD_PROMPT},
{"oldPassword", IDS_PASSWORD_CHANGE_OLD_PASSWORD_LABEL},
{"newPassword", IDS_PASSWORD_CHANGE_NEW_PASSWORD_LABEL},
{"confirmNewPassword", IDS_PASSWORD_CHANGE_CONFIRM_NEW_PASSWORD_LABEL},
{"matchError", IDS_PASSWORD_CHANGE_PASSWORDS_DONT_MATCH},
{"save", IDS_PASSWORD_CHANGE_CONFIRM_SAVE_BUTTON}};
AddLocalizedStringsBulk(source, kLocalizedStrings,
base::size(kLocalizedStrings));
source->SetJsonPath("strings.js");
source->SetDefaultResource(IDR_CONFIRM_PASSWORD_CHANGE_HTML);
source->AddResourcePath("confirm_password_change.js",
IDR_CONFIRM_PASSWORD_CHANGE_JS);
// TODO(https://crbug.com/930109): Add JS and message handler to handle tap
// on the save button, errors, etc.
content::WebUIDataSource::Add(profile, source);
}
InSessionConfirmPasswordChangeUI::~InSessionConfirmPasswordChangeUI() = default;
} // namespace chromeos
......@@ -39,6 +39,16 @@ class InSessionPasswordChangeUI : public ui::WebDialogUI {
DISALLOW_COPY_AND_ASSIGN(InSessionPasswordChangeUI);
};
// For chrome:://confirm-password-change
class InSessionConfirmPasswordChangeUI : public ui::WebDialogUI {
public:
explicit InSessionConfirmPasswordChangeUI(content::WebUI* web_ui);
~InSessionConfirmPasswordChangeUI() override;
private:
DISALLOW_COPY_AND_ASSIGN(InSessionConfirmPasswordChangeUI);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_UI_H_
......@@ -205,6 +205,9 @@ const char kChromeUICellularSetupUrl[] = "chrome://cellular-setup";
const char kChromeUICertificateManagerDialogURL[] =
"chrome://certificate-manager/";
const char kChromeUICertificateManagerHost[] = "certificate-manager";
const char kChromeUIConfirmPasswordChangeHost[] = "confirm-password-change";
const char kChromeUIConfirmPasswordChangeUrl[] =
"chrome://confirm-password-change";
const char kChromeUICryptohomeHost[] = "cryptohome";
const char kChromeUIDeviceEmulatorHost[] = "device-emulator";
const char kChromeUIDiscoverURL[] = "chrome://oobe/discover";
......
......@@ -203,6 +203,8 @@ extern const char kChromeUICellularSetupHost[];
extern const char kChromeUICellularSetupUrl[];
extern const char kChromeUICertificateManagerDialogURL[];
extern const char kChromeUICertificateManagerHost[];
extern const char kChromeUIConfirmPasswordChangeHost[];
extern const char kChromeUIConfirmPasswordChangeUrl[];
extern const char kChromeUICryptohomeHost[];
extern const char kChromeUIDeviceEmulatorHost[];
extern const char kChromeUIDiscoverURL[];
......
......@@ -202,6 +202,35 @@ Try tapping the mic to ask me anything.
Change password
</message>
<!-- In-session password change -->
<message name="IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_TITLE" desc="Title for the dialog where a user corrects and confirms their old and new passwords in order to complete a password change">
Confirm change
</message>
<message name="IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_BOTH_PASSWORDS_PROMPT" desc="Text on the password-change confirmation dialog explaining that the user has to enter both their old and new passwords again to finish the password change.">
To finish, enter your old and new passwords
</message>
<message name="IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_OLD_PASSWORD_PROMPT" desc="Text on the password-change confirmation dialog explaining that the user has to enter their old password again to finish the password change.">
To finish, enter your old password
</message>
<message name="IDS_PASSWORD_CHANGE_CONFIRM_DIALOG_NEW_PASSWORD_PROMPT" desc="Text on the password-change confirmation dialog explaining that the user has to enter their new password again to finish the password change.">
To finish, enter your new password
</message>
<message name="IDS_PASSWORD_CHANGE_OLD_PASSWORD_LABEL" desc="Label for a box where the user enters their old password">
Old password
</message>
<message name="IDS_PASSWORD_CHANGE_NEW_PASSWORD_LABEL" desc="Label for a box where the user enters their new password">
New password
</message>
<message name="IDS_PASSWORD_CHANGE_CONFIRM_NEW_PASSWORD_LABEL" desc="Label for the second box where the user enters their new password again, to ensure they don't mistype it">
Confirm new password
</message>
<message name="IDS_PASSWORD_CHANGE_CONFIRM_SAVE_BUTTON" desc="Text on a button that confirms the change to the password and saves the new password in place of the old one">
Save
</message>
<message name="IDS_PASSWORD_CHANGE_PASSWORDS_DONT_MATCH" desc="Error text in the case that the user entered their new password twice into two different boxes as required, but the two entries do not match">
Passwords do not match
</message>
<message name="IDS_IME_SERVICE_DISPLAY_NAME" desc="The display name (in the system task manager, etc) of the service process providing the input methods.">
Chrome OS Input Method Service
</message>
......
d2cc3ab3fc722730919bc98f70418b7231b70538
\ No newline at end of file
d2cc3ab3fc722730919bc98f70418b7231b70538
\ No newline at end of file
d2cc3ab3fc722730919bc98f70418b7231b70538
\ No newline at end of file
7621e82261b2a3be6f21e9bfed47a659f3b62309
\ No newline at end of file
d1688aa0f76618db03d1ba53332133bc1a8b9c6d
\ No newline at end of file
5ee11284a96e335b3322d22edc998272cd9cea0b
\ No newline at end of file
2317a57dd8bbe587ee2f1167d9d0ecccb36cda44
\ No newline at end of file
f7995864a578f3098c91fc014ec971c570adcc72
\ No newline at end of file
2ec19a0b552ca7afda09c7d6013137b31d31dd3a
\ No newline at end of file
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