Upstream version 11.39.244.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / browser / application.cc
index e0b526f..8b7acc4 100644 (file)
@@ -23,6 +23,7 @@
 #include "xwalk/application/common/manifest_handlers/warp_handler.h"
 #include "xwalk/runtime/browser/runtime.h"
 #include "xwalk/runtime/browser/runtime_context.h"
+#include "xwalk/runtime/browser/runtime_defered_ui_strategy.h"
 #include "xwalk/runtime/browser/xwalk_runner.h"
 
 #if defined(OS_TIZEN)
@@ -90,6 +91,7 @@ Application::Application(
       security_mode_enabled_(false),
       runtime_context_(runtime_context),
       observer_(NULL),
+      ui_strategy_(new RuntimeDeferedUIStrategy),
       remote_debugging_enabled_(false),
       weak_factory_(this) {
   DCHECK(runtime_context_);
@@ -229,10 +231,11 @@ bool Application::Launch(const LaunchParams& launch_params) {
   params.state = is_wgt ?
       GetWindowShowState<Manifest::TYPE_WIDGET>(launch_params):
       GetWindowShowState<Manifest::TYPE_MANIFEST>(launch_params);
+  window_show_params_.state = params.state;
 
   params.splash_screen_path = GetSplashScreenPath();
 
-  runtime->AttachWindow(params);
+  ui_strategy_->Show(runtime, params);
 
   return true;
 }
@@ -261,6 +264,8 @@ int Application::GetRenderProcessHostID() const {
 void Application::OnRuntimeAdded(Runtime* runtime) {
   DCHECK(runtime);
   runtime->set_remote_debugging_enabled(remote_debugging_enabled_);
+  if (!runtimes_.empty())
+    ui_strategy_->Show(runtime, window_show_params_);
   runtimes_.insert(runtime);
 }
 
@@ -268,14 +273,10 @@ void Application::OnRuntimeRemoved(Runtime* runtime) {
   DCHECK(runtime);
   runtimes_.erase(runtime);
 
-  if (runtimes_.empty()) {
-#if defined(OS_TIZEN_MOBILE)
-    runtime->CloseRootWindow();
-#endif
+  if (runtimes_.empty())
     base::MessageLoop::current()->PostTask(FROM_HERE,
         base::Bind(&Application::NotifyTermination,
                    weak_factory_.GetWeakPtr()));
-  }
 }
 
 void Application::RenderProcessExited(RenderProcessHost* host,