Upstream version 9.38.204.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / xwalk_browser_main_parts_tizen.cc
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "xwalk/runtime/browser/xwalk_browser_main_parts_tizen.h"
6
7 #include "base/file_util.h"
8 #include "base/files/file_path.h"
9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/common/content_switches.h"
11 #include "xwalk/application/browser/application.h"
12 #include "xwalk/application/browser/application_service.h"
13 #include "xwalk/application/browser/application_system.h"
14 #include "xwalk/extensions/common/xwalk_extension.h"
15 #include "xwalk/runtime/browser/xwalk_runner.h"
16 #include "xwalk/runtime/common/xwalk_runtime_features.h"
17 #include "ui/gl/gl_switches.h"
18 #include "ui/gfx/switches.h"
19
20 #include "content/browser/device_sensors/device_inertial_sensor_service.h"
21 #include "xwalk/tizen/mobile/sensor/tizen_data_fetcher_shared_memory.h"
22
23 namespace xwalk {
24
25 using application::Application;
26
27 XWalkBrowserMainPartsTizen::XWalkBrowserMainPartsTizen(
28     const content::MainFunctionParams& parameters)
29     : XWalkBrowserMainParts(parameters) {
30 }
31
32 void XWalkBrowserMainPartsTizen::PreMainMessageLoopStart() {
33   CommandLine* command_line = CommandLine::ForCurrentProcess();
34   command_line->AppendSwitch(switches::kIgnoreGpuBlacklist);
35
36   // Enable Accelerated 2D Canvas.
37   command_line->AppendSwitch(switches::kGpuNoContextLost);
38
39   if (!command_line->HasSwitch(switches::kUseGL)) {
40     const char* gl_name;
41     if (base::PathExists(base::FilePath("/usr/lib/libGL.so")))
42       gl_name = gfx::kGLImplementationDesktopName;
43     else
44       gl_name = gfx::kGLImplementationEGLName;
45     command_line->AppendSwitchASCII(switches::kUseGL, gl_name);
46   }
47
48   XWalkBrowserMainParts::PreMainMessageLoopStart();
49 }
50
51 void XWalkBrowserMainPartsTizen::PreMainMessageLoopRun() {
52   if (content::DeviceInertialSensorService* sensor_service =
53           content::DeviceInertialSensorService::GetInstance()) {
54     // As the data fetcher of sensors is implemented outside of Chromium, we
55     // need to make it available to Chromium by "abusing" the test framework.
56     // TODO(zliang7): Find a decent way to inject our sensor fetcher for Tizen.
57     sensor_service->SetDataFetcherForTesting(
58         new TizenDataFetcherSharedMemory());
59   }
60
61   XWalkBrowserMainParts::PreMainMessageLoopRun();
62 }
63
64 }  // namespace xwalk