Chromium Code Reviews| Index: ash/display/display_error_dialog.cc |
| diff --git a/ash/display/display_error_dialog.cc b/ash/display/display_error_dialog.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..53f859b895e810fbffe923c57ffcaeafa07d8864 |
| --- /dev/null |
| +++ b/ash/display/display_error_dialog.cc |
| @@ -0,0 +1,88 @@ |
| +// Copyright (c) 2012 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 "ash/display/display_error_dialog.h" |
| + |
| +#include "ash/display/display_controller.h" |
| +#include "ash/shell.h" |
| +#include "ash/shell_window_ids.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "grit/ash_strings.h" |
| +#include "ui/aura/window.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "ui/base/ui_base_types.h" |
| +#include "ui/gfx/rect.h" |
| +#include "ui/views/border.h" |
| +#include "ui/views/controls/label.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| +namespace ash { |
| +namespace internal { |
| +namespace { |
| + |
| +// The width of the area to show the error message. |
| +const int kDialogMessageWidthPixel = 300; |
| + |
| +// The margin width from the error message to the edge of the dialog. |
| +const int kDialogMessageMarginWidthPixel = 5; |
| + |
| +} // namespace |
| + |
| +// static |
| +void DisplayErrorDialog::ShowDialog() { |
| + DisplayController* display_controller = |
|
oshima
2012/10/01 21:45:20
what happens when I tried to mirror while this is
Jun Mukai
2012/10/01 23:59:34
Good point... Added a global variable to make this
|
| + Shell::GetInstance()->display_controller(); |
| + gfx::Display* secondary_display = display_controller->GetSecondaryDisplay(); |
|
oshima
2012/10/01 21:45:20
SceenAsh::GetSecondaryDisplay()
Jun Mukai
2012/10/01 23:59:34
Done.
|
| + aura::RootWindow* root_window = |
| + display_controller->GetRootWindowForDisplayId(secondary_display->id()); |
| + |
| + DisplayErrorDialog* dialog = new DisplayErrorDialog(); |
| + // Need to specify bounds here since the default bounds will change the parent |
| + // to the primary root. Size will be fixed in CenterWindow() below. |
| + views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds( |
| + dialog, |
| + Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer), |
|
oshima
2012/10/01 21:45:20
can you use Widget::InitParams::keep_on_top?
Jun Mukai
2012/10/01 23:59:34
Done.
|
| + secondary_display->bounds()); |
| + widget->GetNativeView()->SetName("DisplayErrorDialog"); |
| + widget->CenterWindow(widget->GetRootView()->GetPreferredSize()); |
| + widget->Show(); |
| +} |
| + |
| +DisplayErrorDialog::DisplayErrorDialog() { |
| + views::View* container = GetContentsView(); |
| + label_ = new views::Label( |
| + l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING)); |
| + container->AddChildView(label_); |
| + |
| + label_->SetMultiLine(true); |
| + label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| + label_->set_border(views::Border::CreateEmptyBorder( |
| + kDialogMessageMarginWidthPixel, |
| + kDialogMessageMarginWidthPixel, |
| + kDialogMessageMarginWidthPixel, |
| + kDialogMessageMarginWidthPixel)); |
| + label_->SizeToFit(kDialogMessageWidthPixel); |
| +} |
| + |
| +DisplayErrorDialog::~DisplayErrorDialog() { |
| +} |
| + |
| +int DisplayErrorDialog::GetDialogButtons() const { |
| + return ui::DIALOG_BUTTON_OK; |
| +} |
| + |
| +ui::ModalType DisplayErrorDialog::GetModalType() const { |
| + return ui::MODAL_TYPE_NONE; |
| +} |
| + |
| +views::View* DisplayErrorDialog::GetContentsView() { |
| + return this; |
| +} |
| + |
| +gfx::Size DisplayErrorDialog::GetPreferredSize() { |
| + return label_->GetPreferredSize(); |
| +} |
| + |
| +} // namespace internal |
| +} // namespace ash |