Chromium

From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.

Chromium is the open source version of Google's Chrome web browser. It features a minimal user interface, powerful web development tools, and a built in task manager. The Chromium Project is at the forefront of implementing new web standards.

Because Chromium is open source it is legally unable to include several features that the proprietary Google Chrome browser includes by default. Namely automatic updates. A complete list of the differences can be found in the chromium repository.

Installation

USE flags

USE flags for www-client/chromium Open-source version of Google Chrome web browser

X Add support for X11
bindist Flag to enable or disable options for prebuilt (GRP) packages (eg. due to licensing issues)
cups Add support for CUPS (Common Unix Printing System)
custom-cflags Build with user-specified CFLAGS (unsupported)
debug Enable DCHECK feature with severity configurable at runtime. Mostly intended for debugging and development, NOT RECOMMENDED for general use.
ffmpeg-chromium (binpkg only) Use Chromium FFmpeg fork (media-video/ffmpeg-chromium) rather than mainline FFmpeg (media-video/ffmpeg)
gtk4 Build with GTK4 headers.
hangouts Enable support for Google Hangouts features such as screen sharing
headless Build Ozone only with headless backend, NOT RECOMMENDED for general use.
kerberos Add kerberos support
libcxx Use bundled libc++ instead of libstdc++ for building.
lto Build with Link Time Optimizations (via clang's ThinLTO)
official Enable Official build instead of Developer build.
pax-kernel Allow building on a PaX-enabled kernel
pgo Build with Profile Guided Optimizations (2-stage compilation)
proprietary-codecs Enable codecs for patent-encumbered audio and video formats.
pulseaudio Add sound server support via media-libs/libpulse (may be PulseAudio or PipeWire)
qt5 Add support for the Qt 5 application and UI framework
qt6 Add support for the Qt 6 application and UI framework
screencast Enable support for remote desktop and screen cast using PipeWire
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
system-harfbuzz Use system media-libs/harfbuzz instead of the bundled library.
system-icu Use system dev-libs/icu instead of the bundled one
system-png Use system media-libs/libpng instead of the bundled library
system-toolchain Use system toolchain instead of the bundled one (if possible)
system-zstd Use system app-arch/zstd instead of the bundled one.
vaapi Enable Video Acceleration API for hardware decoding
wayland Enable dev-libs/wayland backend
widevine Unsupported closed-source DRM capability (required by Netflix VOD)

icu

Important
To avoid an emerge slot conflict with dev-libs/libxml2, which prevents Chromium to be emerged, icu USE flag must be set in /etc/portage/make.conf. If icu is newly set, update the system before emerging Chromium by issuing:

root #emerge --ask --update --deep --newuse @world

L10N

There are many languages available via the L10N USE_EXPAND variable in Chromium. So many, in fact, that the wiki cannot display all of them. For a full list of localization languages run:

user $equery u www-client/chromium | grep -i l10n
Note
The equery tools comes as part of the app-portage/gentoolkit package. It will need to be installed in order to use the above command.

For more information on localization see the Localization article.

Emerge

Tip
Be aware that compiling Chromium can take a significant amount of real time, CPU time, and system memory. Allow 2Gb of RAM per each make thread (as defined by MAKEOPTS, see this post). It is probably not a good idea to build Chromium when the system is under heavy load.

After setting USE flags as desired, emerge Chromium with the following command:

root #emerge --ask www-client/chromium

Configuration

Clang

To build Chromium with Clang, first see Clang environments.

For Chromium specifically, the following env settings are needed:

FILE /etc/portage/env/clang-chromium
# Optionally, add these to EXTRA_GN:
# - thin_lto_enable_optimizations=true 
# - use_thin_lto=true
# - is_cfi=true 
EXTRA_GN="use_lld=true is_clang=true clang_use_chrome_plugins=false" 
#
# Needed with GCC 11
CHROMIUM_FORCE_LIBCXX=yes

Then enable it (note that we take the base Clang config from the other article, then add the settings we just defined):

FILE /etc/portage/package.env
# compiler-clang: build with a general Clang environment (see Clang article)
# clang-chromium: build with tweaks specifically for Chromium
www-client/chromium compiler-clang clang-chromium

HiDPI

Chromium's visual output is generally disconnected from a Desktop environment's DPI scaling. It can be instructed to start in a scaled mode by using the --force-device-scale-factor command-line option. This option can be passed a integer or decimal value. Standard scaling begins at 1.0. For example, to make Chromium's UI 1.5x larger:

user $chromium --force-device-scale-factor=1.5

A full list of command-line switches can be found here.

Native Wayland support

Since version 87, native Wayland support in Chromium can be enabled by passing the following options:

user $chromium --enable-features=UseOzonePlatform --ozone-platform=wayland

To set Chromium to start every time using the Wayland backend, append the following lines the user's Chromium configuration file:

FILE ~/.config/chromium-flags.conf
--enable-features=UseOzonePlatform
--ozone-platform=wayland

Enable dark theme for pages (prefers-color-scheme)

Because of bug in May 2022 Chromium on GTK do not understand that user want to see dark pages. But you can set this preference manually:

FILE /etc/chromium/default
CHROMIUM_FLAGS="--force-dark-mode
--enable-features=WebUIDarkMode"

First is for regular pages, the second is for internal chrome:// pages.

Disable animations

To turn off animations, set the following parameters:

FILE /etc/chromium/default
CHROMIUM_FLAGS="--wm-window-animations-disabled
--animation-duration-scale=0"

Disable Tab Hover Cards

Since version 91.0.4472.77 it is no longer possible to disable the Tab Hover Cards within Chrome flags. There seems to be no priority at Google to add this feature back in. In order to disable them, you can add this patch to Portage:

FILE /etc/portage/patches/www-client/chromium/hover-card.patch
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 2c94eb0..1f7bde0 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -2149,6 +2149,7 @@ void TabStrip::OnMouseEventInTab(views::View* source,
 }
 
 void TabStrip::UpdateHoverCard(Tab* tab, HoverCardUpdateType update_type) {
+  return;
   // Some operations (including e.g. starting a drag) can cause the tab focus
   // to change at the same time as the tabstrip is starting to animate; the
   // hover card should not be visible at this time.

See also Added setting for Tab Hover Cards.

Security

Policies

It is possible to set specific policies for chromium. This can be useful especially if the browser should be accessible by users, but the content should be restricted to trusted sites. It can also be configured to restrict the access to specified URIs, like the file:// protocol, to prevent users from surfing the file system.

Chromium looks in /etc/chromium/policies for existing policies. There are two types of policies which can be defined:

  • managed
  • recommended

Generally managed policies are maintained by an administrator and recommended policies are recommended for users but not required.
For further information about the two policy types the documentation should be referred on the Google Chrome support page.

The following example assumes managed policies. However, the procedure for recommended policies is very similar and can be found in the Chromium documentation.

Creating of managed policies

To set custom managed policies, a JSON file must be created in /etc/chromium/policies/managed/<filename>.json

Note
It is important to ensure, that the <filename>.json is not writable by non-admin users, to prevent overwriting of the policies by users, which would defeat the purpose of policies! The chown(1) and chmod(1) commands can be used to change ownership and rights if for any reason the file should be writable by non-admin users.

The structure of the JSON file is the same for all chromium based browsers (Chrome, Chromium, Brave etc). An example JSON file could look like this:

CODE
{
"IncognitoModeAvailability": 1,
"URLBlocklist": [
    "https://facebook.com",
    "file://*",
    "javascript://*",
    "ftp://*",
    "mailto:*"
],
"DefaultGeolocationSetting": 2,
"DefaultNotificationsSetting": 2,
}

This prevents the user from surfing on the file system using the file protocol, incognito mode, blocks the listed URIs and URLs, and the location and notifications. More settings, can be found in the policy list: https://www.chromium.org/administrators/policy-list-3/. If configured for other users as a service, it is recommended to block all sites at first and then define the allowed sites, to avoid abuse of the service. Please note that this only blocks the user from visiting specified locations. It does not disable the protocols on the system, so other applications must be configured separately.

If the policy was configured properly can be proofed on the special page: chrome://policy.

For a better structure, it is also possible to spread the policies over multiple JSON files. In this case it is indispensable to ensure that the same policy occurs only once per all files! If a policy is defined multiple times across the JSON files than the state of the policy will be undefined and it would be unclear which rule would be used!

Meaningful filenames and a simple grep across the files in case of doubt can help to prevent such misconfigurations.

Local certificates

Chromium (like many other web browsers, such as Firefox) does not use the system-wide CA certificate list.

To use a custom certificate when using Chromium-based Web browsers like Chrome, open chrome://settings/certificates, choose the "Authorities" tab, and import the certificate.

Usage

Chrome URLs

Much like Firefox, Chromium has many internal Chrome URLs (special pages) that are used for additional configuration, troubleshooting, task management, etc. An exhaustive list of special pages can be accessed by navigating to: chrome://about/

Prominent special pages include:

  • chrome://components/ - Shows enabled components and provides a button to check for updates for each of them. It is sometimes necessary to manually update the PPAPI Adobe flash module via this interfaces when using Chrome.
  • chrome://chrome/ - Displays the About page which includes version information.
  • chrome://extensions/ - A page to manage extensions.
  • chrome://flags/ - Enable/disable experimental features.
  • chrome://flash/ - Displays special information about the Adobe Flash Player (if it is accessible by Chromium).
  • chrome://gpu/ - Displays information about use of graphics acceleration.
  • chrome://history/ - Displays web history. Also accessible through the sandwich menu or by pressing Ctrl+h.
  • chrome://memory-redirect/ - Measure the memory usage of the browser and per-tab usage.
  • chrome://net-internals/ - Lots of information on network connections.
  • chrome://plugins/ - Shows a list of plugins. Enable/disable them from this interface. (Deprecated in Chrome version 57[1].)
  • chrome://version/ - Displays more version information than the chrome page.

Troubleshooting

Screencast support

Screencast is disabled by default at runtime. Either enable it by navigating to chrome://flags/#enable-webrtc-pipewire-capturer inside Chromium or add --enable-features=WebRTCPipeWireCapturer as a value to the CHROMIUM_FLAGS variable in the /etc/chromium/default file.

Tabs crash

Occasionally tabs in Chromium crash. This can be caused by quite a few things, however one of the most common reason for occurrence is that the system is running low on memory. On Gentoo, this can especially happen if the system is compiling a www-client/chromium package update while running Chromium.

The free command can be used to see how much memory is available on the system:

user $free -h
              total        used        free      shared  buff/cache   available
Mem:            15G         11G        735M        789M        3.4G        3.1G

The solution to is to free up memory until the large package compiles have finished. Open a resource monitor of choice and kill applications using large amounts of memory.

See also

  • Firefox — Mozilla's web browser.
  • Chrome — Google's proprietary (closed source) web browser.

References