How to enable web security in Chrome after disabling it? - google-chrome

I did the __disable-web-security in Terminal on Mac. Do I need to enable it again? Or does it enable by itself after restart?
If I need to enable it again, how do I do that? I searched everywhere, but didn't find.

Go to chrome://version and look at the Command Line. If the command line argument is still there, you should restart chrome and then launch it normally (without the flag).
A bit more context: "Flag" refers to two slightly different concepts in Chrome:
Any command line argument that starts with a -- (as opposed to an argument that names a URL or a file, for example).
The list of toggles available at chrome://flags.
Any arguments added manually to the command line will only persist until you quit Chrome. On the other hand, the toggles set at chrome://flags will persist until they are reset. (To further blur this, invoking chrome://restart will preserve the command line flags.)
This particular flag makes its presence fairly obvious, with a banner:
You are using an unsupported command-line flag: --disable-web-security. Stability and security will suffer.
So it should hopefully be clear whether the flag is present (and also why this is the sort of flag that can't be persisted at chrome://flags).
The flags set in #2 are delimited in Chrome's command line by the --flags-switches-begin…--flags-switches-end section. Arguments outside of that section are coming from somewhere other than chrome://flags (namely, from the command line, except in the case of Chrome OS and Android, which have their own startup procedures).

Related

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

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.
--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.

How to set proerties for Chrome.exe - Need to replace the shortcut argument

I created a shortcut for Chrome.exe and passed the arguments --disable-web-security --user-data-dir="C:/Chrome dev session"
However the arguments works fine when clicking the shortcuts and able to see the security got disabled.
However i want this change to be permanent....no matter how many shortcuts pointing to the chrome, the arguments should get executed automatically
Does argument can be set in any chrome property files ?
Please advise
Thanks
One Solution is touching the registry. However don't want to touch it and looking for a solution without touching registry
Example,
Firefox to run with the parameters "-p username" when I run "firefox.exe"
https://superuser.com/questions/12230/how-to-set-default-parameters-for-an-application
Run regedit and take a look at the key:
`My Computer\HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\command`
Put -p username into the command string at the appropriate place.
Thanks.

enable Chrome flags from the command line

I want to enable a flag (enable-token-binding) while launching chrome.
I can do that using chrome://flags page. but for running tests I need to do it from command line.
I tried
chrome --enable-features=token-binding
chrome --enable-token-binding
None of them worked.
go to chrome://version
Find the command line arguments:
Command Line /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --enable-audio-service-sandbox --flag-switches-begin --enable-features=CookiesWithoutSameSiteMustBeSecure,SameSiteByDefaultCookies --flag-switches-end --enable-audio-service-sandbox
Run the above command with all the arguments and your chrome instance would have all the settings preset.
Try --flag-switches-begin --enable-token-binding --flag-switches-end.
The patter is --flag-switches start and ends capping the flags. Then the names of the flags provided as the parameters within with -- prefixed to them.
Token Binding was removed in Chrome release 70
see https://www.chromestatus.com/feature/5097603234529280
mayankSinha's answer works for the flags he mentions. Note the changed naming convention though: "lower case split by -" convention gets changed to CamelCase.
i.e. same-site-by-default-cookies (as shown in chrome://flags) becomes SameSiteByDefaultCookies

Setting enable-gamepad-extensions from Chrome command line

I cannot set --enable-gamepad-extensions from the Chrome command line
(WebVR experimental build Version 56.0.2902.0 (64-bit))
Setting --enable-webvr on the command line works fine,
and setting enable-gamepad-extensions from chrome://flags also works fine.
I'm guessing it may be because enable-gamepad-extensions is a three way setting (default/enabled/disabled) rather than just a two way one.
I see that the corresponding entries in the Local State file is
"enabled_labs_experiments":["enable-gamepad-extensions#1","enable-webvr"]
and have tried various experiments based on this, but haven't found a way that works.
The flag was added in about_flags.cc, not in command line chrome_switches.cc. It was also added in content_features.cc as 2-state (enabled/disabled) so you can force it with --enable-features:
chrome.exe --enable-features=GamepadExtensions

Stylish: "Turn all styles off" from command line?

I frequently end up doing ~5 different manual actions when switching between using my laptop in dark environments and light environments, one of which is clicking Turn all styles off in the Stylish extension toolbar button to disable my dark user styles. I'd like to automate this somehow, probably a script bound to a hotkey. Is there a way to have the same effect as clicking Turn all styles off through the command line or some other way to accomplish this goal? I'm using Stylish in Chrome on Ubuntu.
My findings are that there isn't any way to change chrome extension settings from the command line and that the best way to do this is to set a key binding per #wOxxOm's comment and to use xdotool to send the keystrokes to chrome. There are a lot of gotchas in getting this to work. This is the final command I ended up using:
xdotool search --class 'google-chrome' windowactivate --sync \
key --window 0 --clearmodifiers 'ctrl+shift+5'
Chrome doesn't accept the keystrokes if it's not active, so use windowactivate --sync first. It seems that Chrome ignores XTEST events so use --window 0 to force xdotool to use XSendEvent instead. Finally, I had to use --clearmodifiers because I have Caps_Lock and Control_L swapped.