Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/display/display_error_dialog.h" | |
| 6 | |
| 7 #include "ash/display/display_controller.h" | |
| 8 #include "ash/shell.h" | |
| 9 #include "ash/shell_window_ids.h" | |
| 10 #include "base/utf_string_conversions.h" | |
| 11 #include "grit/ash_strings.h" | |
| 12 #include "ui/aura/window.h" | |
| 13 #include "ui/base/l10n/l10n_util.h" | |
| 14 #include "ui/base/ui_base_types.h" | |
| 15 #include "ui/gfx/rect.h" | |
| 16 #include "ui/views/border.h" | |
| 17 #include "ui/views/controls/label.h" | |
| 18 #include "ui/views/widget/widget.h" | |
| 19 | |
| 20 namespace ash { | |
| 21 namespace internal { | |
| 22 namespace { | |
| 23 | |
| 24 // The width of the area to show the error message. | |
| 25 const int kDialogMessageWidthPixel = 300; | |
| 26 | |
| 27 // The margin width from the error message to the edge of the dialog. | |
| 28 const int kDialogMessageMarginWidthPixel = 5; | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 // static | |
| 33 void DisplayErrorDialog::ShowDialog() { | |
| 34 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
| |
| 35 Shell::GetInstance()->display_controller(); | |
| 36 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.
| |
| 37 aura::RootWindow* root_window = | |
| 38 display_controller->GetRootWindowForDisplayId(secondary_display->id()); | |
| 39 | |
| 40 DisplayErrorDialog* dialog = new DisplayErrorDialog(); | |
| 41 // Need to specify bounds here since the default bounds will change the parent | |
| 42 // to the primary root. Size will be fixed in CenterWindow() below. | |
| 43 views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds( | |
| 44 dialog, | |
| 45 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.
| |
| 46 secondary_display->bounds()); | |
| 47 widget->GetNativeView()->SetName("DisplayErrorDialog"); | |
| 48 widget->CenterWindow(widget->GetRootView()->GetPreferredSize()); | |
| 49 widget->Show(); | |
| 50 } | |
| 51 | |
| 52 DisplayErrorDialog::DisplayErrorDialog() { | |
| 53 views::View* container = GetContentsView(); | |
| 54 label_ = new views::Label( | |
| 55 l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING)); | |
| 56 container->AddChildView(label_); | |
| 57 | |
| 58 label_->SetMultiLine(true); | |
| 59 label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
| 60 label_->set_border(views::Border::CreateEmptyBorder( | |
| 61 kDialogMessageMarginWidthPixel, | |
| 62 kDialogMessageMarginWidthPixel, | |
| 63 kDialogMessageMarginWidthPixel, | |
| 64 kDialogMessageMarginWidthPixel)); | |
| 65 label_->SizeToFit(kDialogMessageWidthPixel); | |
| 66 } | |
| 67 | |
| 68 DisplayErrorDialog::~DisplayErrorDialog() { | |
| 69 } | |
| 70 | |
| 71 int DisplayErrorDialog::GetDialogButtons() const { | |
| 72 return ui::DIALOG_BUTTON_OK; | |
| 73 } | |
| 74 | |
| 75 ui::ModalType DisplayErrorDialog::GetModalType() const { | |
| 76 return ui::MODAL_TYPE_NONE; | |
| 77 } | |
| 78 | |
| 79 views::View* DisplayErrorDialog::GetContentsView() { | |
| 80 return this; | |
| 81 } | |
| 82 | |
| 83 gfx::Size DisplayErrorDialog::GetPreferredSize() { | |
| 84 return label_->GetPreferredSize(); | |
| 85 } | |
| 86 | |
| 87 } // namespace internal | |
| 88 } // namespace ash | |
| OLD | NEW |