| // Copyright 2021 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "chrome/browser/ui/webui/chromeos/shimless_rma_dialog.h" |
| |
| #include <string> |
| |
| #include "ash/webui/shimless_rma/url_constants.h" |
| #include "ui/aura/window.h" |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| #include "ui/views/widget/widget.h" |
| |
| namespace chromeos { |
| // static |
| void ShimlessRmaDialog::ShowDialog() { |
| ShimlessRmaDialog* dialog = new ShimlessRmaDialog(); |
| dialog->ShowSystemDialog(nullptr); |
| } |
| |
| ShimlessRmaDialog::ShimlessRmaDialog() |
| : SystemWebDialogDelegate(GURL(ash::kChromeUIShimlessRMAUrl), |
| /*title=*/std::u16string()) { |
| // MODAL_TYPE_SYSTEM renders over OOBE/login screens, but does not support |
| // ui::SHOW_STATE_FULLSCREEN correctly. |
| // This dialog uses DisplayObserver::OnDisplayMetricsChanged to update the |
| // window size as screen size changes. |
| set_modal_type(ui::ModalType::MODAL_TYPE_SYSTEM); |
| set_can_minimize(false); |
| } |
| |
| ShimlessRmaDialog::~ShimlessRmaDialog() = default; |
| |
| const std::string& ShimlessRmaDialog::Id() { |
| return id_; |
| } |
| |
| void ShimlessRmaDialog::AdjustWidgetInitParams( |
| views::Widget::InitParams* params) { |
| // This overrides the class name so TAST tests can find the root node. |
| params->name = "ShimlessRmaDialogView"; |
| params->type = views::Widget::InitParams::Type::TYPE_WINDOW_FRAMELESS; |
| params->visible_on_all_workspaces = true; |
| params->corner_radius = 0; |
| params->show_state = ui::SHOW_STATE_FULLSCREEN; |
| params->remove_standard_frame = true; |
| params->opacity = views::Widget::InitParams::WindowOpacity::kOpaque; |
| } |
| |
| void ShimlessRmaDialog::GetDialogSize(gfx::Size* size) const { |
| *size = display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| } |
| |
| bool ShimlessRmaDialog::ShouldShowCloseButton() const { |
| return false; |
| } |
| |
| bool ShimlessRmaDialog::ShouldCloseDialogOnEscape() const { |
| return false; |
| } |
| |
| bool ShimlessRmaDialog::CanMaximizeDialog() const { |
| return false; |
| } |
| |
| void ShimlessRmaDialog::OnDisplayMetricsChanged(const display::Display& display, |
| uint32_t changed_metrics) { |
| dialog_window()->SetBounds( |
| display::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
| } |
| |
| } // namespace chromeos |