Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / window_sizer / window_sizer.cc
index ac5486f..34b342b 100644 (file)
@@ -146,8 +146,23 @@ class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider {
       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);
     }