How to write argument for Chrome/Chromium's '--enable-features=' flag

1.7k views Asked by At


I am trying to modify Chromium browser's behavior in Chromium OS.
When I execute Chromium browser, I can handover arguments with '--enable-features=' flag.
And I found a argument (#enable-virtual-keyboard) from Available list in chrome://flags.
Then I executed Chromium browser like below.

example instruction # /opt/google/chrome/chrome --incognito --enable-features=enable-virtual-keyboard

And when I check the flags in chrome://version, I could see the arguments.

Command Line: /opt/google/chrome/chrome --blahblah --enable-features=enable-virtual-keyboard

But actually the virtual keyboard is not working.

When I enable the argument (virtual keyboard) from chrome://flags manually. It works well and I could see the Virtual Keyboard.


What is wrong? I would appreciate it if you guys advise me.

1

There are 1 answers

0
Harry Cutts On

--enable-features actually takes the name of a feature, not the name of a flag. The Chromium documentation explains the difference, but to simplify somewhat, a flag is sort of a user-visible interface to a feature or a command-line switch.

Anyway, to do what you want, you need to find out what feature or command-line switch the enable-virtual-keyboard flag toggles. Searching for enable-virtual-keyboard in Chromium Code Search brings us to these lines in about_flags.cc:

    {"enable-virtual-keyboard", flag_descriptions::kVirtualKeyboardName,
     flag_descriptions::kVirtualKeyboardDescription, kOsCrOS,
     SINGLE_VALUE_TYPE(keyboard::switches::kEnableVirtualKeyboard)},

That last line tells us what we're looking for: that this flag is actually backed by a command-line switch, not a feature. Clicking on kEnableVirtualKeyboard shows us its definition:

const char kEnableVirtualKeyboard[] = "enable-virtual-keyboard";

So, adding --enable-virtual-keyboard to your command line should have the same effect as flipping the flag. (I should note, though, that there are a number of things that can break the virtual keyboard, so you may have to do other things to get it working.)

For the sake of completeness, if you'd found that it was actually backed by a feature, like the gesture-properties-dbus-service flag, for example:

    {"gesture-properties-dbus-service",
     flag_descriptions::kEnableGesturePropertiesDBusServiceName,
     flag_descriptions::kEnableGesturePropertiesDBusServiceDescription, kOsCrOS,
     FEATURE_VALUE_TYPE(chromeos::features::kGesturePropertiesDBusService)},

Then clicking kGesturePropertiesDBusService takes us to its definition which specifies the feature name:

const base::Feature kGesturePropertiesDBusService{
    "GesturePropertiesDBusService", base::FEATURE_DISABLED_BY_DEFAULT};

...so in that case you'd pass --enable-features=GesturePropertiesDBusService to enable the flag from your command line.