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.
5 #include "xwalk/runtime/browser/xwalk_browser_main_parts_tizen.h"
7 #include "base/files/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"
20 #include "content/browser/device_sensors/device_inertial_sensor_service.h"
21 #include "xwalk/tizen/mobile/sensor/tizen_data_fetcher_shared_memory.h"
25 using application::Application;
27 XWalkBrowserMainPartsTizen::XWalkBrowserMainPartsTizen(
28 const content::MainFunctionParams& parameters)
29 : XWalkBrowserMainParts(parameters) {
32 void XWalkBrowserMainPartsTizen::PreMainMessageLoopStart() {
33 CommandLine* command_line = CommandLine::ForCurrentProcess();
34 command_line->AppendSwitch(switches::kIgnoreGpuBlacklist);
36 // Enable Accelerated 2D Canvas.
37 command_line->AppendSwitch(switches::kGpuNoContextLost);
39 if (!command_line->HasSwitch(switches::kUseGL)) {
41 if (base::PathExists(base::FilePath("/usr/lib/libGL.so")))
42 gl_name = gfx::kGLImplementationDesktopName;
44 gl_name = gfx::kGLImplementationEGLName;
45 command_line->AppendSwitchASCII(switches::kUseGL, gl_name);
48 XWalkBrowserMainParts::PreMainMessageLoopStart();
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());
61 XWalkBrowserMainParts::PreMainMessageLoopRun();