const gfx::Screen* screen,
const gfx::Rect& bounds) const OVERRIDE {
#if defined(USE_ASH)
+ bool force_ash = false;
+ // On Windows check if the browser is launched to serve ASH. If yes then
+ // we should get the display for the corresponding root window created for
+ // ASH. This ensures that the display gets the correct workarea, etc.
+ // If the ASH shell does not exist then the current behavior is to open
+ // browser windows if any on the desktop. Preserve that for now.
+ // TODO(ananta).
+ // This effectively means that the running browser process is in a split
+ // personality mode, part of it running in ASH and the other running in
+ // desktop. This may cause apps and other widgets to not work correctly.
+ // Revisit and address.
+#if defined(OS_WIN)
+ force_ash = ash::Shell::HasInstance() &&
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kViewerConnect);
+#endif
// Use the target display on ash.
- if (chrome::ShouldOpenAshOnStartup()) {
+ if (chrome::ShouldOpenAshOnStartup() || force_ash) {
aura::Window* target = ash::Shell::GetTargetRootWindow();
return screen->GetDisplayNearestWindow(target);
}