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

Unified Diff: ash/display/display_error_dialog.cc

Issue 12209026: Fix the crash of DisplayErrorDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 10 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
Index: ash/display/display_error_dialog.cc
diff --git a/ash/display/display_error_dialog.cc b/ash/display/display_error_dialog.cc
index 6757e966f3f0c7d4a4966df3b16c5bde40615512..604d86acf6d9d9d4c9017f8cae2d216b45ade1e0 100644
--- a/ash/display/display_error_dialog.cc
+++ b/ash/display/display_error_dialog.cc
@@ -7,6 +7,7 @@
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "grit/ash_strings.h"
+#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_types.h"
@@ -39,15 +40,22 @@ void DisplayErrorDialog::ShowDialog() {
return;
}
- const gfx::Display& secondary_display = ash::ScreenAsh::GetSecondaryDisplay();
+ gfx::Screen* screen = Shell::GetScreen();
+ const gfx::Display& target_display =
+ (screen->GetNumDisplays() > 1) ?
+ ScreenAsh::GetSecondaryDisplay() : screen->GetPrimaryDisplay();
g_instance = new DisplayErrorDialog();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.delegate = g_instance;
- // Makes |widget| belong to the secondary display. Size and location are
+ // Makes |widget| belong to the target display. Size and location are
// fixed by CenterWindow() below.
- params.bounds = secondary_display.bounds();
+ params.bounds = target_display.bounds();
+ DisplayController* display_controller =
+ Shell::GetInstance()->display_controller();
+ params.context =
+ display_controller->GetRootWindowForDisplayId(target_display.id());
params.keep_on_top = true;
widget->Init(params);
@@ -93,5 +101,10 @@ void DisplayErrorDialog::OnDisplayConfigurationChanging() {
GetWidget()->Close();
}
+// static
+DisplayErrorDialog* DisplayErrorDialog::GetInstanceForTest() {
+ return g_instance;
+}
+
} // namespace internal
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698