Commit ce9a5a4c authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

Chrome OS GetHelp: Don't crash on the lock screen.

Make the best effort to determine sizes.

Bug: 1022764
Change-Id: I4b55302b36a2964cd3b11ff8c5c4540c69300bfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1905550
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Cr-Commit-Position: refs/heads/master@{#713838}
parent 48f227bd
......@@ -56,8 +56,7 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context,
delegate_(delegate),
title_(title),
url_(url) {
if (!parent_window_) {
DCHECK(chromeos::LoginDisplayHost::default_host());
if (!parent_window_ && chromeos::LoginDisplayHost::default_host()) {
parent_window_ =
chromeos::LoginDisplayHost::default_host()->GetNativeWindow();
}
......@@ -93,6 +92,11 @@ void LoginWebDialog::GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const {}
void LoginWebDialog::GetDialogSize(gfx::Size* size) const {
// TODO(https://crbug.com/1022774): Fix for the lock screen.
if (!parent_window_) {
*size = kMaxSize;
return;
}
gfx::Rect bounds = parent_window_->bounds();
bounds.Inset(kMinMargins);
*size = bounds.size();
......
......@@ -45,4 +45,13 @@ IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CloseDialogByAccelerator) {
EXPECT_TRUE(closing_observer.widget_closed());
}
// Tests that LoginWebDialog does not crash with missing parent window.
IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, NoParentWindow) {
LoginWebDialog* dialog = new LoginWebDialog(
browser()->profile(), nullptr, nullptr, base::string16(), GURL());
dialog->Show();
aura::Window* window = dialog->get_dialog_window_for_test();
ASSERT_TRUE(window);
}
} // namespace chromeos
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