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:: ...@@ -65,6 +65,10 @@ ExtensionInstallBlockedByParentDialogView::
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, l10n_util::GetStringUTF16(IDS_OK)); SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, l10n_util::GetStringUTF16(IDS_OK));
set_draggable(true); 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, SetIcon(gfx::CreateVectorIcon(chromeos::kNotificationSupervisedUserIcon,
SK_ColorDKGRAY)); SK_ColorDKGRAY));
SetShowIcon(true); SetShowIcon(true);
...@@ -78,18 +82,6 @@ ExtensionInstallBlockedByParentDialogView:: ...@@ -78,18 +82,6 @@ ExtensionInstallBlockedByParentDialogView::
std::move(done_callback_).Run(); 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() { void ExtensionInstallBlockedByParentDialogView::ConfigureTitle() {
base::string16 title_string; base::string16 title_string;
switch (action_) { switch (action_) {
......
...@@ -18,6 +18,8 @@ class Extension; ...@@ -18,6 +18,8 @@ class Extension;
// Modal dialog that shows when a child user attempts to install an extension // Modal dialog that shows when a child user attempts to install an extension
// but blocked by their parent. // 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 class ExtensionInstallBlockedByParentDialogView
: public views::DialogDelegateView { : public views::DialogDelegateView {
public: public:
...@@ -39,10 +41,6 @@ class ExtensionInstallBlockedByParentDialogView ...@@ -39,10 +41,6 @@ class ExtensionInstallBlockedByParentDialogView
~ExtensionInstallBlockedByParentDialogView() override; ~ExtensionInstallBlockedByParentDialogView() override;
private: private:
// views::DialogDelegateView
gfx::Size CalculatePreferredSize() const override;
ui::ModalType GetModalType() const override;
void ConfigureTitle(); void ConfigureTitle();
void CreateContents(); void CreateContents();
base::string16 GetExtensionTypeString(); base::string16 GetExtensionTypeString();
......
...@@ -281,6 +281,11 @@ ParentPermissionDialogView::ParentPermissionDialogView( ...@@ -281,6 +281,11 @@ ParentPermissionDialogView::ParentPermissionDialogView(
ui::DIALOG_BUTTON_CANCEL, ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_PARENT_PERMISSION_PROMPT_CANCEL_BUTTON)); 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); identity_manager_ = IdentityManagerFactory::GetForProfile(params_->profile);
} }
...@@ -313,13 +318,6 @@ base::string16 ParentPermissionDialogView::GetActiveUserFirstName() const { ...@@ -313,13 +318,6 @@ base::string16 ParentPermissionDialogView::GetActiveUserFirstName() const {
return user->GetGivenName(); 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() { void ParentPermissionDialogView::AddedToWidget() {
auto message_container = std::make_unique<views::View>(); auto message_container = std::make_unique<views::View>();
...@@ -388,18 +386,10 @@ bool ParentPermissionDialogView::Accept() { ...@@ -388,18 +386,10 @@ bool ParentPermissionDialogView::Accept() {
return false; return false;
} }
bool ParentPermissionDialogView::ShouldShowCloseButton() const {
return true;
}
base::string16 ParentPermissionDialogView::GetAccessibleWindowTitle() const { base::string16 ParentPermissionDialogView::GetAccessibleWindowTitle() const {
return params_->message; return params_->message;
} }
ui::ModalType ParentPermissionDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
void ParentPermissionDialogView::CreateContents() { void ParentPermissionDialogView::CreateContents() {
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets())); views::BoxLayout::Orientation::kVertical, gfx::Insets()));
......
...@@ -86,7 +86,6 @@ class ParentPermissionDialogView : public views::DialogDelegateView, ...@@ -86,7 +86,6 @@ class ParentPermissionDialogView : public views::DialogDelegateView,
base::string16 GetActiveUserFirstName() const; base::string16 GetActiveUserFirstName() const;
// views::View: // views::View:
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
// views::DialogDelegate: // views::DialogDelegate:
...@@ -95,8 +94,6 @@ class ParentPermissionDialogView : public views::DialogDelegateView, ...@@ -95,8 +94,6 @@ class ParentPermissionDialogView : public views::DialogDelegateView,
// views::WidgetDelegate: // views::WidgetDelegate:
base::string16 GetAccessibleWindowTitle() const override; base::string16 GetAccessibleWindowTitle() const override;
ui::ModalType GetModalType() const override;
bool ShouldShowCloseButton() const override;
// Changes the widget size to accommodate the contents' preferred size. // Changes the widget size to accommodate the contents' preferred size.
void ResizeWidget(); 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