Software & AppsOperating SystemLinux

How To Make Google Chrome’s “–allow-file-access-from-files” Flag Permanent

Ubuntu 15

In this article, we will delve into the steps required to make Google Chrome’s --allow-file-access-from-files flag permanent. This flag is used to allow web pages to access local files, which can be quite useful for developers. However, it’s important to note that this flag is not recommended for general users due to potential security risks.

Quick Answer

To make Google Chrome’s --allow-file-access-from-files flag permanent, you can either modify the launcher properties or create a new launcher with the flag included. This allows you to enable the flag every time you launch Chrome using the modified or new launcher.

Understanding the “–allow-file-access-from-files” Flag

The --allow-file-access-from-files flag is a command-line switch that instructs Google Chrome to allow web pages to access local files. This is typically used for development purposes, where you might need to load local files for testing or debugging.

However, this flag isn’t enabled by default because it can pose a security risk. If misused, it could allow malicious web pages to access local files on your computer. Therefore, it’s crucial to use this flag responsibly and only when necessary.

Modifying the Launcher Properties

One way to make the --allow-file-access-from-files flag permanent is by modifying the launcher properties. Here’s how to do it:

  1. Navigate to the desktop launcher or menu entry for Google Chrome.
  2. Open the launcher properties dialog.
  3. Look for the command line that launches Google Chrome, which should be something like /usr/bin/google-chrome %U.
  4. Modify it to include the flag: /usr/bin/google-chrome --allow-file-access-from-files.
  5. Delete and re-pin your icon launchers if necessary.

Now, every time you launch Google Chrome using this launcher, it will start with the --allow-file-access-from-files flag enabled.

Creating a New Launcher

If modifying the launcher properties doesn’t work or isn’t preferred, you can create a new launcher. Here’s how:

  1. Create a new launcher with the command /usr/bin/google-chrome --allow-file-access-from-files.
  2. Use this new launcher to start Google Chrome.

This method ensures that the flag is only enabled when you launch Google Chrome using this specific launcher.

Verifying the Flags

After you’ve modified the launcher or created a new one, you’ll want to verify that the flags are being loaded correctly. Here’s how:

  1. Open a terminal and run the command cat ~/.config/google-chrome/Local\ State.
  2. Scroll up to the block entitled session_restore.
  3. Your flags should be listed in the block, before --flag-switches-begin --flag-switches-end.
  4. Additionally, opening Google Chrome and navigating to chrome://version/ should list the enabled flags in the Command Line block.

Conclusion

The --allow-file-access-from-files flag can be a powerful tool for developers, but it should be used with caution due to potential security risks. By modifying the launcher properties or creating a new launcher, you can make this flag permanent. However, always remember to verify that the flags are being loaded correctly to ensure that your browser is functioning as expected.

For more information on Google Chrome/Chromium flags, you can refer to the list of flags at http://peter.sh/experiments/chromium-command-line-switches/.

What is the purpose of the `–allow-file-access-from-files` flag?

The --allow-file-access-from-files flag is used to allow web pages to access local files in Google Chrome. It is primarily used for development purposes, such as testing or debugging.

Why is the `–allow-file-access-from-files` flag not enabled by default?

The flag is not enabled by default because it can pose a security risk. If misused, it could allow malicious web pages to access local files on your computer. Therefore, it is important to use this flag responsibly and only when necessary.

How can I make the `–allow-file-access-from-files` flag permanent?

There are two methods to make the flag permanent. The first method is to modify the launcher properties of Google Chrome to include the flag. The second method is to create a new launcher with the flag included. Both methods ensure that the flag is enabled every time you launch Google Chrome.

How can I modify the launcher properties of Google Chrome?

To modify the launcher properties, navigate to the desktop launcher or menu entry for Google Chrome. Open the launcher properties dialog and locate the command line that launches Google Chrome. Modify the command line to include the --allow-file-access-from-files flag. Finally, delete and re-pin your icon launchers if necessary.

What should I do if modifying the launcher properties doesn’t work or isn’t preferred?

If modifying the launcher properties doesn’t work or isn’t preferred, you can create a new launcher with the --allow-file-access-from-files flag included. Use this new launcher to start Google Chrome, and the flag will be enabled only when you launch Chrome using this specific launcher.

How can I verify if the flags are being loaded correctly?

To verify if the flags are being loaded correctly, open a terminal and run the command cat ~/.config/google-chrome/Local\ State. Scroll up to the block entitled session_restore and check if your flags are listed before --flag-switches-begin --flag-switches-end. Additionally, you can open Google Chrome and navigate to chrome://version/, where the enabled flags should be listed in the Command Line block.

Where can I find more information on Google Chrome/Chromium flags?

For more information on Google Chrome/Chromium flags, you can refer to the list of flags at http://peter.sh/experiments/chromium-command-line-switches/. This resource provides detailed information about various flags and their usage.

Leave a Comment

Your email address will not be published. Required fields are marked *