Commit 03a12f96 authored by A Olsen's avatar A Olsen Committed by Commit Bot

Update hosted password change dialog in line with mocks

Removed frame from system dialog - title and X are not shown.
Added title and X back at the HTML level, inside a cr-dialog for styling.

Dialog no longer needs profile to be initialized, since it now
happens at the webui level.

Internal screenshot is found here: 3_hosted_change.png at
http://go/insessionpwchange-screenshots

Bug: 930109
Change-Id: I7a93d7e856a9019ad201d072d8a0eacbd255d262
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715355
Commit-Queue: A Olsen <olsen@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680485}
parent 60f3921e
......@@ -232,7 +232,8 @@ void InSessionPasswordChangeManager::OnScreenUnlocked() {
void InSessionPasswordChangeManager::StartInSessionPasswordChange() {
NotifyObservers(START_SAML_IDP_PASSWORD_CHANGE);
DismissExpiryNotification();
PasswordChangeDialog::Show(primary_profile_);
PasswordChangeDialog::Show();
ConfirmPasswordChangeDialog::Dismiss();
}
void InSessionPasswordChangeManager::OnSamlPasswordChanged(
......@@ -242,6 +243,7 @@ void InSessionPasswordChangeManager::OnSamlPasswordChanged(
user_manager::UserManager::Get()->SaveForceOnlineSignin(
primary_user_->GetAccountId(), true);
DismissExpiryNotification();
PasswordChangeDialog::Dismiss();
const bool both_passwords_scraped =
......
......@@ -2,20 +2,49 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
html,
body,
#signin-frame {
::part(dialog) {
/* The HTML dialog should fill the entire system dialog. */
height: 100%;
width: 100%;
}
[slot='title'] {
background: rgb(241, 243, 244);
color: rgb(32, 33, 36);
font-family: Roboto, sans-serif;
font-size: 12px;
height: 48px;
line-height: 16px;
margin: 0;
overflow: hidden;
padding: 0;
padding: 16px;
text-align: center;
width: 100%;
}
cr-icon-button {
float: right;
height: 16px;
margin: 0;
padding: 0;
width: 16px;
}
html[dir=rtl] cr-icon-button {
float: left;
}
[slot='body'] {
top: 48px !important;
}
[slot='body'],
#signin-frame {
background-color: #f5f5f5;
background-color: white;
bottom: 0;
left: 0;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
right: 0;
top: 0;
......
......@@ -2,8 +2,11 @@
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
<link rel="stylesheet" href="chrome://password-change/password_change.css">
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/event_target.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
......@@ -12,8 +15,29 @@
<script src="chrome://password-change/authenticator.js"></script>
<script src="chrome://password-change/password_change.js"></script>
<script src="chrome://password-change/strings.js"></script>
<dom-module id="password-change">
<template>
<link rel="stylesheet" href="chrome://password-change/password_change.css">
<cr-dialog id="dialog" exportparts="dialog">
<div slot="title">
[[i18n('hostedHeader')]]
<cr-icon-button iron-icon="cr:close" on-tap="onCloseTap_">
</cr-icon-button>
</div>
<div slot="body">
<webview id="signin-frame" name="signin-frame" allowscaling>
</webview>
</div>
</cr-dialog>
</template>
</dom-module>
</head>
<body>
<webview id="signin-frame" name="signin-frame" allowscaling></webview>
<password-change id="main-element">
</password-change>
</body>
</html>
......@@ -16,7 +16,8 @@ cr.define('insession.password.change', function() {
* Initialize the UI.
*/
function initialize() {
authExtHost = new cr.samlPasswordChange.Authenticator('signin-frame');
const signinFrame = $('main-element').getSigninFrame();
authExtHost = new cr.samlPasswordChange.Authenticator(signinFrame);
authExtHost.addEventListener('authCompleted', onAuthCompleted_);
chrome.send('initialize');
}
......@@ -42,3 +43,22 @@ cr.define('insession.password.change', function() {
document.addEventListener(
'DOMContentLoaded', insession.password.change.initialize);
Polymer({
is: 'password-change',
behaviors: [I18nBehavior],
/** @override */
attached: function() {
this.$.dialog.showModal();
},
getSigninFrame: function() {
return this.$['signin-frame'];
},
/** @private */
onCloseTap_: function() {
chrome.send('dialogClose');
},
});
......@@ -65,9 +65,9 @@ std::string GetPasswordChangeUrl(Profile* profile) {
.password_change_url();
}
base::string16 GetManagementNotice(Profile* profile) {
base::string16 host = base::UTF8ToUTF16(
net::GetHostAndOptionalPort(GURL(GetPasswordChangeUrl(profile))));
base::string16 GetHostedHeaderText(const std::string& password_change_url) {
base::string16 host =
base::UTF8ToUTF16(net::GetHostAndOptionalPort(GURL(password_change_url)));
DCHECK(!host.empty());
return l10n_util::GetStringFUTF16(IDS_LOGIN_SAML_PASSWORD_CHANGE_NOTICE,
host);
......@@ -105,9 +105,9 @@ gfx::Size FitSizeToDisplay(int max_width, int max_height) {
} // namespace
PasswordChangeDialog::PasswordChangeDialog(const base::string16& title)
: SystemWebDialogDelegate(GURL(chrome::kChromeUIPasswordChangeUrl), title) {
}
PasswordChangeDialog::PasswordChangeDialog()
: SystemWebDialogDelegate(GURL(chrome::kChromeUIPasswordChangeUrl),
/*title=*/base::string16()) {}
PasswordChangeDialog::~PasswordChangeDialog() {
DCHECK_EQ(this, g_dialog);
......@@ -119,18 +119,23 @@ void PasswordChangeDialog::GetDialogSize(gfx::Size* size) const {
kMaxPasswordChangeDialogHeight);
}
void PasswordChangeDialog::AdjustWidgetInitParams(
views::Widget::InitParams* params) {
params->type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
}
ui::ModalType PasswordChangeDialog::GetDialogModalType() const {
return ui::ModalType::MODAL_TYPE_SYSTEM;
}
// static
void PasswordChangeDialog::Show(Profile* profile) {
void PasswordChangeDialog::Show() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (g_dialog) {
g_dialog->Focus();
return;
}
g_dialog = new PasswordChangeDialog(GetManagementNotice(profile));
g_dialog = new PasswordChangeDialog();
g_dialog->ShowSystemDialog();
}
......@@ -149,9 +154,11 @@ PasswordChangeUI::PasswordChangeUI(content::WebUI* web_ui)
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIPasswordChangeHost);
const std::string password_change_url = GetPasswordChangeUrl(profile);
web_ui->AddMessageHandler(
std::make_unique<PasswordChangeHandler>(GetPasswordChangeUrl(profile)));
std::make_unique<PasswordChangeHandler>(password_change_url));
source->AddString("hostedHeader", GetHostedHeaderText(password_change_url));
source->SetJsonPath("strings.js");
source->SetDefaultResource(IDR_PASSWORD_CHANGE_HTML);
......
......@@ -10,22 +10,21 @@
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "ui/web_dialogs/web_dialog_ui.h"
class Profile;
namespace chromeos {
// System dialog wrapping chrome:://password-change
class PasswordChangeDialog : public SystemWebDialogDelegate {
public:
static void Show(Profile* profile);
static void Show();
static void Dismiss();
protected:
explicit PasswordChangeDialog(const base::string16& title);
PasswordChangeDialog();
~PasswordChangeDialog() override;
// ui::WebDialogDelegate:
void GetDialogSize(gfx::Size* size) const override;
void AdjustWidgetInitParams(views::Widget::InitParams* params) override;
ui::ModalType GetDialogModalType() const override;
private:
......
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