Commit 8c93a588 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Use set_fixed_width() in supervised_user/

Also replaces some overrides with simple setters of modality and close
button.

Bug: 1128500
Change-Id: Id6c7d64553970d076966c52da9646a034f877a10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511630
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823203}
parent d3d9bac0
......@@ -65,6 +65,10 @@ ExtensionInstallBlockedByParentDialogView::
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, l10n_util::GetStringUTF16(IDS_OK));
set_draggable(true);
SetModalType(ui::MODAL_TYPE_WINDOW);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SetIcon(gfx::CreateVectorIcon(chromeos::kNotificationSupervisedUserIcon,
SK_ColorDKGRAY));
SetShowIcon(true);
......@@ -78,18 +82,6 @@ ExtensionInstallBlockedByParentDialogView::
std::move(done_callback_).Run();
}
gfx::Size ExtensionInstallBlockedByParentDialogView::CalculatePreferredSize()
const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
ui::ModalType ExtensionInstallBlockedByParentDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
void ExtensionInstallBlockedByParentDialogView::ConfigureTitle() {
base::string16 title_string;
switch (action_) {
......
......@@ -18,6 +18,8 @@ class Extension;
// Modal dialog that shows when a child user attempts to install an extension
// but blocked by their parent.
// TODO(pbos): Replace DialogDelegateView with View and use a separate
// DialogDelegate. This no longer overrides any DialogDelegateView methods.
class ExtensionInstallBlockedByParentDialogView
: public views::DialogDelegateView {
public:
......@@ -39,10 +41,6 @@ class ExtensionInstallBlockedByParentDialogView
~ExtensionInstallBlockedByParentDialogView() override;
private:
// views::DialogDelegateView
gfx::Size CalculatePreferredSize() const override;
ui::ModalType GetModalType() const override;
void ConfigureTitle();
void CreateContents();
base::string16 GetExtensionTypeString();
......
......@@ -281,6 +281,11 @@ ParentPermissionDialogView::ParentPermissionDialogView(
ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_PARENT_PERMISSION_PROMPT_CANCEL_BUTTON));
SetModalType(ui::MODAL_TYPE_WINDOW);
SetShowCloseButton(true);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
identity_manager_ = IdentityManagerFactory::GetForProfile(params_->profile);
}
......@@ -313,13 +318,6 @@ base::string16 ParentPermissionDialogView::GetActiveUserFirstName() const {
return user->GetGivenName();
}
gfx::Size ParentPermissionDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void ParentPermissionDialogView::AddedToWidget() {
auto message_container = std::make_unique<views::View>();
......@@ -388,18 +386,10 @@ bool ParentPermissionDialogView::Accept() {
return false;
}
bool ParentPermissionDialogView::ShouldShowCloseButton() const {
return true;
}
base::string16 ParentPermissionDialogView::GetAccessibleWindowTitle() const {
return params_->message;
}
ui::ModalType ParentPermissionDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
void ParentPermissionDialogView::CreateContents() {
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets()));
......
......@@ -86,7 +86,6 @@ class ParentPermissionDialogView : public views::DialogDelegateView,
base::string16 GetActiveUserFirstName() const;
// views::View:
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override;
// views::DialogDelegate:
......@@ -95,8 +94,6 @@ class ParentPermissionDialogView : public views::DialogDelegateView,
// views::WidgetDelegate:
base::string16 GetAccessibleWindowTitle() const override;
ui::ModalType GetModalType() const override;
bool ShouldShowCloseButton() const override;
// Changes the widget size to accommodate the contents' preferred size.
void ResizeWidget();
......
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