Upstream version 11.39.256.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / xwalk_browser_main_parts.cc
index 62ffc55..7f95b55 100644 (file)
 #include "base/message_loop/message_loop.h"
 #include "base/strings/string_number_conversions.h"
 #include "cc/base/switches.h"
-#include "components/nacl/browser/nacl_browser.h"
-#include "components/nacl/browser/nacl_process_host.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/main_function_params.h"
 #include "content/public/common/url_constants.h"
 #include "content/public/common/result_codes.h"
 #include "extensions/browser/extension_system.h"
-#include "net/base/net_util.h"
+#include "net/base/filename_util.h"
 #include "ui/gl/gl_switches.h"
 #include "xwalk/application/browser/application.h"
 #include "xwalk/application/browser/application_system.h"
 #include "xwalk/extensions/browser/xwalk_extension_service.h"
 #include "xwalk/extensions/common/xwalk_extension_switches.h"
-#include "xwalk/runtime/browser/devtools/remote_debugging_server.h"
-#include "xwalk/runtime/browser/nacl_host/nacl_browser_delegate_impl.h"
-#include "xwalk/runtime/browser/runtime.h"
-#include "xwalk/runtime/browser/runtime_context.h"
 #include "xwalk/runtime/browser/xwalk_runner.h"
 #include "xwalk/runtime/common/xwalk_runtime_features.h"
 #include "xwalk/runtime/common/xwalk_switches.h"
 
+#if !defined(DISABLE_NACL)
+#include "components/nacl/browser/nacl_browser.h"
+#include "components/nacl/browser/nacl_process_host.h"
+#include "xwalk/runtime/browser/nacl_host/nacl_browser_delegate_impl.h"
+#endif
+
 #if defined(USE_AURA) && defined(USE_X11)
-#include "ui/base/ime/input_method_initializer.h"
 #include "ui/events/x/touch_factory_x11.h"
 #endif
 
+#if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX)
+#include "ui/base/ime/input_method_initializer.h"
+#endif
+
 namespace {
 
 // FIXME: Compare with method in startup_browser_creator.cc.
@@ -74,7 +77,8 @@ namespace xwalk {
 XWalkBrowserMainParts::XWalkBrowserMainParts(
     const content::MainFunctionParams& parameters)
     : xwalk_runner_(XWalkRunner::GetInstance()),
-      startup_url_(content::kAboutBlankURL),
+      extension_service_(NULL),
+      startup_url_(url::kAboutBlankURL),
       parameters_(parameters),
       run_default_message_loop_(true) {
 #if defined(OS_LINUX)
@@ -96,7 +100,6 @@ XWalkBrowserMainParts::~XWalkBrowserMainParts() {
 void XWalkBrowserMainParts::PreMainMessageLoopStart() {
   CommandLine* command_line = CommandLine::ForCurrentProcess();
   command_line->AppendSwitch(switches::kEnableViewport);
-  command_line->AppendSwitch(switches::kEnableViewportMeta);
 
   command_line->AppendSwitch(xswitches::kEnableOverlayScrollbars);
 
@@ -104,9 +107,6 @@ void XWalkBrowserMainParts::PreMainMessageLoopStart() {
   // This also enables pinch on Tizen.
   command_line->AppendSwitch(switches::kEnableThreadedCompositing);
 
-  // Show feedback on touch.
-  command_line->AppendSwitch(switches::kEnableGestureTapHighlight);
-
   // FIXME: Add comment why this is needed on Android and Tizen.
   command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
 
@@ -126,8 +126,8 @@ void XWalkBrowserMainParts::PostMainMessageLoopStart() {
 }
 
 void XWalkBrowserMainParts::PreEarlyInitialization() {
-#if defined(USE_AURA) && defined(USE_X11)
-    ui::InitializeInputMethodForTesting();
+#if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX)
+  ui::InitializeInputMethodForTesting();
 #endif
 }
 
@@ -139,10 +139,15 @@ void XWalkBrowserMainParts::RegisterExternalExtensions() {
   CommandLine* cmd_line = CommandLine::ForCurrentProcess();
 
 #if defined(OS_TIZEN)
-  static const std::string tec_path = "/usr/lib/tizen-extensions-crosswalk";
   std::string value = cmd_line->GetSwitchValueASCII(
       switches::kXWalkExternalExtensionsPath);
 
+#if defined(ARCH_CPU_64_BITS)
+  const char tec_path[] = "/usr/lib64/tizen-extensions-crosswalk";
+#else
+  const char tec_path[] = "/usr/lib/tizen-extensions-crosswalk";
+#endif
+
   if (value.empty())
     cmd_line->AppendSwitchASCII(switches::kXWalkExternalExtensionsPath,
         tec_path);
@@ -199,12 +204,8 @@ void XWalkBrowserMainParts::PreMainMessageLoopRun() {
     std::string port_str =
         command_line->GetSwitchValueASCII(switches::kRemoteDebuggingPort);
     int port;
-    const char* local_ip = "0.0.0.0";
-    if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) {
-      remote_debugging_server_.reset(
-          new RemoteDebuggingServer(xwalk_runner_->runtime_context(),
-              local_ip, port, std::string()));
-    }
+    base::StringToInt(port_str, &port);
+    xwalk_runner_->EnableRemoteDebugging(port);
   }
 
   NativeAppWindow::Initialize();
@@ -215,20 +216,10 @@ void XWalkBrowserMainParts::PreMainMessageLoopRun() {
     return;
   }
 
-  if (xwalk_runner_->is_running_as_service()) {
-    // In service mode, Crosswalk doesn't launch anything, just waits
-    // for external requests to launch apps.
-    VLOG(1) << "Crosswalk running as Service.";
-    return;
-  }
-
+#if !defined(SHARED_PROCESS_MODE)
   application::ApplicationSystem* app_system = xwalk_runner_->app_system();
-  if (!app_system->HandleApplicationManagementCommands(*command_line,
-      startup_url_, run_default_message_loop_)) {
-    app_system->LaunchFromCommandLine(*command_line, startup_url_,
-                                      run_default_message_loop_);
-  }
-
+  app_system->LaunchFromCommandLine(*command_line, startup_url_,
+                                    run_default_message_loop_);
   // If the |ui_task| is specified in main function parameter, it indicates
   // that we will run this UI task instead of running the the default main
   // message loop. See |content::BrowserTestBase::SetUp| for |ui_task| usage
@@ -238,6 +229,7 @@ void XWalkBrowserMainParts::PreMainMessageLoopRun() {
     delete parameters_.ui_task;
     run_default_message_loop_ = false;
   }
+#endif
 }
 
 bool XWalkBrowserMainParts::MainMessageLoopRun(int* result_code) {