1 // Copyright 2014 Samsung Electronics. 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 "command_line_efl.h"
12 #include "base/base_switches.h"
13 #include "base/logging.h"
14 #include "cc/base/switches.h"
15 #include "common/content_switches_efl.h"
16 #include "components/viz/common/switches.h"
17 #include "content/public/common/content_client.h"
18 #include "content/public/common/content_switches.h"
20 #include "extensions/common/switches.h"
21 #include "gpu/config/gpu_switches.h"
22 #include "sandbox/policy/switches.h"
23 #include "tizen/system_info.h"
24 #include "ui/base/ui_base_switches.h"
25 #include "ui/events/event_switches.h"
26 #include "ui/gl/gl_switches.h"
27 #include "ui/ozone/public/ozone_switches.h"
30 int CommandLineEfl::argc_ = 0;
31 char** CommandLineEfl::argv_ = NULL;
32 CommandLineEfl::ArgumentVector CommandLineEfl::original_arguments_;
33 bool CommandLineEfl::is_initialized_ = false;
35 void CommandLineEfl::Init(int argc, char *argv[]) {
36 if (CommandLineEfl::is_initialized_) {
37 LOG(ERROR) << "CommandLineEfl::Init should not be called more than once";
39 base::CommandLine::Init(argc, argv);
43 // Unfortunately chromium modifies application's argument vector.
44 // during initialization. This means that chromium after initialization
45 // argv will only contain one valid entry, argv[0]. To be able to use
46 // user provided arguments after initialization we need to make a copy
48 // See: chromium/src/content/common/set_process_title_linux.cc
49 for (int i = 0; i < argc; ++i)
50 original_arguments_.push_back(std::string(argv[i]));
51 CommandLineEfl::is_initialized_ = true;
54 content::MainFunctionParams CommandLineEfl::GetDefaultPortParams() {
55 if (!CommandLineEfl::is_initialized_) {
56 CommandLineEfl::Init(0, NULL);
58 base::CommandLine* p_command_line = base::CommandLine::ForCurrentProcess();
60 p_command_line->AppendSwitchASCII(switches::kUseGL,
61 gl::kGLImplementationEGLName);
62 p_command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox);
63 p_command_line->AppendSwitch(switches::kIgnoreGpuBlocklist);
64 p_command_line->AppendSwitch(switches::kInProcessGPU);
65 p_command_line->AppendSwitchASCII(switches::kOzonePlatform, "efl");
66 p_command_line->AppendSwitch(switches::kEnableOffscreenRendering);
68 AppendMemoryOptimizationSwitches(p_command_line);
70 if (IsDesktopProfile())
71 p_command_line->AppendSwitch(switches::kDisableES3GLContext);
73 #if defined(TIZEN_MULTIMEDIA_SUPPORT) && defined(ENABLE_WEBRTC)
74 p_command_line->AppendSwitch(switches::kEnableWebRtcHWH264Encoding);
77 #if BUILDFLAG(IS_TIZEN)
78 #if !defined(EWK_BRINGUP) // FIXME:m85 bringup
79 p_command_line->AppendSwitchASCII(
80 switches::kAcceleratedCanvas2dMSAASampleCount, "4");
81 p_command_line->AppendSwitch(switches::kEnableGestureTapHighlight);
82 p_command_line->AppendSwitch(switches::kEnableSpatialNavigation);
83 p_command_line->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
87 if (IsMobileProfile() || IsWearableProfile()) {
88 p_command_line->AppendSwitch(switches::kUseMobileUserAgent);
89 p_command_line->AppendSwitchASCII(
90 switches::kTouchEventFeatureDetection,
91 switches::kTouchEventFeatureDetectionEnabled);
92 #if !defined(EWK_BRINGUP)
93 p_command_line->AppendSwitch(switches::kEnablePinch);
97 #if !defined(EWK_BRINGUP)
98 if (p_command_line->HasSwitch(switches::kDisableIpcSandbox))
99 p_command_line->AppendSwitch(switches::kDisableRendererZygote);
102 // XXX: Skia benchmarking should be only used for testing,
103 // when enabled the following warning is printed to stderr:
104 // "Enabling unsafe Skia benchmarking extension."
105 // p_command_line->AppendSwitch(switches::kEnableSkiaBenchmarking);
107 AppendUserArgs(*p_command_line);
109 return content::MainFunctionParams(p_command_line);
112 void CommandLineEfl::AppendProcessSpecificArgs(base::CommandLine& command_line) {
113 std::string process_type = command_line.GetSwitchValueASCII(switches::kProcessType);
115 AppendUserArgs(command_line);
118 void CommandLineEfl::AppendSwitch(std::string arg) {
119 original_arguments_.push_back(arg);
122 void CommandLineEfl::AppendUserArgs(base::CommandLine& command_line) {
123 for (ArgumentVector::const_iterator it = original_arguments_.begin();
124 it != original_arguments_.end(); ++it) {
125 command_line.AppendSwitch(*it);
129 void CommandLineEfl::AppendMemoryOptimizationSwitches(
130 base::CommandLine* command_line) {
131 #if !defined(EWK_BRINGUP)
132 // [M44_2403] Temporary disabling the codes for switching to new chromium
133 // FIXME: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=14040
134 // For optimizing tile buffer size.
135 command_line->AppendSwitchASCII(switches::kDefaultTileRoundUp, "16");
136 command_line->AppendSwitch(switches::kEnableMultipleTextureSizes);
138 // For purging unused resources.
139 command_line->AppendSwitch(switches::kEnablePurgingUnusedResources);
141 // For adding runtime switch to configure the discardable image cache size.
142 command_line->AppendSwitchASCII(switches::kImageCacheSize, "0");
145 // For reuse of timers with message pump
146 command_line->AppendSwitch(switches::kLimitMemoryAllocationInScheduleDelayedWork);