Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1441)

Unified Diff: athena/system/shutdown_dialog.cc

Issue 662763002: Support modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: fix leaks Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/system/shutdown_dialog.h ('k') | athena/system/status_icon_container_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/system/shutdown_dialog.cc
diff --git a/athena/system/shutdown_dialog.cc b/athena/system/shutdown_dialog.cc
index 865349ea7613927444a9ff8ecbf2e2ab1515b3a7..d4648d7ebed5955ee675f42e0bb32bb9d8164b5c 100644
--- a/athena/system/shutdown_dialog.cc
+++ b/athena/system/shutdown_dialog.cc
@@ -15,6 +15,7 @@
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/window/dialog_delegate.h"
namespace athena {
namespace {
@@ -23,10 +24,33 @@ namespace {
// device after shutdown dialog is shown.
const int kShutdownTimeoutMs = 4000;
+class ModalWidgetDelegate : public views::WidgetDelegate {
+ public:
+ explicit ModalWidgetDelegate(views::View* contents_view)
+ : contents_view_(contents_view) {}
+ virtual ~ModalWidgetDelegate() {}
+
+ // Overridden from WidgetDelegate:
+ virtual views::Widget* GetWidget() override {
+ return contents_view_->GetWidget();
+ }
+ virtual const views::Widget* GetWidget() const override {
+ return contents_view_->GetWidget();
+ }
+ virtual views::View* GetContentsView() override { return contents_view_; }
+ virtual ui::ModalType GetModalType() const override {
+ return ui::MODAL_TYPE_SYSTEM;
+ }
+
+ private:
+ views::View* contents_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate);
+};
+
} // namespace
-ShutdownDialog::ShutdownDialog(aura::Window* dialog_container)
- : warning_message_container_(dialog_container), state_(STATE_OTHER) {
+ShutdownDialog::ShutdownDialog() : state_(STATE_OTHER) {
InputManager::Get()->AddPowerButtonObserver(this);
}
@@ -37,13 +61,6 @@ ShutdownDialog::~ShutdownDialog() {
void ShutdownDialog::ShowShutdownWarningDialog() {
state_ = STATE_SHUTDOWN_WARNING_VISIBLE;
- shutdown_warning_message_.reset(new views::Widget);
-
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.parent = warning_message_container_;
- shutdown_warning_message_->Init(params);
-
views::Label* label =
new views::Label(l10n_util::GetStringUTF16(IDS_ATHENA_SHUTDOWN_WARNING));
label->SetBackgroundColor(SK_ColorWHITE);
@@ -59,9 +76,18 @@ void ShutdownDialog::ShowShutdownWarningDialog() {
views::Background::CreateSolidBackground(SK_ColorWHITE));
container->SetBorder(views::Border::CreateSolidBorder(1, SK_ColorBLACK));
- shutdown_warning_message_->SetContentsView(container);
- shutdown_warning_message_->CenterWindow(container->GetPreferredSize());
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
+ params.delegate = new ModalWidgetDelegate(container);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.context = ScreenManager::Get()->GetContext();
+ // Use top most modal container.
+ params.keep_on_top = true;
+
+ shutdown_warning_message_.reset(new views::Widget);
+ shutdown_warning_message_->Init(params);
shutdown_warning_message_->Show();
+ shutdown_warning_message_->CenterWindow(container->GetPreferredSize());
+
timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs),
this,
« no previous file with comments | « athena/system/shutdown_dialog.h ('k') | athena/system/status_icon_container_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698