Commit b25c25af authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

Crostini Upgrader: add minimize button.

To do this as cleanly as possible, added CanMinimizeDialog method to
WebDialogDelegate. This is used by WebDialogView. The default return value is
false. This should only be used when there is a corresponding shelf item for
the dialog.

Bug: 1122481
Change-Id: Id0da680c4c88ac7462f8cc3d4111cda767ea4bfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379450
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarDavid Munro <davidmunro@google.com>
Auto-Submit: Nicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802660}
parent 99a91de0
......@@ -14,6 +14,7 @@
#include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -63,6 +64,7 @@ CrostiniUpgraderDialog::CrostiniUpgraderDialog(
DCHECK(profile_);
crostini::CrostiniManager::GetForProfile(profile_)->SetCrostiniDialogStatus(
crostini::DialogType::UPGRADER, true);
set_can_minimize(true);
}
CrostiniUpgraderDialog::~CrostiniUpgraderDialog() {
......@@ -89,6 +91,10 @@ bool CrostiniUpgraderDialog::ShouldCloseDialogOnEscape() const {
return false;
}
bool CrostiniUpgraderDialog::CanResizeDialog() const {
return false;
}
void CrostiniUpgraderDialog::AdjustWidgetInitParams(
views::Widget::InitParams* params) {
params->z_order = ui::ZOrderLevel::kNormal;
......
......@@ -46,6 +46,7 @@ class CrostiniUpgraderDialog : public SystemWebDialogDelegate {
bool ShouldShowCloseButton() const override;
bool ShouldShowDialogTitle() const override;
bool ShouldCloseDialogOnEscape() const override;
bool CanResizeDialog() const override;
void AdjustWidgetInitParams(views::Widget::InitParams* params) override;
bool OnDialogCloseRequested() override;
void OnDialogShown(content::WebUI* webui) override;
......
......@@ -81,6 +81,7 @@ WebDialogView::WebDialogView(content::BrowserContext* context,
delegate_(delegate),
web_view_(new ObservableWebView(context, delegate)),
use_dialog_frame_(use_dialog_frame) {
SetCanMinimize(!delegate_ || delegate_->can_minimize());
SetModalType(GetDialogModalType());
web_view_->set_allow_accelerators(true);
AddChildView(web_view_);
......
......@@ -80,6 +80,11 @@ class WEB_DIALOGS_EXPORT WebDialogDelegate {
// returns false.
virtual bool CanMaximizeDialog() const;
// Returns true if the dialog can ever be minimized. Default implementation
// returns false.
bool can_minimize() const { return can_minimize_; }
void set_can_minimize(bool can_minimize) { can_minimize_ = can_minimize; }
// A callback to notify the delegate that |source|'s loading state has
// changed.
virtual void OnLoadingStateChanged(content::WebContents* source) {}
......@@ -180,6 +185,9 @@ class WEB_DIALOGS_EXPORT WebDialogDelegate {
blink::mojom::MediaStreamType type);
virtual ~WebDialogDelegate() = default;
private:
bool can_minimize_ = false;
};
} // namespace ui
......
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