Commit 5dfdd4fb authored by Yicheng Li's avatar Yicheng Li Committed by Commit Bot

ash: Set in-session auth dialog bounds according to parent window

This change sets the bounds of the in-session auth dialog according
to the parent window bounds and the contents view's preferred size.

This also fixes a bug introduced in http://crrev/c/2441963 where the
dialog was not shown because no bound was specified and the contents
view uses FillLayout.

Bug: b/156258540
Change-Id: I30f863ded3eb1a7b6ec20c88a0bb46c1d23cd4cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504638
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823444}
parent bc4e20fd
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
namespace ash { namespace ash {
namespace { namespace {
// The initial height does nothing except determining the vertical position of // The top inset value is set such that the dialog overlaps with the browser
// the dialog, since the dialog is centered with the initial height. // address bar, for anti-spoofing.
constexpr int kTopInsetDp = 36;
constexpr int kCornerRadius = 12; constexpr int kCornerRadius = 12;
std::unique_ptr<views::Widget> CreateAuthDialogWidget( std::unique_ptr<views::Widget> CreateAuthDialogWidget(
...@@ -51,6 +52,13 @@ InSessionAuthDialog::InSessionAuthDialog(uint32_t auth_methods, ...@@ -51,6 +52,13 @@ InSessionAuthDialog::InSessionAuthDialog(uint32_t auth_methods,
: auth_methods_(auth_methods) { : auth_methods_(auth_methods) {
widget_ = CreateAuthDialogWidget( widget_ = CreateAuthDialogWidget(
std::make_unique<AuthDialogContentsView>(auth_methods), parent_window); std::make_unique<AuthDialogContentsView>(auth_methods), parent_window);
gfx::Rect bounds = parent_window->GetBoundsInScreen();
gfx::Size preferred_size = widget_->GetContentsView()->GetPreferredSize();
int horizontal_inset_dp = (bounds.width() - preferred_size.width()) / 2;
int bottom_inset_dp = bounds.height() - kTopInsetDp - preferred_size.height();
bounds.Inset(horizontal_inset_dp, kTopInsetDp, horizontal_inset_dp,
bottom_inset_dp);
widget_->SetBounds(bounds);
aura::Window* window = widget_->GetNativeWindow(); aura::Window* window = widget_->GetNativeWindow();
rounded_corner_decorator_ = std::make_unique<RoundedCornerDecorator>( rounded_corner_decorator_ = std::make_unique<RoundedCornerDecorator>(
......
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