Commit 454c4015 authored by glevin's avatar glevin Committed by Commit Bot

Harmonize SessionAbortedDialog

As per crbug.com/788026 Comments 1,11:
- Change title text
- Consolidate text into one paragraph
- Remove excess whitespace near bottom
- Width = 448px
- Remove X (Close) button from upper right

Bug: 788026
Test: Set whatever policy is needed to disallow multi-signin from an
account, try signing in from that account, observe Harmonious dialog.

Change-Id: I1b5f2d2bf3ae092a28aa8ee48069cfead7c1559d
Reviewed-on: https://chromium-review.googlesource.com/944258Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Greg Levin <glevin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558302}
parent 01a28868
......@@ -1274,11 +1274,10 @@ This file contains the strings for ash.
<!-- Session aborted dialog -->
<message name="IDS_ASH_MULTIPROFILES_SESSION_ABORT_HEADLINE" desc="Title for a dialog that describes that the current multi profile session is ending because one user is no longer allowed.">
Multiple sign-in has been disallowed for a user in this session
Multiple sign-in has been disabled
</message>
<message name="IDS_ASH_MULTIPROFILES_SESSION_ABORT_MESSAGE" desc="Body text for a dialog that describes that the current multi profile session is ending because one user is no longer allowed.">
An administrator has disallowed multiple sign-in for <ph name="USER_EMAIL">$1<ex>john@google.com</ex></ph>.
All users must sign out to continue.
An administrator has disallowed multiple sign-in for <ph name="USER_EMAIL">$1<ex>john@google.com</ex></ph>. All users must sign out to continue.
</message>
<message name="IDS_ASH_MULTIPROFILES_SESSION_ABORT_BUTTON_LABEL" desc="The label for the one (and only) button on a dialog that describes why the multi profile session is ending.">
Sign out
......
......@@ -12,32 +12,30 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
// Default width/height of the dialog.
// TODO(crbug.com/766395): use layout provider for this dialog.
const int kDefaultWidth = 600;
const int kDefaultHeight = 250;
const int kPaddingToMessage = 20;
// Default width of the dialog.
constexpr int kDefaultWidth = 448;
} // namespace
// static
void SessionAbortedDialog::Show(const std::string& user_email) {
SessionAbortedDialog* dialog_view = new SessionAbortedDialog();
dialog_view->InitDialog(user_email);
views::DialogDelegate::CreateDialogWidget(
dialog_view, Shell::GetRootWindowForNewWindows(), nullptr);
dialog_view->InitDialog(user_email);
views::Widget* widget = dialog_view->GetWidget();
DCHECK(widget);
widget->Show();
......@@ -70,48 +68,39 @@ ui::ModalType SessionAbortedDialog::GetModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
base::string16 SessionAbortedDialog::GetWindowTitle() const {
return l10n_util::GetStringUTF16(
IDS_ASH_MULTIPROFILES_SESSION_ABORT_HEADLINE);
}
bool SessionAbortedDialog::ShouldShowCloseButton() const {
// Material UI has no [X] in the corner of this dialog.
return !ui::MaterialDesignController::IsSecondaryUiMaterial();
}
gfx::Size SessionAbortedDialog::CalculatePreferredSize() const {
return gfx::Size(kDefaultWidth, kDefaultHeight);
return gfx::Size(
kDefaultWidth,
GetLayoutManager()->GetPreferredHeightForWidth(this, kDefaultWidth));
}
SessionAbortedDialog::SessionAbortedDialog() = default;
SessionAbortedDialog::~SessionAbortedDialog() = default;
void SessionAbortedDialog::InitDialog(const std::string& user_email) {
constexpr int kTopInset = 10;
constexpr int kOtherInset = 40;
// Create the views and layout manager and set them up.
views::GridLayout* grid_layout =
SetLayoutManager(std::make_unique<views::GridLayout>(this));
SetBorder(views::CreateEmptyBorder(kTopInset, kOtherInset, kOtherInset,
kOtherInset));
views::ColumnSet* column_set = grid_layout->AddColumnSet(0);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
views::GridLayout::USE_PREF, 0, 0);
views::Label* title_label_ = new views::Label(
l10n_util::GetStringUTF16(IDS_ASH_MULTIPROFILES_SESSION_ABORT_HEADLINE));
title_label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
ui::ResourceBundle::MediumBoldFont));
title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
grid_layout->StartRow(0, 0);
grid_layout->AddView(title_label_);
grid_layout->AddPaddingRow(0, kPaddingToMessage);
const views::LayoutProvider* provider = views::LayoutProvider::Get();
SetBorder(views::CreateEmptyBorder(
provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT)));
SetLayoutManager(std::make_unique<views::FillLayout>());
// Explanation string.
views::Label* label = new views::Label(
l10n_util::GetStringFUTF16(IDS_ASH_MULTIPROFILES_SESSION_ABORT_MESSAGE,
base::ASCIIToUTF16(user_email)));
label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
ui::ResourceBundle::MediumFont));
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetAllowCharacterBreak(true);
grid_layout->StartRow(0, 0);
grid_layout->AddView(label);
Layout();
AddChildView(label);
}
} // namespace ash
......@@ -25,6 +25,8 @@ class SessionAbortedDialog : public views::DialogDelegateView {
// views::WidgetDelegate overrides.
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
// views::View overrides.
gfx::Size CalculatePreferredSize() const override;
......
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