1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
// Copyright 2021 The Chromium Authors
// 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/ash/shimless_rma_dialog/shimless_rma_dialog.h"
#include <string>
#include "ash/webui/shimless_rma/url_constants.h"
#include "ui/aura/window.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/base/mojom/window_show_state.mojom.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/views/widget/widget.h"
namespace ash {
// static
void ShimlessRmaDialog::ShowDialog() {
ShimlessRmaDialog* dialog = new ShimlessRmaDialog();
dialog->ShowSystemDialog(nullptr);
}
ShimlessRmaDialog::ShimlessRmaDialog()
: SystemWebDialogDelegate(GURL(kChromeUIShimlessRMAUrl),
/*title=*/std::u16string()) {
// MODAL_TYPE_SYSTEM renders over OOBE/login screens, but does not support
// ui::mojom::WindowShowState::kFullscreen correctly.
// This dialog uses DisplayObserver::OnDisplayMetricsChanged to update the
// window size as screen size changes.
set_dialog_modal_type(ui::mojom::ModalType::kSystem);
set_can_minimize(false);
}
ShimlessRmaDialog::~ShimlessRmaDialog() = default;
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::mojom::WindowShowState::kFullscreen;
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 ash
|